WinEquipmentRelation-Web.xaml.cs 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. using CEFSharpWPF;
  2. using SAGA.MBI.Common;
  3. using SAGA.Models;
  4. using SAGA.RevitUtils.Windows;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Collections.ObjectModel;
  8. using System.Linq;
  9. using System.Text;
  10. using System.Text.RegularExpressions;
  11. using System.Threading.Tasks;
  12. using System.Windows;
  13. using System.Windows.Media;
  14. using System.Windows.Threading;
  15. namespace SAGA.GplotDrawData
  16. {
  17. /// <summary>
  18. /// WinEquipmentRelation_Web.xaml 的交互逻辑
  19. /// </summary>
  20. public partial class WinEquipmentRelation_Web : WinBase
  21. {
  22. public WinEquipmentRelation_Web()
  23. {
  24. InitializeComponent();
  25. this.Loaded += MainWindow_Loaded;
  26. }
  27. public ObservableCollection<DataNode> InDataNodes;
  28. private bool m_isReadData = true;
  29. private List<DataNode> dataNodes;
  30. private List<DataNode> orphanNodes;
  31. public WinEquipmentRelation_Web(List<DataNode> dataNodes, List<DataNode> orphanNodes) : this()
  32. {
  33. this.dataNodes = dataNodes;
  34. this.orphanNodes = orphanNodes;
  35. m_isReadData = false;
  36. }
  37. public UcGplotShow UcShow => ucShowElement;
  38. public void ReLoad(List<DataNode> dataNodes, List<DataNode> orphanNodes)
  39. {
  40. this.dataNodes = dataNodes;
  41. this.orphanNodes = orphanNodes;
  42. MainWindow_Loaded(null, null);
  43. }
  44. private void MainWindow_Loaded(object sender, RoutedEventArgs e)
  45. {
  46. if (m_isReadData)
  47. {
  48. #region 自定义读取
  49. var dataNodes = DbHelper.FindOneByFile<DataNode>();
  50. DataNode root = new DataNode("低压配电图") { Sno = "root", FloorName = "1" };
  51. dataNodes.Childrens.ForEach(d =>
  52. {
  53. //if (d.Type != "母联柜")
  54. {
  55. root.Childrens.Add(new DataNode(d.EName)
  56. {
  57. EId = d.EId,
  58. Sno = d.Sno,
  59. Type = d.Type,
  60. InLineNo = d.InLineNo,
  61. FloorName = d.FloorName
  62. });
  63. }
  64. });
  65. this.InDataNodes = new ObservableCollection<DataNode>(dataNodes.Childrens);
  66. this.rootNode.ItemsSource = new ObservableCollection<DataNode> { root };
  67. #endregion
  68. }
  69. else
  70. {
  71. #region 整理显示数据
  72. DataNode root = new DataNode("低压配电图") { Sno = "root", FloorName = "1" };
  73. var orphan = new DataNode("孤立节点") { Sno = "orphan", FloorName = "2" };
  74. //配电箱
  75. var orphanTdls = new DataNode("配电箱") { Sno = "TDLS", FloorName = "1" };
  76. //设备
  77. var orphanEq = new DataNode("设备") { Sno = "EQ", FloorName = "2" };
  78. orphan.Childrens.Add(orphanTdls);
  79. orphan.Childrens.Add(orphanEq);
  80. this.InDataNodes = new ObservableCollection<DataNode>(dataNodes);
  81. dataNodes.ForEach(d =>
  82. {
  83. root.Childrens.Add(new DataNode(d.EName)
  84. {
  85. EId = d.EId,
  86. Sno = d.Sno,
  87. Type = d.Type,
  88. InLineNo = d.InLineNo,
  89. FloorName = d.FloorName
  90. });
  91. });
  92. orphanNodes.ForEach(d =>
  93. {
  94. InDataNodes.Add(d);
  95. if (d.Type == "TDLS")
  96. {
  97. orphan.Childrens[0].Childrens.Add(new DataNode(d.EName)
  98. {
  99. EId = d.EId,
  100. Sno = d.Sno,
  101. Type = d.Type,
  102. InLineNo = d.InLineNo,
  103. FloorName = d.FloorName
  104. });
  105. }
  106. else
  107. {
  108. orphan.Childrens[1].Childrens.Add(new DataNode(d.EName)
  109. {
  110. EId = d.EId,
  111. Sno = d.Sno,
  112. Type = d.Type,
  113. InLineNo = d.InLineNo,
  114. FloorName = d.FloorName
  115. });
  116. }
  117. });
  118. root.Childrens = root.Childrens.OrderBy(t => t.FloorName).ToList();
  119. orphan.Childrens = orphan.Childrens.OrderBy(t => t.FloorName).ToList();
  120. orphan.Childrens[0].Childrens = orphan.Childrens[0].Childrens.OrderBy(t => t.FloorName).ToList();
  121. orphan.Childrens[1].Childrens = orphan.Childrens[1].Childrens.OrderBy(t => t.FloorName).ToList();
  122. this.rootNode.ItemsSource = new ObservableCollection<DataNode> { root, orphan };
  123. #endregion
  124. }
  125. }
  126. private void RootNode_OnSelectedItemChanged(object sender, RoutedPropertyChangedEventArgs<object> e)
  127. {
  128. Dispatcher.BeginInvoke(DispatcherPriority.Background, (Action) delegate
  129. {
  130. if (this.rootNode.SelectedItem is DataNode currNode)
  131. {
  132. if (currNode.Sno == "root")
  133. {
  134. // this.m_rootElements.ForEach(t => this.Canvas.Children.Add(t));
  135. }
  136. else
  137. {
  138. var data = InDataNodes.FirstOrDefault(d => d.EId == currNode.EId);
  139. if (data != null)
  140. {
  141. EquipmentGraphView view = new EquipmentGraphView();
  142. var db = view.CreateDb(data);
  143. ConstData.ResponseData = db.CreateJObjectGroup();
  144. ucShowElement.Show(WebGplotSettings.MindMapUrl);
  145. //显示属性窗体
  146. RevitModelFileUpload.ShowSpaceProperty(data.EId);
  147. }
  148. }
  149. }
  150. });
  151. }
  152. }
  153. }