Beispiel #1
0
        private Dev_Monitor InsertDataToEveryDev(Dev_Monitor Dm, List <TModel.Location.AreaAndDev.DevMonitorNode> dataList)
        {
            Dev_Monitor send      = new Dev_Monitor();
            string      strDevKKs = Dm.KKSCode;
            List <TModel.Location.AreaAndDev.DevMonitorNode> MonitorNodeList = dataList.FindAll(p => p.ParentKKS == strDevKKs);

            if (Dm.MonitorNodeList != null)
            {
                foreach (TModel.Location.AreaAndDev.DevMonitorNode item in Dm.MonitorNodeList)
                {
                    //string strNodeKKS = item.KKS;
                    TModel.Location.AreaAndDev.DevMonitorNode data = MonitorNodeList.Find(p => p.KKS == item.KKS);
                    //DevMonitorNode data = dataList.Find(p => p.TagName == item.TagName);
                    if (data == null || MonitorNodeList.Count == 0)
                    {
                        data = dataList.Find(p => p.TagName == item.TagName);
                    }
                    else
                    {
                    }

                    if (data != null)
                    {
                        item.Value = data.Value;
                        item.Time  = data.Time;
                    }
                }
            }

            if (Dm.ChildrenList != null && Dm.ChildrenList.Count > 0)
            {
                foreach (Dev_Monitor item2 in Dm.ChildrenList)
                {
                    Dev_Monitor ChildDm = InsertDataToEveryDev(item2, dataList);
                    if (ChildDm != null)
                    {
                        if (send.ChildrenList == null)
                        {
                            send.ChildrenList = new List <Dev_Monitor>();
                        }

                        send.ChildrenList.Add(ChildDm);
                    }
                }
            }

            send.KKSCode         = Dm.KKSCode;
            send.Name            = Dm.Name;
            send.MonitorNodeList = Dm.MonitorNodeList;

            return(send);
        }
Beispiel #2
0
 /// <summary>
 /// 实时获取sis数据
 /// </summary>
 /// <param name="tags"></param>
 /// <returns></returns>
 public Dev_Monitor getNowDevMonitorInfoByTags(string tags)
 {
     try
     {
         //替换特殊字符
         //   空格    -    %20
         //    "          -    %22
         //    #         -    %23
         //    %        -    %25
         //    &         -    %26
         //    (          -    %28
         //    )          -    %29
         //    +         -    %2B
         //    ,          -    %2C
         //    /          -    %2F
         //    :          -    %3A
         //    ;          -    %3B
         //    <         -    %3C
         //    =         -    %3D
         //    >         -    %3E
         //    ?         -    %3F
         //    @       -    %40
         //    \          -    %5C
         //    |          -    %7C
         tags = tags.Replace(" ", "%20").Replace("#", "%23").Replace("+", "%2B").Replace("/", "%2F");
         Dev_Monitor monitor = new Dev_Monitor();
         List <TModel.Location.AreaAndDev.DevMonitorNode> nodesList = new List <TModel.Location.AreaAndDev.DevMonitorNode>();
         List <SisData> sisList = WebApiHelper.GetEntity <List <SisData> >("http://10.146.33.9:20080/MIS/GetRtMonTagInfosByNames?tagNames=" + tags);
         foreach (SisData sisData in sisList)
         {
             TModel.Location.AreaAndDev.DevMonitorNode dev = new TModel.Location.AreaAndDev.DevMonitorNode();
             dev.TagName   = sisData.Name;
             dev.Value     = sisData.Value;
             dev.Unit      = sisData.Unit;
             dev.ParentKKS = sisData.Desc;
             nodesList.Add(dev);
         }
         monitor.MonitorNodeList.AddRange(nodesList);
         return(monitor);
     }
     catch (Exception ex)
     {
         Log.Error("DevService.getNowDevMonitorInfoByTags:" + ex.ToString());
         return(null);
     }
 }