using Hydro.CommonBase; using Newtonsoft.Json; using System.Collections.Generic; using System.ComponentModel; using System.Linq; namespace Hydro.ConfigModel { public class LogicPoint { public dict History = null; public static dict Compare(LogicPoint host1, LogicPoint host2) { dict di=new dict(); bool flag = true; //比较host1和host2的所有属性,并记录不同的属性,按照以下格式记录:"属性名(old)":host1的属性值(old) "属性名(new)":host2的属性值(new),如果属性值相同,则不记录,例如:di.Add("Name (old)", host1.Name.ToString()); di.Add("Name (new)", host2.Name.ToString()); if (host1.Name != host2.Name) { flag = false; di.Add("Name (old)", host1.Name); di.Add("Name (new)", host2.Name); } if (host1.LogicType != host2.LogicType) { flag = false; di.Add("LogicType (old)", host1.LogicType); di.Add("LogicType (new)", host1.LogicType); } if (host1.ExpressionType != host2.ExpressionType) { flag = false; di.Add("ExpressionType (old)", host1.ExpressionType); di.Add("ExpressionType (new)", host2.ExpressionType); } if (host1.IndicatorType != host2.IndicatorType) { flag = false; di.Add("IndicatorType (old)", host1.IndicatorType); di.Add("IndicatorType (new)", host2.IndicatorType); } if (host1.ModelObjectID != host2.ModelObjectID) { flag = false; di.Add("ModelObjectID (old)", host1.ModelObjectID); di.Add("ModelObjectID (new)", host2.ModelObjectID); } //if (host1.Sort != host2.Sort) { flag = false; di.Add("Sort", host1.Sort); } if (host1.ParentId != host2.ParentId) { flag = false; di.Add("ParentId (old)", host1.ParentId); di.Add("ParentId (new)", host2.ParentId); } if (host1.Expression != host2.Expression) { flag = false; di.Add("Expression (old)", host1.Expression); di.Add("Expression (new)", host2.Expression); } if (host1.ObjectType != host2.ObjectType) { flag = false; di.Add("ObjectType (old)", host1.ObjectType); di.Add("ObjectType (new)", host2.ObjectType); } if (host1.accurary != host2.accurary) { flag = false; di.Add("accurary (old)", host1.accurary); di.Add("accurary (new)", host2.accurary); } if (host1.childSolution != host2.childSolution) { flag = false; di.Add("childSolution (old)", host1.childSolution); di.Add("childSolution (new)", host2.childSolution); } if (host1.childTag != host2.childTag) { flag = false; di.Add("childTag (old)", host1.childTag); di.Add("childTag (new)", host2.childTag); } if (host1.childType != host2.childType) { flag = false; di.Add("childType (old)", host1.childType); di.Add("childType (new)", host2.childType); } if (host1.SaveAcc != host2.SaveAcc) { flag = false; di.Add("SaveAcc (old)", host1.SaveAcc); di.Add("SaveAcc (new)", host2.SaveAcc); } if (host1.isSave != host2.isSave) { flag = false; di.Add("isSave (old)", host1.isSave); di.Add("isSave (new)", host2.isSave); } if (host1.SaveRange != host2.SaveRange) { flag = false; di.Add("SaveRange (old)", host1.SaveRange); di.Add("SaveRange (new)", host2.SaveRange); } if (host1.isMemSave != host2.isMemSave) { flag = false; di.Add("isMemSave (old)", host1.isMemSave); di.Add("isMemSave (new)", host2.isMemSave); } if (host1.MemSaveRange != host2.MemSaveRange) { flag = false; di.Add("MemSaveRange (old)", host1.MemSaveRange); di.Add("MemSaveRange (new)", host2.MemSaveRange); } if (host1.MemSaveAcc != host2.MemSaveAcc) { flag = false; di.Add("MemSaveAcc (old)", host1.MemSaveAcc); di.Add("MemSaveAcc (new)", host2.MemSaveAcc); } if (host1.MemSaveIndex != host2.MemSaveIndex) { flag = false; di.Add("MemSaveIndex (old)", host1.MemSaveIndex); di.Add("MemSaveIndex (new)", host2.MemSaveIndex); } if (host1.Enable != host2.Enable) { flag = false; di.Add("Enable (old)", host1.Enable); di.Add("Enable (new)", host2.Enable); } if (host1.Visible != host2.Visible) { flag = false; di.Add("Visible (old)", host1.Visible); di.Add("Visible (new)", host2.Visible); } return di; } public static string selectColumn = "Id, Name, LogicType, ExpressionType, IndicatorType, ModelObjectID, Sort, ParentId, Expression, ExtJson"; public static List Columns { get { return selectColumn.Split(',').Select(item => item.Trim()).ToList(); } set { selectColumn = string.Concat(value, ','); } } [DisplayName("编号")] [Category("1、基本信息")] public int Id { get; set; } [DisplayName("名称")] [Category("1、基本信息")] public string Name { get; set; } [DisplayName("类型")] [Category("1、基本信息")] public string LogicType { get; set; } [DisplayName("值类型")] [Category("2、计算参数")] public string ExpressionType { get; set; } private string _fullAddress; [Browsable(false)] public string FullAddress => _fullAddress ?? (_fullAddress = ExpressionType == "3389" ? LogicType : $"{LogicType}:{ExpressionType}"); [Browsable(false)] public string ExpressionToShow { get { if (ExpressionType == null) return null; if (ExpressionType.IndexOf("接口") >= 0 ) { return ExpressionType + " " + Expression; } else if (ExpressionType.IndexOf("基准值") >= 0 || ExpressionType.IndexOf("计算值") >= 0 || ExpressionType.IndexOf("变化值") >= 0 || ExpressionType.IndexOf("初始计算值") >= 0) { return ExpressionType + " " + Expression; } else if (ExpressionType.IndexOf("值") >= 0 || ExpressionType.IndexOf("系数") >= 0) { return ExpressionType; } else { return $"{ExpressionType} " + (ExpressionType == "∈" ? $"[{Expression}] ▲{accurary}" : (ExpressionType == "最小" || ExpressionType == "最大" ? $"| 容许范围[{Expression}]" : Expression)); } } } [DisplayName("监测类型")] [Category("1、基本信息")] public string IndicatorType { get; set; } [DisplayName("模型编号或内容")] [Category("2、计算参数")] public string ModelObjectID { get; set; } [DisplayName("排序")] [Category("4、其他")] public int Sort { get; set; } [DisplayName("父节点编号")] [Category("4、其他")] public int ParentId { get; set; } [DisplayName("值")] [Category("2、计算参数")] public string Expression { get; set; } [Browsable(false)] public string ExtJson { get; set; } = ""; private HostExt _ext; [Browsable(false)] public HostExt Ext { get { if (_ext == null) { try { _ext = JsonConvert.DeserializeObject(ExtJson); if (_ext == null) _ext = new HostExt(); return _ext; } catch { return (_ext=new HostExt()); } } else return _ext;// ?? } } [Browsable(false)] public byte[] VPN { get; set; } = null; [DisplayName("结果")] [Category("2、计算参数")] public string Result { get; set; } = null; public string objListString = null; public string Text_change = null; [DisplayName("对象名称")] [Category("1、基本信息")] public string ObjectType { get { return this.Ext.ObjectType; } set { this.Ext.ObjectType = value; } } [DisplayName("精度")] [Category("2、计算参数")] public string accurary { get { return this.Ext.accurary; } set { this.Ext.accurary = value; } } [DisplayName("子方案名称")] [Category("3、子方案")] public string childSolution { get { return this.Ext.childSolution; } set { this.Ext.childSolution = value; } } [DisplayName("子方案键")] [Category("3、子方案")] public string childTag { get { return this.Ext.childTag; } set { this.Ext.childTag = value; } } [DisplayName("子方案传输")] [Category("3、子方案")] public string childType { get { return this.Ext.childType; } set { this.Ext.childType = value; } } [DisplayName("子搜索精度")] [Category("3、子方案")] public string SaveAcc { get { return this.Ext.SaveAcc; } set { this.Ext.SaveAcc = value; } } [DisplayName("是否存储")] [Category("3、子方案")] public string isSave { get { return this.Ext.isSave; } set { this.Ext.isSave = value; } } [DisplayName("存储键值")] [Category("3、子方案")] public string SaveRange { get { return this.Ext.SaveRange; } set { this.Ext.SaveRange = value; } } [DisplayName("是否内存存储")] [Category("3、子方案")] public string isMemSave { get { return this.Ext.isMemSave; } set { this.Ext.isMemSave = value; } } [DisplayName("内存存储范围")] [Category("3、子方案")] public string MemSaveRange { get { return this.Ext.MemSaveRange; } set { this.Ext.MemSaveRange = value; } } [DisplayName("内存存储精度")] [Category("3、子方案")] public string MemSaveAcc { get { return this.Ext.MemSaveAcc; } set { this.Ext.MemSaveAcc = value; } } [DisplayName("内存存储次序")] [Category("3、子方案")] public string MemSaveIndex { get { return this.Ext.MemSaveIndex; } set { this.Ext.MemSaveIndex = value; } } [DisplayName("启用")] [Category("1、基本信息")] public bool Enable { get { return this.Ext.Enable; } set { this.Ext.Enable = value; } } [DisplayName("可见性")] [Category("1、基本信息")] public bool Visible { get { return this.Ext.Visible; } set { this.Ext.Visible = value; } } } }