예제 #1
0
        public static void UpdateSubStationRun(ref SubStationRunModel subStationRunModel,
                                               List <SubStationRunModel> subStationRunModels,
                                               RealDataModel realDataModel, SubStationModel subStationModel)
        {
            if (subStationRunModel == null)
            {
                subStationRunModel       = NewSubStationRunModel(realDataModel, subStationModel);
                subStationRunModel.State = 0;
                subStationRunModels.Add(subStationRunModel.DeepClone());
            }
            else
            {
                subStationRunModel.EndTime = realDataModel.RealDate;

                if (subStationRunModel.IsTimeToSave(realDataModel))
                {
                    var newM = subStationRunModel.DeepClone();
                    SubStationRunModel existM;
                    if ((existM = subStationRunModels.FirstOrDefault(o => o.Key == newM.Key)) != null)
                    {
                        existM.EndTime              = newM.EndTime;
                        existM.SubStationState      = newM.SubStationState;
                        existM.SubStationStateValue = newM.SubStationStateValue;
                        existM.SpanTime             = (int)newM.EndTime.Subtract(existM.StartTime).TotalSeconds;
                    }
                    else
                    {
                        subStationRunModels.Add(subStationRunModel.DeepClone());
                    }
                }

                if (subStationRunModel.IsRequireNew(realDataModel))
                {
                    // 需要新增加一条数据.
                    subStationRunModel       = NewSubStationRunModel(realDataModel, subStationModel);
                    subStationRunModel.State = 0;
                    subStationRunModels.Add(subStationRunModel.DeepClone());
                }
            }
        }
예제 #2
0
        private static SubStationRunModel NewSubStationRunModel(RealDataModel realDataModel, SubStationModel subStationModel)
        {
            var model = new SubStationRunModel();

            model.SubStationID         = realDataModel.SubStationID;
            model.SubStationName       = subStationModel.SubStationName;
            model.Location             = subStationModel.Location;
            model.SubStationState      = realDataModel.RealState;
            model.SubStationStateValue = realDataModel.RealValue;
            model.StartTime            = realDataModel.RealDate;
            model.EndTime       = realDataModel.RealDate;
            model.SpanTime      = 0;
            model.State         = 0;
            model.Treatement    = "";
            model.TreatmentTime = DateTime.Now;
            model.Writer        = 0;
            return(model);
        }