PEPCodeConvert.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. /* ==============================================================================
  2. * 功能描述:PEPCodeConvert
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/4/8 11:50:03
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Threading.Tasks;
  11. using Newtonsoft.Json.Linq;
  12. using SAGA.DotNetUtils.Extend;
  13. using SAGA.DotNetUtils.Http;
  14. using SAGA.MBI.Common;
  15. using SAGA.MBI.DataArrange;
  16. using SAGA.MBI.Model;
  17. using SAGA.MBI.RequestData;
  18. using SAGA.MBI.Tools;
  19. using SAGA.RevitUtils;
  20. namespace SAGA.MBI.JsonConvert
  21. {
  22. /// <summary>
  23. /// PEPCodeConvert
  24. /// </summary>
  25. public class PEPCodeConvert
  26. {
  27. /// <summary>
  28. /// 信息点的定义
  29. /// </summary>
  30. /// <param name="code"></param>
  31. /// <returns></returns>
  32. public static PropertyDefineTb GetPropertyDefineTb(string code)
  33. {
  34. List<PropertyDefineTb> tbs = MBIControl.PropertyDefineTbs;
  35. PropertyDefineTb tb = tbs.FirstOrDefault(t => t.Code == code);
  36. if (tb == null)
  37. {
  38. //暂时只处理独有的信息点
  39. tb = DataPlatFormSysOrEqInfos(code);
  40. tbs.Add(tb);
  41. }
  42. return tb;
  43. }
  44. /// <summary>
  45. /// 数据平台系统和设备的完整信息点
  46. /// </summary>
  47. /// <returns></returns>
  48. public static PropertyDefineTb DataPlatFormSysOrEqInfos(string code)
  49. {
  50. PropertyDefineTb tb = new PropertyDefineTb(code);
  51. try
  52. {
  53. //控制是否显示,包含自定义信息点
  54. var json = PEPCodeRequest.InfoCodeQuery(code);
  55. if (json.IsSuccessRequest())
  56. {
  57. JObject jObject = JObject.Parse(json);
  58. foreach (JObject subj in jObject["Content"])
  59. {
  60. PropertyDefineItem item = new PropertyDefineItem();
  61. item.Category = (string)subj["firstTag"];
  62. item.SubCategory = (string)subj["secondTag"];
  63. item.Name = (string)subj["infoPointName"];
  64. item.CodeName = (string)subj["infoPointCode"];
  65. item.Unit = (string)subj["unit"];
  66. item.Type = (string)subj["dataType"];
  67. item.InputType = (string)subj["inputMode"];
  68. item.EnumSource = subj.GetValueEx("dataSource");
  69. item.Remark = (string)subj["note"];
  70. item.Classification = (string)subj["classification"];
  71. item.IsShow = (bool)subj["visible"];
  72. item.CollectionCmptCode = DalInfoCode.GetInputType(item.InputType);
  73. tb.PropertyDefineItems.Add(item);
  74. }
  75. }
  76. }
  77. catch (Exception e)
  78. {
  79. MessageShow.Show(e);
  80. }
  81. return tb;
  82. }
  83. }
  84. }