/// <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 }
private void getdt(DateTime nowtime) { DataRow[] rows = null; DataRow row = null, r = null; TimeSpan span; string point = "", ssz1, ssz2; double ssz, zdz, zxz, pjz, allvlaue; int zt = -1; DataTable dt = showdt.Clone(); List <int> fzh; int x = -1, y = -1, count = 0, toprowindex = 0; try { #region 模拟量预警信息 lock (StaticClass.allPointDtLockObj) { rows = StaticClass.AllPointDt.Select("lx='模拟量' and ( zt='8' or zt='14')", "fzh,tdh,dzh"); //modified by 20170315 //在调试代码时,发现此select返回的行,第一行有时有为null的情况(估计是datatable读写并发引起返回为空行记录,临时通过特殊处理空行记录), if (rows != null && rows.Length > 0) { List <DataRow> list = new List <DataRow>(); foreach (DataRow dr in rows) { if (dr != null) //移除空行 { list.Add(dr); } } rows = list.ToArray(); } if (rows.Length > 0) { DataTable dt1 = rows.CopyToDataTable(); #region 除已结束的报警 lock (objShowDt) { for (int i = 0; i < showdt.Rows.Count; i++) { rows = dt1.Select("point='" + showdt.Rows[i]["point"].ToString() + "'"); if (rows.Length > 0) { #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(); ssz1 = rows[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.ToInt32(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; showdt.Rows[i]["allvalue"] = allvlaue; } } #endregion } else { showdt.Rows.RemoveAt(i); i--; } } } #endregion #region 添加新的报警 lock (objShowDt) { for (int kj = 0; kj < dt1.Rows.Count; kj++) { r = dt1.Rows[kj]; rows = showdt.Select("point='" + r["point"].ToString() + "'"); { if (rows.Length > 0) { continue; } } row = showdt.NewRow(); row["point"] = r["point"]; row["wz"] = r["wz"]; if (r["zt"].ToString() == StaticClass.itemStateToClient.EqpState7.ToString()) { row["yjz"] = r["sxyj"]; } else { row["yjz"] = r["xxyj"]; } //row["fzh"] = r["fzh"] + "/" + r["tdh"] + "/" + r["dzh"]; row["ssz"] = r["ssz"]; row["state"] = OprFuction.StateChange(r["zt"].ToString()); row["sbstate"] = OprFuction.StateChange(r["sbzt"].ToString()); row["stime"] = OprFuction.TimeToString(DateTime.Parse(r["time"].ToString())); span = nowtime - DateTime.Parse(r["time"].ToString()); row["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); row["zdz"] = r["ssz"]; row["zxz"] = r["ssz"]; row["pjz"] = r["ssz"]; row["count"] = 1; row["allvalue"] = r["ssz"]; row["id"] = 0; row["devname"] = r["lb"]; row["dw"] = r["dw"]; showdt.Rows.InsertAt(row, 0);//添加新记录 } } #endregion } else { lock (objShowDt) { showdt.Rows.Clear(); } } } #endregion } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } }
private void getdt(DateTime nowtime) { DataRow[] rows = null; DataRow row = null, r = null; TimeSpan span; string point = "", ssz1, ssz2; double ssz, zdz, zxz, pjz, allvlaue; int zt = -1; DataTable dt = showdt.Clone(); List <int> fzh; int x = -1, y = -1, count = 0, toprowindex = 0; long temp = 0; string[] kdid1; Jc_BInfo tempobj = null; bool updateflag = true; List <Jc_BInfo> endkdlist = new List <Jc_BInfo>(); Jc_BInfo lb = new Jc_BInfo(); string nt = string.Empty; try { #region 模拟量信息 lock (StaticClass.allPointDtLockObj) { rows = StaticClass.AllPointDt.Select("lx='开关量' ", "fzh,tdh,dzh"); //modified by 20170315 //在调试代码时,发现此select返回的行,第一行有时有为null的情况(估计是datatable读写并发引起返回为空行记录,临时通过特殊处理空行记录), if (rows != null && rows.Length > 0) { List <DataRow> list = new List <DataRow>(); foreach (DataRow dr in rows) { if (dr != null) //移除空行 { list.Add(dr); } } rows = list.ToArray(); } if (rows.Length > 0) { DataTable dt1 = rows.CopyToDataTable(); #region 除已结束的报警 lock (objShowDt) { for (int i = 0; i < showdt.Rows.Count; i++) { rows = dt1.Select("point='" + showdt.Rows[i]["point"].ToString() + "'"); if (rows.Length > 0) { #region 刷新实时值、最大值、最小值、平均值 point = showdt.Rows[i]["point"].ToString(); ssz2 = showdt.Rows[i]["ssz"].ToString(); ssz1 = rows[0]["ssz"].ToString(); if (ssz1 != ssz2) { showdt.Rows[i]["ssz"] = ssz1; showdt.Rows[i]["state"] = OprFuction.StateChange(rows[0]["zt"].ToString()); showdt.Rows[i]["sbstate"] = OprFuction.StateChange(rows[0]["sbzt"].ToString()); showdt.Rows[i]["stime"] = OprFuction.TimeToString(DateTime.Parse(rows[0]["time"].ToString())); showdt.Rows[i]["time"] = OprFuction.TimeToString(DateTime.Parse(rows[0]["time"].ToString())); } #endregion lock (StaticClass.bjobj) { var bjobj = StaticClass.jcbdata.Values.Where(pp => pp.Point == showdt.Rows[i]["point"].ToString() && ( (OprFuction.KGLisAlarm(pp) || !string.IsNullOrEmpty(pp.Kzk))) && (OprFuction.IsInitTime(pp.Etime))).OrderByDescending(pp => pp.Stime).FirstOrDefault(); if (bjobj != null && !string.IsNullOrEmpty(bjobj.Point)) { if (OprFuction.KGLisAlarm(bjobj)) { if (showdt.Rows[i]["bjtime"] != null && showdt.Rows[i]["bjtime"].ToString() != "报警/" + OprFuction.TimeToString(bjobj.Etime)) { showdt.Rows[i]["bjtime"] = "报警/" + OprFuction.TimeToString(bjobj.Stime); } } else { if (showdt.Rows[i]["bjtime"] != null && showdt.Rows[i]["bjtime"].ToString() != "断电/" + OprFuction.TimeToString(bjobj.Stime)) { showdt.Rows[i]["bjtime"] = "断电/" + OprFuction.TimeToString(bjobj.Stime); } } if (!string.IsNullOrEmpty(bjobj.Kzk)) { string[] kzk = bjobj.Kzk.Split('|'); string kzqy = ""; if (kzk.Length > 0) { for (int k = 0; k < kzk.Length; k++) { lock (StaticClass.allPointDtLockObj) { DataRow[] row1 = StaticClass.AllPointDt.Select("point='" + kzk[i] + "'"); if (row1.Length > 0) { kzqy = kzqy + kzk[i] + "(" + row1[0]["wz"] + ")|"; } } } } if (kzqy.Length > 1) { kzqy = kzqy.Substring(0, kzqy.Length - 1); } showdt.Rows[i]["ddqy"] = kzqy; } else { showdt.Rows[i]["ddqy"] = ""; } if (showdt.Rows[i]["cstime"] != null && showdt.Rows[i]["cstime"].ToString() != bjobj.Cs + "/" + bjobj.Bz2) { showdt.Rows[i]["cstime"] = bjobj.Cs + "/" + bjobj.Bz2; } if (!string.IsNullOrEmpty(bjobj.Kdid)) { if (null != showdt.Rows[i]["kdid"]) { if (showdt.Rows[i]["kdid"].ToString() != bjobj.Kdid) { #region 修改馈电 kdid1 = bjobj.Kdid.Split(','); lock (StaticClass.bjobj) { try { for (int z = 0; z < kdid1.Length; z++) { if (!string.IsNullOrEmpty(kdid1[z])) { temp = long.Parse(kdid1[z]); if (StaticClass.jcbdata.ContainsKey(temp)) { tempobj = StaticClass.jcbdata[temp]; showdt.Rows[i]["kdtime"] = OprFuction.StateChange(tempobj.Type.ToString()) + "/" + tempobj.Stime; } } } } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } } showdt.Rows[i]["kdid"] = bjobj.Kdid; #endregion } else { updateflag = true; kdid1 = bjobj.Kdid.Split(','); for (int z = 0; z < kdid1.Length; z++) { if (!string.IsNullOrEmpty(kdid1[z])) { temp = long.Parse(kdid1[z]); if (StaticClass.jcbdata.ContainsKey(temp)) { tempobj = StaticClass.jcbdata[temp]; endkdlist.Add(tempobj); if (OprFuction.IsInitTime(tempobj.Etime)) { updateflag = false; } } } } if (updateflag) { lb = endkdlist.OrderByDescending(pp => pp.Etime).First(); if (lb.Type == (short)DeviceDataState.DataPowerOffFail) { nt = ((short)DeviceDataState.DataPowerOffSuc).ToString(); } else if (lb.Type == (short)DeviceDataState.DataPowerOnFail) { nt = ((short)DeviceDataState.DataPowerOnSuc).ToString(); } showdt.Rows[i]["kdtime"] = OprFuction.StateChange(nt) + "/" + lb.Etime; } } } } } else { showdt.Rows[i]["bjtime"] = ""; showdt.Rows[i]["ddqy"] = ""; showdt.Rows[i]["kdtime"] = ""; showdt.Rows[i]["cstime"] = ""; } } } else { showdt.Rows.RemoveAt(i); i--; } } } #endregion #region 添加新的报警 lock (objShowDt) { for (int kj = 0; kj < dt1.Rows.Count; kj++) { r = dt1.Rows[kj]; rows = showdt.Select("point='" + r["point"].ToString() + "'"); { if (rows.Length > 0) { continue; } } row = showdt.NewRow(); row["point"] = r["point"]; row["wz"] = r["wz"]; if (r["zt"].ToString() == StaticClass.itemStateToClient.EqpState7.ToString()) { row["yjz"] = r["sxyj"]; } else { row["yjz"] = r["xxyj"]; } row["fzh"] = r["fzh"] + "/" + r["tdh"] + "/" + r["dzh"]; row["ssz"] = r["ssz"]; row["state"] = OprFuction.StateChange(r["zt"].ToString()); row["sbstate"] = OprFuction.StateChange(r["sbzt"].ToString()); row["stime"] = OprFuction.TimeToString(DateTime.Parse(r["time"].ToString())); row["time"] = OprFuction.TimeToString(DateTime.Parse(r["time"].ToString())); span = nowtime - DateTime.Parse(r["time"].ToString()); row["cxtime"] = String.Format("{0:D2}:{1:D2}:{2:D2}:{3:D2}", span.Days, span.Hours, span.Minutes, span.Seconds); row["zdz"] = r["ssz"]; row["zxz"] = r["ssz"]; row["pjz"] = r["ssz"]; row["count"] = 1; row["allvalue"] = r["ssz"]; row["id"] = 0; row["devname"] = r["lb"]; row["dw"] = r["dw"]; showdt.Rows.InsertAt(row, 0);//添加新记录 } } #endregion } else { lock (objShowDt) { showdt.Rows.Clear(); } } } #endregion } catch (Exception ex) { Basic.Framework.Logging.LogHelper.Error(ex); } }
/// <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 }
/// <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; 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> 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) { 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 }