Services.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172
  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 Services
  10. {
  11. public Services()
  12. {
  13. //
  14. // TODO: Add constructor logic here
  15. //
  16. }
  17. public int id { get; set; }
  18. public string sv_name { get; set; }
  19. public string sv_code { get; set; }
  20. // service report
  21. public string db_name { get; set; }
  22. public string connection_string { get; set; }
  23. public string db_username { get; set; }
  24. public string db_password { get; set; }
  25. public string sql_report_daily { get; set; }
  26. public string sql_report_hourly { get; set; }
  27. // service adv
  28. public int adv_id { get; set; }
  29. public string msg_adv { get; set; }
  30. public string adv_name { get; set; }
  31. public string channel_adv { get; set; }
  32. public string message_type { get; set; }
  33. public string from_money { get; set; }
  34. // status
  35. public int status { get; set; }
  36. public static List<Services> Parse(OracleDataReader reader)
  37. {
  38. List<Services> result = new List<Services>();
  39. try
  40. {
  41. while (reader.Read())
  42. {
  43. Services sv = new Services();
  44. for (int i = 0; i < reader.FieldCount; i++)
  45. {
  46. if (reader.GetName(i).ToUpper() == "ID")
  47. try
  48. {
  49. sv.id = int.Parse(reader.GetValue(i).ToString());
  50. }
  51. catch { }
  52. else if (reader.GetName(i).ToUpper() == "SV_NAME")
  53. {
  54. try
  55. {
  56. sv.sv_name = reader.GetValue(i).ToString();
  57. }
  58. catch { }
  59. }
  60. else if (reader.GetName(i).ToUpper() == "SV_CODE")
  61. {
  62. try
  63. {
  64. sv.sv_code = reader.GetValue(i).ToString();
  65. }
  66. catch { }
  67. }
  68. else if (reader.GetName(i).ToUpper() == "DB_NAME")
  69. {
  70. try
  71. {
  72. sv.db_name = reader.GetValue(i).ToString();
  73. }
  74. catch { }
  75. }
  76. else if (reader.GetName(i).ToUpper() == "CONNECTION_STRING")
  77. try
  78. {
  79. sv.connection_string = reader.GetValue(i).ToString();
  80. }
  81. catch { }
  82. else if (reader.GetName(i).ToUpper() == "DB_USERNAME")
  83. try
  84. {
  85. sv.db_username = reader.GetValue(i).ToString();
  86. }
  87. catch { }
  88. else if (reader.GetName(i).ToUpper() == "DB_PASSWORD")
  89. try
  90. {
  91. sv.db_password = reader.GetValue(i).ToString();
  92. }
  93. catch { }
  94. else if (reader.GetName(i).ToUpper() == "SQL_REPORT_DAILY")
  95. try
  96. {
  97. sv.sql_report_daily = reader.GetValue(i).ToString();
  98. }
  99. catch { }
  100. else if (reader.GetName(i).ToUpper() == "SQL_REPORT_HOURLY")
  101. try
  102. {
  103. sv.sql_report_hourly = reader.GetValue(i).ToString();
  104. }
  105. catch { }
  106. else if (reader.GetName(i).ToUpper() == "ADV_ID")
  107. try
  108. {
  109. sv.adv_id = int.Parse(reader.GetValue(i).ToString());
  110. }
  111. catch { }
  112. else if (reader.GetName(i).ToUpper() == "MSG_ADV")
  113. try
  114. {
  115. sv.msg_adv = reader.GetValue(i).ToString();
  116. }
  117. catch { }
  118. else if (reader.GetName(i).ToUpper() == "ADV_NAME")
  119. try
  120. {
  121. sv.adv_name = reader.GetValue(i).ToString();
  122. }
  123. catch { }
  124. else if (reader.GetName(i).ToUpper() == "MESSAGE_TYPE")
  125. try
  126. {
  127. sv.message_type = reader.GetValue(i).ToString();
  128. }
  129. catch { }
  130. else if (reader.GetName(i).ToUpper() == "CHANNEL_ADV")
  131. try
  132. {
  133. sv.channel_adv = reader.GetValue(i).ToString();
  134. }
  135. catch { }
  136. else if (reader.GetName(i).ToUpper() == "FROM_MONEY")
  137. try
  138. {
  139. sv.from_money = reader.GetValue(i).ToString();
  140. }
  141. catch { }
  142. else if (reader.GetName(i).ToUpper() == "STATUS")
  143. try
  144. {
  145. sv.status = int.Parse(reader.GetValue(i).ToString());
  146. }
  147. catch { }
  148. }
  149. result.Add(sv);
  150. }
  151. reader.Close();
  152. }
  153. catch
  154. {
  155. }
  156. finally
  157. {
  158. try
  159. {
  160. reader.Close();
  161. }
  162. catch { }
  163. }
  164. return result;
  165. }
  166. }
  167. }