ErrorCodeManager.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Resources;
  7. using System.Text;
  8. using System.Threading;
  9. using Muchinfo.MTPClient.Resources;
  10. //----------------------------------------------------------------
  11. //Module Name: $safeprojectname$
  12. //Purpose:
  13. //CopyRight: Muchinfo
  14. //History:
  15. //----------------------------------------------------------------
  16. //DateTime 2016/12/15
  17. //Author
  18. //Description Create
  19. //----------------------------------------------------------------
  20. using Muchinfo.PC.Common.Bosn;
  21. namespace Muchinfo.MTPClient.CustomException
  22. {
  23. public class ErrorCodeManager
  24. {
  25. private const string _fileName = "ErrorCodes.dll";
  26. /// <summary>
  27. /// 保存错误资源文件
  28. /// </summary>
  29. /// <param name="hastableResx"></param>
  30. /// <param name="ver"></param>
  31. public void SaveErrorCode(Hashtable hastableResx,ulong ver)
  32. {
  33. var resx = new CommonResx() { ResourceHashtable = hastableResx, Version = ver };
  34. string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName);
  35. JsonHelper.SaveData<CommonResx>(path, resx, null, true);
  36. }
  37. /// <summary>
  38. /// 获取 资源信息
  39. /// </summary>
  40. /// <returns></returns>
  41. public CommonResx GetErrorCode()
  42. {
  43. var resx = new CommonResx() { Version = 0 };
  44. string path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, _fileName);
  45. if (!File.Exists(path))
  46. return resx;
  47. return JsonHelper.LoadData<CommonResx>(path).FirstOrDefault();
  48. }
  49. }
  50. }