AppSettleTool.cs 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. //************************************************************************
  2. // author: yuzhengyang
  3. // date: 2017.10.12 - 2017.10.12
  4. // desc: 客户端定居工具
  5. // Copyright (c) yuzhengyang. All rights reserved.
  6. //************************************************************************
  7. using Azylee.Core.IOUtils.DirUtils;
  8. using Azylee.Core.IOUtils.FileUtils;
  9. using System.Collections.Generic;
  10. using System.IO;
  11. namespace Azylee.Core.AppUtils
  12. {
  13. /// <summary>
  14. /// 客户端定居工具
  15. /// </summary>
  16. public class AppSettleTool
  17. {
  18. /// <summary>
  19. /// 判断是否已定居
  20. /// </summary>
  21. /// <param name="path">定居路径</param>
  22. /// <param name="list">货物清单</param>
  23. /// <returns></returns>
  24. public static bool IsSettle(string path, Dictionary<string, string> list)
  25. {
  26. if (Directory.Exists(path))
  27. {
  28. if (list != null)
  29. {
  30. bool allOk = true;
  31. foreach (var l in list)
  32. {
  33. if (!string.IsNullOrWhiteSpace(l.Value))
  34. allOk &= File.Exists(l.Value);
  35. }
  36. return allOk;
  37. }
  38. else
  39. {
  40. return true;
  41. }
  42. }
  43. return false;
  44. }
  45. /// <summary>
  46. /// 定居
  47. /// </summary>
  48. /// <param name="path">定居路径</param>
  49. /// <param name="list">货物清单</param>
  50. /// <returns></returns>
  51. public static bool Settle(string path, Dictionary<string, string> list)
  52. {
  53. if (DirTool.Create(path))
  54. {
  55. if (list != null)
  56. {
  57. foreach (var l in list)
  58. {
  59. FileTool.Copy(l.Key, l.Value, true);
  60. }
  61. }
  62. }
  63. return IsSettle(path, list);
  64. }
  65. }
  66. }