TradeDateResxManager.cs 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  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 TradeDateResxManager
  11. {
  12. private const string _fileName = "TradeDateResx.dll";
  13. public static CommonResx TradeDateResx { get; set; }
  14. public static void SaveTradeDateResx(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 GetTradeDateResx()
  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 TradeDateDesc(string constKey)
  29. {
  30. if (TradeDateResx != null && TradeDateResx.ResourceHashtable != null &&
  31. TradeDateResx.ResourceHashtable.ContainsKey(constKey))
  32. {
  33. return TradeDateResx.ResourceHashtable[constKey] as string;
  34. }
  35. else
  36. {
  37. return Client_Resource.ResourceManager.GetString(constKey);
  38. }
  39. }
  40. public static void InitTradeDateResx()
  41. {
  42. TradeDateResx = GetTradeDateResx();
  43. }
  44. public static void TradeDateResxSaveRep(Hashtable resxHashtable, ulong ver)
  45. {
  46. TradeDateResx = new CommonResx() { ResourceHashtable = resxHashtable, Version = ver };
  47. SaveTradeDateResx(resxHashtable, ver);
  48. }
  49. #region 数据存在UserData目录
  50. public static void InitTradeDateResx(string filePath)
  51. {
  52. TradeDateResx = GetTradeDateResx(filePath);
  53. }
  54. public static void SaveTradeDateResx(Hashtable hastableResx, ulong ver, string filePath)
  55. {
  56. string path = Path.Combine(filePath, _fileName);
  57. ResxManagerHelper.SaveData(hastableResx, ver, path);
  58. }
  59. private static CommonResx GetTradeDateResx(string filePath)
  60. {
  61. string path = Path.Combine(filePath, _fileName);
  62. return ResxManagerHelper.GetData(path);
  63. }
  64. #endregion
  65. }
  66. }