diff --git a/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs b/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs index 018d08d29..fe3795501 100644 --- a/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs +++ b/BeWo/Scheduler/View/AbstractAppointmentEditForm.cs @@ -51,8 +51,11 @@ namespace BeWo.Scheduler.View return false; } + // TODO: Endzeit und Startzeit werden als Dauer auf das Start-Objekt addiert if (ShouldShowRecurrence) { + var rvcStart = RecurrenceVisualController.Start; + RecurrenceVisualController.ApplyRecurrence(); } diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml b/BeWo/Scheduler/View/NewSchedulerView.xaml index 3c631b1ff..12d152b67 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml @@ -927,7 +927,9 @@ - + diff --git a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs index 3fe6bc251..51ad5000b 100644 --- a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs +++ b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.ComponentModel; +using System.Diagnostics; using System.Globalization; using System.Linq; using System.Windows; @@ -184,7 +185,7 @@ namespace BeWo.Scheduler.View SelectedEmployees.Add(new Employee2SchedulerAppointmentDC { Employee = BeWoApp.CompactLoggedOnEmployee }); MitarbeiterToggleButton.IsChecked = true; } - + InitRights(); } @@ -447,7 +448,7 @@ namespace BeWo.Scheduler.View var start = NewSchedulerAppointmentFormController.Start; var end = NewSchedulerAppointmentFormController.End; - ViewModel.NewVM.AllDay = !Appointment.AllDay; + ViewModel.NewVM.AllDay = NewSchedulerAppointmentFormController.AllDay; ViewModel.NewVM.IsPrivate = isPrivate; ViewModel.NewVM.ResourceList = resources; ViewModel.NewVM.CustomerList = customers; @@ -483,7 +484,7 @@ namespace BeWo.Scheduler.View customerOids.AddIfNotIn(customer.CustomerOid); } - var item = (SchedulerAppointmentVM) Appointment.GetSourceObject(Control.GetCoreStorage()); + var item = Appointment.GetSourceObject(Control.GetCoreStorage()); ViewModel.ShouldLockOverlappingAppointmentCheck = Appointment.Type == AppointmentType.ChangedOccurrence; @@ -492,8 +493,8 @@ namespace BeWo.Scheduler.View ViewModel.ApplyChangesToChangedOccurencyCustomFields(employees, customers, resources, originator, isPrivate, Appointment.RecurrenceIndex.ToString(), new Guid(Appointment.RecurrenceInfo.Id.ToString()), isTask, taskDescription, completedDate, dueDate, completedNotice, supportConceptList, Appointment.Subject, Appointment.AllDay); } - ApplyChanges(); - } + ApplyChanges(); + } catch (Exception exception) { MessageBox.Show(exception.Message + "\n" + exception.StackTrace); @@ -648,14 +649,14 @@ namespace BeWo.Scheduler.View private void DueDate_OnEditValueChanged(object sender, EditValueChangedEventArgs e) { - if(e.NewValue != null && e.NewValue is DateTime dueDate) - { - var newEnd = dueDate.GetShortDateTime().AddDays(1); + // if(e.NewValue != null && e.NewValue is DateTime dueDate) + // { + // var newEnd = dueDate.GetShortDateTime().AddDays(1); - NewSchedulerAppointmentFormController.End = newEnd; - NewSchedulerAppointmentFormController.DisplayEnd = newEnd; - NewSchedulerAppointmentFormController.DisplayEndDate = newEnd; - } + // NewSchedulerAppointmentFormController.End = newEnd; + // NewSchedulerAppointmentFormController.DisplayEnd = newEnd; + // NewSchedulerAppointmentFormController.DisplayEndDate = newEnd; + //} } /* @@ -668,47 +669,106 @@ namespace BeWo.Scheduler.View * If the new Appointment. End property's value is less than the Appointment. * Start property's value, an exception is raised. * - * Endzeit = Startzeit + Vorherige Dauer + * Ende = Start + Vorherige Dauer */ private DateTime? _PreviousEndDate; + private DateTime? _PreviousEndDate2; - private bool _HasBeenChangedByStartTime; + private bool _EndTimeHasBeenChangedByStartTime; + private bool _EndDateHasBeenChangedByStartDate; + + // TODO: Bei jeder Änderung darauf achten, dass keinn anderer Wert manipuliert wird! - // TOOD: KGW? private void StartDate_OnChange(object sender, EditValueChangedEventArgs e) { - //_HasBeenChangedByStartTime = false; + // BeWoApp.LogMessage("StartDate changed", Colors.DarkTurquoise); + // LogAllDates(); + + //_EndTimeHasBeenChangedByStartTime = false; + + // _PreviousEndDate2 = NewSchedulerAppointmentFormController.End; + + //_EndDateHasBeenChangedByStartDate = true; } - // TOOD: KGW? - private void EndDate_OnChange(object sender, EditValueChangedEventArgs e) + private void EndDate_OnChange(object sender, EditValueChangedEventArgs e) { - //_HasBeenChangedByStartTime = false; - } + // BeWoApp.LogMessage("EndDate changed", Colors.DarkTurquoise); + // LogAllDates(); + + //_EndTimeHasBeenChangedByStartTime = false; + + + // if(_EndDateHasBeenChangedByStartDate && _PreviousEndDate2.HasValue) + // { + // var start = NewSchedulerAppointmentFormController.Start; + + // if(_PreviousEndDate2 > start) + // { + // var neuesEnddatum = NewSchedulerAppointmentFormController.End.MergeDatesByDateReversed(_PreviousEndDate2.Value); + + // //NewSchedulerAppointmentFormController.End = neuesEnddatum; + // } + // } + + // _EndDateHasBeenChangedByStartDate = true; + } private void StartTimeTextEdit_OnEditValueChanged(object sender, EditValueChangedEventArgs e) { - _PreviousEndDate = NewSchedulerAppointmentFormController.End; + // BeWoApp.LogMessage("StartTime changed", Colors.DarkTurquoise); + // LogAllDates(); + + //_PreviousEndDate = NewSchedulerAppointmentFormController.End; - _HasBeenChangedByStartTime = true; + // _EndTimeHasBeenChangedByStartTime = true; } private void EndTimeTextEdit_OnEditValueChanged(object sender, EditValueChangedEventArgs e) { - //if (_HasBeenChangedByStartTime && _PreviousEndDate.HasValue) - //{ - // var start = NewSchedulerAppointmentFormController.Start; + // BeWoApp.LogMessage("EndTime changed", Colors.DarkTurquoise); + // LogAllDates(); - // if (_PreviousEndDate > start) - // { - // NewSchedulerAppointmentFormController.End = NewSchedulerAppointmentFormController.End.MergeDatesByDate(_PreviousEndDate.Value); - // } - //} + //if (_EndTimeHasBeenChangedByStartTime && _PreviousEndDate.HasValue) + // { + // var start = NewSchedulerAppointmentFormController.Start; - _HasBeenChangedByStartTime = false; + // if (_PreviousEndDate > start) + // { + // //NewSchedulerAppointmentFormController.End = NewSchedulerAppointmentFormController.End.MergeDatesByDate(_PreviousEndDate.Value); + // } + // } + + // _EndTimeHasBeenChangedByStartTime = false; } - } + + // Was beeinflusst was? Startzeit -> Endzeit + // Ganztag -> DisplayEndDate + // + + private void AllDay_OnEditValueChanged(object sender, EditValueChangedEventArgs e) + { + //BeWoApp.LogMessage("AllDay changed", Colors.DarkTurquoise); + //LogAllDates(); + } + + private void LogAllDates() + { + var initialStartValue = NewSchedulerAppointmentFormController.Start; + var initialEndValue = NewSchedulerAppointmentFormController.End; + var isAllDay = NewSchedulerAppointmentFormController.AllDay; + var initialDisplayStart = NewSchedulerAppointmentFormController.DisplayStart; + var initialDisplayEnd = NewSchedulerAppointmentFormController.DisplayEnd; + + BeWoApp.LogMessage("\n" + + $"\t\t\tIs AllDay: {isAllDay}\n" + + $"\t\t\tStart: {initialStartValue:dd.MM.yy HH:mm}\n" + + $"\t\t\tEnd: {initialEndValue:dd.MM.yy HH:mm}\n" + + $"\t\t\tDisplayStart: {initialDisplayStart:dd.MM.yy HH:mm}\n" + + $"\t\t\tDisplayEnd: {initialDisplayEnd:dd.MM.yy HH:mm}"); + } + } public class NewSchedulerAppointmentFormController : AppointmentFormController { diff --git a/BeWo/View/Detail/DebugMessageLogView.xaml b/BeWo/View/Detail/DebugMessageLogView.xaml index 6c40b8621..22c02e1b3 100644 --- a/BeWo/View/Detail/DebugMessageLogView.xaml +++ b/BeWo/View/Detail/DebugMessageLogView.xaml @@ -4,6 +4,7 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:BeWo.View.Detail" + WindowStartupLocation="Manual" Topmost="True" Title="Debug Log" mc:Ignorable="d" Height="900" Width="700"> diff --git a/BeWo/View/HomeView.xaml.cs b/BeWo/View/HomeView.xaml.cs index b2d9a13d2..cc20e95e1 100644 --- a/BeWo/View/HomeView.xaml.cs +++ b/BeWo/View/HomeView.xaml.cs @@ -469,19 +469,19 @@ namespace BeWo.View private void HyperlinkChat_OnRequestNavigate(object sender, RequestNavigateEventArgs e) { #if DEBUG - //OpenServiceRecordEditViewTest(); + ////OpenServiceRecordEditViewTest(); + ////return; + //var kundennummer = "5473568546"; + ////var apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"; + + //Login _login = new Login(kundennummer, "kihqx-PiGka", "cb", "bewo", "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"); + + //var x1 = _login.AnmeldevorgangDurchFuehren(); + + //ServiceChatView = new ChatView(x1); + //ServiceChatView.Show(); + //return; - var kundennummer = "5473568546"; - //var apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"; - - Login _login = new Login(kundennummer, "kihqx-PiGka", "cb", "bewo", "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97"); - - var x1 = _login.AnmeldevorgangDurchFuehren(); - - ServiceChatView = new ChatView(x1); - ServiceChatView.Show(); - - return; #endif @@ -491,10 +491,10 @@ namespace BeWo.View #if DEBUG if(true) { - string _Code = "ZMCKb-BckTt"; - string _kundennummer = "4368658436"; - string _benutzername = "muellerp"; - string _passwort = "F5aTk9Co47JFJCWB2Z7Y"; + string _Code = "B7x0b-FhhJA";//"ZMCKb-BckTt"; + string _kundennummer = "4368658436";//"4368658436"; + string _benutzername = "jettenl";//"muellerp"; + string _passwort = "n8-yR+3Q=6nX#";//"F5aTk9Co47JFJCWB2Z7Y"; string _apikey; #else diff --git a/Shared/Extensions/DateTimeExtensions.cs b/Shared/Extensions/DateTimeExtensions.cs index c59d99537..03197e305 100644 --- a/Shared/Extensions/DateTimeExtensions.cs +++ b/Shared/Extensions/DateTimeExtensions.cs @@ -412,7 +412,7 @@ namespace BS.Shared.Extensions /// /// Erzeugt aus zwei Datumsobjekten ein neues mit den Datumsangaben des ersten und den Zeitangaben des zweiten Parameters. /// - /// Datum dessen Datewerte übernommen werden. + /// Datum dessen Datumswerte übernommen werden. /// Datum dessen Zeitwerte übernommen werden. /// Gibt ein neues Objekt der Klasse Datum mit dem Datum des ersten Parameters und der Zeit des zweiten Parameters zurück. public static DateTime MergeDatesByDate(this DateTime first, DateTime second) @@ -420,6 +420,17 @@ namespace BS.Shared.Extensions return new DateTime(first.Year, first.Month, first.Day, second.Hour, second.Minute, second.Second); } + /// + /// Erzeugt aus zwei Datumsobjekten ein neues mit den Datumsangaben des zweiten und den Zeitangaben des ersten Parameters. + /// + /// Datum dessen Zeitwerte übernommen werden. + /// Datum dessen Datumswerte übernommen werden. + /// Gibt ein neues Objekt der Klasse Datum mit dem Datum des zweiten Parameters und der Zeit des ersten Parameters zurück. + public static DateTime MergeDatesByDateReversed(this DateTime first, DateTime second) + { + return new DateTime(second.Year, second.Month, second.Day, first.Hour, first.Minute, first.Second); + } + public static DateTime MergeDateAndTimeSpan(this DateTime pDate, TimeSpan pTimeSpan) { return new DateTime(pDate.Year, pDate.Month, pDate.Day, pTimeSpan.Hours, pTimeSpan.Minutes, pTimeSpan.Seconds);