protected override void ParseContent(List <string> lines, DateTime realTime) { var lineContents = lines.Select(p => GetLines(p)); var tempModels = lineContents.Where(p => p.Length == 16).Select(o => new AlarmToday(o, realTime)).Where(q => q.IsValid); var alarmTodayModels = tempModels.Select(p => p.AlarmTodayModel); /* * var alarmTodayList = from t in alarmTodayModels * join a in _dev.EquipmentInfoModels * on t.EquipId equals a.EquipId * select t; * var tableName = "AlarmToday"; * var dt = ListToDataTableHelper.Models2Datatable<AlarmTodayModel>(tableName, alarmTodayList.ToList()); * DataRepo.Dapper.BulkUpdate(dt, tableName, "EquipId", "Index", "StartTime", "ValueState"); */ var analogAlarmList = from t in tempModels.Where(p => p.IsAnalogAlarm).Select(p => p.AnalogAlarmModel) join a in _dev.AnalogPointModels on t.EquipId equals a.EquipId select t; var analogAlarmTableName = $"AnalogAlarm{realTime:yyyyMM}"; var analogAlarmDt = ListToDataTableHelper.Models2Datatable <AnalogAlarmModel>(analogAlarmTableName, analogAlarmList.ToList()); DataRepo.YearDapper.BulkUpdate(analogAlarmDt, analogAlarmTableName, "EquipId", "Index", "PointCode", "StartTime", "ValueState"); }
protected override void ParseContent(List <string> lines, DateTime realTime) { if (_startTime.Hour != realTime.Hour) { FluxRealDataModels.Clear(); _startTime = realTime; } var lineContents = lines.Select(p => GetLines(p)); var realDatas = lineContents.Where(p => p.Length == 3 && p[0].Contains("A")).Select(p => GetRealData(p, realTime)); if (realDatas != null && realDatas.Any()) { RealDatas.Clear(); RealDatas.AddRange(realDatas); } foreach (var fluxPoint in _dev.FluxPointModels) { var tempList = lineContents.Where(p => p.Length == 3 && p[0].Contains("Q") && GetPointCode(p[0]).Substring(1, 3).ToInt() == fluxPoint.FluxID); if (!tempList.Any()) { continue; } var fluxTotal = GetFluxTotalInfo(tempList, FluxTypeFlag.FluxTotal); var pureFluxTotal = GetFluxTotalInfo(tempList, FluxTypeFlag.PureFluxTotal); var industrialFluxTotal = GetFluxTotalInfo(tempList, FluxTypeFlag.IndustrialFluxTotal); var industrialPureFluxTotal = GetFluxTotalInfo(tempList, FluxTypeFlag.IndustrialPureFluxTotal); var fluxRealDataCache = FluxRealDataModels.FirstOrDefault(p => p.FluxID == fluxPoint.FluxID); if (fluxRealDataCache != null) { fluxRealDataCache.FluxHour = GetFluxSum(fluxRealDataCache.FluxHour, fluxTotal); fluxRealDataCache.PureFluxHour = GetFluxSum(fluxRealDataCache.FluxHour, pureFluxTotal); fluxRealDataCache.IndustrialFluxHour = GetFluxSum(fluxRealDataCache.IndustrialFluxHour, industrialFluxTotal); fluxRealDataCache.IndustrialPureFluxHour = GetFluxSum(fluxRealDataCache.IndustrialPureFluxHour, industrialPureFluxTotal); } else { FluxRealDataModels.Add(new KJ370_FluxRealDataModel() { FluxID = fluxPoint.FluxID, RealDate = realTime, FluxHour = fluxTotal, PureFluxHour = pureFluxTotal, IndustrialFluxHour = industrialFluxTotal, IndustrialPureFluxHour = industrialPureFluxTotal }); } } var tableName = $"KJ370_FluxRealData"; var dt = ListToDataTableHelper.Models2Datatable <KJ370_FluxRealDataModel>(tableName, FluxRealDataModels); DataRepo.Dapper.BulkUpdate(dt, tableName, "FluxID"); var realDataTableName = "KJ370_RealData"; var realDataDt = ListToDataTableHelper.Models2Datatable <KJ370_RealDataModel>(realDataTableName, RealDatas); DataRepo.Dapper.BulkUpdate(realDataDt, realDataTableName, "PointID"); }
protected override void ParseContent(List <string> lines, DateTime realTime) { var lineContents = lines.Select(p => GetLines(p)); var tempDataList = lineContents.Where(p => p.Length == 6).Select(p => GetAnalogStatisticModel(p, realTime)).Where(p => p != default); var tableName = $"KJ370_AnalogStatistic{realTime:yyyyMMdd}"; var dt = ListToDataTableHelper.Models2Datatable <KJ370_AnalogStatisticModel>(tableName, tempDataList); DataRepo.YearDapper.BulkUpdate(dt, tableName, "PointID", "StartTime"); }
protected override void ParseContent(List <string> lines, DateTime realTime) { var lineContents = lines.Select(p => GetLines(p)); var tempDataList = lineContents.Where(p => p.Length == 6).Select(o => new AnalogStatistic(o, realTime)).Where(q => q.IsValid).Select(p => p.AnalogStatisticModel); var analogStatisticDataList = from t in tempDataList join a in _dev.AnalogPointModels on t.EquipId equals a.EquipId select t; var tableName = $"AnalogStatistic{realTime:yyyyMMdd}"; var dt = ListToDataTableHelper.Models2Datatable <AnalogStatisticModel>(tableName, analogStatisticDataList.ToList()); DataRepo.YearDapper.BulkUpdate(dt, tableName, "EquipId", "Index", "PointCode", "StartTime"); }
protected override void ParseContent(List <string> lines, DateTime realTime) { var lineContents = lines.Select(p => GetLines(p)); var realDataList = lineContents.Where(p => p.Length == 3).Select(o => new RealData(o, realTime)).Where(q => q.IsValid).Select(p => p.RealDataModel).ToList(); var analogRunList = new List <AnalogRunModel>(); var switchRunList = new List <SwitchRunModel>(); for (var i = 0; i < realDataList.Count(); i++) { var item = realDataList[i]; if (item.PointCode.Contains("D")) { var switchPoint = _dev.SwitchPointModels.FirstOrDefault(p => p.EquipId == item.EquipId); if (switchPoint != null) { var realValue = GetSwitchStateName((PointState)item.ValueState, switchPoint); item.Update(realValue); } switchRunList.Add(item.ToSwitchRunModel()); } else if (item.PointCode.Contains("C")) { var controlPoint = _dev.ControlPointModels.FirstOrDefault(p => p.EquipId == item.EquipId); if (controlPoint != null) { var realValue = GetControlStateName((PointState)item.ValueState, controlPoint); item.Update(realValue); } switchRunList.Add(item.ToSwitchRunModel()); } else if (item.PointCode.Contains("A")) { analogRunList.Add(item.ToAnalogRunModel()); } } var dt = ListToDataTableHelper.Models2Datatable <RealDataModel>("RealData", realDataList.ToList()); DataRepo.Dapper.BulkUpdate(dt, "RealData", "EquipId", "Index"); var analogRunTableName = $"AnalogRun{realTime:yyyyMMdd}"; var analogRunDt = ListToDataTableHelper.Models2Datatable <AnalogRunModel>(analogRunTableName, analogRunList); DataRepo.YearDapper.BulkUpdate(analogRunDt, analogRunTableName, "EquipId", "PointCode", "Index", "StartTime"); var switchRunTableName = $"SwitchRun{realTime:yyyyMM}"; var switchRunDt = ListToDataTableHelper.Models2Datatable <SwitchRunModel>(switchRunTableName, switchRunList); DataRepo.YearDapper.BulkUpdate(switchRunDt, switchRunTableName, "EquipId", "PointCode", "Index", "StartTime"); }
protected override void ParseContent(List <string> lines, DateTime realTime) { var lineContents = lines.Select(p => GetLines(p)); var tempAnalogPoints = lineContents.Where(p => p.Length == 20).Select(p => new AnalogPoint(p, realTime)).Where(p => p.IsValid); if (tempAnalogPoints != null && tempAnalogPoints.Any()) { AnalogPointModels.Clear(); var analogPointModels = tempAnalogPoints.Select(p => p.AnalogPointModel).ToList(); var analogPointDt = ListToDataTableHelper.Models2Datatable <AnalogPointModel>("AnalogPoint", analogPointModels); DataRepo.Dapper.BulkUpdate(analogPointDt, "AnalogPoint", "EquipId"); AnalogPointModels.AddRange(analogPointModels); } var tempSwitchPoints = lineContents.Where(p => p.Length == 15).Select(p => new SwitchPoint(p, realTime)).Where(p => p.IsValid); if (tempSwitchPoints != null && tempSwitchPoints.Any()) { SwitchPointModels.Clear(); var switchPointModels = tempSwitchPoints.Select(p => p.SwitchPointModel).ToList(); var switchPointDt = ListToDataTableHelper.Models2Datatable <SwitchPointModel>("SwitchPoint", switchPointModels); DataRepo.Dapper.BulkUpdate(switchPointDt, "SwitchPoint", "EquipId"); SwitchPointModels.AddRange(switchPointModels); } var tempControlPoints = lineContents.Where(p => p.Length == 4).Select(p => new ControlPoint(p, realTime)).Where(p => p.IsValid); if (tempControlPoints != null && tempControlPoints.Any()) { ControlPointModels.Clear(); var controlPointModels = tempControlPoints.Select(p => p.ControlPointModel); var controlPointDt = ListToDataTableHelper.Models2Datatable <ControlPointModel>("ControlPoint", controlPointModels); DataRepo.Dapper.BulkUpdate(controlPointDt, "ControlPoint", "EquipId"); ControlPointModels.AddRange(controlPointModels); } var equipmentInfoModels = tempAnalogPoints.Select(p => p.EquipmentInfo).Union(tempSwitchPoints.Select(p => p.EquipmentInfo)).Union(tempControlPoints.Select(p => p.EquipmentInfo)); if (equipmentInfoModels.Any()) { var equipmentInfoDt = ListToDataTableHelper.Models2Datatable <EquipmentInfoModel>("EquipmentInfo", equipmentInfoModels); DataRepo.Dapper.BulkUpdate(equipmentInfoDt, "EquipmentInfo", "EquipId"); EquipmentInfoModels.AddRange(equipmentInfoModels); } }
protected override void ParseContent(List <string> lines, DateTime realTime) { var lineContents = lines.Select(p => GetLines(p)); var tempLines = lineContents.Where(p => p.Length == 16 && p[0].Contains("A")); var models = new List <KJ370_AnalogAlarmModel>(); foreach (var segments in tempLines) { var pointId = GetPointCode(segments[0]); var analogPoint = _dev.AnalogPointModels.FirstOrDefault(p => p.PointID == pointId); if (analogPoint == null) { continue; } models.Add(new KJ370_AnalogAlarmModel() { PointID = pointId, SubStationID = analogPoint.SubStationID, PortNO = analogPoint.PortNO, PointName = analogPoint.PointName, Location = analogPoint.Location, AlarmValue = segments[2].ToFloat(), StartTime = segments[5].ToDateTime(), EndTime = segments[6].ToUpper() == "X" ? DateTime.Now : segments[6].ToDateTime(), MaxValue = segments[7].ToFloat(), MaxValueTime = segments[8].ToDateTime(), MinValueTime = segments[9].ToDateTime(), AvgValue = segments[10].ToFloat(), MinValue = segments[11].ToFloat(), Treatment = segments[13], TreatmentTime = segments[14].ToDateTime(), }); } var tableName = $"KJ370_AnalogAlarm{realTime:yyyyMM}"; var dt = ListToDataTableHelper.Models2Datatable <KJ370_AnalogAlarmModel>(tableName, models); DataRepo.YearDapper.BulkUpdate(dt, tableName, "FluxID", "StartTime"); }
protected override void ParseContent(List <string> lines, DateTime realTime) { var lineContents = lines.Select(p => GetLines(p)); var tempAnalogPoints = lineContents.Where(p => p.Length == 20).Select(GetAnalogPointModel).Where(p => p != default); if (tempAnalogPoints != null && tempAnalogPoints.Any()) { AnalogPointModels.Clear(); var dt = ListToDataTableHelper.Models2Datatable <KJ370_AnalogPointModel>("KJ370_AnalogPoint", tempAnalogPoints); DataRepo.Dapper.BulkUpdate(dt, "KJ370_AnalogPoint", "PointId"); AnalogPointModels.AddRange(tempAnalogPoints); } var tempFluxPointsLines = lineContents.Where(p => p.Length == 7); var fluxFluxPoints = GetKJ370_FluxPointModels(tempFluxPointsLines); if (fluxFluxPoints.Any()) { FluxPointModels.Clear(); var dt = ListToDataTableHelper.Models2Datatable <KJ370_FluxPointModel>("KJ370_FluxPoint", fluxFluxPoints); DataRepo.Dapper.BulkUpdate(dt, "KJ370_FluxPoint", "FluxId"); FluxPointModels.AddRange(fluxFluxPoints); } }
protected override void ParseContent(List <string> lines, DateTime realTime) { if (_lastWriteTime.Day != realTime.Day) { _fluxRunModels.Clear(); _lastWriteTime = realTime; } var lineContents = lines.Select(p => GetLines(p)).Where(p => p.Length == 6); foreach (var line in lineContents) { var fluxInfos = GetFluxCode(line[0]); var fluxPoint = _dev.FluxPointModels.FirstOrDefault(p => p.FluxID == fluxInfos.FluxId); if (fluxPoint == null) { continue; } var fluxRun = _fluxRunModels.FirstOrDefault(p => p.FluxID == fluxInfos.FluxId); if (fluxRun == null) { fluxRun = new KJ370_FluxRunModel() { FluxID = fluxPoint.FluxID, SubStationID = fluxPoint.SubStationID, Location = fluxPoint.Location, FluxName = fluxPoint.FluxName, Flag = 2, MethaneChromaMaxTime = realTime, TemperatureMaxTime = realTime, PressureMaxTime = realTime, FluxMaxTime = realTime, MethaneChromaMinTime = realTime, TemperatureMinTime = realTime, PressureMinTime = realTime, FluxMinTime = realTime, UpdateTime = realTime }; _fluxRunModels.Add(fluxRun); } var value = GetStringSum(line.Skip(2)); switch (fluxInfos.Flag) { case FluxTypeFlag.FluxTotal: fluxRun.FluxTotal = value; break; case FluxTypeFlag.PureFluxTotal: fluxRun.PureFluxTotal = value; break; case FluxTypeFlag.IndustrialFluxTotal: fluxRun.PureFluxTotal = value; break; case FluxTypeFlag.IndustrialPureFluxTotal: fluxRun.IndustrialPureFluxTotal = value; break; default: continue; } } var tableName = $"KJ370_FluxRun{realTime:yyyy}"; var dt = ListToDataTableHelper.Models2Datatable <KJ370_FluxRunModel>(tableName, _fluxRunModels); DataRepo.YearDapper.BulkUpdate(dt, tableName, "FluxID", "Year", "Month", "Day", "Hour", "Flag"); }