UserCoin.cs 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149
  1. 
  2. using System;
  3. using System.Collections.Generic;
  4. using Oracle.ManagedDataAccess.Client;
  5. using System.Linq;
  6. using System.Web;
  7. namespace ReportWeb.Models
  8. {
  9. public class UserCoin
  10. {
  11. public UserCoin()
  12. { }
  13. public long id { get; set; }
  14. public string msisdn { get; set; }
  15. public int rank { get; set; }
  16. public DateTime? start_time { get; set; }
  17. public DateTime? end_time { get; set; }
  18. public DateTime? last_update { get; set; }
  19. public DateTime? process_time { get; set; }
  20. public int status { get; set; }
  21. public int total_coin { get; set; }
  22. public int prize_id { get; set; }
  23. public string product_name { get; set; }
  24. public static List<UserCoin> Parse(OracleDataReader reader)
  25. {
  26. List<UserCoin> result = new List<UserCoin>();
  27. try
  28. {
  29. while (reader.Read())
  30. {
  31. UserCoin UserCoin = new UserCoin();
  32. for (int i = 0; i < reader.FieldCount; i++)
  33. {
  34. if (reader.GetName(i).ToUpper() == "MSISDN")
  35. {
  36. try
  37. {
  38. UserCoin.msisdn = reader.GetValue(i).ToString();
  39. }
  40. catch { }
  41. }
  42. else if (reader.GetName(i).ToUpper() == "START_TIME")
  43. try
  44. {
  45. UserCoin.start_time = reader.GetDateTime(i);
  46. }
  47. catch { }
  48. else if (reader.GetName(i).ToUpper() == "END_TIME")
  49. try
  50. {
  51. UserCoin.end_time = reader.GetDateTime(i);
  52. }
  53. catch { }
  54. else if (reader.GetName(i).ToUpper() == "LAST_UPDATE")
  55. try
  56. {
  57. UserCoin.last_update = reader.GetDateTime(i);
  58. }
  59. catch { }
  60. else if (reader.GetName(i).ToUpper() == "TOTAL_COIN")
  61. {
  62. try
  63. {
  64. UserCoin.total_coin = int.Parse(reader.GetValue(i).ToString());
  65. }
  66. catch { }
  67. }
  68. else if (reader.GetName(i).ToUpper() == "PRODUCT_NAME")
  69. {
  70. try
  71. {
  72. UserCoin.product_name = (string)reader.GetValue(i);
  73. }
  74. catch { }
  75. }
  76. else if (reader.GetName(i).ToUpper() == "RANK")
  77. {
  78. try
  79. {
  80. UserCoin.rank = int.Parse(reader.GetValue(i).ToString());
  81. }
  82. catch { }
  83. }
  84. else if (reader.GetName(i).ToUpper() == "ID")
  85. {
  86. try
  87. {
  88. UserCoin.id = long.Parse(reader.GetValue(i).ToString());
  89. }
  90. catch { }
  91. }
  92. else if (reader.GetName(i).ToUpper() == "PROCESS_TIME")
  93. {
  94. try
  95. {
  96. UserCoin.process_time = reader.GetDateTime(i);
  97. }
  98. catch { }
  99. }
  100. else if (reader.GetName(i).ToUpper() == "PRIZE_ID")
  101. {
  102. try
  103. {
  104. UserCoin.prize_id = int.Parse(reader.GetValue(i).ToString());
  105. }
  106. catch { }
  107. }
  108. }
  109. // set status
  110. if (UserCoin.end_time.Value > new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1))
  111. {
  112. // not in time
  113. UserCoin.status = 3;
  114. }
  115. else if (UserCoin.process_time != null)
  116. {
  117. UserCoin.status = 2; // processed
  118. }
  119. else if (UserCoin.prize_id > 0)
  120. {
  121. UserCoin.status = 1; // processing
  122. }
  123. else
  124. {
  125. UserCoin.status = 0; // not processed
  126. }
  127. result.Add(UserCoin);
  128. }
  129. reader.Close();
  130. }
  131. catch
  132. {
  133. }
  134. finally
  135. {
  136. try
  137. {
  138. reader.Close();
  139. }
  140. catch { }
  141. }
  142. return result;
  143. }
  144. }
  145. }