private void cmb_adr_SelectedIndexChanged(object sender, EventArgs e) { obj.showdt.Clear(); obj.kzpoint = cmb_adr.Text; List <Jc_DefInfo> dtos = pointDefineService.GetAllPointDefineCache().Data; DataTable dt = Model.RealInterfaceFuction.Getzkpoint(obj.kzpoint); getmsg(dtos, dt); realshow(); }
private void cmb_adr_SelectedIndexChanged(object sender, EventArgs e) { obj.clear(); obj.analogpoint = cmb_adr.Text; List <Jc_DefInfo> pointDefineList = pointDefineService.GetAllPointDefineCache().Data; List <Jc_BInfo> alarmInfoList = Model.RealInterfaceFuction.GetBjData(); getmsg(pointDefineList, alarmInfoList); realshow(); }
public override void Load() { //GetRealDataRequest realDataRequest = new GetRealDataRequest(); //realDataRequest.LastRefreshRealDataTime = DateTime.MinValue; var response = pointDefineService.GetAllPointDefineCache(); if (response.IsSuccess && response.Data != null) { _cache.Clear(); _cache = response.Data; } }
public BasicResponse <DataTable> GetDyxFz() { DataTable msg = new DataTable(); List <string> keys = null; Jc_DefInfo def = null; msg.Columns.Add("fzh", typeof(int)); msg.Columns.Add("fd", typeof(int)); msg.TableName = "fz"; try { //List<Jc_DefInfo> _JC_DEF = _CacheMrg.ServerCache.Cache_jc_def.QueryAllCacheList(); var res = _pointDefineService.GetAllPointDefineCache(); if (!res.IsSuccess) { throw new Exception(res.Message); } List <Jc_DefInfo> _JC_DEF = res.Data; if (_JC_DEF.Count > 0) { //keys = new List<string>(_CacheMrg.ServerCache.Cache_jc_def._JC_DEF.Keys); for (int i = 0; i < _JC_DEF.Count; i++) { def = _JC_DEF[i]; if (def.Activity == "1" && def.DevPropertyID == 0) { if ((def.Bz3 & 0x8) == 0x8) { msg.Rows.Add(def.Fzh, 0); } } } } if (msg.Rows.Count > 0) { DataView ds = new DataView(msg); ds.Sort = "fzh"; msg = ds.ToTable("ff"); } } catch (Exception ex) { LogHelper.Error("获取所有绑定电源箱分站", ex); } var ret = new BasicResponse <DataTable> { Data = msg }; return(ret); }
/// <summary> /// 查找所有测点信息 /// </summary> /// <returns></returns> public static List <Jc_DefInfo> QueryAllCache() { var result = _PointDefineService.GetAllPointDefineCache(); if (result.IsSuccess == true) { return(result.Data); } else { throw new Exception(result.Message); } }
private void LoadData() { try { IPointDefineService service = ServiceFactory.Create <IPointDefineService>(); var result = service.GetAllPointDefineCache(); if (result.IsSuccess && result.Data != null) { List <Jc_DefInfo> allDef = result.Data.OrderBy(a => a.Point).ToList(); List <Jc_DefInfo> tempDef; //模拟量本地控制 tempDef = allDef.Where(a => a.DevPropertyID == 1 && a.DevClassID != 13).ToList(); for (int i = 0; i < tempDef.Count; i++) { mnlkzDt.Rows.Add(i + 1, tempDef[i].Point, tempDef[i].DevName, tempDef[i].Wz, tempDef[i].Z2, tempDef[i].Z3, tempDef[i].Z4, GetLocalControlText(tempDef[i].Fzh, tempDef[i].K1), GetLocalControlText(tempDef[i].Fzh, tempDef[i].K2), GetLocalControlText(tempDef[i].Fzh, tempDef[i].K3), GetLocalControlText(tempDef[i].Fzh, tempDef[i].K4), GetLocalControlText(tempDef[i].Fzh, tempDef[i].K7) ); } //开关量本地控制 tempDef = allDef.Where(a => a.DevPropertyID == 2).ToList(); for (int i = 0; i < tempDef.Count; i++) { kglkzDt.Rows.Add(i + 1, tempDef[i].Point, tempDef[i].DevName, tempDef[i].Wz, GetLocalControlText(tempDef[i].Fzh, tempDef[i].K1), GetLocalControlText(tempDef[i].Fzh, tempDef[i].K2), GetLocalControlText(tempDef[i].Fzh, tempDef[i].K3) ); } //交叉控制 tempDef = allDef.Where(a => (a.DevPropertyID == 1 || a.DevPropertyID == 2) && a.DevClassID != 13).ToList(); for (int i = 0; i < tempDef.Count; i++) { jckzDt.Rows.Add(i + 1, tempDef[i].Point, tempDef[i].DevName, tempDef[i].Wz, tempDef[i].Jckz1, tempDef[i].Jckz2, tempDef[i].Jckz3 ); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }
public BasicResponse <List <Jc_DefInfo> > GetAllPointDefineCache() { return(_PointDefineService.GetAllPointDefineCache()); }
protected override void DoWork() { try { DateTime pointDefineServerSideTime = DateTime.MinValue; BasicResponse <string> pointDefineLastChangedTimeResponse = largeDataAnalysisLastChangedService.GetPointDefineLastChangedTime(new LargeDataAnalysisLastChangedRequest()); if (pointDefineLastChangedTimeResponse.IsSuccess && !string.IsNullOrEmpty(pointDefineLastChangedTimeResponse.Data)) { pointDefineServerSideTime = DateTime.Parse(pointDefineLastChangedTimeResponse.Data); } if (pointDefineServerSideTime > pointDefineLastChangedTime || pointCache.Count == 0) { //测点定义发生变化后重新初始化测点定义缓存. //GetRealDataRequest realDataRequest = new GetRealDataRequest(); //realDataRequest.LastRefreshRealDataTime = DateTime.MinValue; var getAllPointResponse = pointDefineService.GetAllPointDefineCache(); if (getAllPointResponse.IsSuccess && getAllPointResponse.Data != null) { pointCache.Clear(); foreach (var item in getAllPointResponse.Data) { if (item.DttStateTime > lastRefreshRealDataTime) { lastRefreshRealDataTime = item.DttStateTime; } pointCache.AddItem(item); } } pointDefineLastChangedTime = pointDefineServerSideTime; } else { //测点定义没有发生变化没有重新初始化测点定义缓存时,更新本地测点缓存 //GetRealDataRequest realDataRequest = new GetRealDataRequest(); //realDataRequest.LastRefreshRealDataTime = lastRefreshRealDataTime; //var getAllPointResponse = realMessageService.GetRealData(realDataRequest); var getAllPointResponse = pointDefineService.GetAllPointDefineCache(); if (getAllPointResponse.IsSuccess && getAllPointResponse.Data != null) { foreach (var item in getAllPointResponse.Data) { if (item.DttStateTime > lastRefreshRealDataTime) { lastRefreshRealDataTime = item.DttStateTime; } var oldPointDefine = pointCache.Query(q => q.PointID == item.PointID).FirstOrDefault(); if (null == oldPointDefine) { pointCache.AddItem(item); } else { pointCache.UpdateItem(item); } } } } } catch (Exception ex) { pointCache.Clear();//获取监控服务端获取缓存出错时,清除内部缓存。 LogHelper.Error(string.Format("更新内部维护的缓存列表时出错:{0}", ex.StackTrace)); } base.DoWork(); }
private void GetCalibrationDue() { try { List <EnumcodeInfo> enumcodeInfos = new List <EnumcodeInfo>(); EnumcodeInfo enumcodeInfo; EnumcodeGetByEnumTypeIDRequest enumcoderequest = new EnumcodeGetByEnumTypeIDRequest(); enumcoderequest.EnumTypeId = "3"; var result = enumcodeService.GetEnumcodeByEnumTypeID(enumcoderequest); if (result.IsSuccess & result.Data != null) { enumcodeInfos = result.Data; } //获取设备类型及测点定义基础数据 if (deviceDefineList.Count == 0 || bIsDevChange()) { deviceDefineList = deviceDefineService.GetAllDeviceDefineCache().Data; pointDefineList = pointDefineService.GetAllPointDefineCache().Data; } GetRealDataRequest request = new GetRealDataRequest(); realDataList = realMessageService.GetRealData(request).Data; //标效及传感器到期提醒 //查询近90天内的标效记录(统计前一天,及之前90天的记录) DateTime startTime = DateTime.Parse(DateTime.Now.AddDays(-91).ToShortDateString()); DateTime endTime = DateTime.Parse(DateTime.Now.ToShortDateString() + " 23:59:59"); DataTable calibrationRecord = ClientAlarmServer.GetCalibrationRecord(startTime, endTime); //按设备类型循环获取未标校、到期的传感器数量 int NoCalibrationCount = 0; int DueCount = 0; foreach (Jc_DevInfo dev in deviceDefineList) { //2018.5.9 by AI enumcodeInfo = enumcodeInfos.FirstOrDefault(a => a.LngEnumValue == dev.Bz4); if (enumcodeInfo == null) { //LogHelper.Error("【GetCalibrationDue】枚举中未找到设备:" + dev.Bz4); continue; } int tempCalibrationTime = 0; int.TryParse(dev.Pl4.ToString(), out tempCalibrationTime);//标校周期 List <Jc_DefInfo> pointList = pointDefineList.FindAll(a => a.Devid == dev.Devid); if (tempCalibrationTime > 0) { #region 标效周期报警 //计算当前设备类型下面的传感器是否到标效期 foreach (Jc_DefInfo def in pointList) { DataRow[] dr = calibrationRecord.Select("point='" + def.Point + "' and stime<='" + endTime + "'", "stime desc"); if (dr.Length > 0) { TimeSpan ts = endTime - DateTime.Parse(dr[0]["stime"].ToString()); if ((int)ts.TotalDays >= tempCalibrationTime)//如果上一次标校记录时间超过了设置的标校时间周期,则记入未标校数量 { NoCalibrationCount++; SensorCalibrationInfo tempSensorCalibrationInfo = new SensorCalibrationInfo(); tempSensorCalibrationInfo.Point = def.Point; tempSensorCalibrationInfo.Position = def.Wz; tempSensorCalibrationInfo.DevName = def.DevName; tempSensorCalibrationInfo.SetCalibrationTime = tempCalibrationTime.ToString(); tempSensorCalibrationInfo.LastCalibrationTime = dr[0]["stime"].ToString(); tempSensorCalibrationInfo.CalibrationDays = ((int)(ts.TotalDays)).ToString(); tempSensorCalibrationInfo.id = dr[0]["id"].ToString(); tempSensorCalibrationInfo.pointid = def.PointID; if (ClientAlarmServer.sensorCalibrationInfoList.Find(a => a.Point == tempSensorCalibrationInfo.Point) == null) { ClientAlarmServer.sensorCalibrationInfoList.Add(tempSensorCalibrationInfo); } } else { int index = ClientAlarmServer.sensorCalibrationInfoList.FindIndex(a => a.Point == def.Point); if (index >= 0) { ClientAlarmServer.sensorCalibrationInfoList.RemoveAt(index); } } } else//未找到标校记录,则直接记入未标校 { NoCalibrationCount++; SensorCalibrationInfo tempSensorCalibrationInfo = new SensorCalibrationInfo(); tempSensorCalibrationInfo.Point = def.Point; tempSensorCalibrationInfo.Position = def.Wz; tempSensorCalibrationInfo.DevName = def.DevName; tempSensorCalibrationInfo.SetCalibrationTime = tempCalibrationTime.ToString(); tempSensorCalibrationInfo.LastCalibrationTime = "未记录"; tempSensorCalibrationInfo.CalibrationDays = "-"; tempSensorCalibrationInfo.pointid = def.PointID; //tempSensorCalibrationInfo.id = dr[0]["id"].ToString(); if (ClientAlarmServer.sensorCalibrationInfoList.Find(a => a.Point == tempSensorCalibrationInfo.Point) == null) { ClientAlarmServer.sensorCalibrationInfoList.Add(tempSensorCalibrationInfo); } } } #endregion } } //清除已删除的测点 foreach (SensorCalibrationInfo tempSensorCalibrationInfo in ClientAlarmServer.sensorCalibrationInfoList) { if (pointDefineList.FindAll(a => a.Point == tempSensorCalibrationInfo.Point).Count == 0)//如果测点定义缓存中不存在测点,则清除未标校集合中的记录 { ClientAlarmServer.sensorCalibrationInfoList.Remove(tempSensorCalibrationInfo); } } } catch (Exception ex) { LogHelper.Error(ex); } }