/// <summary> /// 获取所有KKS的相关监控数据 /// </summary> public static void GetAllKKSMonitorData() { WebApiHelper.IsSaveJsonToFile = true; try { LocationService service = new LocationService(); var bll = Bll.Instance(); var lst = bll.KKSCodes.ToList(); for (int i = 0; i < lst.Count; i++) { DbModel.Location.AreaAndDev.KKSCode item = lst[i]; var monitor = service.GetDevMonitorInfoByKKS(item.Code, true); if (i % 20 == 0) { Log.Info(LogTags.KKS, string.Format("获取KKS数据[{3:p3}]:{0},({1}/{2})", item, i, lst.Count, ((i + 0.0f) / lst.Count))); } } } catch (Exception ex) { Log.Error(LogTags.KKS, "获取监控点数据失败:" + ex.Message); } WebApiHelper.IsSaveJsonToFile = false; }
public void AddChild(KKSCode code) { if (Children == null) { Children = new List <KKSCode>(); } Children.Add(code); code.Parent = this; }
public void SetParent(KKSCode parent) { if (parent == null) { return; } Parent = parent; ParentCode = parent.Code; Parent.AddChild(this); }
public KKSCode GetAncestor(string type) { KKSCode p = Parent; while (p != null && p.MainType != type) { p = p.Parent; } return(p); }
public List <KKSCode> GetAncestors() { List <KKSCode> ancestors = new List <KKSCode>(); KKSCode p = Parent; while (p != null) { ancestors.Add(p); p = p.Parent; } return(ancestors); }
public void SetSystem(KKSCode sys, KKSCode subSys) { if (System == "") { if (subSys != null && subSys != this) { System = subSys.Name; } else if (sys != null) { System = sys.Name; } } }
private List <Dev_Monitor> GetChildMonitorDev(DbModel.Location.AreaAndDev.KKSCode KKS) { Dictionary <string, Dev_Monitor> devMoniters = new Dictionary <string, Dev_Monitor>(); List <DbModel.Location.AreaAndDev.KKSCode> childrenKKS = KKS.Children; if (childrenKKS != null) { List <string> kksList = new List <string>(); foreach (DbModel.Location.AreaAndDev.KKSCode item in childrenKKS) { kksList.Add(item.Code);//获取所有的子kks //Dev_Monitor dev = new Dev_Monitor(); //dev.Name = item.Name; //dev.KKSCode = item.Code; //dev.MonitorNodeList = GetDevMonitorNodeListByKKS(dev.KKSCode); //dev.ChildrenList = GetChildMonitorDev(item, bFlag); //child.Add(dev); } var monitorList = GetDevMonitorNodeListByKKS(kksList);//从数据库获取 if (monitorList != null) { foreach (DbModel.Location.AreaAndDev.KKSCode item in childrenKKS) { kksList.Add(item.Code); Dev_Monitor dev = new Dev_Monitor(); dev.Name = item.Name; dev.KKSCode = item.Code; dev.MonitorNodeList = monitorList.Where(i => i.ParentKKS == item.Code).ToList();//放到相应的对象中 //dev.ChildrenList = GetChildMonitorDev(item, bFlag); devMoniters.Add(item.Code, dev); } foreach (DbModel.Location.AreaAndDev.KKSCode item in childrenKKS) { Dev_Monitor dev = devMoniters[item.Code]; dev.ChildrenList = GetChildMonitorDev(item);//递归找子物体 } } } if (devMoniters.Count == 0) { return(null); } return(devMoniters.Values.ToList()); }
public Dev_Monitor GetDevMonitor(string KKS, bool isShowAll) { Dev_Monitor monitor = new Dev_Monitor(); DbModel.Location.AreaAndDev.KKSCode kksCode = KKSCodes.FirstOrDefault(p => p.Code == KKS); if (kksCode == null) { string dirPath = AppDomain.CurrentDomain.BaseDirectory + "Data\\DeviceData\\" + KKS + ".xml"; if (File.Exists(dirPath)) { var list = XmlSerializeHelper.LoadFromFile <TModel.Location.AreaAndDev.DevMonitorNodeList>(dirPath); monitor.Name = KKS; monitor.KKSCode = KKS; monitor.MonitorNodeList = list; } else { monitor = null; } } else { monitor.Name = kksCode.Name; monitor.KKSCode = kksCode.Code; var monitorNodeList = GetDevMonitorNodeListByKKS(kksCode.Code); monitor.MonitorNodeList = monitorNodeList; monitor.ChildrenList = GetChildMonitorDev(kksCode); if (isShowAll == false) { monitor.RemoveEmpty(); } monitor.AddChildrenMonitorNodes(); } if (monitor != null) { monitor.SetEmpty(); } return(monitor); }
public TEntity GetEntityByCode(string code) { DbEntity de = db.KKSCodes.DbSet.Where(p => p.Code == code).FirstOrDefault(); return(de.ToTModel()); }
public TEntity GetEntity(int id) { DbEntity de = db.KKSCodes.DbSet.Where(p => p.Id == id).FirstOrDefault(); return(de.ToTModel()); }