| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149 |
-
- using System;
- using System.Collections.Generic;
- using Oracle.ManagedDataAccess.Client;
- using System.Linq;
- using System.Web;
- namespace ReportWeb.Models
- {
- public class UserCoin
- {
- public UserCoin()
- { }
- public long id { get; set; }
- public string msisdn { get; set; }
- public int rank { get; set; }
- public DateTime? start_time { get; set; }
- public DateTime? end_time { get; set; }
- public DateTime? last_update { get; set; }
- public DateTime? process_time { get; set; }
- public int status { get; set; }
- public int total_coin { get; set; }
- public int prize_id { get; set; }
- public string product_name { get; set; }
- public static List<UserCoin> Parse(OracleDataReader reader)
- {
- List<UserCoin> result = new List<UserCoin>();
- try
- {
- while (reader.Read())
- {
- UserCoin UserCoin = new UserCoin();
- for (int i = 0; i < reader.FieldCount; i++)
- {
- if (reader.GetName(i).ToUpper() == "MSISDN")
- {
- try
- {
- UserCoin.msisdn = reader.GetValue(i).ToString();
- }
- catch { }
- }
- else if (reader.GetName(i).ToUpper() == "START_TIME")
- try
- {
- UserCoin.start_time = reader.GetDateTime(i);
- }
- catch { }
- else if (reader.GetName(i).ToUpper() == "END_TIME")
- try
- {
- UserCoin.end_time = reader.GetDateTime(i);
- }
- catch { }
- else if (reader.GetName(i).ToUpper() == "LAST_UPDATE")
- try
- {
- UserCoin.last_update = reader.GetDateTime(i);
- }
- catch { }
- else if (reader.GetName(i).ToUpper() == "TOTAL_COIN")
- {
- try
- {
- UserCoin.total_coin = int.Parse(reader.GetValue(i).ToString());
- }
- catch { }
- }
- else if (reader.GetName(i).ToUpper() == "PRODUCT_NAME")
- {
- try
- {
- UserCoin.product_name = (string)reader.GetValue(i);
- }
- catch { }
- }
- else if (reader.GetName(i).ToUpper() == "RANK")
- {
- try
- {
- UserCoin.rank = int.Parse(reader.GetValue(i).ToString());
- }
- catch { }
- }
- else if (reader.GetName(i).ToUpper() == "ID")
- {
- try
- {
- UserCoin.id = long.Parse(reader.GetValue(i).ToString());
- }
- catch { }
- }
- else if (reader.GetName(i).ToUpper() == "PROCESS_TIME")
- {
- try
- {
- UserCoin.process_time = reader.GetDateTime(i);
- }
- catch { }
- }
- else if (reader.GetName(i).ToUpper() == "PRIZE_ID")
- {
- try
- {
- UserCoin.prize_id = int.Parse(reader.GetValue(i).ToString());
- }
- catch { }
- }
- }
- // set status
- if (UserCoin.end_time.Value > new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1))
- {
- // not in time
- UserCoin.status = 3;
- }
- else if (UserCoin.process_time != null)
- {
- UserCoin.status = 2; // processed
- }
- else if (UserCoin.prize_id > 0)
- {
- UserCoin.status = 1; // processing
- }
- else
- {
- UserCoin.status = 0; // not processed
- }
- result.Add(UserCoin);
- }
- reader.Close();
- }
- catch
- {
- }
- finally
- {
- try
- {
- reader.Close();
- }
- catch { }
- }
- return result;
- }
- }
- }
|