public void CopyTo(ServiceScheduleMapping serviceScheduleMapping)
 {
     serviceScheduleMapping.Id = Id;
     serviceScheduleMapping.PlantsAreaId = PlantsAreaId;
     serviceScheduleMapping.ServiceState = ServiceState;
     serviceScheduleMapping.ServicingSpan = ServicingSpan;
     serviceScheduleMapping.ServicingPauseSpan = ServicingPauseSpan;
     serviceScheduleMapping.MeasurableParametersIds = MeasurableParametersIds;
 }
Exemple #2
0
        public ServiceSchedule RestoreServiceSchedule(ServiceScheduleMapping serviceScheduleMapping, List<MeasurableParameter> measurableParameters)
        {
            try
            {
                List<MeasurableParameter> mps = new List<MeasurableParameter>();
                if (!string.IsNullOrEmpty(serviceScheduleMapping.MeasurableParametersIds))
                {
                    string[] ids = serviceScheduleMapping.MeasurableParametersIds.Split(',');
                    List<MeasurableParameterMapping> measurableParameterMappings =
                        ids.Select(id => _sqlMeasurableParameterMappingRepository.Get(Guid.Parse(id))).ToList();

                    measurableParameterMappings.ForEach(
                        mapping =>
                        {
                            var param =
                                measurableParameters.SingleOrDefault(
                                    parameter => parameter != null && parameter.Id == mapping.Id);
                            if (param != null)
                            {
                                mps.Add(param);
                            }
                        });
                }
                return new ServiceSchedule(serviceScheduleMapping.Id, serviceScheduleMapping.PlantsAreaId,
                    serviceScheduleMapping.ServiceState,
                    new TimeSpan(0, 0, serviceScheduleMapping.ServicingSpan),
                    new TimeSpan(0, 0, serviceScheduleMapping.ServicingPauseSpan),
                    mps);
            }
            catch (Exception e)
            {
                MessageBox.Show(e.StackTrace, $"ServiceSchedule Id: {serviceScheduleMapping.Id}");
                return null;
            }
        }