TicketObj.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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 TicketObj
  10. {
  11. public long id { get; set; }
  12. public string msisdn { get; set; }
  13. public string ticket_code { get; set; }
  14. public DateTime? insert_time { get; set; }
  15. public DateTime? expire_time { get; set; }
  16. public DateTime? draw_time { get; set; }
  17. public int ticket_src { get; set; }
  18. public int prize_id { get; set; }
  19. public int status { get; set; }
  20. public static List<TicketObj> Parse(OracleDataReader reader)
  21. {
  22. List<TicketObj> result = new List<TicketObj>();
  23. try
  24. {
  25. while (reader.Read())
  26. {
  27. TicketObj chargeLog = new TicketObj();
  28. for (int i = 0; i < reader.FieldCount; i++)
  29. {
  30. if (reader.GetName(i).ToUpper() == "ID")
  31. try
  32. {
  33. chargeLog.id = long.Parse(reader.GetValue(i).ToString());
  34. }
  35. catch { }
  36. else if (reader.GetName(i).ToUpper() == "TICKET_CODE")
  37. {
  38. try
  39. {
  40. chargeLog.ticket_code = reader.GetValue(i).ToString();
  41. }
  42. catch { }
  43. }
  44. else if (reader.GetName(i).ToUpper() == "MSISDN")
  45. {
  46. try
  47. {
  48. chargeLog.msisdn = reader.GetValue(i).ToString();
  49. }
  50. catch { }
  51. }
  52. else if (reader.GetName(i).ToUpper() == "PRIZE_ID")
  53. try
  54. {
  55. chargeLog.prize_id = int.Parse(reader.GetValue(i).ToString());
  56. }
  57. catch { }
  58. else if (reader.GetName(i).ToUpper() == "TICKET_SRC")
  59. try
  60. {
  61. chargeLog.ticket_src = int.Parse(reader.GetValue(i).ToString());
  62. }
  63. catch { }
  64. else if (reader.GetName(i).ToUpper() == "INSERT_TIME")
  65. try
  66. {
  67. chargeLog.insert_time = reader.GetDateTime(i);
  68. }
  69. catch { }
  70. else if (reader.GetName(i).ToUpper() == "EXPIRE_TIME")
  71. try
  72. {
  73. chargeLog.expire_time = reader.GetDateTime(i);
  74. }
  75. catch { }
  76. else if (reader.GetName(i).ToUpper() == "DRAW_TIME")
  77. try
  78. {
  79. chargeLog.draw_time = reader.GetDateTime(i);
  80. if (chargeLog.draw_time > DateTime.Now)
  81. {
  82. // available
  83. chargeLog.status = 1;
  84. }
  85. else
  86. {
  87. chargeLog.status = 0;
  88. }
  89. }
  90. catch { }
  91. }
  92. result.Add(chargeLog);
  93. }
  94. reader.Close();
  95. }
  96. catch (Exception ex)
  97. {
  98. throw ex;
  99. }
  100. finally
  101. {
  102. try
  103. {
  104. reader.Close();
  105. }
  106. catch { }
  107. }
  108. return result;
  109. }
  110. }
  111. }