/// <summary> /// 开关量状态变动 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem9_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Dictionary <string, string> point1 = new Dictionary <string, string>(); try { string point = GetSelectPoint(); if (!string.IsNullOrEmpty(point)) { if (PointLx(point, "开关量")) { //point = GetPointID(point); point1.Add("SourceIsList", "true"); point1.Add("Key_ViewJC_KGStateMonth1_point", "等于&&$" + point); point1.Add("Display_ViewJC_KGStateMonth1_point", "等于&&$" + point); } else { OprFuction.MessageBoxShow(0, "请选择开关量测点"); return; } } point1.Add("ListID", "17"); //RequestUtil.ExcuteCommand("RequestKGLStateRBReport", point1, false); Sys.Safety.Reports.frmList listReport = new Sys.Safety.Reports.frmList(point1); listReport.Show(); } catch (Exception ex) { OprFuction.SaveErrorLogs("开关量状态变动记录", ex); } }
/// <summary> /// 开关量柱状图 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem7_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Dictionary <string, string> point1 = new Dictionary <string, string>(); try { string point = GetSelectPoint(); if (!string.IsNullOrEmpty(point)) { if (PointLx(point, "开关量")) { point = GetPointID(point); point1.Add("PointID", point); //RequestUtil.ExcuteCommand("RequestKgl_StateBar", point1, false); Kgl_StateBar kgl_StateBar = new Kgl_StateBar(point1); kgl_StateBar.Show(); } else { OprFuction.MessageBoxShow(0, "请选择开关量测点"); } } else { //RequestUtil.ExcuteCommand("RequestKgl_StateBar", null, false); Kgl_StateBar kgl_StateBar = new Kgl_StateBar(); kgl_StateBar.Show(); } } catch (Exception ex) { OprFuction.SaveErrorLogs("开关量柱状图", ex); } }
/// <summary> /// 模拟量密采记录 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem8_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Dictionary <string, string> point1 = new Dictionary <string, string>(); try { string point = GetSelectPoint(); if (!string.IsNullOrEmpty(point)) { if (PointLx(point, "模拟量")) { point1.Add("SourceIsList", "true"); point1.Add("Key_viewmcrunlogreport1_point", "等于&&$" + point); point1.Add("Display_viewmcrunlogreport1_point", "等于&&$" + point); } else { OprFuction.MessageBoxShow(0, "请选择模拟量测点"); return; } } point1.Add("ListID", "28"); //RequestUtil.ExcuteCommand("RequestMCRungLogReport", point1, false); Sys.Safety.Reports.frmList listReport = new Sys.Safety.Reports.frmList(point1); listReport.Show(); } catch (Exception ex) { OprFuction.SaveErrorLogs("模拟量密采记录", ex); } }
/// <summary> /// 自定义编排初始化树 /// </summary> public void tree_custom_init(int n, int m, string s) { if (m == 12) { #region 给自定义树节点赋名称 DevExpress.XtraTreeList.Nodes.TreeListNode node; treeList_bp.BeginUpdate(); treeList_bp.Nodes[0].Nodes.Clear(); try { for (int i = 0; i < StaticClass.arrangeconfig.CustomCofig.Length; i++) { if (StaticClass.arrangeconfig.CustomCofig[i] != null) { node = treeList_bp.AppendNode( new object[] { StaticClass.arrangeconfig.CustomCofig[i].PageName, i.ToString(), "" }, treeList_bp.Nodes[0]); node.ImageIndex = 0; node.Tag = (i + 1).ToString(); node.SelectImageIndex = 1; node.StateImageIndex = 0; } } treeList_bp.EndUpdate(); treeList_bp.ExpandAll(); } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } #endregion } }
/// <summary> /// 状态树初始化 /// </summary> private void tree_zt_init() { treeList_zt.BeginUpdate(); treeList_zt.Nodes[0].StateImageIndex = 0; try { for (int j = 0; j < treeList_zt.Nodes[0].Nodes.Count; j++) { treeList_zt.Nodes[0].Nodes[j].StateImageIndex = 0; if (treeList_zt.Nodes[0].Nodes[j].Nodes.Count > 0) { for (int i = 0; i < treeList_zt.Nodes[0].Nodes[j].Nodes.Count; i++) { treeList_zt.Nodes[0].Nodes[j].Nodes[i].StateImageIndex = 0; } } } treeList_zt.EndUpdate(); treeList_zt.ExpandAll(); } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } }
private bool PointLx(string point, string lx) { bool flg = false; try { DataRow[] rows = null; if (!string.IsNullOrEmpty(point)) { lock (StaticClass.allPointDtLockObj) { rows = StaticClass.AllPointDt.Select("point='" + point + "'"); if (rows.Length > 0) { if (rows[0]["lx"].ToString() == lx) { flg = true; } } } } } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } return(flg); }
/// <summary> /// 小时曲线 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem5_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Dictionary <string, string> point1 = new Dictionary <string, string>(); try { string point = GetSelectPoint(); if (!string.IsNullOrEmpty(point)) { if (PointLx(point, "模拟量")) { point = GetPointID(point); point1.Add("PointID", point); //RequestUtil.ExcuteCommand("RequestMnl_DayZdzLine", point1, false); Mnl_DayZdzLine mnl_DayZdzLine = new Mnl_DayZdzLine(point1); mnl_DayZdzLine.Show(); } else { OprFuction.MessageBoxShow(0, "请选择模拟量测点"); } } else { //RequestUtil.ExcuteCommand("RequestMnl_DayZdzLine", null, false); Mnl_DayZdzLine mnl_DayZdzLine = new Mnl_DayZdzLine(); mnl_DayZdzLine.Show(); } } catch (Exception ex) { OprFuction.SaveErrorLogs("模拟量小时曲线", ex); } }
private void comb_zl_SelectedIndexChanged(object sender, EventArgs e) { DataRow[] rows = null; string temp = "", str1 = "", str2 = "", str3 = ""; try { listB.Items.Clear(); temp = comb_zl.Text.Trim(); lock (StaticClass.allPointDtLockObj) { if (fzh != "") { rows = StaticClass.AllPointDt.Select("fzh='" + fzh + "' and ( lb='" + temp + "' or zl='" + temp + "')"); } else { rows = StaticClass.AllPointDt.Select("lb='" + temp + "' or zl='" + temp + "'"); } if (rows.Length > 0) { for (int i = 0; i < rows.Length; i++) { if (!rows[i].IsNull("point")) { #region 加载测点 str1 = rows[i]["point"].ToString(); if (!rows[i].IsNull("wz")) { str2 = rows[i]["wz"].ToString(); } else { str2 = ""; } if (!rows[i].IsNull("lb")) { str3 = rows[i]["lb"].ToString(); } else { str3 = ""; } listB.Items.Add(string.Format("[{0}]{1}[{2}]", str1, str2, str3)); #endregion } } } } } catch (Exception ex) { OprFuction.SaveErrorLogs("根据种类加载测点", ex); } }
private void comb_fz_SelectedIndexChanged(object sender, EventArgs e) { string temp = ""; DataRow[] rows = null; try { #region 加载分站下测点 fzh = ""; listB.Items.Clear(); comb_lb.Text = ""; comb_zl.Text = ""; comb_lb.Properties.Items.Clear(); comb_zl.Properties.Items.Clear(); if (!string.IsNullOrEmpty(comb_fz.Text)) { temp = comb_fz.Text.Trim(); temp = temp.Substring(temp.IndexOf('[') + 1, temp.IndexOf(']') - temp.IndexOf('[') - 1); lock (StaticClass.allPointDtLockObj) { rows = StaticClass.AllPointDt.Select("point='" + temp + "'", "tdh asc"); if (rows.Length > 0) { fzh = rows[0]["fzh"].ToString(); rows = StaticClass.AllPointDt.Select("fzh='" + rows[0]["fzh"].ToString() + "'", "tdh asc"); if (rows.Length > 0) { foreach (DataRow row in rows) { listB.Items.Add(string.Format("[{0}]{1}[{2}]", row["point"].ToString(), row["wz"].ToString(), row["lb"].ToString())); } } } } } dtlx = OprFuction.GetAlllb(fzh); DataView view = new DataView(dtlx); view.Sort = "lxtype asc"; DataTable dts = view.ToTable(true, "lx", "lxtype"); if (dts != null && dts.Rows.Count > 0) { foreach (DataRow row in dts.Rows) { comb_lb.Properties.Items.Add(row["lx"].ToString()); } } #endregion } catch (Exception ex) { OprFuction.SaveErrorLogs("加载分站下测点", ex); } }
/// <summary> /// 设备树初始化 /// </summary> private void tree_devtype_init() { DataTable dt = GetAllDev(); DevExpress.XtraTreeList.Nodes.TreeListNode node; treeList_fz.BeginUpdate(); treeList_fz.Nodes[0].Nodes.Clear(); treeList_fz.Nodes[0].StateImageIndex = 0; try { if (dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { node = treeList_fz.AppendNode( new object[] { dt.Rows[i]["point"].ToString(), i.ToString(), "" }, treeList_fz.Nodes[0]); node.ImageIndex = 0; node.Tag = dt.Rows[i]["fzh"].ToString(); node.SelectImageIndex = 1; node.StateImageIndex = 0; } } treeList_fz.EndUpdate(); treeList_fz.ExpandAll(); //根据配置判断,是否可以休眠 20180307 string enableDormancyStr = Model.RealInterfaceFuction.ReadConfig("EnableDormancy"); bool enableDormancy = true; if (enableDormancyStr == "1") { enableDormancy = true; } else { enableDormancy = false; } if (!enableDormancy) { for (int j = 0; j < treeList_zt.Nodes[0].Nodes.Count; j++) { if (treeList_zt.Nodes[0].Nodes[j].GetValue("Column5").ToString() == "休眠") { treeList_zt.Nodes[0].Nodes.RemoveAt(j); } } } } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } }
private void GetPoint() { DataRow[] rows = null; DateTime time = dateTimePicker1.Value; string str2 = "", str3 = "", point = ""; DataTable dt; try { dt = Model.RealInterfaceFuction.Getbxpoint(time); listA.Items.Clear(); if (dt != null && dt.Rows.Count > 0) { for (int i = 0; i < dt.Rows.Count; i++) { point = dt.Rows[i]["point"].ToString(); if (!string.IsNullOrEmpty(point)) { lock (StaticClass.allPointDtLockObj) { rows = StaticClass.AllPointDt.Select("point='" + point + "'"); if (rows.Length > 0) { #region 加载测点 if (!rows[0].IsNull("wz")) { str2 = rows[0]["wz"].ToString(); } else { str2 = ""; } if (!rows[0].IsNull("lb")) { str3 = rows[0]["lb"].ToString(); } else { str3 = ""; } listA.Items.Add(string.Format("[{0}]{1}[{2}]", point, str2, str3)); #endregion } } } } } } catch (Exception ex) { OprFuction.SaveErrorLogs("加载标校测点", ex); } }
private void btn_save_Click(object sender, EventArgs e) { if (listA.ItemCount == 0) { // 20170628 //MessageBox.Show("请先选择测点。"); XtraMessageBox.Show("请先选择测点。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } DateTime time = dateTimePicker1.Value; if (Convert.ToDateTime(time.ToShortDateString()) < Convert.ToDateTime(DateTime.Now.ToShortDateString())) { XtraMessageBox.Show("标校日期不能小于当日。", "提示", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } btn_save.Enabled = false; labelControl13.Text = "存储中..."; labelControl13.Visible = true; string spoint = ""; if (listA.Items.Count > 0) { for (int i = 0; i < listA.Items.Count; i++) { spoint += listA.Items[i].ToString().Substring(1, 7) + "|"; } spoint = spoint.Substring(0, spoint.Length - 1); } #region 存储测点信息 try { if (Model.RealInterfaceFuction.SavePoint(time, spoint)) { labelControl13.Text = "保存成功"; } else { labelControl13.Text = "保存失败"; } } catch (Exception ex) { OprFuction.SaveErrorLogs("测点编排保存测点到数据库", ex); } #endregion btn_save.Enabled = true; }
/// <summary> /// 刷新 /// </summary> public void refresh() { try { //StaticClass.AllPointDt = Model.RealInterfaceFuction.GetAllPoint(); //#region 初始化 //Initree(); //#endregion //#region 赋值 //SelectTreeList(); //#endregion //#region 刷新 //if (ShowType != 5) //{ // if (StaticClass.real_del != null) // { // StaticClass.real_del(ShowType, bpShowPage, checkmsg); // } //} //#endregion //txy 20170401 优化刷新 DataTable dt = null; dt = Model.RealInterfaceFuction.GetAllPoint(); lock (StaticClass.allPointDtLockObj) { if (dt != null && dt.Rows.Count > 0) { StaticClass.AllPointDt = dt; } else { StaticClass.AllPointDt = Model.RealInterfaceFuction.GetAllPoint(); } } if (dt != null) { MethodInvoker In = new MethodInvoker(() => RefreshControl()); if (this.IsHandleCreated) { this.BeginInvoke(In); } } } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } }
private void DyxForm_Load(object sender, EventArgs e) { DataRow[] rows; DataTable dt = new DataTable(); int i = 0; try { if (StaticClass.AllPointDt.Rows.Count > 0) { lock (StaticClass.allPointDtLockObj) { rows = StaticClass.AllPointDt.Select("lx='分站'", "fzh"); if (rows.Length > 0) { foreach (DataRow r in rows) { tbarray[i] = new Label(); tbarray[i].BorderStyle = BorderStyle.Fixed3D; tbarray[i].TextAlign = ContentAlignment.MiddleCenter; tbarray[i].Width = 40; tbarray[i].Height = 28; tbarray[i].Name = "textbox" + Convert.ToString(r["fzh"].ToString()); tbarray[i].Text = r["point"].ToString().PadLeft(3, '0'); //tbarray[i].ReadOnly = true; tbarray[i].Font = new Font("宋体", 10, FontStyle.Bold); tbarray[i].Tag = "0"; if (r["zt"].ToString() == "3" || r["zt"].ToString() == "4") { } tbarray[i].Click += new System.EventHandler(this.XJ_DoubleClick); flowLayoutPanel1.Controls.Add(tbarray[i]); tbarray[i].Tag = "1"; i++; } } } } } catch (Exception ex) { OprFuction.SaveErrorLogs("分站运行界面,测点获取", ex); } freshthread = new Thread(new ThreadStart(fthread)); freshthread.Start(); }
/// <summary> /// 初始化电源管理界面 xuzp20151015 /// </summary> private void InitChargeMrg() { try { if (objfz.fzh != 0) { //TODO:与其它业务模块相关联 //JCDEFDTO tempDef = Model.ChargeMrg.QueryPointByCodeCache(objfz.point); //if (null != tempDef) //{ // JCDEVDTO tempDev = Model.ChargeMrg.QueryDevByDevIDCache(tempDef.Devid); // if (null != tempDev) // { // if (tempDev.LC2 == 12 || tempDev.LC2 == 13)//如果是KJ306-F(16)/KJ306-F(16)H智能分站协议 // { // xtraTabPage4.PageVisible = true; // CuCharge tempCharge = new CuCharge(tempDef.Point); // CpanelPowerPac.Controls.Clear(); // CpanelPowerPac.Controls.Add(tempCharge); // tempCharge.Dock = DockStyle.Fill; // } // else // { // CpanelPowerPac.Controls.Clear(); // xtraTabPage4.PageVisible = false; // } // } // else // { // CpanelPowerPac.Controls.Clear(); // xtraTabPage4.PageVisible = false; // } //} //else //{ // CpanelPowerPac.Controls.Clear(); // xtraTabPage4.PageVisible = false; //} } } catch (Exception ex) { OprFuction.SaveErrorLogs("分站运行界面,初始化电源管理界面", ex); } }
/// <summary> /// 获取点号 /// </summary> private void getpoint() { DataRow[] rows; DataTable dt = new DataTable(); cmb_fzadr.Properties.Items.Clear(); try { if (StaticClass.AllPointDt.Rows.Count > 0) { lock (StaticClass.allPointDtLockObj) { rows = StaticClass.AllPointDt.Select("lx='分站'", "fzh"); if (rows.Length > 0) { foreach (DataRow r in rows) { cmb_fzadr.Properties.Items.Add(r["fzh"].ToString().PadLeft(3, '0')); } if (objfz.fzh != 0) { for (int i = 0; i < cmb_fzadr.Properties.Items.Count; i++) { if (objfz.fzh.ToString().PadLeft(3, '0') == cmb_fzadr.Properties.Items[i].ToString()) { cmb_fzadr.SelectedIndex = i; break; } } } else { cmb_fzadr.SelectedIndex = 0; } } } } } catch (Exception ex) { OprFuction.SaveErrorLogs("分站运行界面,测点获取", ex); } }
private string GetSelectPoint() { int row = 0; string point = ""; try { row = mainGridView.FocusedRowHandle; if (row > -1 && mainGridView.FocusedColumn != null) { point = mainGridView.GetFocusedRowCellValue("point").ToString(); } } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } return(point); }
/// <summary> /// 刷新故障数据 /// </summary> public void refresh1(DateTime nowtime) { TimeSpan span; #region 刷新 持续时间 cs try { for (int i = 0; i < showdt.Rows.Count; i++) { #region 刷新持续时间 span = nowtime - Convert.ToDateTime(showdt.Rows[i]["stime"]); showdt.Rows[i]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); #endregion } } catch (Exception ex) { OprFuction.SaveErrorLogs("刷新故障时间", ex); } #endregion }
/// <summary> /// 运行记录查询 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void barButtonItem1_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { Dictionary <string, string> point1 = new Dictionary <string, string>(); try { string point = GetSelectPoint(); if (!string.IsNullOrEmpty(point)) { point1.Add("SourceIsList", "true"); point1.Add("Key_viewsbrunlogreport1_point", "等于&&$" + point); point1.Add("Display_viewsbrunlogreport1_point", "等于&&$" + point); } point1.Add("ListID", "27"); //RequestUtil.ExcuteCommand("Requestsbrunlogreport", point1, false); Sys.Safety.Reports.frmList listReport = new Sys.Safety.Reports.frmList(point1); listReport.Show(); } catch (Exception ex) { OprFuction.SaveErrorLogs("历史运行记录", ex); } }
/// <summary> /// 刷新报警数据 /// </summary> public void refresh(DateTime nowtime) { string point = ""; DataRow[] row; DataRow r; int countn = 0; long id = 0; Jc_BInfo 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_b.ContainsKey(key)) { jc_b.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_b.ContainsKey(key)) { obj = jc_b[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.Ssz; state = OprFuction.StateChange(obj.Type.ToString()); sbstate = OprFuction.StateChange(obj.State.ToString()); stime = OprFuction.TimeToString(obj.Stime); id = key; lock (objShowDt) { r = showdt.NewRow(); r["point"] = point; r["wz"] = wz; //r["fzh"] = fzh; //r["ssz"] = sszn; if (state.ToString() == "0态") { r["state"] = row[0]["0t"].ToString(); } else if (state.ToString() == "1态") { r["state"] = row[0]["1t"].ToString(); } else { r["state"] = row[0]["2t"].ToString(); } r["sbstate"] = sbstate; r["time"] = stime; r["id"] = key; showdt.Rows.InsertAt(r, 0);//添加新记录 } } } #endregion } catch (Exception ex) { OprFuction.SaveErrorLogs("添加开关量报警记录", ex); } //tbcount = showdt.Rows.Count - tbcount; //StaticClass.yccount[5] += tbcount; addlist.Clear(); //mainGridView.FocusedRowHandle = 0; } #endregion #region 当前报警条数 tbcount = showdt.Rows.Count; StaticClass.yccount[5] = tbcount; #endregion }
/// <summary> /// 刷新报警数据 /// </summary> public void refresh(DateTime nowtime, List <Jc_DefInfo> pointDefineControlList) { string point = ""; DataRow[] row, row1; DataRow r; int countn = 0; string[] kzk = null; Jc_BInfo obj = null; Jc_DefInfo tempdef = null; int state1 = 0, state2 = 0; int tbcount = 0; Dictionary <string, string> kzkd = new Dictionary <string, string>(); string kdk = ""; object wz = "", dw = "", bjz = "", ddz = "", fzh = "", sszn = "", bjtime = "", ddtime = "", cs = "", idn = "", qy = "", sbstate = ""; long key = 0; List <long> listkey; #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_b.ContainsKey(key)) { jc_b.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]; kzkd.Clear(); if (jc_b.ContainsKey(key)) { obj = jc_b[key]; point = obj.Point; sbstate = OprFuction.StateChange(obj.State.ToString()); if (obj.State == (short)StaticClass.itemStateToClient.EqpState32) { continue;//类型有误不做处理 } lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + point + "'"); if (row.Length > 0) { sszn = obj.Ssz + "/" + OprFuction.TimeToString(obj.Stime); if (obj.Type == StaticClass.itemStateToClient.EqpState9) { ddz = row[0]["sxbj"] + "|" + row[0]["sxyj"]; } else if (obj.Type == StaticClass.itemStateToClient.EqpState11) { ddz = row[0]["sxdd"] + "|" + row[0]["sxfd"]; } else if (obj.Type == StaticClass.itemStateToClient.EqpState19) { ddz = row[0]["xxbj"] + "|" + row[0]["xxyj"]; } else if (obj.Type == StaticClass.itemStateToClient.EqpState21) { ddz = row[0]["xxdd"] + "|" + row[0]["xxfd"]; } else { bjz = obj.Ssz; ddz = obj.Ssz; } } } bjtime = OprFuction.TimeToString(obj.Stime); idn = key; #region 控制口 if (!string.IsNullOrEmpty(obj.Kzk)) { kzk = obj.Kzk.Split('|'); if (kzk.Length > 0) { for (int i = 0; i < kzk.Length; i++) { #region 添加记录 //tempdef = Model.RealInterfaceFuction.Getpoint(kzk[i]); tempdef = pointDefineControlList.Find(a => a.Point == kzk[i]); if (tempdef != null) { lock (objShowDt) { r = showdt.NewRow(); r["point"] = point; r["ddz"] = ddz; r["ssz"] = sszn; r["sbstate"] = sbstate; r["qy"] = tempdef.Wz; r["kzk"] = kzk[i]; lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + kzk[i] + "'"); if (row.Length > 0) { kdk = OprFuction.StateChange(row[0]["zt"].ToString()); if (kdk == "0态") { r["kzzt"] = row[0]["0t"].ToString(); } else if (kdk == "1态") { r["kzzt"] = row[0]["1t"].ToString(); } else { r["kzzt"] = kdk; } } } if (tempdef.K2 != 0) { lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("fzh='" + tempdef.Fzh + "' and tdh='" + tempdef.K2 + "' and lx='开关量'"); if (row.Length > 0) { r["kdk"] = row[0]["point"].ToString(); kdk = OprFuction.StateChange(row[0]["zt"].ToString()); if (kdk == "0态") { r["kdkzt"] = row[0]["0t"].ToString(); } else if (kdk == "1态") { r["kdkzt"] = row[0]["1t"].ToString(); } else if (kdk == "2态") { r["kdkzt"] = row[0]["2t"].ToString(); } else { r["kdkzt"] = kdk; } } } r["kdzt"] = "检测中"; } else { r["kdk"] = "无"; r["kdkzt"] = "无"; r["kdzt"] = "无"; } r["stime"] = bjtime; r["id"] = key; r["endtime"] = ""; r["alarmstate"] = "进行中"; row = showdt.Select("id='" + key + "' and kzk='" + kzk[i] + "'"); if (row.Length < 1) { showdt.Rows.InsertAt(r, 0);//添加新记录 } } } #endregion } } } #endregion } } #endregion } catch (Exception ex) { OprFuction.SaveErrorLogs("添加控制记录", ex); } //tbcount = showdt.Rows.Count - tbcount; //StaticClass.yccount[4] += tbcount; addlist.Clear(); //mainGridView.FocusedRowHandle = 0; } #endregion #region 刷新记录,控制状态、馈电开关状态、馈电状态 try { if (showdt.Rows.Count > 0) { lock (objShowDt) { for (int i = 0; i < showdt.Rows.Count; i++) { r = showdt.Rows[i]; if (r["endtime"].ToString() == "")//只要在列表中,并且未结束,就实时更新控制口状态 20170712 { if (!r.IsNull("kzk")) { #region 控制口状态 lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + r["kzk"].ToString() + "'"); // 20170326 if (row.Length > 0) { if (row[0].Table.Columns.Contains("zt")) { if (!row[0].IsNull("zt")) { kdk = OprFuction.StateChange(row[0]["zt"].ToString()); if (kdk == "0态") { r["kzzt"] = row[0]["0t"].ToString(); } else if (kdk == "1态") { r["kzzt"] = row[0]["1t"].ToString(); } else { r["kzzt"] = kdk; } state1 = int.Parse(row[0]["zt"].ToString()); } } } } #endregion #region 馈电及状态 if (!r.IsNull("kdk") && r["kdk"].ToString() != "无") { lock (StaticClass.allPointDtLockObj) { row1 = StaticClass.AllPointDt.Select("point='" + r["kdk"].ToString() + "'"); // 20170326 if (row1.Length > 0) { if (row1[0].Table.Columns.Contains("zt")) { if (!row1[0].IsNull("zt")) { kdk = OprFuction.StateChange(row1[0]["zt"].ToString()); if (kdk == "0态") { r["kdkzt"] = row1[0]["0t"].ToString(); } else if (kdk == "1态") { r["kdkzt"] = row1[0]["1t"].ToString(); } else if (kdk == "2态") { r["kdkzt"] = row1[0]["2t"].ToString(); } else { r["kdkzt"] = kdk; } state2 = int.Parse(row1[0]["zt"].ToString()); //if (((nowtime -DateTime .Parse (row [0]["stime"].ToString ())).TotalSeconds>20)) //{ #region 馈电判断 //if (state1 == StaticClass.itemStateToClient.EqpState44)//控制口断开 //{ // if (state2 == StaticClass.itemStateToClient.EqpState26)//馈电开关量为2态 // { // r["kdzt"] = "断电失败"; // } // else if (state2 == StaticClass.itemStateToClient.EqpState25)//馈电开关量为1态 // { // r["kdzt"] = "断电成功"; // } // else//馈电开关量为0态 // { // r["kdzt"] = "断电成功";//0态默认是断电成功 20170622 // } //} //else//控制口接通 //{ // r["kdzt"] = "断电失败"; //} //不自己判断,取内存中的控制量对应的馈电状态 if (row[0]["NCtrlSate"].ToString() == "0") //复电成功 { r["kdzt"] = "复电成功"; } else if (row[0]["NCtrlSate"].ToString() == "2") //断电成功 { r["kdzt"] = "断电成功"; } else if (row[0]["NCtrlSate"].ToString() == "30") //复电失败 { r["kdzt"] = "复电失败"; } else if (row[0]["NCtrlSate"].ToString() == "32") //断电失败 { r["kdzt"] = "断电失败"; } else if (row[0]["NCtrlSate"].ToString() == "46") //未知 { r["kdzt"] = "未知"; } #endregion //} //else //{ // if (state1 == StaticClass.itemStateToClient.EqpState44) // { // if (state2 == StaticClass.itemStateToClient.EqpState25) // { // r["kdzt"] = "断电成功"; // } // } //} } } } } } #endregion #region 结束时间 //if (uplist.Contains(long.Parse(r["id"].ToString()))) //{ // r["endtime"] = "jieshu"; //} lock (StaticClass.bjobj) { if (!OprFuction.IsInitTime(StaticClass.jcbdata[long.Parse(r["id"].ToString())].Etime)) { r["endtime"] = StaticClass.jcbdata[long.Parse(r["id"].ToString())].Etime.ToString("yyyy-MM-dd HH:mm:ss"); r["alarmstate"] = "已结束"; } } #endregion } } } } //uplist.Clear(); } } catch (Exception ex) { OprFuction.SaveErrorLogs("刷新控制记录", ex); } #endregion #region 当前报警条数 tbcount = showdt.Select("endtime=''").Length; StaticClass.yccount[4] = tbcount; #endregion }
private void comb_lb_SelectedIndexChanged(object sender, EventArgs e) { DataView view; DataTable dts; DataRow [] rows; string lx = ""; try { lx = comb_lb.Text; comb_zl.Properties.Items.Clear(); comb_zl.Text = ""; if (!string.IsNullOrEmpty(lx)) { dtlx = OprFuction.GetAlllb(fzh); view = new DataView(dtlx); dts = view.ToTable(true, "lx", "zl"); rows = dts.Select("lx='" + lx + "'"); if (rows.Length > 0) { foreach (DataRow row in rows) { comb_zl.Properties.Items.Add(row["zl"].ToString()); } } } } catch (Exception ex) { OprFuction.SaveErrorLogs("加载种类", ex); } string str1 = "", str2 = "", str3 = ""; try { listB.Items.Clear(); if (!string.IsNullOrEmpty(lx)) { lock (StaticClass.allPointDtLockObj) { if (fzh != "") { rows = StaticClass.AllPointDt.Select("fzh='" + fzh + "' and lx='" + lx + "'"); } else { rows = StaticClass.AllPointDt.Select("lx='" + lx + "'"); } if (rows.Length > 0) { for (int i = 0; i < rows.Length; i++) { if (!rows[i].IsNull("point")) { #region 加载测点 str1 = rows[i]["point"].ToString(); if (!rows[i].IsNull("wz")) { str2 = rows[i]["wz"].ToString(); } else { str2 = ""; } if (!rows[i].IsNull("lb")) { str3 = rows[i]["lb"].ToString(); } else { str3 = ""; } listB.Items.Add(string.Format("[{0}]{1}[{2}]", str1, str2, str3)); #endregion } } } } } } catch (Exception ex) { OprFuction.SaveErrorLogs("根据种类加载测点", ex); } }
/// <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 }
/// <summary> /// 设备类别树初始化 /// </summary> private void tree_devlb_init() { DataRow[] rows = null; int i = 0; DataView view; DataTable dts; string lx = "", zl = ""; DevExpress.XtraTreeList.Nodes.TreeListNode node; try { treeList_zl.BeginUpdate(); treeList_zl.Nodes[0].StateImageIndex = 0; treeList_zl.Nodes[0].Nodes.Clear(); DataTable dt = OprFuction.GetAlllb(""); #region 加载类型 view = new DataView(dt); view.Sort = "lxtype"; dts = view.ToTable(true, "lx", "lxtype"); if (dts != null && dts.Rows.Count > 0) { foreach (DataRow row in dts.Rows) { node = treeList_zl.AppendNode( new object[] { row["lx"].ToString(), i, "" }, treeList_zl.Nodes[0]); i++; node.ImageIndex = 0; node.Tag = row["lx"].ToString(); node.SelectImageIndex = 1; node.StateImageIndex = 0; } } #endregion #region 加载种类 view = new DataView(dt); dts = view.ToTable(true, "lx", "zl"); if (treeList_zl.Nodes[0].Nodes.Count > 0) { for (int j = 0; j < treeList_zl.Nodes[0].Nodes.Count; j++) { lx = treeList_zl.Nodes[0].Nodes[j].Tag.ToString(); rows = dts.Select("lx='" + lx + "'"); if (rows.Length > 0) { foreach (DataRow row in rows) { //if (row["zl"].ToString() != "") //{ node = treeList_zl.AppendNode( new object[] { string.IsNullOrEmpty(row["zl"].ToString()) ? "" : row["zl"].ToString(), i, "" }, treeList_zl.Nodes[0].Nodes[j]); i++; node.ImageIndex = 0; node.Tag = row["zl"].ToString(); node.SelectImageIndex = 1; node.StateImageIndex = 0; //} } } } } #endregion #region 加载设备名称 view = new DataView(dt); dts = view.ToTable(true, "lx", "zl", "lb"); if (treeList_zl.Nodes[0].Nodes.Count > 0) { for (int j = 0; j < treeList_zl.Nodes[0].Nodes.Count; j++) { if (treeList_zl.Nodes[0].Nodes[j].Nodes.Count > 0) { for (int k = 0; k < treeList_zl.Nodes[0].Nodes[j].Nodes.Count; k++) { lx = treeList_zl.Nodes[0].Nodes[j].Tag.ToString(); zl = treeList_zl.Nodes[0].Nodes[j].Nodes[k].Tag.ToString(); rows = dts.Select("lx='" + lx + "' and zl='" + zl + "'"); if (rows.Length > 0) { foreach (DataRow row in rows) { node = treeList_zl.AppendNode( new object[] { row["lb"].ToString(), i, "" }, treeList_zl.Nodes[0].Nodes[j].Nodes[k]); i++; node.ImageIndex = 0; node.Tag = row["lb"].ToString(); node.SelectImageIndex = 1; node.StateImageIndex = 0; node.Visible = true; } } } } } } #endregion treeList_zl.EndUpdate(); treeList_zl.ExpandAll(); } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } }
/// <summary> /// 刷新预警数据 /// </summary> public void refresh(DateTime nowtime) { string point = "", ssz1, ssz2; double ssz, zdz, zxz, pjz, allvlaue, count; DataRow[] row; DataRow r; TimeSpan span; int countn = 0; long id = 0; Jc_BInfo obj = null; int tbcount = 0; long key = 0; List <long> listkey; #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_b.ContainsKey(key)) { jc_b.Remove(key); } } deletelist.Clear(); #endregion } } catch (Exception ex) { OprFuction.SaveErrorLogs("删除预警记录", ex); } #endregion #region 刷新实时值、最大值、最小值、平均值 持续时间 结束时间 try { lock (objShowDt)//防止删除的时候,遍历datatable修改对象找不到对象 { for (int i = 0; i < showdt.Rows.Count; i++) { if (showdt.Rows[i].IsNull("endtime") || showdt.Rows[i]["endtime"].ToString() == "") { id = long.Parse(showdt.Rows[i]["id"].ToString()); if (updatelist.Contains(id)) { #region 刷新 最大值、平均值 结束时间 obj = jc_b[id]; //showdt.Rows[i]["zdz"] = obj .Zdz; showdt.Rows[i]["pjz"] = obj.Pjz; showdt.Rows[i]["endtime"] = OprFuction.TimeToString(obj.Etime); #endregion #region 刷新持续时间 span = obj.Etime - Convert.ToDateTime(showdt.Rows[i]["stime"]); showdt.Rows[i]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); #endregion } else { #region 刷新持续时间 span = nowtime - Convert.ToDateTime(showdt.Rows[i]["stime"]); showdt.Rows[i]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); #endregion #region 刷新实时值、最大值、最小值、平均值 point = showdt.Rows[i]["point"].ToString(); ssz2 = showdt.Rows[i]["ssz"].ToString(); lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + point + "'"); if (row.Length > 0) { ssz1 = row[0]["ssz"].ToString(); if (ssz1 != ssz2) { if (double.TryParse(ssz1, out ssz)) { zdz = Convert.ToDouble(showdt.Rows[i]["zdz"]); zxz = Convert.ToDouble(showdt.Rows[i]["zxz"]); pjz = Convert.ToDouble(showdt.Rows[i]["pjz"]); count = Convert.ToDouble(showdt.Rows[i]["count"]); allvlaue = Convert.ToDouble(showdt.Rows[i]["allvalue"]); if (ssz > zdz) { zdz = ssz; } else if (ssz < zxz) { zxz = ssz; } count += 1; allvlaue += ssz; pjz = Math.Round(allvlaue / count, 2); showdt.Rows[i]["zdz"] = zdz; showdt.Rows[i]["zxz"] = zxz; showdt.Rows[i]["pjz"] = pjz; showdt.Rows[i]["ssz"] = ssz; showdt.Rows[i]["count"] = count; if (showdt.Rows[i].Table.Columns.Contains("allvlaue")) { showdt.Rows[i]["allvlaue"] = allvlaue; } } } } } #endregion } } } } updatelist.Clear(); } catch (Exception ex) { OprFuction.SaveErrorLogs("刷新实时值、最大值、最小值、平均值", ex); } #endregion #region 添加记录 if (addlist.Count > 0) { lock (objShowDt) { for (int kj = 0; kj < addlist.Count; kj++) { key = addlist[kj]; if (jc_b.ContainsKey(key)) { obj = jc_b[key]; r = showdt.NewRow(); r["point"] = obj.Point; lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + obj.Point + "'"); if (row.Length > 0) { r["wz"] = row[0]["wz"]; if (obj.Type == StaticClass.itemStateToClient.EqpState7) { r["yjz"] = row[0]["sxyj"]; } else { r["yjz"] = row[0]["xxyj"]; } } } //TODO:和其它业务模块相关联 //r["fzh"] = obj.Fzh + "/" + obj.Kh + "/" + obj.Dzh; //r["ssz"] = obj.Ssz; //r["state"] = OprFuction.StateChange(obj.Type.ToString()); //r["sbstate"] = OprFuction.StateChange(obj.State.ToString()); //r["stime"] = OprFuction.TimeToString(obj.Stime); //if (!OprFuction.IsInitTime(obj.Etime)) //{ // r["endtime"] = OprFuction.TimeToString(obj.Etime); //} //span = nowtime - obj.Stime; //r["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); //r["zdz"] = obj.Ssz; //r["zxz"] = obj.Ssz; //r["pjz"] = obj.Ssz; //r["count"] = 1; //r["allvalue"] = obj.Ssz; r["id"] = key; showdt.Rows.InsertAt(r, 0);//添加新记录 } } } addlist.Clear(); //mainGridView.FocusedRowHandle = 0; } #endregion #region 当前报警条数 tbcount = showdt.Rows.Count; StaticClass.yccount[0] = tbcount; #endregion }
/// <summary> /// 刷新报警数据 /// </summary> public void refresh(DateTime nowtime) { string point = ""; DataRow[] row; DataRow r; int countn = 0; string[] kzk = null, kdid = null; long temp = 0; Jc_BInfo obj = null, tempobj = null; int tbcount = 0; Dictionary <string, string> kzkd = new Dictionary <string, string>(); object wz = "", dw = "", bjz = "", ddz = "", fzh = "", sszn = "", bjtime = "", ddtime = "", cs = "", idn = "", qy = "", 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()))) { if (jc_kd.ContainsKey(long.Parse(showdt.Rows[i]["kdid"].ToString()))) { jc_kd.Remove(long.Parse(showdt.Rows[i]["kdid"].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_b.ContainsKey(key)) { jc_b.Remove(key); } } deletelist.Clear(); #endregion } } catch (Exception ex) { OprFuction.SaveErrorLogs("删除馈电记录", ex); } #endregion #region 修改及刷新记录 if (updatelist.Count > 0) { try { #region 添加记录 for (int kj = 0; kj < updatelist.Count; kj++) { key = updatelist[kj]; kzkd.Clear(); if (jc_b.ContainsKey(key)) { obj = jc_b[key]; point = obj.Point; lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + point + "'"); if (row.Length > 0) { wz = row[0]["wz"]; sbstate = OprFuction.StateChange(obj.State.ToString()); sszn = obj.Ssz + "/" + OprFuction.TimeToString(obj.Stime); if (int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState9 || int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState11) { bjz = row[0]["sxbj"] + "/" + row[0]["sxyj"]; ddz = row[0]["sxdd"] + "/" + row[0]["sxfd"]; dw = row[0]["dw"]; } else if (int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState19 || int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState21) { bjz = row[0]["xxbj"] + "/" + row[0]["xxyj"]; ddz = row[0]["xxdd"] + "/" + row[0]["xxfd"]; dw = row[0]["dw"]; } else { bjz = obj.Ssz; ddz = obj.Ssz; } } } fzh = obj.Fzh + "/" + obj.Kh + "/" + obj.Dzh; bjtime = ddtime = OprFuction.TimeToString(obj.Stime); cs = obj.Cs; idn = key; #region 控制口 //if (!string.IsNullOrEmpty(obj.Kdid)) //{ // kdid = obj.Kdid.Split('|'); // if (kdid.Length > 0) // { // if (!string.IsNullOrEmpty(kdid[0])) // { // kdid1 = kdid[0].Split(','); // #region 断电失败 // lock (StaticClass.bjobj) // { // for (int i = 0; i < kdid1.Length; i++) // { // temp = long.Parse(kdid1[i]); // if (StaticClass.jcbdata.ContainsKey(temp)) // { // tempobj = StaticClass.jcbdata[temp]; // if (!jc_kd.ContainsKey(temp)) // { // jc_kd.Add(temp, OprFuction.NewDTO(tempobj)); // #region 添加记录 // row = StaticClass.AllPointDt.Select("point='" + tempobj.Point + "'"); // if (row.Length > 0) // { // qy = row[0]["wz"]; // } // r = showdt.NewRow(); // r["point"] = point; // r["wz"] = wz; // r["bjz"] = bjz; // r["ddz"] = ddz; // r["dw"] = dw; // //r["fzh"] = fzh; // r["ssz"] = sszn; // r["bjtime"] = bjtime; // r["ddtime"] = ddtime; // r["kdid"] = temp; // r["id"] = key; // r["qy"] = qy; // r["kzk"] = tempobj.Point; // r["kdtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; // showdt.Rows.InsertAt(r, 0);//添加新记录 // #endregion // } // } // } // } // #endregion // } // if (kdid.Length > 1) // { // #region 复电失败 // if (!string.IsNullOrEmpty(kdid[1])) // { // kdid1 = kdid[1].Split(','); // lock (StaticClass.bjobj) // { // for (int i = 0; i < kdid1.Length; i++) // { // temp = long.Parse(kdid1[i]); // if (StaticClass.jcbdata.ContainsKey(temp)) // { // tempobj = StaticClass.jcbdata[temp]; // if (!jc_kd.ContainsKey(temp)) // { // jc_kd.Add(temp, OprFuction.NewDTO(tempobj)); // #region 添加记录 // row = StaticClass.AllPointDt.Select("point='" + tempobj.Point + "'"); // if (row.Length > 0) // { // qy = row[0]["wz"]; // } // r = showdt.NewRow(); // r["point"] = point; // r["wz"] = wz; // r["bjz"] = bjz; // r["ddz"] = ddz; // r["dw"] = dw; // //r["fzh"] = fzh; // r["ssz"] = sszn; // r["bjtime"] = bjtime; // r["ddtime"] = ddtime; // r["kdid"] = temp; // r["id"] = key; // r["qy"] = qy; // r["kzk"] = tempobj.Point; // r["kdtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; // showdt.Rows.InsertAt(r, 0);//添加新记录 // #endregion // } // } // } // } // } // #endregion // } // } //} #endregion #region 控制口 if (!string.IsNullOrEmpty(obj.Kdid)) { kdid = obj.Kdid.Split(','); if (kdid.Length > 0) { #region 馈电异常 lock (StaticClass.bjobj) { try { for (int i = 0; i < kdid.Length; i++) { if (!string.IsNullOrEmpty(kdid[i])) { temp = long.Parse(kdid[i]); if (StaticClass.jcbdata.ContainsKey(temp)) { tempobj = StaticClass.jcbdata[temp]; if (!jc_kd.ContainsKey(temp))// { jc_kd.Add(temp, OprFuction.NewDTO(tempobj)); #region 添加记录 lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + tempobj.Point + "'"); if (row.Length > 0) { qy = row[0]["wz"]; } } lock (objShowDt) { r = showdt.NewRow(); r["point"] = point; r["sbstate"] = sbstate; r["wz"] = wz; r["bjz"] = bjz; r["ddz"] = ddz; r["dw"] = dw; //r["fzh"] = fzh; r["ssz"] = sszn; r["bjtime"] = bjtime; r["ddtime"] = ddtime; r["kdid"] = temp; r["id"] = key; r["qy"] = qy; r["kzk"] = tempobj.Point; r["kdtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; r["cs"] = cs; showdt.Rows.InsertAt(r, 0);//添加新记录 } #endregion } else {//措施改变之后,对对应的记录更新 20180206 for (int k = 0; k < showdt.Rows.Count; k++) { if (showdt.Rows[k]["id"].ToString() == key.ToString()) { showdt.Rows[k]["cs"] = cs; } } } } } } } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } } #endregion } } #endregion } } #endregion } catch (Exception ex) { OprFuction.SaveErrorLogs("添加馈电记录1", ex); } updatelist.Clear(); } #endregion #region 添加记录 if (addlist.Count > 0) { //tbcount = showdt.Rows.Count; try { #region 添加记录 for (int kj = 0; kj < addlist.Count; kj++) { key = addlist[kj]; kzkd.Clear(); if (jc_b.ContainsKey(key)) { obj = jc_b[key]; point = obj.Point; lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + point + "'"); if (row.Length > 0) { wz = row[0]["wz"]; sbstate = OprFuction.StateChange(obj.State.ToString()); sszn = obj.Ssz + "/" + OprFuction.TimeToString(obj.Stime); if (int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState9 || int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState11) { bjz = row[0]["sxbj"] + "/" + row[0]["sxyj"]; ddz = row[0]["sxdd"] + "/" + row[0]["sxfd"]; dw = row[0]["dw"]; } else if (int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState19 || int.Parse(obj.Type.ToString()) == StaticClass.itemStateToClient.EqpState21) { bjz = row[0]["xxbj"] + "/" + row[0]["xxyj"]; dw = row[0]["dw"]; ddz = row[0]["xxdd"] + "/" + row[0]["xxfd"]; } else { bjz = obj.Ssz; ddz = obj.Ssz; } } } fzh = obj.Fzh + "/" + obj.Kh + "/" + obj.Dzh; bjtime = ddtime = OprFuction.TimeToString(obj.Stime); cs = obj.Cs; idn = key; #region 控制口 //if (!string.IsNullOrEmpty(obj.Kdid)) //{ // kdid = obj.Kdid.Split('|'); // if (kdid.Length > 0) // { // if (!string.IsNullOrEmpty(kdid[0])) // { // kdid1 = kdid[0].Split(','); // #region 断电失败 // lock (StaticClass.bjobj) // { // for (int i = 0; i < kdid1.Length; i++) // { // temp = long.Parse(kdid1[i]); // if (StaticClass.jcbdata.ContainsKey(temp)) // { // tempobj = StaticClass.jcbdata[temp]; // if (!jc_kd.ContainsKey(temp)) // { // jc_kd.Add(temp, OprFuction.NewDTO(tempobj)); // } // #region 添加记录 // row = StaticClass.AllPointDt.Select("point='" + tempobj.Point + "'"); // if (row.Length > 0) // { // qy = row[0]["wz"]; // } // r = showdt.NewRow(); // r["point"] = point; // r["wz"] = wz; // r["bjz"] = bjz; // r["ddz"] = ddz; // r["dw"] = dw; // //r["fzh"] = fzh; // r["ssz"] = sszn; // r["bjtime"] = bjtime; // r["ddtime"] = ddtime; // r["kdid"] = temp; // r["id"] = key; // r["qy"] = qy; // r["kzk"] = tempobj.Point; // r["kdtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; // showdt.Rows.InsertAt(r, 0);//添加新记录 // #endregion // } // } // } // #endregion // } // if (kdid.Length>1) // { // #region 复电失败 // if (!string.IsNullOrEmpty(kdid[1])) // { // kdid1 = kdid[1].Split(','); // lock (StaticClass.bjobj) // { // for (int i = 0; i < kdid1.Length; i++) // { // temp = long.Parse(kdid1[i]); // if (StaticClass.jcbdata.ContainsKey(temp)) // { // tempobj = StaticClass.jcbdata[temp]; // if (!jc_kd.ContainsKey(temp)) // { // jc_kd.Add(temp, OprFuction.NewDTO(tempobj)); // } // #region 添加记录 // row = StaticClass.AllPointDt.Select("point='" + tempobj.Point + "'"); // if (row.Length > 0) // { // qy = row[0]["wz"]; // } // r = showdt.NewRow(); // r["point"] = point; // r["wz"] = wz; // r["bjz"] = bjz; // r["ddz"] = ddz; // r["dw"] = dw; // //r["fzh"] = fzh; // r["ssz"] = sszn; // r["bjtime"] = bjtime; // r["ddtime"] = ddtime; // r["kdid"] = temp; // r["id"] = key; // r["qy"] = qy; // r["kzk"] = tempobj.Point; // r["kdtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; // showdt.Rows.InsertAt(r, 0);//添加新记录 // } // } // } // #endregion // } // #endregion // } // } //} #endregion #region 控制口 if (!string.IsNullOrEmpty(obj.Kdid)) { kdid = obj.Kdid.Split(','); if (kdid.Length > 0) { #region 馈电异常 lock (StaticClass.bjobj) { try { for (int i = 0; i < kdid.Length; i++) { if (!string.IsNullOrEmpty(kdid[i])) { temp = long.Parse(kdid[i]); if (StaticClass.jcbdata.ContainsKey(temp)) { tempobj = StaticClass.jcbdata[temp]; if (!jc_kd.ContainsKey(temp)) { jc_kd.Add(temp, OprFuction.NewDTO(tempobj)); } #region 添加记录 lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + tempobj.Point + "'"); if (row.Length > 0) { qy = row[0]["wz"]; } } lock (objShowDt) { r = showdt.NewRow(); r["point"] = point; r["wz"] = wz; r["sbstate"] = sbstate; r["bjz"] = bjz; r["ddz"] = ddz; r["dw"] = dw; //r["fzh"] = fzh; r["ssz"] = sszn; r["bjtime"] = bjtime; r["ddtime"] = ddtime; r["kdid"] = temp; r["id"] = key; r["qy"] = qy; r["kzk"] = tempobj.Point; r["kdtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; r["cs"] = cs; showdt.Rows.InsertAt(r, 0);//添加新记录 } #endregion } } } } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } } #endregion } } #endregion } } #endregion } catch (Exception ex) { OprFuction.SaveErrorLogs("添加馈电记录", ex); } //tbcount = showdt.Rows.Count - tbcount; //StaticClass.yccount[3] += tbcount; addlist.Clear(); //mainGridView.FocusedRowHandle = 0; } #endregion #region 当前报警条数 tbcount = showdt.Rows.Count; StaticClass.yccount[3] = tbcount; #endregion }
/// <summary> /// 刷新报警数据 /// </summary> public void refresh(DateTime nowtime) { string point = ""; DataRow[] row, row1; DataRow r; TimeSpan span; int countn = 0; long id = 0; string[] kzk = null, kdid = null, kdid1 = null; long temp = 0; Jc_BInfo obj = null, tempobj = null; int tbcount = 0; long key = 0; List <long> listkey; Dictionary <string, string> kzkd = new Dictionary <string, string>(); object wz = "", devname = "", bjddzt = "", bjz = "", ddz = "", fzh = "", sszn = "", state = "", stime = "", etime = "", cxtime = "", ddtime = "", cs = "", cut = "", allvalue = "", idn = "", qy = "", sbstate = ""; #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_b.ContainsKey(key)) { jc_b.Remove(key); } if (CSlist.ContainsKey(key)) { CSlist.Remove(key); } } deletelist.Clear(); #endregion } } catch (Exception ex) { OprFuction.SaveErrorLogs("删除开关量报警断电记录", ex); } #endregion #region 修改及刷新记录 //foreach (long key in jc_b.Keys) //{ //try //{ // listkey = jc_b.Keys.ToList(); // for (int kj = 0; kj < listkey.Count; kj++) // { // key = listkey[kj]; // if (updatelist.Contains(key)) // { // row = showdt.Select("id='" + key + "'"); // if (row.Length > 0) // { // #region 刷新 结束时间 持续时间 // if (row[0]["endtime"].ToString() == "")//结束时间更新 // { // for (int i = 0; i < row.Length; i++) // { // #region 刷新 结束时间 持续时间 // obj = jc_b[key]; // if (!OprFuction.IsInitTime(obj.Etime)) // { // row[i]["endtime"] = OprFuction.TimeToString(obj.Etime); // span = obj.Etime - Convert.ToDateTime(row[i]["stime"]); // row[i]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); // } // else // { // span = nowtime - Convert.ToDateTime(row[i]["stime"]); // row[i]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); // } // #endregion // } // } // #endregion // #region 刷新cs // if (row[0]["cs"].ToString() != jc_b[key].Cs && !OprFuction.GetClientType()) // { // for (int i = 0; i < row.Length; i++) // { // #region 刷新 cs // row[i]["cs"] = jc_b[key]; // #endregion // } // } // #endregion // } // #region 修改馈电 // if (kdlist.Contains(key)) // { // obj = jc_b[key]; // kdid = obj.Kdid.Split('|'); // if (kdid.Length > 0) // { // if (!string.IsNullOrEmpty(kdid[0])) // { // kdid1 = kdid[0].Split(','); // lock (StaticClass.bjobj) // { // try // { // for (int i = 0; i < kdid1.Length; i++) // { // if (!string.IsNullOrEmpty(kdid1[i])) // { // temp = long.Parse(kdid1[i]); // if (StaticClass.jcbdata.ContainsKey(temp)) // { // tempobj = StaticClass.jcbdata[temp]; // row = showdt.Select("id ='" + obj.ID + "' and point='" + obj.Point + "' and kzk='" + tempobj.Point + "'"); // if (row.Length > 0) // { // row[0]["ddtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; // } // } // } // } // } // catch (Exception ex) // { // Basic.Framework.Logging.LogHelper.Error(ex); // } // } // } // } // } // #endregion // } // else // { // row = showdt.Select("id='" + key + "'"); // if (row.Length > 0) // { // if (row[0]["endtime"].ToString() == "") // { // #region //刷新持续时间 // span = nowtime - Convert.ToDateTime(row[0]["stime"]); // cxtime = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); // for (int j = 0; j < row.Length; j++) // { // row[j]["cxtime"] = cxtime; // } // #endregion // } // } // } // } //} //catch (Exception ex) //{ // OprFuction.SaveErrorLogs("修改开关量报警记录", ex); //} #region//重写刷新方法,每次刷新会导致客户端卡死 20170719 try { listkey = jc_b.Keys.ToList(); for (int kj = 0; kj < showdt.Rows.Count; kj++) { key = long.Parse(showdt.Rows[kj]["id"].ToString()); if (updatelist.Contains(key)) { #region 刷新 结束时间 持续时间 if (showdt.Rows[kj]["endtime"].ToString() == "")//结束时间更新 { #region 刷新 结束时间 持续时间 obj = jc_b[key]; if (!OprFuction.IsInitTime(obj.Etime)) { showdt.Rows[kj]["endtime"] = OprFuction.TimeToString(obj.Etime); span = obj.Etime - Convert.ToDateTime(showdt.Rows[kj]["stime"]); showdt.Rows[kj]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); } else { span = nowtime - Convert.ToDateTime(showdt.Rows[kj]["stime"]); showdt.Rows[kj]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); } #endregion } #endregion #region 刷新cs if (!string.IsNullOrEmpty(jc_b[key].Cs)) { if (showdt.Rows[kj]["cs"].ToString() != (jc_b[key].Cs + "/" + jc_b[key].Bz2))//&& !OprFuction.GetClientType() 注释 20170817 { #region 刷新 cs showdt.Rows[kj]["cs"] = (jc_b[key].Cs + "/" + jc_b[key].Bz2); #endregion } } else { showdt.Rows[kj]["cs"] = ""; } #endregion #region 修改馈电 if (kdlist.Contains(key)) { obj = jc_b[key]; kdid = obj.Kdid.Split('|'); if (kdid.Length > 0) { if (!string.IsNullOrEmpty(kdid[0])) { kdid1 = kdid[0].Split(','); lock (StaticClass.bjobj) { try { for (int i = 0; i < kdid1.Length; i++) { if (!string.IsNullOrEmpty(kdid1[i])) { temp = long.Parse(kdid1[i]); if (StaticClass.jcbdata.ContainsKey(temp)) { tempobj = StaticClass.jcbdata[temp]; row = showdt.Select("id ='" + obj.ID + "' and point='" + obj.Point + "' and kzk='" + tempobj.Point + "'"); if (row.Length > 0) { showdt.Rows[kj]["ddtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; } } } } } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } } } } } #endregion } else { if (showdt.Rows[kj]["endtime"].ToString() == "") { #region //刷新持续时间 span = nowtime - Convert.ToDateTime(showdt.Rows[kj]["stime"]); cxtime = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); showdt.Rows[kj]["cxtime"] = cxtime; #endregion } } } } catch (Exception ex) { OprFuction.SaveErrorLogs("修改开关量报警记录", ex); } #endregion //} updatelist.Clear(); kdlist.Clear(); #endregion #region 添加记录 if (addlist.Count > 0) { //tbcount = showdt.Rows.Count; try { #region 添加记录 for (int kj = 0; kj < addlist.Count; kj++) { key = addlist[kj]; kzkd.Clear(); if (jc_b.ContainsKey(key)) { obj = jc_b[key]; point = obj.Point; lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + point + "'"); if (row.Length > 0) { wz = row[0]["wz"]; devname = row[0]["devname"]; } } fzh = obj.Fzh + "/" + obj.Kh + "/" + obj.Dzh; sszn = obj.Ssz; bjz = sszn; ddz = sszn; state = OprFuction.StateChange(obj.Type.ToString()); sbstate = OprFuction.StateChange(obj.State.ToString()); stime = OprFuction.TimeToString(obj.Stime); span = nowtime - obj.Stime; cxtime = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); etime = ""; //by if (!OprFuction.IsInitTime(obj.Etime)) { etime = OprFuction.TimeToString(obj.Etime); } ddtime = OprFuction.TimeToString(obj.Stime); if (obj.Isalarm > 0 && string.IsNullOrEmpty(obj.Kzk)) { bjddzt = "报警"; } else if (!string.IsNullOrEmpty(obj.Kzk)) { bjddzt = "断电"; } cs = obj.Cs; cut = 1; allvalue = obj.Ssz; id = key; if (!string.IsNullOrEmpty(obj.Kzk)) { #region 控制口 kzk = obj.Kzk.Split('|'); if (!string.IsNullOrEmpty(obj.Kdid)) { kdid = obj.Kdid.Split('|'); if (kdid.Length > 0) { if (!string.IsNullOrEmpty(kdid[0])) { kdid1 = kdid[0].Split(','); lock (StaticClass.bjobj) { try { for (int i = 0; i < kdid1.Length; i++) { if (!string.IsNullOrEmpty(kdid1[i])) { temp = long.Parse(kdid1[i]); if (StaticClass.jcbdata.ContainsKey(temp)) { tempobj = StaticClass.jcbdata[temp]; kzkd.Add(tempobj.Point, OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime); } } } } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } } } } } if (kzk.Length > 0) { for (int i = 0; i < kzk.Length; i++) { #region 添加记录 lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + kzk[i] + "'"); if (row.Length > 0) { qy = row[0]["wz"]; } } lock (objShowDt) { r = showdt.NewRow(); r["point"] = point; r["wz"] = wz; r["devname"] = devname; r["bjddzt"] = bjddzt; r["bjz"] = bjz; r["ddz"] = ddz; //r["fzh"] = fzh; r["ssz"] = sszn; r["sbstate"] = sbstate; //r["state"] = state; r["stime"] = stime; r["cxtime"] = cxtime; r["endtime"] = etime; r["ddtime"] = ddtime; if (!string.IsNullOrEmpty(cs.ToString())) { r["cs"] = cs + "/" + obj.Bz2; } else { r["cs"] = ""; } //r["count"] = 1; r["id"] = key; r["qy"] = qy; r["kzk"] = kzk[i]; if (kzkd.ContainsKey(kzk[i])) { r["ddtime"] = kzkd[kzk[i]]; } row1 = showdt.Select("id='" + key + "' and kzk='" + kzk[i] + "'"); if (row1.Length < 1) { showdt.Rows.InsertAt(r, 0);//添加新记录 } } //showdt.Rows.InsertAt(r, 0);//添加新记录 #endregion } } #endregion } else { #region 无控制口 lock (objShowDt) { r = showdt.NewRow(); r["point"] = point; r["wz"] = wz; r["devname"] = devname; r["bjddzt"] = bjddzt; r["bjz"] = bjz; //r["fzh"] = fzh; r["ssz"] = sszn; r["sbstate"] = sbstate; //r["state"] = state; r["stime"] = stime; r["cxtime"] = cxtime; r["endtime"] = etime; if (!string.IsNullOrEmpty(cs.ToString())) { r["cs"] = cs + "/" + obj.Bz2; } else { r["cs"] = ""; } //r["count"] = 1; //r["allvalue"] = obj.Ssz; r["id"] = key; row1 = showdt.Select("id='" + key + "'"); if (row1.Length < 1) { showdt.Rows.InsertAt(r, 0);//添加新记录 } } #endregion } } } #endregion } catch (Exception ex) { OprFuction.SaveErrorLogs("添加开关量报警记录", ex); } //tbcount = showdt.Rows.Count - tbcount; //StaticClass.yccount[2] += tbcount; addlist.Clear(); //mainGridView.FocusedRowHandle = 0; } #endregion #region 当前报警条数 tbcount = showdt.Select("endtime='' or endtime='1900-01-01 00:00:00'", "").Length; StaticClass.yccount[2] = tbcount; #endregion }
/// <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 }
/// <summary> /// 刷新故障数据 /// </summary> public void refresh1(DateTime nowtime) { string point = "", ssz1, ssz2, state; double ssz, zdz, zxz, pjz, allvlaue, count, yjz; DataRow[] row; TimeSpan span; int tbcount = 0; #region 刷新实时值、最大值、最小值、平均值 持续时间 结束时间 try { lock (objShowDt) { for (int i = 0; i < showdt.Rows.Count; i++) { #region 刷新持续时间 span = nowtime - Convert.ToDateTime(showdt.Rows[i]["stime"]); showdt.Rows[i]["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); #endregion #region 刷新实时值、最大值、最小值、平均值 point = showdt.Rows[i]["point"].ToString(); ssz2 = showdt.Rows[i]["ssz"].ToString(); lock (StaticClass.allPointDtLockObj) { row = StaticClass.AllPointDt.Select("point='" + point + "'"); if (row.Length > 0) { ssz1 = row[0]["ssz"].ToString(); if (ssz1 != ssz2) { if (double.TryParse(ssz1, out ssz)) { state = showdt.Rows[i]["state"].ToString(); yjz = Convert.ToDouble(showdt.Rows[i]["yjz"]); zdz = Convert.ToDouble(showdt.Rows[i]["zdz"]); zxz = Convert.ToDouble(showdt.Rows[i]["zxz"]); pjz = Convert.ToDouble(showdt.Rows[i]["pjz"]); count = Convert.ToDouble(showdt.Rows[i]["count"]); allvlaue = Convert.ToDouble(showdt.Rows[i]["allvalue"]); if (ssz > zdz) { zdz = ssz; } else if (ssz < zxz) { zxz = ssz; } count += 1; allvlaue += ssz; pjz = Math.Round(allvlaue / count, 2); if ((state.Contains("上限") && (ssz >= yjz)) || (state.Contains("下限") && (ssz <= yjz))) { showdt.Rows[i]["zdz"] = zdz; showdt.Rows[i]["zxz"] = zxz; showdt.Rows[i]["pjz"] = pjz; showdt.Rows[i]["ssz"] = ssz; showdt.Rows[i]["count"] = count; showdt.Rows[i]["allvalue"] = allvlaue; } } } } } #endregion } } #region 当前报警条数 tbcount = showdt.Rows.Count; StaticClass.yccount[0] = tbcount; #endregion } catch (Exception ex) { OprFuction.SaveErrorLogs("刷新实时值、最大值、最小值、平均值", ex); } #endregion }
public static void iniform() { try { string state; #region 从本地读取配置信息到内存 string realDisplaySync = RealInterfaceFuction.ReadConfig("RealDisplaySync"); if (realDisplaySync == "1") { OprFuction.ReadRealConfigFromDB();//修改支持多个客户端显示设置同步 20180113 } OprFuction.ReadRealDataDisplayConfig(); OprFuction.ReadDefalutDataConfig(); OprFuction.ReadCustomConfig(); #endregion lock (StaticClass.allPointDtLockObj) { StaticClass.AllPointDt = RealInterfaceFuction.GetAllPoint(); for (int i = 0; i < StaticClass.AllPointDt.Rows.Count; i++) { state = StaticClass.AllPointDt.Rows[i]["zt"].ToString(); if (state == StaticClass.itemStateToClient.EqpState24.ToString() || state == StaticClass.itemStateToClient.EqpState43.ToString()) { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, StaticClass.AllPointDt.Rows[i]["0tcolor"].ToString(), StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } else if (state == StaticClass.itemStateToClient.EqpState44.ToString() || state == StaticClass.itemStateToClient.EqpState25.ToString()) { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, StaticClass.AllPointDt.Rows[i]["1tcolor"].ToString(), StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } else if (state == StaticClass.itemStateToClient.EqpState26.ToString()) { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, StaticClass.AllPointDt.Rows[i]["2tcolor"].ToString(), StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } else { StaticClass.AllPointDt.Rows[i]["statecolor"] = StaticClass.AllPointDt.Rows[i]["sszcolor"] = OprFuction.GetShowColor(state, "0", StaticClass.AllPointDt.Rows[i]["bj"].ToString()); } } } real_s = new RealDisplayForm(); real_s.Dock = DockStyle.Fill; real_del = real_s.Gv_init; _type_s = new DisplayNavagation(); _type_s.Dock = DockStyle.Fill; _type_dele = _type_s.refresh; GetbjThread = new Thread(new ThreadStart(OprFuction.GetbjTh)); GetbjThread.Start(); InitRealWarGridControl(); //Initalarm(); } catch (Exception ex) { OprFuction.SaveErrorLogs(ex.Message, ex); } }