UserCoin.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101
  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 string msisdn { get; set; }
  14. public int rank { get; set; }
  15. public DateTime? start_time { get; set; }
  16. public DateTime? end_time { get; set; }
  17. public DateTime? last_update { get; set; }
  18. public int total_coin { get; set; }
  19. public string product_name { get; set; }
  20. public static List<UserCoin> Parse(OracleDataReader reader)
  21. {
  22. List<UserCoin> result = new List<UserCoin>();
  23. try
  24. {
  25. while (reader.Read())
  26. {
  27. UserCoin UserCoin = new UserCoin();
  28. for (int i = 0; i < reader.FieldCount; i++)
  29. {
  30. if (reader.GetName(i).ToUpper() == "MSISDN")
  31. {
  32. try
  33. {
  34. UserCoin.msisdn = reader.GetValue(i).ToString();
  35. }
  36. catch { }
  37. }
  38. else if (reader.GetName(i).ToUpper() == "START_TIME")
  39. try
  40. {
  41. UserCoin.start_time = reader.GetDateTime(i);
  42. }
  43. catch { }
  44. else if (reader.GetName(i).ToUpper() == "END_TIME")
  45. try
  46. {
  47. UserCoin.end_time = reader.GetDateTime(i);
  48. }
  49. catch { }
  50. else if (reader.GetName(i).ToUpper() == "LAST_UPDATE")
  51. try
  52. {
  53. UserCoin.last_update = reader.GetDateTime(i);
  54. }
  55. catch { }
  56. else if (reader.GetName(i).ToUpper() == "TOTAL_COIN")
  57. {
  58. try
  59. {
  60. UserCoin.total_coin = int.Parse(reader.GetValue(i).ToString());
  61. }
  62. catch { }
  63. }
  64. else if (reader.GetName(i).ToUpper() == "PRODUCT_NAME")
  65. {
  66. try
  67. {
  68. UserCoin.product_name = (string)reader.GetValue(i);
  69. }
  70. catch { }
  71. }
  72. else if (reader.GetName(i).ToUpper() == "RANK")
  73. {
  74. try
  75. {
  76. UserCoin.rank = int.Parse(reader.GetValue(i).ToString());
  77. }
  78. catch { }
  79. }
  80. }
  81. result.Add(UserCoin);
  82. }
  83. reader.Close();
  84. }
  85. catch
  86. {
  87. }
  88. finally
  89. {
  90. try
  91. {
  92. reader.Close();
  93. }
  94. catch { }
  95. }
  96. return result;
  97. }
  98. }
  99. }