Example #1
0
        /// <summary>
        /// 获取新增运行记录信息
        /// </summary>
        public void getdata()
        {
            Jc_RInfo obj = null;
            long     key = 0;

            #region 获取运行记录数据
            try
            {
                List <Jc_RInfo> runLogList = Model.RealInterfaceFuction.GetRunRecordByCounter(LastCounter);
                for (int kj = 0; kj < runLogList.Count; kj++)
                {
                    key = long.Parse(runLogList[kj].ID);
                    if (runLogList[kj].Counter > LastCounter)
                    {//取最后获取的时间,作为下次获取数据的开始时间  20170909
                        LastCounter = runLogList[kj].Counter;
                    }
                    if (!jc_r.ContainsKey(key) && !runLogList[kj].Point.Contains("."))//修改,不显示网络模块运行记录  20180421
                    {
                        var tempDev = devAllList.Find(a => a.Devid == runLogList[kj].Devid);
                        if (tempDev != null)
                        {
                            if (tempDev.Name.Contains("风门") && !isDispalyDamper)
                            {
                                continue;//如果设置了风门不显示,则添加时,不添加风门运行记录到列表中
                            }
                        }

                        #region 新增运行记录
                        obj         = new Jc_RInfo();
                        obj.ID      = runLogList[kj].ID;
                        obj.PointID = runLogList[kj].PointID;
                        obj.Fzh     = runLogList[kj].Fzh;
                        obj.Kh      = runLogList[kj].Kh;
                        obj.Dzh     = runLogList[kj].Dzh;
                        obj.Devid   = runLogList[kj].Devid;
                        obj.Wzid    = runLogList[kj].Wzid;
                        obj.Point   = runLogList[kj].Point;
                        obj.Type    = runLogList[kj].Type;
                        obj.State   = runLogList[kj].State;
                        obj.Val     = runLogList[kj].Val;
                        obj.Timer   = runLogList[kj].Timer;
                        obj.Remark  = runLogList[kj].Remark;
                        obj.Bz1     = runLogList[kj].Bz1;
                        obj.Bz2     = runLogList[kj].Bz2;
                        obj.Bz3     = runLogList[kj].Bz3;
                        obj.Bz4     = runLogList[kj].Bz4;
                        obj.Bz5     = runLogList[kj].Bz5;
                        obj.Upflag  = runLogList[kj].Upflag;

                        jc_r.Add(long.Parse(obj.ID), obj);
                        addlist.Add(long.Parse(obj.ID));
                        #endregion
                    }
                }
            }
            catch (Exception ex)
            {
                Basic.Framework.Logging.LogHelper.Error(ex);
            }

            #region 判断运行记录记录是否可以删除
            DateTime    now     = Model.RealInterfaceFuction.GetServerNowTime();
            List <long> listkey = jc_r.Keys.ToList();
            for (int kj = 0; kj < listkey.Count; kj++)
            {
                key = listkey[kj];
                if ((now - jc_r[key].Timer).TotalMinutes > 1440)//将一天内的运行记录保留在客户端界面上  20170909
                {
                    deletelist.Add(key);
                }
            }
            #endregion
            #endregion

            #region //获取人员采集的轨迹实时信息 20171214
            try
            {
                //R_PhistoryInfo obj1 = null;
                //List<R_PhistoryInfo> r_PhistoryInfoList = Model.RealInterfaceFuction.GetRealR_PhistoryInfoList(R_PhistoryLastGetTime);
                //for (int kj = 0; kj < r_PhistoryInfoList.Count; kj++)
                //{
                //    key = long.Parse(r_PhistoryInfoList[kj].Id);
                //    if (r_PhistoryInfoList[kj].Timer > R_PhistoryLastGetTime)
                //    {//取最后获取的时间,作为下次获取数据的开始时间  20171214
                //        R_PhistoryLastGetTime = r_PhistoryInfoList[kj].Timer;
                //    }
                //    if (!R_PhistoryList.ContainsKey(key))
                //    {
                //        #region 新增人员实时采集记录
                //        obj1 = new R_PhistoryInfo();
                //        obj1.Id = r_PhistoryInfoList[kj].Id;
                //        obj1.Bh = r_PhistoryInfoList[kj].Bh;
                //        obj1.Name = r_PhistoryInfoList[kj].Name;
                //        obj1.Rtime = r_PhistoryInfoList[kj].Rtime;
                //        obj1.Timer = r_PhistoryInfoList[kj].Timer;
                //        obj1.Flag = r_PhistoryInfoList[kj].Flag;

                //        R_PhistoryList.Add(long.Parse(obj1.Id), obj1);
                //        r_phistoryaddlist.Add(long.Parse(obj1.Id));
                //        #endregion
                //    }
                //}
            }
            catch (Exception ex)
            {
                Basic.Framework.Logging.LogHelper.Error(ex);
            }
            #endregion

            #region 判断人员定位采集记录是否可以删除
            List <long> listkey1 = R_PhistoryList.Keys.ToList();
            for (int kj = 0; kj < listkey1.Count; kj++)
            {
                key = listkey1[kj];
                if ((now - R_PhistoryList[key].Timer).TotalMinutes > 120)//将1小时内的人员采集记录保留在客户端界面上  20170909
                {
                    r_phistorydeletelist.Add(key);
                }
            }
            #endregion
        }
