DalUserMenuPermission.cs 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. /* ==============================================================================
  2. * 功能描述:用户加载的菜单权限
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/9/18 10:28:07
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.IO;
  9. using System.Linq;
  10. using System.Text;
  11. using System.Threading.Tasks;
  12. using Newtonsoft.Json.Linq;
  13. using SAGA.DotNetUtils.MBI;
  14. using SAGA.DotNetUtils.Others;
  15. using SAGA.MBI.Common;
  16. using SAGA.MBI.RequestData;
  17. using SAGA.MBI.Tools;
  18. namespace SAGA.MBI.DataArrange
  19. {
  20. /// <summary>
  21. /// DalUserMenuMession
  22. /// </summary>
  23. class DalUserMenuPermission
  24. {
  25. /// <summary>
  26. /// 获取当前用户的可用的Revit命令列表
  27. /// </summary>
  28. /// <returns></returns>
  29. private static List<string> GetPermissionList()
  30. {
  31. List<string> list=new List<string>();
  32. string phone = MBIControl.ManageInfo.Phone_Num;
  33. string projectId = MBIControl.ProjectCur.Id;
  34. string str = LoginRequest.QueryPermission(phone, projectId);
  35. string msg = "";
  36. if (str.IsSuccessRequest2(ref msg))
  37. {
  38. JObject jobject = JObject.Parse(str);
  39. foreach (JToken jToken in jobject["content"])
  40. {
  41. list.Add(jToken.ToString());
  42. }
  43. }
  44. else
  45. {
  46. MessageShowBase.Infomation(msg);
  47. }
  48. return list;
  49. }
  50. /// <summary>
  51. /// 保存当前用户的权限数据
  52. /// </summary>
  53. public static void SavePermissionData()
  54. {
  55. var list = GetPermissionList();
  56. string dictionPath = OutReachConst.MBITempSettingPath;
  57. string fileName = OutReachConst.UserMenuPermission;
  58. string path =
  59. Path.Combine(Path.Combine(dictionPath, fileName));
  60. //先清空数据
  61. if (File.Exists(path))
  62. {
  63. File.Delete(path);
  64. }
  65. if (!Directory.Exists(dictionPath))
  66. Directory.CreateDirectory(dictionPath);
  67. foreach (var str in list) {
  68. var context = $"{str}\r\n";
  69. File.AppendAllText(path, context);
  70. }
  71. }
  72. }
  73. }