RiskMsgResxManager.cs 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.IO;
  6. using System.Collections;
  7. using Muchinfo.PC.Common.Bosn;
  8. namespace Muchinfo.MTPClient.Resources
  9. {
  10. public class RiskMsgResxManager
  11. {
  12. private const string _fileName = "RiskMsgResx.dll";
  13. public static CommonResx RiskMsgResx { get; set; }
  14. public static void SaveRiskMsgResx(Hashtable hastableResx, ulong ver)
  15. {
  16. var resx = new CommonResx() { ResourceHashtable = hastableResx, Version = ver };
  17. string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName);
  18. JsonHelper.SaveData<CommonResx>(path, resx, null, true);
  19. }
  20. public static CommonResx GetRiskMsgResx()
  21. {
  22. var resx = new CommonResx() { Version = 0 };
  23. string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName);
  24. if (!File.Exists(path))
  25. return resx;
  26. return JsonHelper.LoadData<CommonResx>(path).FirstOrDefault();
  27. }
  28. public static string RiskMsgDesc(string constKey)
  29. {
  30. if (RiskMsgResx != null && RiskMsgResx.ResourceHashtable != null &&
  31. RiskMsgResx.ResourceHashtable.ContainsKey(constKey))
  32. {
  33. return RiskMsgResx.ResourceHashtable[constKey] as string;
  34. }
  35. else
  36. {
  37. return Client_Resource.ResourceManager.GetString(constKey);
  38. }
  39. }
  40. public static void InitRiskMsgResx()
  41. {
  42. RiskMsgResx = GetRiskMsgResx();
  43. }
  44. #region 数据存在UserData目录
  45. public static void InitRiskMsgResx(string filePath)
  46. {
  47. RiskMsgResx = GetRiskMsgResx(filePath);
  48. }
  49. public static void SaveRiskMsgResx(Hashtable hastableResx, ulong ver, string filePath)
  50. {
  51. string path = Path.Combine(filePath, _fileName);
  52. ResxManagerHelper.SaveData(hastableResx, ver, path);
  53. }
  54. private static CommonResx GetRiskMsgResx(string filePath)
  55. {
  56. string path = Path.Combine(filePath, _fileName);
  57. return ResxManagerHelper.GetData(path);
  58. }
  59. #endregion
  60. }
  61. }