PrizeObj.cs 8.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  1. using Newtonsoft.Json.Linq;
  2. using Oracle.ManagedDataAccess.Client;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Web;
  7. namespace ReportWeb.Models
  8. {
  9. public class PrizeObj
  10. {
  11. public long id { get; set; }
  12. public string action_code { get; set; }
  13. public string msisdn { get; set; }
  14. public string code { get; set; }
  15. public int prize_id { get; set; }
  16. public string description { get; set; }
  17. public string description1 { get; set; }
  18. public string description2 { get; set; }
  19. public string prize_name { get; set; }
  20. public string prize_name1 { get; set; }
  21. public string prize_name2 { get; set; }
  22. public DateTime? code_time { get; set; }
  23. public DateTime? process_time { get; set; }
  24. public string process_by { get; set; }
  25. public int period { get; set; }
  26. public int times_prize { get; set; }
  27. public int status { get; set; }
  28. public int channel { get; set; }
  29. public int is_auto { get; set; }
  30. public int group_prize { get; set; }
  31. public int sub_group_prize { get; set; }
  32. public int code_type { get; set; }
  33. public string statusStr { get; set; }
  34. public static List<PrizeObj> Parse(OracleDataReader reader)
  35. {
  36. List<PrizeObj> result = new List<PrizeObj>();
  37. try
  38. {
  39. while (reader.Read())
  40. {
  41. PrizeObj chargeLog = new PrizeObj();
  42. for (int i = 0; i < reader.FieldCount; i++)
  43. {
  44. if (reader.GetName(i).ToUpper() == "ID")
  45. try
  46. {
  47. chargeLog.id = long.Parse(reader.GetValue(i).ToString());
  48. }
  49. catch { }
  50. else if (reader.GetName(i).ToUpper() == "ACTION_CODE")
  51. {
  52. try
  53. {
  54. chargeLog.action_code = reader.GetValue(i).ToString();
  55. }
  56. catch { }
  57. }
  58. else if (reader.GetName(i).ToUpper() == "MSISDN")
  59. {
  60. try
  61. {
  62. chargeLog.msisdn = reader.GetValue(i).ToString();
  63. }
  64. catch { }
  65. }
  66. else if (reader.GetName(i).ToUpper() == "CODE")
  67. {
  68. try
  69. {
  70. chargeLog.code = reader.GetValue(i).ToString();
  71. }
  72. catch { }
  73. }
  74. else if (reader.GetName(i).ToUpper() == "PRIZE_ID")
  75. try
  76. {
  77. chargeLog.prize_id = int.Parse(reader.GetValue(i).ToString());
  78. }
  79. catch { }
  80. else if (reader.GetName(i).ToUpper() == "PRIZE_NAME")
  81. {
  82. try
  83. {
  84. JObject json = JObject.Parse(reader.GetValue(i).ToString());
  85. chargeLog.prize_name = (String)json.GetValue("prizeName");
  86. chargeLog.prize_name1 = (String)json.GetValue("prizeName1");
  87. chargeLog.prize_name2 = (String)json.GetValue("prizeName2");
  88. }
  89. catch { }
  90. }
  91. else if (reader.GetName(i).ToUpper() == "DESCRIPTION")
  92. {
  93. try
  94. {
  95. JObject json = JObject.Parse(reader.GetValue(i).ToString());
  96. chargeLog.description = (String)json.GetValue("description");
  97. chargeLog.description1 = (String)json.GetValue("description1");
  98. chargeLog.description2 = (String)json.GetValue("description2");
  99. }
  100. catch { }
  101. }
  102. else if (reader.GetName(i).ToUpper() == "CODE_TIME")
  103. try
  104. {
  105. chargeLog.code_time = reader.GetDateTime(i);
  106. }
  107. catch { }
  108. else if (reader.GetName(i).ToUpper() == "PROCESS_TIME")
  109. try
  110. {
  111. chargeLog.process_time = reader.GetDateTime(i);
  112. }
  113. catch { }
  114. else if (reader.GetName(i).ToUpper() == "PROCESS_BY")
  115. {
  116. try
  117. {
  118. chargeLog.process_by = reader.GetValue(i).ToString();
  119. }
  120. catch { }
  121. }
  122. else if (reader.GetName(i).ToUpper() == "STATUS")
  123. try
  124. {
  125. chargeLog.status = int.Parse(reader.GetValue(i).ToString());
  126. }
  127. catch { }
  128. else if (reader.GetName(i).ToUpper() == "PERIOD")
  129. try
  130. {
  131. chargeLog.period = int.Parse(reader.GetValue(i).ToString());
  132. }
  133. catch { }
  134. else if (reader.GetName(i).ToUpper() == "TIMES_PRIZE")
  135. try
  136. {
  137. chargeLog.times_prize = int.Parse(reader.GetValue(i).ToString());
  138. }
  139. catch { }
  140. else if (reader.GetName(i).ToUpper() == "CHANNEL")
  141. try
  142. {
  143. chargeLog.channel = int.Parse(reader.GetValue(i).ToString());
  144. }
  145. catch { }
  146. else if (reader.GetName(i).ToUpper() == "IS_AUTO")
  147. try
  148. {
  149. chargeLog.is_auto = int.Parse(reader.GetValue(i).ToString());
  150. }
  151. catch { }
  152. else if (reader.GetName(i).ToUpper() == "GROUP_PRIZE")
  153. try
  154. {
  155. chargeLog.group_prize = int.Parse(reader.GetValue(i).ToString());
  156. }
  157. catch { }
  158. else if (reader.GetName(i).ToUpper() == "SUB_GROUP_PRIZE")
  159. try
  160. {
  161. chargeLog.sub_group_prize = int.Parse(reader.GetValue(i).ToString());
  162. }
  163. catch { }
  164. else if (reader.GetName(i).ToUpper() == "CODE_TYPE")
  165. try
  166. {
  167. chargeLog.code_type = int.Parse(reader.GetValue(i).ToString());
  168. }
  169. catch { }
  170. }
  171. result.Add(chargeLog);
  172. }
  173. reader.Close();
  174. }
  175. catch (Exception ex)
  176. {
  177. throw ex;
  178. }
  179. finally
  180. {
  181. try
  182. {
  183. reader.Close();
  184. }
  185. catch { }
  186. }
  187. return result;
  188. }
  189. }
  190. }