PhoneInfo.cs 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677
  1. using System;
  2. using System.Collections.Generic;
  3. using Oracle.ManagedDataAccess.Client;
  4. using System.Linq;
  5. using System.Web;
  6. namespace ReportWeb.Models
  7. {
  8. public class PhoneInfo
  9. {
  10. public string id { get; set; }
  11. public string code { get; set; }
  12. public string msisdn { get; set; }
  13. public string insert_time { get; set; }
  14. public string last_update { get; set; }
  15. public int status { get; set; }
  16. public static List<PhoneInfo> Parse(OracleDataReader reader)
  17. {
  18. List<PhoneInfo> result = new List<PhoneInfo>();
  19. try
  20. {
  21. while (reader.Read())
  22. {
  23. PhoneInfo sv = new PhoneInfo();
  24. for (int i = 0; i < reader.FieldCount; i++)
  25. {
  26. if (reader.GetName(i).ToUpper() == "MSISDN")
  27. try
  28. {
  29. sv.msisdn = reader.GetValue(i).ToString();
  30. }
  31. catch { }
  32. else if (reader.GetName(i).ToUpper() == "CODE")
  33. try
  34. {
  35. sv.code = reader.GetValue(i).ToString();
  36. }
  37. catch { }
  38. else if (reader.GetName(i).ToUpper() == "INSERT_TIME")
  39. try
  40. {
  41. sv.insert_time = reader.GetDateTime(i).ToString("dd/MM/yyyy HH:mm:ss");
  42. }
  43. catch { }
  44. else if (reader.GetName(i).ToUpper() == "LAST_UPDATE")
  45. try
  46. {
  47. sv.last_update = reader.GetDateTime(i).ToString("dd/MM/yyyy HH:mm:ss");
  48. }
  49. catch { }
  50. else if (reader.GetName(i).ToUpper() == "STATUS")
  51. try
  52. {
  53. sv.status = int.Parse(reader.GetValue(i).ToString());
  54. }
  55. catch { }
  56. }
  57. result.Add(sv);
  58. }
  59. reader.Close();
  60. }
  61. catch
  62. {
  63. }
  64. finally
  65. {
  66. try
  67. {
  68. reader.Close();
  69. }
  70. catch { }
  71. }
  72. return result;
  73. }
  74. }
  75. }