PEPCodeConvert.cs 2.7 KB

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