Common.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. using ReportWeb.Models;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Configuration;
  5. using System.Security.Cryptography;
  6. namespace ReportWeb
  7. {
  8. /// <summary>
  9. /// Summary description for Common
  10. /// </summary>
  11. public class Common
  12. {
  13. //public static string CountryCode = ConfigurationManager.AppSettings["CountryCode"];
  14. //public static string Channel = ConfigurationManager.AppSettings["Channel"];
  15. public class PortStatus
  16. {
  17. public const int Closed = 0;
  18. public const int Opened = 1;
  19. }
  20. public class UserRole
  21. {
  22. public const int Admin = 1;
  23. public const int VAS = 2;
  24. public const int Agent = 3;
  25. }
  26. public class PortError
  27. {
  28. public const String NoError = "0";
  29. public const String NoMoney = "1";
  30. public const String Blocked = "2";
  31. }
  32. public class SmsError
  33. {
  34. public const int Success = 0;
  35. public const int NoSender = 1;
  36. public const int SendError = 2;
  37. public const int AuthenFail = 3;
  38. public const int Timeout = 4;
  39. public const int Exception = 5;
  40. public const int ParamInvalid = 6;
  41. }
  42. public class SmsStatus
  43. {
  44. public const int Sending = 1;
  45. public const int Wating = 0;
  46. }
  47. public Common()
  48. {
  49. }
  50. public static string EncryptPassword(string username, string password)
  51. {
  52. SHA256CryptoServiceProvider sha1 = new SHA256CryptoServiceProvider();
  53. byte[] bs = System.Text.Encoding.UTF8.GetBytes(password + username);
  54. bs = sha1.ComputeHash(bs);
  55. System.Text.StringBuilder encryptedPass = new System.Text.StringBuilder();
  56. foreach (byte b in bs)
  57. {
  58. encryptedPass.Append(b.ToString("x1").ToLower());
  59. }
  60. return encryptedPass.ToString();
  61. }
  62. //public static Services GetServiceById(List<Services> list, int serviceId)
  63. //{
  64. // HttpContext.Session.GetComplexData<List<Services>>("listService")
  65. // foreach (Services sv in (List<Services>)list)
  66. // {
  67. // if (sv.id == serviceId)
  68. // {
  69. // return sv;
  70. // }
  71. // }
  72. // return null;
  73. //}
  74. }
  75. }