Esempio n. 1
0
        public void InitPointModel(List <AnalogPointModel> analogPointModels, List <FluxPointModel> fluxPointModels,
                                   List <FluxRunModel> fluxRunModels)
        {
            lock (_lock)
            {
                AnalogPointModels.Clear();
                AnalogPointModels.AddRange(analogPointModels);
                FluxPointModels.Clear();
                FluxPointModels.AddRange(fluxPointModels);

                AnalogPointModels.ForEach(p => p.InitPointModel());
                FluxPointModels.ForEach(p => p.InitPointModel(fluxRunModels?.FirstOrDefault(q => q.FluxID == p.FluxID)));
            }
            InitRealDataModel(RealDataModel);
        }
Esempio n. 2
0
        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);
            }
        }
Esempio n. 3
0
        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);
            }
        }