ReportDetail.cs 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150
  1. using System;
  2. using System.Collections.Generic;
  3. using Oracle.ManagedDataAccess.Client;
  4. namespace ReportWeb.Models
  5. {
  6. public class ReportDetail
  7. {
  8. public ReportDetail()
  9. { }
  10. public int service_id { get; set; }
  11. public string service_name { get; set; }
  12. public string report_date { get; set; }
  13. public long revenue_others { get; set; }
  14. public long revenue_mocha { get; set; }
  15. public long revenue_web { get; set; }
  16. public long revenue_buy_others { get; set; }
  17. public long revenue_buy_mocha { get; set; }
  18. public long revenue_buy_web { get; set; }
  19. public long count_reg_others { get; set; }
  20. public long count_reg_mocha { get; set; }
  21. public long count_reg_web { get; set; }
  22. public static List<ReportDetail> Parse(OracleDataReader reader)
  23. {
  24. List<ReportDetail> result = new List<ReportDetail>();
  25. try
  26. {
  27. while (reader.Read())
  28. {
  29. ReportDetail report = new ReportDetail();
  30. for (int i = 0; i < reader.FieldCount; i++)
  31. {
  32. if (reader.GetName(i).ToUpper() == "SERVICE_ID")
  33. {
  34. try
  35. {
  36. report.service_id = int.Parse(reader.GetValue(i).ToString());
  37. }
  38. catch { }
  39. }
  40. else if (reader.GetName(i).ToUpper() == "SERVICE_NAME")
  41. try
  42. {
  43. report.service_name = reader.GetValue(i).ToString();
  44. }
  45. catch { }
  46. else if (reader.GetName(i).ToUpper() == "REPORT_DATE")
  47. try
  48. {
  49. report.report_date = reader.GetValue(i).ToString();
  50. }
  51. catch { }
  52. else if (reader.GetName(i).ToUpper() == "REVENUE_MOCHA")
  53. try
  54. {
  55. report.revenue_mocha = long.Parse(reader.GetValue(i).ToString());
  56. }
  57. catch { }
  58. else if (reader.GetName(i).ToUpper() == "REVENUE_WEB")
  59. try
  60. {
  61. report.revenue_web = long.Parse(reader.GetValue(i).ToString());
  62. }
  63. catch { }
  64. else if (reader.GetName(i).ToUpper() == "REVENUE_OTHERS")
  65. try
  66. {
  67. report.revenue_others = long.Parse(reader.GetValue(i).ToString());
  68. }
  69. catch { }
  70. else if (reader.GetName(i).ToUpper() == "REVENUE_BUY_MOCHA")
  71. try
  72. {
  73. report.revenue_buy_mocha = long.Parse(reader.GetValue(i).ToString());
  74. }
  75. catch { }
  76. else if (reader.GetName(i).ToUpper() == "REVENUE_BUY_WEB")
  77. try
  78. {
  79. report.revenue_buy_web = long.Parse(reader.GetValue(i).ToString());
  80. }
  81. catch { }
  82. else if (reader.GetName(i).ToUpper() == "REVENUE_BUY_OTHERS")
  83. try
  84. {
  85. report.revenue_buy_others = long.Parse(reader.GetValue(i).ToString());
  86. }
  87. catch { }
  88. else if (reader.GetName(i).ToUpper() == "COUNT_REG_OTHERS")
  89. try
  90. {
  91. report.count_reg_others = long.Parse(reader.GetValue(i).ToString());
  92. }
  93. catch { }
  94. else if (reader.GetName(i).ToUpper() == "COUNT_REG_MOCHA")
  95. try
  96. {
  97. report.count_reg_mocha = long.Parse(reader.GetValue(i).ToString());
  98. }
  99. catch { }
  100. else if (reader.GetName(i).ToUpper() == "COUNT_REG_WEB")
  101. try
  102. {
  103. report.count_reg_web = long.Parse(reader.GetValue(i).ToString());
  104. }
  105. catch { }
  106. }
  107. result.Add(report);
  108. }
  109. reader.Close();
  110. }
  111. catch (Exception ex)
  112. {
  113. result = null;
  114. }
  115. finally
  116. {
  117. try
  118. {
  119. reader.Close();
  120. }
  121. catch { }
  122. }
  123. return result;
  124. }
  125. }
  126. }