Users.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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 Users
  9. {
  10. //public int account_id { get; set; }
  11. public string user_name { get; set; }
  12. public string password { get; set; }
  13. public int status { get; set; }
  14. public int role { get; set; }
  15. public static List<Users> Parse(OracleDataReader reader)
  16. {
  17. List<Users> result = new List<Users>();
  18. try
  19. {
  20. while (reader.Read())
  21. {
  22. Users sv = new Users();
  23. for (int i = 0; i < reader.FieldCount; i++)
  24. {
  25. //if (reader.GetName(i).ToUpper() == "ACCOUNT_ID")
  26. // try
  27. // {
  28. // sv.account_id = int.Parse(reader.GetValue(i).ToString());
  29. // }
  30. // catch { }
  31. //else
  32. if (reader.GetName(i).ToUpper() == "USERNAME")
  33. {
  34. try
  35. {
  36. sv.user_name = reader.GetValue(i).ToString();
  37. }
  38. catch { }
  39. }
  40. else if (reader.GetName(i).ToUpper() == "PASSWORD")
  41. try
  42. {
  43. sv.password = reader.GetValue(i).ToString();
  44. }
  45. catch { }
  46. else if (reader.GetName(i).ToUpper() == "STATUS")
  47. try
  48. {
  49. sv.status = int.Parse(reader.GetValue(i).ToString());
  50. }
  51. catch { }
  52. else if (reader.GetName(i).ToUpper() == "ROLE")
  53. try
  54. {
  55. sv.role = int.Parse(reader.GetValue(i).ToString());
  56. }
  57. catch { }
  58. }
  59. result.Add(sv);
  60. }
  61. reader.Close();
  62. }
  63. catch
  64. {
  65. }
  66. finally
  67. {
  68. try
  69. {
  70. reader.Close();
  71. }
  72. catch { }
  73. }
  74. return result;
  75. }
  76. }
  77. }