private Approval_Inspection CreateInspection(DateTime begin, DateTime end, bool isAllDay, ObservableCollection <ConditionInspection> conditionInspections, ResponsibleSubject responsibleSubject, Series relatedSeries) { Approval_Inspection result = new Approval_Inspection(); foreach (var conditionInspection in conditionInspections) { var ci = new ConditionInspection(); ci.EntryDate = DateTime.Now; ci.AuxillaryConditionId = conditionInspection.AuxillaryConditionId; result.ConditionInspections.Add(ci); } result.DueDate = new Appointment { Begin = begin, End = end, IsAllDay = isAllDay }; result.Progress = 0.0f; result.RelatedSeries = relatedSeries; result.AppointmentResponsibleSubject = responsibleSubject; return(result); }
private IEnumerable <Plant> SearchForPlantsFromInspection(Approval_Inspection inspection) { var auxillaryConditionsOfInspection = inspection.ConditionInspections.SelectMany( ci => m_Repository.AuxillaryConditions.Where(ac => ac.Id == ci.AuxillaryConditionId && ac.InEffect)); var permissionsOfAuxillaryConditions = new Collection <Permission>(); foreach (var auxillaryCondition in auxillaryConditionsOfInspection) { foreach (var permission in m_Repository.Permissions) { foreach (var condition in permission.AuxillaryConditions) { if (auxillaryCondition == condition) { permissionsOfAuxillaryConditions.Add(permission); } } } } IEnumerable <Plant> plantConnectedToPermissions = permissionsOfAuxillaryConditions.SelectMany(p => p.Plants.Select(p2 => p2)).Distinct(); return(plantConnectedToPermissions); }
private InspectionViewModel CreateInspectionViewModel(Approval_Inspection inspection) { var ivm = m_InspectionViewModelFactory.CreateInspectionViewModel(inspection); var now = DateTime.Now; var dueDate = ivm.Inspection.DueDate.Begin; if (dueDate.Date >= now.GetFirstDayOfWeek() && dueDate.Date <= now.GetLastDayOfWeek() && dueDate >= now) { //diese Woche ivm.DateIndicator = 0; } else if (dueDate < now) { if (dueDate.Date == now.Date && ivm.Inspection.DueDate.IsAllDay) { //ganztägig und heute = diese Woche (duedate-zeit ignorieren) ivm.DateIndicator = 0; } else { //abgelaufen ivm.DateIndicator = 1; } } else { //alle anderen ivm.DateIndicator = 2; } return(ivm); }
private void DeleteReadingFromRepository(Approval_Inspection meterReading) { m_Repository.DeleteObject(meterReading.DueDate); if (m_SelectedInspection.EntryDate != null) { m_Repository.DeleteObject(m_SelectedInspection.EntryDate); } m_Repository.Inspections.Remove(meterReading); }
public SeriesEditViewModel(Series model, IApprovalRepository repository, IPlantManagementViewModelFactory plantManagementViewModelFactory, IResponsibleSubjectViewModelFactory responsibleSubjectViewModelFactory, ITaskGenerator taskGenerator, Approval_Inspection selectedInspection, IEnumerable <Approval_Inspection> allInspections) : base(model, repository, plantManagementViewModelFactory, responsibleSubjectViewModelFactory, taskGenerator) { m_Repository = repository; m_SelectedInspection = selectedInspection; m_AllInspections = allInspections; DisplayName = TranslationProvider.Translate("InspectionEdit"); SelectResponsibleSubject(); SelectWeekDays(); SelectAuxillaryConditions(); }
public InspectionViewModel(Approval_Inspection model, SeriesViewModel seriesViewModel, IEnumerable <Plant> plants) { m_Model = model; m_RelatedSeriesViewModel = seriesViewModel; m_ResponsibleSubject = model.AppointmentResponsibleSubject; m_Model.PropertyChanged += OnModelPropertyChanged; m_Model.RelatedSeries.SeriesColor.PropertyChanged += OnSeriesColorPropertyChanged; m_Model.RelatedSeries.PropertyChanged += OnRelatedSeriesPropertyChanged; m_Model.DueDate.PropertyChanged += OnDueDatePropertyChanged; var color = Color.FromRgb(m_Model.RelatedSeries.SeriesColor.R, m_Model.RelatedSeries.SeriesColor.G, m_Model.RelatedSeries.SeriesColor.B); SeriesColor = new SolidColorBrush(color); m_CalendarEntry = new CalendarEntry(m_Model.DueDate.Begin, m_Model.DueDate.End, null, color, m_Model.DueDate.IsAllDay, this); m_Plants = plants; }
public InspectionViewModel CreateInspectionViewModel(Approval_Inspection model) { return(new InspectionViewModel(model, m_ReadingPlanningViewModelFactory.CreateSeriesViewModel(model.RelatedSeries), SearchForPlantsFromInspection(model))); }