/// <summary>
        /// 修改人员轨迹
        /// </summary>
        /// <param name="item"></param>
        public static void UpdateR_P(R_PhistoryInfo item)
        {
            item.InfoState = InfoState.Modified;
            DataToDbAddRequest <R_PhistoryInfo> dataToDbRequest = new DataToDbAddRequest <R_PhistoryInfo>();

            dataToDbRequest.Item = item;
            phistoryTodbService.AddItem(dataToDbRequest);
        }
        public static R_PhistoryInfo GetLastHistoryRP(string yid)
        {
            R_PhistoryInfo r_p = new R_PhistoryInfo();
            R_PhistoryGetLastByYidRequest request = new R_PhistoryGetLastByYidRequest();

            request.yid = yid;
            r_p         = r_PhistoryService.GetPersonLastR_Phistory(request).Data;
            return(r_p);
        }
        public BasicResponse <R_PhistoryInfo> GetPhistoryByPar(R_PhistoryGetByParRequest request)
        {
            var            result       = _Repository.QueryTable("global_R_PhistoryService_QueryR_PhistoryByPar", DateTime.Now.ToString("yyyyMMdd"), request.yid, request.pointid, request.rtime);
            var            resultToList = ObjectConverter.Copy <R_PhistoryInfo>(result);
            R_PhistoryInfo phistoryInfo = null;

            if (resultToList.Count > 0)
            {
                phistoryInfo = ObjectConverter.Copy <R_PhistoryInfo>(result)[0];
            }
            var phistoryresponse = new BasicResponse <R_PhistoryInfo>();

            phistoryresponse.Data = phistoryInfo;
            return(phistoryresponse);
        }
        public static R_PhistoryInfo GetR_PByPar(string pointid, string yid, DateTime rtime)
        {
            R_PhistoryInfo            item    = null;
            R_PhistoryGetByParRequest request = new R_PhistoryGetByParRequest();

            request.pointid = pointid;
            request.yid     = yid;
            request.rtime   = rtime;
            var result = r_PhistoryService.GetPhistoryByPar(request);

            if (result.IsSuccess && result.Data != null)
            {
                item = result.Data;
            }
            return(item);
        }
        /// <summary>
        /// 根据存储时间查询轨迹记录
        /// </summary>
        /// <param name="request"></param>
        /// <returns></returns>
        public BasicResponse <List <R_PhistoryInfo> > GetPersonR_PhistoryByTimer(R_PhistoryGetLastByTimerRequest request)
        {
            var result = _Repository.QueryTable("global_R_PhistoryService_QueryR_PhistoryByTimer", DateTime.Now.ToString("yyyyMMdd"), request.Timer);
            List <R_PhistoryInfo> R_PhistoryInfoList = new List <R_PhistoryInfo>();

            for (int i = 0; i < result.Rows.Count; i++)
            {
                R_PhistoryInfo tempInfo = new R_PhistoryInfo();
                tempInfo.Id    = result.Rows[i]["id"].ToString();
                tempInfo.Bh    = result.Rows[i]["bh"].ToString();
                tempInfo.Name  = result.Rows[i]["name"].ToString();
                tempInfo.Rtime = DateTime.Parse(result.Rows[i]["rtime"].ToString());
                tempInfo.Timer = DateTime.Parse(result.Rows[i]["timer"].ToString());
                tempInfo.Flag  = result.Rows[i]["flag"].ToString();
                R_PhistoryInfoList.Add(tempInfo);
            }
            var phistoryresponse = new BasicResponse <List <R_PhistoryInfo> >();

            phistoryresponse.Data = R_PhistoryInfoList;
            return(phistoryresponse);
        }
Example #6
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
        }