Example #2
0
        /// <summary>
        /// 获取新增运行记录信息
        /// </summary>
        public void getdata()
        {
            Jc_RInfo obj = null;
            long     key = 0;


            #region 获取自动挂接数据

            try
            {
                automaticArticulatedDeviceInfo = DEFServiceModel.GetAllAutomaticArticulatedDeviceCache();
                //测试数据
                //AutomaticArticulatedDeviceInfo temp = new AutomaticArticulatedDeviceInfo();
                //temp.ID = "1111";
                //temp.DeviceOnlyCode = "2018000000";
                //temp.AddressNumber = 0;
                //temp.BranchNumber = 2;
                //temp.ChanelNumber = 8;
                //temp.DeviceModel = 34;
                //temp.ReciveTime = DateTime.Now;
                //temp.StationNumber = 1;
                //temp.Value = "10.0";
                //automaticArticulatedDeviceInfo.Add(temp);

                //List<AutomaticArticulatedDeviceInfo> automaticArticulatedDeviceInfo = new List<AutomaticArticulatedDeviceInfo>();

                //判断实时运行记录自动挂接记录是否还存在,如果不存在,则删除此自动挂接记录
                DataRow[] acrowinfos = showdt.Select("point='未定义'");
                if (acrowinfos != null && acrowinfos.Length > 0)
                {
                    for (int i = 0; i < acrowinfos.Length; i++)
                    {
                        var arid = acrowinfos[i]["id"].ToString();

                        if (automaticArticulatedDeviceInfo.FirstOrDefault(o => o.DeviceOnlyCode == arid) == null)
                        {
                            //deletelist.Add(long.Parse(arid));
                            deletelist.Add(arid);
                        }
                    }
                }
                if (automaticArticulatedDeviceInfo.Count > 0)
                {
                    automaticArticulatedDeviceInfo.ForEach(arinfo =>
                    {
                        if (arinfo.ChanelNumber <= 16)
                        {
                            //判断实时运行记录是否存在此自动挂接记录,如不存在,则添加一条记录
                            var rowinfo = showdt.Select("id='" + arinfo.DeviceOnlyCode + "'");
                            if (rowinfo == null || rowinfo.Length == 0)
                            {
                                #region 新增运行记录
                                obj                = new Jc_RInfo();
                                obj.ID             = arinfo.DeviceOnlyCode;
                                obj.Fzh            = arinfo.StationNumber;
                                obj.Kh             = arinfo.ChanelNumber;
                                Jc_DevInfo tempdev = devAllList.Find(a => a.Bz4 == arinfo.DeviceModel);
                                if (tempdev != null)
                                {
                                    obj.Devid = tempdev.Devid;
                                }
                                else
                                {
                                    obj.Devid = "";
                                }
                                obj.Dzh   = arinfo.AddressNumber;
                                obj.Wzid  = "-";
                                obj.Point = "未定义";
                                obj.Type  = -1;
                                obj.State = -1;
                                obj.Val   = arinfo.Value;
                                obj.Timer = arinfo.ReciveTime;
                                jc_r.Add(obj.ID, obj);
                                //addlist.Add(long.Parse(obj.ID));
                                addlist.Add(obj.ID);
                                #endregion
                            }
                            else
                            {
                                rowinfo[0]["ssz"] = arinfo.Value;//刷新实时值
                            }
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                Basic.Framework.Logging.LogHelper.Error(ex);
            }
            #endregion
        }
Example #3
0
        /// <summary>
        /// 刷新运行记录数据
        /// </summary>
        public void refresh(DateTime nowtime)
        {
            string point = "";

            DataRow[] row;
            DataRow   r;
            int       countn = 0;
            long      id = 0;
            Jc_RInfo  obj = null;
            int       tbcount = 0;
            object    wz = "", fzh = "", sszn = "", state = "", stime = "", sbstate = "";
            long      key = 0;

            #region  除已结束的记录
            try
            {
                if (deletelist.Count > 0)
                {
                    #region  除显示
                    countn = showdt.Rows.Count;
                    lock (objShowDt)
                    {
                        for (int i = 0; i < countn; i++)
                        {
                            try
                            {
                                if (deletelist.Contains(long.Parse(showdt.Rows[i]["id"].ToString())))
                                {
                                    showdt.Rows.Remove(showdt.Rows[i]);
                                    i--; countn--;
                                }
                            }
                            catch (Exception ex)
                            {
                                Basic.Framework.Logging.LogHelper.Error(ex);
                            }
                        }
                    }
                    #endregion

                    #region  除内存
                    for (int kj = 0; kj < deletelist.Count; kj++)
                    {
                        key = deletelist[kj];
                        if (jc_r.ContainsKey(key))
                        {
                            jc_r.Remove(key);
                        }
                    }
                    deletelist.Clear();
                    #endregion
                }
            }
            catch (Exception ex)
            {
                OprFuction.SaveErrorLogs("删除运行记录", ex);
            }
            #endregion

            #region  除已结束的人员实时采集记录
            try
            {
                if (r_phistorydeletelist.Count > 0)
                {
                    #region  除显示
                    countn = showdt1.Rows.Count;
                    lock (objShowDt1)
                    {
                        for (int i = 0; i < countn; i++)
                        {
                            try
                            {
                                if (r_phistorydeletelist.Contains(long.Parse(showdt1.Rows[i]["id"].ToString())))
                                {
                                    showdt1.Rows.Remove(showdt1.Rows[i]);
                                    i--; countn--;
                                }
                            }
                            catch (Exception ex)
                            {
                                Basic.Framework.Logging.LogHelper.Error(ex);
                            }
                        }
                    }
                    #endregion

                    #region  除内存
                    for (int kj = 0; kj < r_phistorydeletelist.Count; kj++)
                    {
                        key = r_phistorydeletelist[kj];
                        if (R_PhistoryList.ContainsKey(key))
                        {
                            R_PhistoryList.Remove(key);
                        }
                    }
                    r_phistorydeletelist.Clear();
                    #endregion
                }
            }
            catch (Exception ex)
            {
                OprFuction.SaveErrorLogs("删除人员实时采集记录", ex);
            }
            #endregion

            #region 添加记录

            if (addlist.Count > 0)
            {
                //tbcount = showdt.Rows.Count;
                try
                {
                    #region 添加记录
                    for (int kj = 0; kj < addlist.Count; kj++)
                    {
                        key = addlist[kj];
                        if (jc_r.ContainsKey(key))
                        {
                            obj   = jc_r[key];
                            point = obj.Point;
                            lock (StaticClass.allPointDtLockObj)
                            {
                                row = StaticClass.AllPointDt.Select("point='" + point + "'");
                                if (row.Length > 0)
                                {
                                    wz = row[0]["wz"];
                                }
                            }
                            fzh     = obj.Fzh + "/" + obj.Kh + "/" + obj.Dzh;
                            sszn    = obj.Val;
                            state   = OprFuction.StateChange(obj.Type.ToString());
                            sbstate = OprFuction.StateChange(obj.State.ToString());
                            stime   = OprFuction.TimeToString(obj.Timer);
                            id      = key;

                            // 20180821
                            //设备类型
                            var    devid   = obj.Devid;
                            var    dev     = listJcdev.FirstOrDefault(a => a.Devid == devid);
                            string devName = "";
                            if (dev != null)
                            {
                                devName = dev.Name;
                            }
                            lock (objShowDt)
                            {
                                r          = showdt.NewRow();
                                r["point"] = point;
                                r["wz"]    = wz;
                                r["fzh"]   = fzh;
                                r["ssz"]   = sszn;
                                r["state"] = state;
                                //r["sbstate"] = sbstate;
                                r["devName"] = devName;
                                r["time"]    = stime;
                                r["id"]      = key;
                                showdt.Rows.InsertAt(r, 0);//添加新记录

                                this.mainGridView.FocusedRowHandle = 0;
                            }
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    OprFuction.SaveErrorLogs("添加开关量运行记录记录", ex);
                }
                //tbcount = showdt.Rows.Count - tbcount;
                //StaticClass.yccount[5] += tbcount;
                addlist.Clear();
                //mainGridView.FocusedRowHandle = 0;
            }
            #endregion

            #region 添加人员采集记录

            R_PhistoryInfo obj1 = null;
            if (r_phistoryaddlist.Count > 0)
            {
                //tbcount = showdt.Rows.Count;
                try
                {
                    #region 添加记录
                    for (int kj = 0; kj < r_phistoryaddlist.Count; kj++)
                    {
                        key = r_phistoryaddlist[kj];
                        if (R_PhistoryList.ContainsKey(key))
                        {
                            obj1 = R_PhistoryList[key];
                            lock (objShowDt1)
                            {
                                r          = showdt1.NewRow();
                                r["Id"]    = R_PhistoryList[key].Id;
                                r["bh"]    = R_PhistoryList[key].Bh;
                                r["name"]  = R_PhistoryList[key].Name;
                                r["flag"]  = R_PhistoryList[key].Flag;
                                r["rtime"] = R_PhistoryList[key].Rtime;

                                showdt1.Rows.InsertAt(r, 0);//添加新记录

                                this.gridView1.FocusedRowHandle = 0;
                            }
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    OprFuction.SaveErrorLogs("添加人员实时采集记录", ex);
                }
                //tbcount = showdt.Rows.Count - tbcount;
                //StaticClass.yccount[5] += tbcount;
                r_phistoryaddlist.Clear();
                //mainGridView.FocusedRowHandle = 0;
            }
            #endregion

            #region 当前运行记录条数
            //tbcount = showdt.Rows.Count;
            //StaticClass.yccount[5] = tbcount;
            #endregion
        }
Example #4
0
        /// <summary>
        /// 刷新运行记录数据
        /// </summary>
        public void refresh(DateTime nowtime)
        {
            string point = "";

            DataRow[] row;
            DataRow   r;
            int       countn = 0;
            string    id = "0";
            Jc_RInfo  obj = null;
            int       tbcount = 0;
            object    wz = "", fzh = "", sszn = "", state = "", stime = "", sbstate = "";
            string    key = "0";

            #region  除已结束的记录
            try
            {
                if (deletelist.Count > 0)
                {
                    #region  除显示
                    countn = showdt.Rows.Count;
                    lock (objShowDt)
                    {
                        for (int i = 0; i < countn; i++)
                        {
                            try
                            {
                                if (deletelist.Contains(showdt.Rows[i]["id"].ToString()))
                                {
                                    showdt.Rows.Remove(showdt.Rows[i]);
                                    i--; countn--;
                                }
                            }
                            catch (Exception ex)
                            {
                                Basic.Framework.Logging.LogHelper.Error(ex);
                            }
                        }
                    }
                    #endregion

                    #region  除内存
                    for (int kj = 0; kj < deletelist.Count; kj++)
                    {
                        key = deletelist[kj];
                        if (jc_r.ContainsKey(key))
                        {
                            jc_r.Remove(key);
                        }
                    }
                    deletelist.Clear();
                    #endregion
                }
            }
            catch (Exception ex)
            {
                OprFuction.SaveErrorLogs("删除运行记录", ex);
            }
            #endregion



            #region 添加记录

            if (addlist.Count > 0)
            {
                //tbcount = showdt.Rows.Count;
                try
                {
                    #region 添加记录
                    for (int kj = 0; kj < addlist.Count; kj++)
                    {
                        key = addlist[kj];
                        if (jc_r.ContainsKey(key))
                        {
                            obj   = jc_r[key];
                            point = obj.Point;
                            lock (StaticClass.allPointDtLockObj)
                            {
                                row = StaticClass.AllPointDt.Select("point='" + point + "'");
                                if (row.Length > 0)
                                {
                                    wz = row[0]["wz"];
                                }
                            }
                            fzh     = obj.Fzh + "/" + obj.Kh + "/" + obj.Dzh;
                            sszn    = obj.Val;
                            state   = OprFuction.StateChange(obj.Type.ToString());
                            sbstate = OprFuction.StateChange(obj.State.ToString());
                            stime   = OprFuction.TimeToString(obj.Timer);
                            id      = key;

                            // 20180821
                            //设备类型
                            var    devid   = obj.Devid;
                            var    dev     = devAllList.FirstOrDefault(a => a.Devid == devid);
                            string devName = "";
                            if (dev != null)
                            {
                                devName = dev.Name;
                                if (dev.Type == 1)
                                {
                                    fzh = obj.Fzh.ToString("000") + "A" + obj.Kh.ToString("00") + obj.Dzh.ToString("0");
                                }
                                else if (dev.Type == 2)
                                {
                                    fzh = obj.Fzh.ToString("000") + "D" + obj.Kh.ToString("00") + obj.Dzh.ToString("0");
                                }
                                else if (dev.Type == 3)
                                {
                                    fzh = obj.Fzh.ToString("000") + "C" + obj.Kh.ToString("00") + obj.Dzh.ToString("0");
                                }
                            }

                            //判断自动挂接记录
                            if (point != "未定义")
                            {
                                lock (StaticClass.allPointDtLockObj)
                                {
                                    row = StaticClass.AllPointDt.Select("point='" + point + "'");
                                    if (row.Length > 0)
                                    {
                                        wz = row[0]["wz"];
                                    }
                                }
                                state   = OprFuction.StateChange(obj.Type.ToString());
                                sbstate = OprFuction.StateChange(obj.State.ToString());
                            }
                            else
                            {
                                wz      = "-";
                                state   = "自动挂接";
                                sbstate = "自动挂接";
                            }

                            lock (objShowDt)
                            {
                                r          = showdt.NewRow();
                                r["point"] = point;
                                r["wz"]    = wz;
                                r["fzh"]   = fzh;
                                r["ssz"]   = sszn;
                                //r["state"] = state;
                                //r["sbstate"] = sbstate;
                                r["devName"] = devName;
                                r["time"]    = stime;
                                r["id"]      = key;
                                showdt.Rows.InsertAt(r, 0);//添加新记录

                                this.mainGridView.FocusedRowHandle = 0;
                            }
                        }
                    }
                    #endregion
                }
                catch (Exception ex)
                {
                    OprFuction.SaveErrorLogs("添加开关量运行记录记录", ex);
                }
                tbcount = showdt.Rows.Count;
                StaticClass.yccount[7] += tbcount;
                addlist.Clear();
                //mainGridView.FocusedRowHandle = 0;
            }
            #endregion

            #region 当前自动挂接记录条数
            tbcount = showdt.Rows.Count;
            StaticClass.yccount[7] = tbcount;
            #endregion
        }