From 68cf4d9d4890c00893539c8f85bddb81c6361621 Mon Sep 17 00:00:00 2001 From: staccatomamba Date: Thu, 28 Sep 2017 14:00:40 +0200 Subject: [PATCH] =?UTF-8?q?Kalender:=20=20=20=20=20Beim=20=C3=84ndern=20ei?= =?UTF-8?q?nes=20Serientermins=20kommt=20es=20nicht=20mehr=20zu=20einer=20?= =?UTF-8?q?Exception.=20=20=20=20=20Wenn=20man=20bei=20einem=20Serientermi?= =?UTF-8?q?n=20die=20CustomFields=20=C3=A4ndert=20und=20andere=20Standardf?= =?UTF-8?q?elder,=20werden=20beide=20=C3=84nderungen=20=C3=BCbernommen.=20?= =?UTF-8?q?Bisher=20wurden=20nur=20die=20=C3=84nderungen=20der=20CustomFie?= =?UTF-8?q?lds=20=C3=BCbernommen.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../View/AbstractAppointmentEditForm.cs | 70 ++++----- BeWo/Scheduler/View/NewSchedulerView.xaml.cs | 12 +- BeWo/Scheduler/View/RequestAnswerView.xaml.cs | 39 ++--- .../View/SchedulerAppointmentEditForm.xaml | 12 +- .../View/SchedulerAppointmentEditForm.xaml.cs | 92 ++++++------ .../ViewModel/SchedulerAppointmentListVM.cs | 138 +++++++++--------- BeWoChatServer/Multitenancy/demo.config | 8 +- BeWoPlanerMobil/Web.config | 4 +- Host/Multitenancy/demo.config | 8 +- 9 files changed, 191 insertions(+), 192 deletions(-) diff --git a/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs b/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs index 3b39f446a..4c4e5618a 100644 --- a/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs +++ b/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs @@ -15,20 +15,15 @@ namespace BeWo.Scheduler.View { public class AbstractAppointmentEditForm : UserControl { - private readonly SchedulerControl mSchedulerControl; - private readonly Appointment mAppointment; - private readonly AppointmentFormController mController; - private RecurrenceVisualController mRecurrenceVisualController; - - protected AbstractAppointmentEditForm() { } + protected AbstractAppointmentEditForm() { } public AbstractAppointmentEditForm(SchedulerControl schedulerControl, Appointment appointment) { - mSchedulerControl = schedulerControl; - mAppointment = appointment; + Control = schedulerControl; + Appointment = appointment; - mController = CreateFormController(schedulerControl, appointment); - mRecurrenceVisualController = new RecurrenceVisualController(mController); + Controller = CreateFormController(Control, Appointment); + RecurrenceVisualController = new RecurrenceVisualController(Controller); } public virtual AppointmentFormController CreateFormController(SchedulerControl schedulerControl, Appointment appointment) @@ -36,38 +31,40 @@ namespace BeWo.Scheduler.View return new AppointmentFormController(schedulerControl, appointment); } - public SchedulerControl Control => mSchedulerControl; - public Appointment Appointment => mAppointment; - public AppointmentFormController Controller => mController; + public SchedulerControl Control { get; } + + public Appointment Appointment { get; } + + public AppointmentFormController Controller { get; } public string TimeEditMask => CultureInfo.CurrentCulture.DateTimeFormat.LongTimePattern; - public RecurrenceVisualController RecurrenceVisualController => mRecurrenceVisualController; + public RecurrenceVisualController RecurrenceVisualController { get; } - protected internal bool IsNewAppointment => mController == null || mController.IsNewAppointment; + protected internal bool IsNewAppointment => Controller == null || Controller.IsNewAppointment; - protected bool ShouldShowRecurrence => !mAppointment.IsOccurrence && mController.ShouldShowRecurrenceButton; + protected bool ShouldShowRecurrence => !Appointment.IsOccurrence && Controller.ShouldShowRecurrenceButton; protected virtual bool ApplyChanges() { - if (!mController.IsConflictResolved()) + if (!Controller.IsConflictResolved()) { return false; } if (ShouldShowRecurrence) { - mRecurrenceVisualController.ApplyRecurrence(); + RecurrenceVisualController.ApplyRecurrence(); } try { - mController.ApplyChanges(); + Controller.ApplyChanges(); } catch (Exception e) { MessageBox.Show($"Es ist leider ein Fehler aufgetreten. Die von Ihnen getätigten Änderungen am Termin konnten leider nicht übernommen werden.\n{e.Message}\n{e.StackTrace}", "Fehler", MessageBoxButton.OK, MessageBoxImage.Error); } - + SchedulerFormBehavior.Close(this, true); return true; @@ -81,29 +78,33 @@ namespace BeWo.Scheduler.View protected virtual void DeleteAppointment() { if (IsNewAppointment) - return; + { + return; + } - mController.DeleteAppointment(); + Controller.DeleteAppointment(); SchedulerFormBehavior.Close(this, false); } protected static void LocalizeVisualChild(DependencyObject obj) { - for (int i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) + for (var i = 0; i < VisualTreeHelper.GetChildrenCount(obj); i++) { - DependencyObject child = VisualTreeHelper.GetChild(obj, i); + var child = VisualTreeHelper.GetChild(obj, i); if (child is WeekOfMonthEdit) { var edt = child as WeekOfMonthEdit; - edt.CustomDisplayText -= edt_CustomDisplayText; - edt.CustomDisplayText += edt_CustomDisplayText; + edt.CustomDisplayText -= EditCustomDisplayText; + edt.CustomDisplayText += EditCustomDisplayText; foreach (var womEditItem in edt.Items) { var ne = womEditItem as NamedElement; if (ne != null) - ne.Caption = Translate(ne.Caption); + { + ne.Caption = Translate(ne.Caption); + } } } @@ -111,14 +112,16 @@ namespace BeWo.Scheduler.View { var edt = child as WeekDaysEdit; - edt.CustomDisplayText -= edt_CustomDisplayText; - edt.CustomDisplayText += edt_CustomDisplayText; + edt.CustomDisplayText -= EditCustomDisplayText; + edt.CustomDisplayText += EditCustomDisplayText; foreach (var womEditItem in edt.Items) { var ne = womEditItem as NamedElement; if (ne != null) - ne.Caption = Translate(ne.Caption); + { + ne.Caption = Translate(ne.Caption); + } } } @@ -126,13 +129,13 @@ namespace BeWo.Scheduler.View } } - static void edt_CustomDisplayText(object sender, DevExpress.Xpf.Editors.CustomDisplayTextEventArgs e) + private static void EditCustomDisplayText(object sender, DevExpress.Xpf.Editors.CustomDisplayTextEventArgs e) { e.DisplayText = Translate(e.DisplayText); e.Handled = true; } - private static string Translate(String text) + private static string Translate(string text) { switch (text) { @@ -152,8 +155,9 @@ namespace BeWo.Scheduler.View return "Arbeitstag"; case "Weekend day": return "Wochenendtag"; + default: + return text; } - return text; } } } diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs index 84fd5fcdb..876e1d91d 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs @@ -549,7 +549,6 @@ namespace BeWo.Scheduler.View Scheduler.Storage.BeginUpdate(); UpdateSchedulerSettings(); - int idx = 1; foreach (var item in Scheduler.Storage.AppointmentStorage.Items) { @@ -560,7 +559,7 @@ namespace BeWo.Scheduler.View foreach (var exc in ausnahmen) { var b = exc.GetSourceObject(Scheduler.GetCoreStorage()) as IBeWoAppointment; - if (b == null || b.CustomFields == null) + if (b?.CustomFields == null) { continue; } @@ -572,7 +571,10 @@ namespace BeWo.Scheduler.View } } - if (bapp == null || bapp.CustomFields == null) continue; + if (bapp?.CustomFields == null) + { + continue; + } foreach (var field in bapp.CustomFields) { @@ -1829,8 +1831,8 @@ namespace BeWo.Scheduler.View private void UpdateViewModelFilter() { - OnPropertyChanged("SelectedEmployees"); - OnPropertyChanged("SelectedItems"); + OnPropertyChanged(nameof(SelectedEmployees)); + OnPropertyChanged(nameof(SelectedItems)); Scheduler.ActiveView.LayoutChanged(); } diff --git a/BeWo/Scheduler/View/RequestAnswerView.xaml.cs b/BeWo/Scheduler/View/RequestAnswerView.xaml.cs index c834fa14c..d3058f792 100644 --- a/BeWo/Scheduler/View/RequestAnswerView.xaml.cs +++ b/BeWo/Scheduler/View/RequestAnswerView.xaml.cs @@ -55,13 +55,14 @@ namespace BeWo.Scheduler.View } } - public RequestAnswerView(IEnumerable appointments, List statusUpdates) + public RequestAnswerView(IEnumerable appointments, IEnumerable statusUpdates) { var statusUpdatesAsAppointments = new List(); - foreach(SchedulerAppointmentVM item in statusUpdates) + foreach(var beWoAppointment in statusUpdates) { - foreach(var relation in item.EmployeeList.Where(emp => emp.IsPChanged && emp.ParticipationAnswer != ParticipationAnswer.Offen && emp.ParticipationAnswer != ParticipationAnswer.Verstrichen && !emp.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))) + var item = (SchedulerAppointmentVM) beWoAppointment; + foreach(var relation in item.EmployeeList.Where(emp => emp.IsPChanged && emp.ParticipationAnswer != ParticipationAnswer.Offen && emp.ParticipationAnswer != ParticipationAnswer.Verstrichen && !emp.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid))) { if(statusUpdatesAsAppointments.All(a => a.LabelId != relation.Employee2SchedulerAppointmentOid)) { @@ -81,24 +82,24 @@ namespace BeWo.Scheduler.View { return new SchedulerAppointmentVM(new SchedulerAppointmentDC { - SchedulerAppointmentOid = item.CommitToDataContract().SchedulerAppointmentOid, + SchedulerAppointmentOid = item.CommitToDataContract().SchedulerAppointmentOid, NewSchedulerAppointmentVersion = item.CommitToDataContract().NewSchedulerAppointmentVersion, - IsPrivate = item.IsPrivate, - RecurrenceInfo = item.RecurrenceInfo, - Type = item.EventType, - CustomerList = (List)item.CustomFields["CustomerList"], - ResourceList = (List)item.CustomFields["ResourceList"], - AllDay = item.AllDay, - EmployeeList = item.EmployeeList, - Description = item.Description, - EndDate = item.End, - StartDate = item.Start, - Location = item.Location, - Subject = item.Subject, - Status = 1, - Originator = (CompactEmployeeDC)item.CustomFields["Originator"] + IsPrivate = item.IsPrivate, + RecurrenceInfo = item.RecurrenceInfo, + Type = item.EventType, + CustomerList = (List)item.CustomFields["CustomerList"], + ResourceList = (List)item.CustomFields["ResourceList"], + AllDay = item.AllDay, + EmployeeList = item.EmployeeList, + Description = item.Description, + EndDate = item.End, + StartDate = item.Start, + Location = item.Location, + Subject = item.Subject, + Status = 1, + Originator = (CompactEmployeeDC)item.CustomFields["Originator"] }) - { CustomFields = item.CustomFields, LabelId = Convert.ToInt32(emp2appOid)}; + { CustomFields = item.CustomFields, LabelId = Convert.ToInt32(emp2appOid)}; } private void CloseButton_Click(object sender, RoutedEventArgs e) diff --git a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml index 77d0cccab..b96b909cc 100644 --- a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml +++ b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml @@ -225,7 +225,7 @@ -