LuckyCode.cs 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. using Oracle.ManagedDataAccess.Client;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Web;
  6. namespace ReportWeb.Models
  7. {
  8. public class LuckyCode
  9. {
  10. public long id { get; set; }
  11. public string msisdn { get; set; }
  12. public string code { get; set; }
  13. public DateTime? insert_time { get; set; }
  14. public DateTime? expire_time { get; set; }
  15. public int period { get; set; }
  16. public int status { get; set; }
  17. public DateTime? confirm_time { get; set; }
  18. public int confirm_channel { get; set; }
  19. public int fee { get; set; }
  20. public int count_times { get; set; }
  21. public int code_type { get; set; }
  22. public static List<LuckyCode> Parse(OracleDataReader reader)
  23. {
  24. List<LuckyCode> result = new List<LuckyCode>();
  25. try
  26. {
  27. while (reader.Read())
  28. {
  29. LuckyCode chargeLog = new LuckyCode();
  30. for (int i = 0; i < reader.FieldCount; i++)
  31. {
  32. if (reader.GetName(i).ToUpper() == "MSISDN")
  33. {
  34. try
  35. {
  36. chargeLog.msisdn = reader.GetValue(i).ToString();
  37. }
  38. catch { }
  39. }
  40. else if (reader.GetName(i).ToUpper() == "CODE")
  41. {
  42. try
  43. {
  44. chargeLog.code = reader.GetValue(i).ToString();
  45. }
  46. catch { }
  47. }
  48. else if (reader.GetName(i).ToUpper() == "INSERT_TIME")
  49. try
  50. {
  51. chargeLog.insert_time = reader.GetDateTime(i);
  52. }
  53. catch { }
  54. else if (reader.GetName(i).ToUpper() == "EXPIRE_TIME")
  55. try
  56. {
  57. chargeLog.expire_time = reader.GetDateTime(i);
  58. }
  59. catch { }
  60. else if (reader.GetName(i).ToUpper() == "CONFIRM_TIME")
  61. try
  62. {
  63. chargeLog.confirm_time = reader.GetDateTime(i);
  64. }
  65. catch { }
  66. else if (reader.GetName(i).ToUpper() == "ID")
  67. try
  68. {
  69. chargeLog.id = long.Parse(reader.GetValue(i).ToString());
  70. }
  71. catch { }
  72. else if (reader.GetName(i).ToUpper() == "STATUS")
  73. try
  74. {
  75. chargeLog.status = int.Parse(reader.GetValue(i).ToString());
  76. }
  77. catch { }
  78. else if (reader.GetName(i).ToUpper() == "PERIOD")
  79. try
  80. {
  81. chargeLog.period = int.Parse(reader.GetValue(i).ToString());
  82. }
  83. catch { }
  84. else if (reader.GetName(i).ToUpper() == "CONFIRM_CHANNEL")
  85. try
  86. {
  87. chargeLog.confirm_channel = int.Parse(reader.GetValue(i).ToString());
  88. }
  89. catch { }
  90. else if (reader.GetName(i).ToUpper() == "FEE")
  91. try
  92. {
  93. chargeLog.fee = int.Parse(reader.GetValue(i).ToString());
  94. }
  95. catch { }
  96. else if (reader.GetName(i).ToUpper() == "COUNT_TIMES")
  97. try
  98. {
  99. chargeLog.count_times = int.Parse(reader.GetValue(i).ToString());
  100. }
  101. catch { }
  102. else if (reader.GetName(i).ToUpper() == "CODE_TYPE")
  103. try
  104. {
  105. chargeLog.code_type = int.Parse(reader.GetValue(i).ToString());
  106. }
  107. catch { }
  108. }
  109. result.Add(chargeLog);
  110. }
  111. reader.Close();
  112. }
  113. catch (Exception ex)
  114. {
  115. throw ex;
  116. }
  117. finally
  118. {
  119. try
  120. {
  121. reader.Close();
  122. }
  123. catch { }
  124. }
  125. return result;
  126. }
  127. }
  128. }