MEquipmentPart.cs 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232
  1. /* ==============================================================================
  2. * 功能描述:MEquipment
  3. * 创 建 者:Garrett
  4. * 创建日期:2018/3/27 15:39:12
  5. * ==============================================================================*/
  6. using System;
  7. using System.Collections.Generic;
  8. using System.Collections.ObjectModel;
  9. using System.ComponentModel;
  10. using System.Drawing;
  11. using System.Linq;
  12. using System.Reflection;
  13. using System.Text;
  14. using System.Threading.Tasks;
  15. using Autodesk.Revit.DB;
  16. using CEFSharpWpf;
  17. using Newtonsoft.Json.Linq;
  18. using SAGA.DotNetUtils;
  19. using SAGA.DotNetUtils.Extend;
  20. using SAGA.DotNetUtils.Logger;
  21. using SAGA.DotNetUtils.Others;
  22. using SAGA.DotNetUtils.WPF;
  23. using SAGA.MBI.Common;
  24. using SAGA.MBI.DataArrange;
  25. using SAGA.MBI.JsonConvert;
  26. using SAGA.MBI.RequestData;
  27. using SAGA.MBI.Tools;
  28. using SAGA.MBI.WinView.ModeInfoMaintenance;
  29. using WPG.Data;
  30. using WPG.UserControls;
  31. namespace SAGA.MBI.Model
  32. {
  33. /// <summary>
  34. /// MEquipment
  35. /// </summary>
  36. public class MEquipmentPart : MRevitEquipBase
  37. {
  38. public MEquipmentPart(string floorId, string bimMId)
  39. {
  40. this.FloorId = floorId;
  41. this.BimID = bimMId;
  42. ServirceImages = new ObservableCollection<MServiceAttachment>();
  43. }
  44. #region AttachProperty
  45. /// <summary>
  46. /// 关联的设备
  47. /// </summary>
  48. public MRevitEquipBase MEquipment { get; set; }
  49. #endregion
  50. #region CloudProperty
  51. private string m_Name;
  52. [Description("CompName")]
  53. public string Name
  54. {
  55. get { return m_Name; }
  56. set
  57. {
  58. m_Name = value;
  59. NotifyPropertyChanged("Name");
  60. }
  61. }
  62. private string m_LocalId;
  63. [Description("CompLocalID")]
  64. public string LocalId
  65. {
  66. get { return m_LocalId; }
  67. set
  68. {
  69. m_LocalId = value;
  70. NotifyPropertyChanged("LocalId");
  71. }
  72. }
  73. private string m_LocalName;
  74. [Description("CompLocalName")]
  75. public string LocalName
  76. {
  77. get { return m_LocalName; }
  78. set
  79. {
  80. m_LocalName = value;
  81. RaisePropertyChanged(() => this.LocalName);
  82. }
  83. }
  84. #endregion Model
  85. #region VirtualMethod
  86. public override string ToString()
  87. {
  88. string result = this.LocalName;
  89. if (result.IsNotNullEmpty())
  90. return result;
  91. result = this.Name;
  92. if (result.IsNotNullEmpty())
  93. return result;
  94. return "未知";
  95. }
  96. public override bool AddObject()
  97. {
  98. if (MEquipment == null)
  99. {
  100. Log4Net.Info($"部件 {BimID} 无关联的设备,Add操作失败");
  101. return false;
  102. }
  103. return EquipmentPartConvert.AddEquipmentPart(this);
  104. }
  105. public override bool DelObject()
  106. {
  107. if (Id.IsNullOrEmpty()) return false;
  108. var rlt = new RltEquipInSpace(this.Id, null) { Operator = DocumentChangedOperator.Delete };
  109. rlt.DelObject();
  110. //删除设备所在楼层
  111. var rltequipinfloor = new RltEquipinFloor(this.Id, null) { Operator = DocumentChangedOperator.Delete };
  112. rltequipinfloor.AddorUpdateObject();
  113. return EquipmentPartConvert.DelEquipmentPart(this.Id);
  114. }
  115. /// <summary>
  116. /// 信息点维护的固定参数
  117. /// </summary>
  118. /// <returns></returns>
  119. public override CompositeItem SetFixedProperty()
  120. {
  121. CompositeItem item = new PropertyCollection();
  122. string code = this.EquipClassCode;
  123. PropertyDefineTb pdtb = PEPCodeConvert.GetPropertyDefineTb(code);
  124. Property property = new Property(this);
  125. //属性窗格用到的信息
  126. property.Category = "编码及关系";
  127. property.Name = "模型ID";
  128. //Type应该先于Value进行赋值
  129. property.PropertyType = typeof(string);
  130. property.IsReadOnly = true;
  131. property.Define = pdtb.PropertyDefineItems.FirstOrDefault(t => t.CodeName == "BIMID");
  132. //property.PropertyChangeAction += PropertyChangeAction;
  133. item.Items.Add(property);
  134. Property property1 = new Property(this);
  135. //属性窗格用到的信息
  136. property1.Category = "编码及关系";
  137. property1.Name = "设备ID";
  138. //Type应该先于Value进行赋值
  139. property1.PropertyType = typeof(string);
  140. property1.IsReadOnly = true;
  141. property1.Define = pdtb.PropertyDefineItems.FirstOrDefault(t => t.CodeName == "CompID");
  142. //property1.PropertyChangeAction += PropertyChangeAction;
  143. item.Items.Add(property1);
  144. Property property2 = new Property(this);
  145. //属性窗格用到的信息
  146. property2.Category = "编码及关系";
  147. property2.Name = "对应资产";
  148. //Type应该先于Value进行赋值
  149. property2.PropertyType = typeof(UcReferenceFM);
  150. property2.Value = this.FMID.IsNullOrEmpty() ? "请选择" : this.FMID;
  151. property2.ExtendClickAction = PWGInstace.WinMatchFMClick;
  152. //property2.PropertyChangeAction += PropertyChangeAction;
  153. item.Items.Add(property2);
  154. //设备关联过资产后才有二维码图片
  155. if (this.FMID.IsNotNullEmpty())
  156. {
  157. Property propertyi2 = new Property(this);
  158. propertyi2.Category = "编码及关系";
  159. propertyi2.Name = "设备二维码图片";
  160. propertyi2.PropertyType = typeof(UcHyperlink);
  161. propertyi2.ItemClickAction = PWGInstace.WinQRCodeItemClick;
  162. propertyi2.Value = this.FMID.IsNullOrEmpty() ? null : "点击查看二维码图片";
  163. item.Items.Add(propertyi2);
  164. }
  165. MSpace = DalSpace.GetMSpace(this.Id);
  166. Property propertySpace = new Property(this);
  167. //属性窗格用到的信息
  168. propertySpace.Category = "编码及关系";
  169. propertySpace.Name = "所在元空间";
  170. //Type应该先于Value进行赋值
  171. propertySpace.PropertyType = typeof(UcHyperlink);
  172. propertySpace.ItemClickAction = PWGInstace.WinISpaceItemClick;
  173. propertySpace.Value = this.MSpace?.ToString();
  174. item.Items.Add(propertySpace);
  175. return item;
  176. }
  177. #endregion
  178. /// <summary>
  179. /// 查看详细信息
  180. /// </summary>
  181. /// <param name="param"></param>
  182. [Command]
  183. public void ShowDetail(object param)
  184. {
  185. try
  186. {
  187. var url =
  188. $"{MBIConst.Html5DetailLocalHost}details?perjectId={MBIControl.ProjectCur.Id}&secret={MBIControl.ProjectCur.Password}&FmId={this.Id}&type=0&code={EquipClassCode}";
  189. //url = "www.baidu.com";
  190. var win = WinBrowser.Instance;
  191. win.Width = 1233;
  192. win.Height = 902;
  193. win.Show(url);
  194. }
  195. catch (Exception e)
  196. {
  197. MessageShowBase.Show(e);
  198. }
  199. }
  200. public bool CanShowDetail(object param)
  201. {
  202. return true;
  203. }
  204. }
  205. }