Services.cs 7.1 KB

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