123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232 |
- /* ==============================================================================
- * 功能描述:MEquipment
- * 创 建 者:Garrett
- * 创建日期:2018/3/27 15:39:12
- * ==============================================================================*/
- using System;
- using System.Collections.Generic;
- using System.Collections.ObjectModel;
- using System.ComponentModel;
- using System.Drawing;
- using System.Linq;
- using System.Reflection;
- using System.Text;
- using System.Threading.Tasks;
- using Autodesk.Revit.DB;
- using CEFSharpWpf;
- using Newtonsoft.Json.Linq;
- using SAGA.DotNetUtils;
- using SAGA.DotNetUtils.Extend;
- using SAGA.DotNetUtils.Logger;
- using SAGA.DotNetUtils.Others;
- using SAGA.DotNetUtils.WPF;
- using SAGA.MBI.Common;
- using SAGA.MBI.DataArrange;
- using SAGA.MBI.JsonConvert;
- using SAGA.MBI.RequestData;
- using SAGA.MBI.Tools;
- using SAGA.MBI.WinView.ModeInfoMaintenance;
- using WPG.Data;
- using WPG.UserControls;
- namespace SAGA.MBI.Model
- {
- /// <summary>
- /// MEquipment
- /// </summary>
- public class MEquipmentPart : MRevitEquipBase
- {
- public MEquipmentPart(string floorId, string bimMId)
- {
- this.FloorId = floorId;
- this.BimID = bimMId;
- ServirceImages = new ObservableCollection<MServiceAttachment>();
- }
- #region AttachProperty
- /// <summary>
- /// 关联的设备
- /// </summary>
- public MRevitEquipBase MEquipment { get; set; }
- #endregion
- #region CloudProperty
- private string m_Name;
- [Description("CompName")]
- public string Name
- {
- get { return m_Name; }
- set
- {
- m_Name = value;
- NotifyPropertyChanged("Name");
- }
- }
- private string m_LocalId;
- [Description("CompLocalID")]
- public string LocalId
- {
- get { return m_LocalId; }
- set
- {
- m_LocalId = value;
- NotifyPropertyChanged("LocalId");
- }
- }
- private string m_LocalName;
- [Description("CompLocalName")]
- public string LocalName
- {
- get { return m_LocalName; }
- set
- {
- m_LocalName = value;
- RaisePropertyChanged(() => this.LocalName);
- }
- }
- #endregion Model
- #region VirtualMethod
- public override string ToString()
- {
- string result = this.LocalName;
- if (result.IsNotNullEmpty())
- return result;
- result = this.Name;
- if (result.IsNotNullEmpty())
- return result;
- return "未知";
- }
- public override bool AddObject()
- {
- if (MEquipment == null)
- {
- Log4Net.Info($"部件 {BimID} 无关联的设备,Add操作失败");
- return false;
- }
- return EquipmentPartConvert.AddEquipmentPart(this);
- }
- public override bool DelObject()
- {
- if (Id.IsNullOrEmpty()) return false;
- var rlt = new RltEquipInSpace(this.Id, null) { Operator = DocumentChangedOperator.Delete };
- rlt.DelObject();
- //删除设备所在楼层
- var rltequipinfloor = new RltEquipinFloor(this.Id, null) { Operator = DocumentChangedOperator.Delete };
- rltequipinfloor.AddorUpdateObject();
- return EquipmentPartConvert.DelEquipmentPart(this.Id);
- }
- /// <summary>
- /// 信息点维护的固定参数
- /// </summary>
- /// <returns></returns>
- public override CompositeItem SetFixedProperty()
- {
- CompositeItem item = new PropertyCollection();
- string code = this.EquipClassCode;
- PropertyDefineTb pdtb = PEPCodeConvert.GetPropertyDefineTb(code);
- Property property = new Property(this);
- //属性窗格用到的信息
- property.Category = "编码及关系";
- property.Name = "模型ID";
- //Type应该先于Value进行赋值
- property.PropertyType = typeof(string);
- property.IsReadOnly = true;
- property.Define = pdtb.PropertyDefineItems.FirstOrDefault(t => t.CodeName == "BIMID");
- //property.PropertyChangeAction += PropertyChangeAction;
- item.Items.Add(property);
- Property property1 = new Property(this);
- //属性窗格用到的信息
- property1.Category = "编码及关系";
- property1.Name = "设备ID";
- //Type应该先于Value进行赋值
- property1.PropertyType = typeof(string);
- property1.IsReadOnly = true;
- property1.Define = pdtb.PropertyDefineItems.FirstOrDefault(t => t.CodeName == "CompID");
- //property1.PropertyChangeAction += PropertyChangeAction;
- item.Items.Add(property1);
- Property property2 = new Property(this);
- //属性窗格用到的信息
- property2.Category = "编码及关系";
- property2.Name = "对应资产";
- //Type应该先于Value进行赋值
- property2.PropertyType = typeof(UcReferenceFM);
- property2.Value = this.FMID.IsNullOrEmpty() ? "请选择" : this.FMID;
- property2.ExtendClickAction = PWGInstace.WinMatchFMClick;
- //property2.PropertyChangeAction += PropertyChangeAction;
- item.Items.Add(property2);
- //设备关联过资产后才有二维码图片
- if (this.FMID.IsNotNullEmpty())
- {
- Property propertyi2 = new Property(this);
- propertyi2.Category = "编码及关系";
- propertyi2.Name = "设备二维码图片";
- propertyi2.PropertyType = typeof(UcHyperlink);
- propertyi2.ItemClickAction = PWGInstace.WinQRCodeItemClick;
- propertyi2.Value = this.FMID.IsNullOrEmpty() ? null : "点击查看二维码图片";
- item.Items.Add(propertyi2);
- }
- MSpace = DalSpace.GetMSpace(this.Id);
- Property propertySpace = new Property(this);
- //属性窗格用到的信息
- propertySpace.Category = "编码及关系";
- propertySpace.Name = "所在元空间";
- //Type应该先于Value进行赋值
- propertySpace.PropertyType = typeof(UcHyperlink);
- propertySpace.ItemClickAction = PWGInstace.WinISpaceItemClick;
- propertySpace.Value = this.MSpace?.ToString();
- item.Items.Add(propertySpace);
- return item;
- }
- #endregion
- /// <summary>
- /// 查看详细信息
- /// </summary>
- /// <param name="param"></param>
- [Command]
- public void ShowDetail(object param)
- {
- try
- {
- var url =
- $"{MBIConst.Html5DetailLocalHost}details?perjectId={MBIControl.ProjectCur.Id}&secret={MBIControl.ProjectCur.Password}&FmId={this.Id}&type=0&code={EquipClassCode}";
- //url = "www.baidu.com";
- var win = WinBrowser.Instance;
- win.Width = 1233;
- win.Height = 902;
- win.Show(url);
- }
- catch (Exception e)
- {
- MessageShowBase.Show(e);
- }
- }
- public bool CanShowDetail(object param)
- {
- return true;
- }
- }
- }
|