From ce1de21f90dbf6642ceea36ae33566025fe1f478 Mon Sep 17 00:00:00 2001 From: Lyndon Date: Fri, 9 Feb 2018 18:07:10 +0100 Subject: [PATCH] Termine durch Tippen anlegen --- BeWo/Scheduler/View/NewSchedulerView.xaml | 29 +- BeWo/Scheduler/View/NewSchedulerView.xaml.cs | 318 +++++++++--------- .../View/SchedulerAppointmentEditForm.xaml | 2 +- .../View/SchedulerAppointmentEditForm.xaml.cs | 184 +++++----- .../ViewModel/SchedulerAppointmentListVM.cs | 104 +++--- BeWoPlanerMobil/Controllers/MainController.cs | 1 - Data/Access/SearchDAO.cs | 100 +----- 7 files changed, 324 insertions(+), 414 deletions(-) diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml b/BeWo/Scheduler/View/NewSchedulerView.xaml index d76e79c85..b4156372a 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml @@ -970,21 +970,22 @@ + AllowAppointmentDrag="AllowAppointmentAenderung" + AllowAppointmentEdit="AllowAppointmentAenderung" + AllowAppointmentResize="AllowAppointmentAenderung" + AllowAppointmentCreate="AllowAppointmentCreateEvent" + AllowAppointmentDragBetweenResources="AllowAppointmentAenderung" + AllowAppointmentDelete="AllowAppointmentAenderung" + ActiveViewType="WorkWeek"> diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs index ca72ad4f0..5c9c64b2f 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs @@ -26,6 +26,7 @@ using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; using BS.Shared.Translation; + using DevExpress.Xpf.Bars; using DevExpress.Xpf.Editors; using DevExpress.Xpf.Scheduler; @@ -35,35 +36,35 @@ using DevExpress.XtraScheduler; using Appointment = DevExpress.XtraScheduler.Appointment; using ColorConverter = System.Windows.Media.ColorConverter; using DateTime = System.DateTime; +using InplaceEditorEventArgs = DevExpress.Xpf.Scheduler.InplaceEditorEventArgs; using SchedulerControl = DevExpress.Xpf.Scheduler.SchedulerControl; - namespace BeWo.Scheduler.View { public partial class NewSchedulerView : INotifyPropertyChanged { - private bool _isEmployeeBrushVisible; + private bool _IsEmployeeBrushVisible; public bool IsEmployeeBrushVisible { - get => _isEmployeeBrushVisible; + get => _IsEmployeeBrushVisible; set { - _isEmployeeBrushVisible = value; + _IsEmployeeBrushVisible = value; OnPropertyChanged(nameof(IsEmployeeBrushVisible)); } } - private bool _isAbsenceTimeVisible; + private bool _IsAbsenceTimeVisible; public bool IsAbsenceTimeVisible { - get => _isAbsenceTimeVisible; + get => _IsAbsenceTimeVisible; set { - _isAbsenceTimeVisible = value; + _IsAbsenceTimeVisible = value; OnPropertyChanged(nameof(IsAbsenceTimeVisible)); } } @@ -72,7 +73,7 @@ namespace BeWo.Scheduler.View public event PropertyChangedEventHandler PropertyChanged; - private SchedulerPrintingSettings _printingSettings = new SchedulerPrintingSettings(); + private SchedulerPrintingSettings _PrintingSettings = new SchedulerPrintingSettings(); public NewSchedulerViewModel ViewModel { get; set; } @@ -97,115 +98,115 @@ namespace BeWo.Scheduler.View } } - private List _allEmployees; + private List _AllEmployees; public List AllEmployees { - get => _allEmployees ?? (_allEmployees = new List()); + get => _AllEmployees ?? (_AllEmployees = new List()); set { - if(!ListEquals(_allEmployees, value)) + if(!ListEquals(_AllEmployees, value)) { - _allEmployees = value; + _AllEmployees = value; OnPropertyChanged(nameof(AllEmployees)); } } } - private List _gefilterteMitarbeiter; + private List _GefilterteMitarbeiter; public List GefilterteMitarbeiter { - get => _gefilterteMitarbeiter ?? (_gefilterteMitarbeiter = new List(AllEmployees)); + get => _GefilterteMitarbeiter ?? (_GefilterteMitarbeiter = new List(AllEmployees)); set { - if(!ListEquals(_gefilterteMitarbeiter, value)) + if(!ListEquals(_GefilterteMitarbeiter, value)) { - _gefilterteMitarbeiter = value; - _gefilterteMitarbeiter.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); + _GefilterteMitarbeiter = value; + _GefilterteMitarbeiter.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); OnPropertyChanged(nameof(GefilterteMitarbeiter)); } } } - private List _gefilterteKlienten; + private List _GefilterteKlienten; public List GefilterteKlienten { - get => _gefilterteKlienten ?? (_gefilterteKlienten = new List(AllCustomers)); + get => _GefilterteKlienten ?? (_GefilterteKlienten = new List(AllCustomers)); set { - if(!ListEquals(_gefilterteKlienten, value)) + if(!ListEquals(_GefilterteKlienten, value)) { - _gefilterteKlienten = value; - _gefilterteKlienten.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); + _GefilterteKlienten = value; + _GefilterteKlienten.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); OnPropertyChanged(nameof(GefilterteKlienten)); } } } - private List _allCustomers; + private List _AllCustomers; public List AllCustomers { - get => _allCustomers ?? (_allCustomers = new List()); + get => _AllCustomers ?? (_AllCustomers = new List()); set { - if(!ListEquals(_allCustomers, value)) + if(!ListEquals(_AllCustomers, value)) { - _allCustomers = value; + _AllCustomers = value; OnPropertyChanged(nameof(AllCustomers)); } } } - private List _allResources; + private List _AllResources; public List AllResources { - get => _allResources ?? (_allResources = new List()); + get => _AllResources ?? (_AllResources = new List()); set { - if(!ListEquals(_allResources, value)) + if(!ListEquals(_AllResources, value)) { - _allResources = value; + _AllResources = value; OnPropertyChanged(nameof(AllResources)); } } } - private List _customerList; + private List _CustomerList; public List CustomerList { - get => _customerList ?? (_customerList = new List()); + get => _CustomerList ?? (_CustomerList = new List()); set { - if(!ListEquals(_customerList, value)) + if(!ListEquals(_CustomerList, value)) { - _customerList = value; - _customerList.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); + _CustomerList = value; + _CustomerList.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); OnPropertyChanged(nameof(CustomerList)); } } } - private int _timelineDayCount; - private SchedulerViewType _currentViewType; + private int _TimelineDayCount; + private SchedulerViewType _CurrentViewType; - private Dictionary> _category2ResourcesDictionary; + private Dictionary> _Category2ResourcesDictionary; public Dictionary> Category2ResourcesDictionary { - get => _category2ResourcesDictionary ?? (_category2ResourcesDictionary = new Dictionary>()); + get => _Category2ResourcesDictionary ?? (_Category2ResourcesDictionary = new Dictionary>()); set { if(!CheckCats2ResourcesForEqualitiy(value)) { - _category2ResourcesDictionary = value; + _Category2ResourcesDictionary = value; AllResources = new List(); value.DoForEach(d => AllResources.AddRange(d.Value)); @@ -217,12 +218,12 @@ namespace BeWo.Scheduler.View private bool CheckCats2ResourcesForEqualitiy(Dictionary> dic2) { - if(_category2ResourcesDictionary == null && dic2 != null || dic2 == null && _category2ResourcesDictionary != null) + if(_Category2ResourcesDictionary == null && dic2 != null || dic2 == null && _Category2ResourcesDictionary != null) { return false; } - return _category2ResourcesDictionary == null && dic2 == null || _category2ResourcesDictionary != null && dic2 != null && _category2ResourcesDictionary.Count == dic2.Count && _category2ResourcesDictionary.Except(dic2).Any(); + return _Category2ResourcesDictionary == null && dic2 == null || _Category2ResourcesDictionary != null && dic2 != null && _Category2ResourcesDictionary.Count == dic2.Count && _Category2ResourcesDictionary.Except(dic2).Any(); } private static bool ListEquals(IReadOnlyCollection list1, List list2) @@ -240,19 +241,19 @@ namespace BeWo.Scheduler.View return list1.Count == list2.Count && list1.All(list2.Contains); } - private List _selectedEmployees = new List(); - private List _selectedCustomers = new List(); - private List _selectedResources = new List(); + private List _SelectedEmployees = new List(); + private List _SelectedCustomers = new List(); + private List _SelectedResources = new List(); public List SelectedEmployees { - get => _selectedEmployees; + get => _SelectedEmployees; set { - if(!ListEquals(_selectedEmployees, value)) + if(!ListEquals(_SelectedEmployees, value)) { - _selectedEmployees = value; - _selectedEmployees.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); + _SelectedEmployees = value; + _SelectedEmployees.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); if (value.Equals(AllEmployees)) { @@ -269,13 +270,13 @@ namespace BeWo.Scheduler.View public List SelectedCustomers { - get => _selectedCustomers; + get => _SelectedCustomers; set { - if(!ListEquals(_selectedCustomers, value)) + if(!ListEquals(_SelectedCustomers, value)) { - _selectedCustomers = value; - _selectedCustomers.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, + _SelectedCustomers = value; + _SelectedCustomers.Sort((x, y) => string.Compare(x.LastName + ", " + x.FirstName, y.LastName + ", " + y.FirstName, StringComparison.Ordinal)); if(NurMeineKlientenCB.IsChecked.HasValue && NurMeineKlientenCB.IsChecked.Value && @@ -292,12 +293,12 @@ namespace BeWo.Scheduler.View public List SelectedResources { - get => _selectedResources; + get => _SelectedResources; set { - if(!ListEquals(_selectedResources, value)) + if(!ListEquals(_SelectedResources, value)) { - _selectedResources = value; + _SelectedResources = value; if(value.Equals(AllResources)) { AlleRessourcenCB.IsChecked = true; @@ -336,22 +337,22 @@ namespace BeWo.Scheduler.View public static bool IgnoreChangeEvents; - private List _employeesTeams = new List(); + private List _EmployeesTeams = new List(); - private string _requests; + private string _Requests; public string Requests { - get => _requests ?? (_requests = "keine Benachrichtigungen"); + get => _Requests ?? (_Requests = "keine Benachrichtigungen"); set { - _requests = value; + _Requests = value; OnPropertyChanged(nameof(Requests)); } } public static TimeSpan FetchPadding = TimeSpan.FromDays(14); - private TimeInterval _lastFetchedInterval = new TimeInterval(); + private TimeInterval _LastFetchedInterval = new TimeInterval(); public long CustomerOidToPreselect { get; set; } @@ -448,7 +449,7 @@ namespace BeWo.Scheduler.View Category2ResourcesDictionary = dict; })); - ServiceFacade.DoEmployeeServiceSync(es => _employeesTeams = es.GetTeamOidsByEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value)); + ServiceFacade.DoEmployeeServiceSync(es => _EmployeesTeams = es.GetTeamOidsByEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value)); InitializeComponent(); InitViewModel(); @@ -458,7 +459,7 @@ namespace BeWo.Scheduler.View DataContext = this; - _currentViewType = Scheduler.ActiveViewType; + _CurrentViewType = Scheduler.ActiveViewType; EditorLocalizer.Active = new GermanEditorLocalizer(); @@ -491,7 +492,7 @@ namespace BeWo.Scheduler.View // synchronizer.Synchronize(); //} - private bool _istErsterAufruf = true; + private bool _IstErsterAufruf = true; #region InitViewModel private void InitViewModel() @@ -511,14 +512,14 @@ namespace BeWo.Scheduler.View UpdateDataSource(e.Data); - if (_istErsterAufruf) + if (_IstErsterAufruf) { if (MainControl.HatNeueTermine) { FensterOeffnen(); } - _istErsterAufruf = false; + _IstErsterAufruf = false; } WriteToDebugLog("Done"); @@ -529,7 +530,7 @@ namespace BeWo.Scheduler.View { WriteToDebugLog("Beginning"); Scheduler.Start = DateTime.Now; - _timelineDayCount = 0; + _TimelineDayCount = 0; Scheduler.DayView.NavigationButtonVisibility = NavigationButtonVisibility.Always; Scheduler.DayView.AppointmentDisplayOptions.ShowRecurrence = true; Scheduler.DayView.AppointmentDisplayOptions.ShowReminder = true; @@ -630,7 +631,7 @@ namespace BeWo.Scheduler.View Scheduler.Start = settings.StartDate; var starttimeInterval = settings.StartDate.Date; starttimeInterval = starttimeInterval.AddHours(Scheduler.WorkWeekView.WorkTime.Start.Hours); - settings.ViewType = ViewTypeConvert.ToAppointmentViewType(_currentViewType); + settings.ViewType = ViewTypeConvert.ToAppointmentViewType(_CurrentViewType); switch (settings.ViewType) { @@ -767,7 +768,6 @@ namespace BeWo.Scheduler.View private void ListItemCheckedEvent(object sender, RoutedEventArgs e) { - WriteToDebugLog(""); UpdateVM(true); } @@ -814,7 +814,7 @@ namespace BeWo.Scheduler.View private void ButtonDayView_Click(object sender, RoutedEventArgs e) { Scheduler.ActiveViewType = SchedulerViewType.Day; - _currentViewType = Scheduler.ActiveViewType; + _CurrentViewType = Scheduler.ActiveViewType; UpdateOptionPanel(); DayViewOptions.Visibility = Visibility.Visible; @@ -824,7 +824,7 @@ namespace BeWo.Scheduler.View private void ButtonMonthView_Click(object sender, RoutedEventArgs e) { Scheduler.ActiveViewType = SchedulerViewType.Month; - _currentViewType = Scheduler.ActiveViewType; + _CurrentViewType = Scheduler.ActiveViewType; var interval = Scheduler.ActiveView.GetVisibleIntervals(); Scheduler.ActiveView.SetVisibleIntervals(new TimeIntervalCollection {new TimeInterval(interval.Start, new TimeSpan(35, 0, 0, 0))}); @@ -834,21 +834,21 @@ namespace BeWo.Scheduler.View private void ButtonWorkWeekView_Click(object sender, RoutedEventArgs e) { Scheduler.ActiveViewType = SchedulerViewType.WorkWeek; - _currentViewType = Scheduler.ActiveViewType; + _CurrentViewType = Scheduler.ActiveViewType; UpdateOptionPanel(); } private void ButtonWeekView_Click(object sender, RoutedEventArgs e) { Scheduler.ActiveViewType = SchedulerViewType.Week; - _currentViewType = Scheduler.ActiveViewType; + _CurrentViewType = Scheduler.ActiveViewType; UpdateOptionPanel(); } private void ButtonTimelineView_Click(object sender, RoutedEventArgs e) { Scheduler.ActiveViewType = SchedulerViewType.Timeline; - _currentViewType = Scheduler.ActiveViewType; + _CurrentViewType = Scheduler.ActiveViewType; UpdateOptionPanel(); DayViewOptions.Visibility = Visibility.Collapsed; @@ -860,7 +860,7 @@ namespace BeWo.Scheduler.View if (e.NewValue != null && int.TryParse(e.NewValue.ToString(), out var count) && count > 0) { Scheduler.DayView.DayCount = count; - _timelineDayCount = count; + _TimelineDayCount = count; } } @@ -874,28 +874,28 @@ namespace BeWo.Scheduler.View if (count > 0) { Scheduler.TimelineView.IntervalCount = count; - _timelineDayCount = count; + _TimelineDayCount = count; } } #endregion - private bool _enabled; + private bool _Enabled; public bool Enabled { - get => _enabled; + get => _Enabled; set { - _enabled = value; + _Enabled = value; OnPropertyChanged("Enabled"); } } private void UpdateRequestString() { - ServiceFacade.DoResourceServiceSync(r => Liste = r.GetAllOpenAppointmentsForEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value)); + ServiceFacade.DoResourceServiceSync(r => _Liste = r.GetAllOpenAppointmentsForEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value)); var count = 0; var oidList = new List(); - foreach (var termin in Liste) + foreach (var termin in _Liste) { if (termin.Originator.EmployeeOid == BeWoApp.LoggedOnEmployee.EmployeeOid.Value) { @@ -928,19 +928,18 @@ namespace BeWo.Scheduler.View Requests = $"{(count == 0 ? "keine" : count.ToString())} Benachrichtigung{(count == 1 ? "" : "en")}"; } - private List Liste = new List(); + private List _Liste = new List(); private void NewSchedulerStorage_AppointmentsChanged(object sender, PersistentObjectsEventArgs e) { - WriteToDebugLog("Beginning"); - if (IgnoreChangeEvents) { - WriteToDebugLog("Aborting"); return; } - var appList = e.Objects.Cast().ToList(); + WriteToDebugLog("Appointment chaning..."); + + var appList = e.Objects.Cast().ToList(); if (appList.Any(f => f.CustomFields["IsPrivate"] != null && (bool)f.CustomFields["IsPrivate"])) { @@ -950,13 +949,13 @@ namespace BeWo.Scheduler.View ViewModel.ActiveAppointmentViewModel.SaveAppointments(Scheduler, appList); UpdateVM(true); - - WriteToDebugLog("Done"); } private void NewSchedulerStorage_AppointmentDeleting(object sender, PersistentObjectCancelEventArgs e) { - if (e.Object is Appointment app && app.Type != AppointmentType.ChangedOccurrence) + WriteToDebugLog("Appointment deleting"); + + if (e.Object is Appointment app && app.Type != AppointmentType.ChangedOccurrence) { const string msg = "Möchten Sie den gewählten Termin wirklich löschen?"; @@ -983,7 +982,9 @@ namespace BeWo.Scheduler.View private void NewSchedulerStorage_AppointmentsInserted(object sender, PersistentObjectsEventArgs e) { - var appList = e.Objects.Cast().ToList(); + WriteToDebugLog("Appointments inserted"); + + var appList = e.Objects.Cast().ToList(); if(appList.Any(f => f.CustomFields["IsPrivate"] != null && (bool) f.CustomFields["IsPrivate"])) { @@ -997,9 +998,9 @@ namespace BeWo.Scheduler.View private void Scheduler_EditAppointmentFormShowing(object sender, EditAppointmentFormEventArgs e) { - var control = (SchedulerControl) sender; + var control = (SchedulerControl) sender; - if (_isNew) + if (_IsNew) { var n = SelectedEmployees.Select(item => new Employee2SchedulerAppointmentDC {Employee = item, ParticipationAnswer = ParticipationAnswer.Offen}).ToList(); e.Appointment.CustomFields["EmployeeList"] = n; @@ -1010,15 +1011,22 @@ namespace BeWo.Scheduler.View var form = ViewModel.GetEditAppointmentForm(control, e.Appointment); if (form == null) { - return; + WriteToDebugLog("Appointment edit form is null!"); + + if(_IsNew) + { + _IsNew = false; + } + + return; } e.Form = form; e.AllowResize = false; - if (_isNew) + if (_IsNew) { - _isNew = false; + _IsNew = false; } } @@ -1059,16 +1067,18 @@ namespace BeWo.Scheduler.View } - private bool _isNew; + private bool _IsNew; private void Scheduler_InitNewAppointment(object sender, AppointmentEventArgs e) { - _isNew = true; + WriteToDebugLog("Initiating new appointment"); + + _IsNew = true; ViewModel.InitNewAppointment(e.Appointment); } private void Scheduler_AppointmentViewInfoCustomizing(object sender, DevExpress.Xpf.Scheduler.AppointmentViewInfoCustomizingEventArgs e) { - var cf = e.ViewInfo.Appointment.CustomFields; + var cf = e.ViewInfo.Appointment.CustomFields; if(cf[SchedulerAppointmentListVM.CustomField_CustomerList] == null && cf[SchedulerAppointmentListVM.CustomField_EmployeeList] == null && @@ -1135,28 +1145,30 @@ namespace BeWo.Scheduler.View private void AllowAppointmentCreateEvent(object sender, AppointmentOperationEventArgs e) { - var darfAnlegen = BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderKliententermineAnlegen) || BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnlegen); + WriteToDebugLog("Allowing appointment create event"); + + var darfAnlegen = BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderKliententermineAnlegen) || BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnlegen); e.Allow = darfAnlegen; } private void UpdateOptionPanel() { - switch (ViewTypeConvert.ToAppointmentViewType(_currentViewType)) + switch (ViewTypeConvert.ToAppointmentViewType(_CurrentViewType)) { case AppointmentViewType.Day: TimelineViewOptions.Visibility = Visibility.Collapsed; DayViewOptions.Visibility = Visibility.Visible; SpinEditDayViewDayCount.Value = Scheduler.DayView.DayCount; - _timelineDayCount = 0; + _TimelineDayCount = 0; break; case AppointmentViewType.Timeline: TimelineViewOptions.Visibility = Visibility.Visible; DayViewOptions.Visibility = Visibility.Collapsed; - SpinEditTimelineViewDayCount.Value = _timelineDayCount == 0 ? Scheduler.TimelineView.IntervalCount : _timelineDayCount; + SpinEditTimelineViewDayCount.Value = _TimelineDayCount == 0 ? Scheduler.TimelineView.IntervalCount : _TimelineDayCount; break; default: - _timelineDayCount = 0; + _TimelineDayCount = 0; TimelineViewOptions.Visibility = Visibility.Collapsed; DayViewOptions.Visibility = Visibility.Collapsed; break; @@ -1225,7 +1237,7 @@ namespace BeWo.Scheduler.View private void FensterOeffnen() { - var neueListe = new SchedulerAppointmentListVM(Liste, AllCustomers, AllEmployees, Category2ResourcesDictionary); + var neueListe = new SchedulerAppointmentListVM(_Liste, AllCustomers, AllEmployees, Category2ResourcesDictionary); var vm = neueListe; @@ -1486,27 +1498,28 @@ namespace BeWo.Scheduler.View private void SchedulerStorage_OnFetchAppointments(object sender, FetchAppointmentsEventArgs e) { - WriteToDebugLog("Beginning"); - UpdateVM(); - - WriteToDebugLog("Done"); } - private bool updatingViewModel = false; - + private bool _UpdatingViewModel; private void UpdateVM(bool shouldForceUpdate = false) { - if (updatingViewModel) + WriteToDebugLog(new StackTrace().GetFrame(1).GetMethod().Name); + + if (_UpdatingViewModel) + { + WriteToDebugLog("Already updating. Aborting second try."); return; - updatingViewModel = true; + } + + _UpdatingViewModel = true; WriteToDebugLog("Beginning"); if (ViewModel == null) { WriteToDebugLog("Aborting"); - updatingViewModel = false; + _UpdatingViewModel = false; return; } @@ -1518,22 +1531,22 @@ namespace BeWo.Scheduler.View var selectedEmployeeOids = SelectedEmployees.Select(s => s.EmployeeOid).ToList(); var selectedCustomerOids = SelectedCustomers.Select(s => s.CustomerOid).ToList(); - var selectedResourceOids = SelectedResources.Select(s => s.ResourceOid.Value).ToList(); - var employeesOnly = MitarbeiterEbenenCheckBox.IsChecked.Value; - var customersOnly = KlientenEbenenCheckBox.IsChecked.Value; - var resourcesOnly = RessourcenEbenenCheckBox.IsChecked.Value; - var onlyPrivateAppointments = ShowPrivateAppointmentsCheckBox.IsChecked.Value; + var selectedResourceOids = SelectedResources.Where(w => w.ResourceOid.HasValue).Select(s => s.ResourceOid.Value).ToList(); + var employeesOnly = MitarbeiterEbenenCheckBox.IsChecked != null && MitarbeiterEbenenCheckBox.IsChecked.Value; + var customersOnly = KlientenEbenenCheckBox.IsChecked != null && KlientenEbenenCheckBox.IsChecked.Value; + var resourcesOnly = RessourcenEbenenCheckBox.IsChecked != null && RessourcenEbenenCheckBox.IsChecked.Value; + var onlyPrivateAppointments = ShowPrivateAppointmentsCheckBox.IsChecked != null && ShowPrivateAppointmentsCheckBox.IsChecked.Value; var showOnlyMyAppointments = ZeigeNurMeineTermine; - var showAbsenceTimes = AbwesenheitenEinAusCheckBox.IsChecked.Value; + var showAbsenceTimes = AbwesenheitenEinAusCheckBox.IsChecked != null && AbwesenheitenEinAusCheckBox.IsChecked.Value; - if(!shouldForceUpdate && newFetchingInterval.Equals(_lastFetchedInterval)) + if(!shouldForceUpdate && newFetchingInterval.Equals(_LastFetchedInterval)) { - updatingViewModel = false; + _UpdatingViewModel = false; WriteToDebugLog("Aborting. Redundant call."); return; } - _lastFetchedInterval = newFetchingInterval; + _LastFetchedInterval = newFetchingInterval; UpdateAppointmentViewModel(start, end, selectedEmployeeOids, selectedCustomerOids, selectedResourceOids, employeesOnly, customersOnly, resourcesOnly, onlyPrivateAppointments, showOnlyMyAppointments, showAbsenceTimes); } @@ -1565,30 +1578,12 @@ namespace BeWo.Scheduler.View ServiceFacade.DoResourceServiceAsync(s3 => s3.GetAllActiveAbsenceTimesInInterval(start, end, BeWoApp.LoggedOnEmployee.EmployeeOid.Value, BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)), absenceTimes => { - - //var prefilteredAppointments = appointments.Where(w => (w.EmployeeList.Count == 0 && w.Originator.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) || - // w.EmployeeList.Count > 0 && w.EmployeeList.Any(a => a.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)) || - // BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) && (!w.EmployeeList.TrueForAll(e2a => e2a.ParticipationAnswer == ParticipationAnswer.Absage) || (w.EmployeeList == null || w.EmployeeList.Count == 0))).ToList(); - - - //var vm = new SchedulerAppointmentListVM(prefilteredAppointments, customers, allEmployees, cats2Res); - //if(pShouldShowAbsenceTimes) - //{ - // vm.Appointments.AddRange(ConvertAbsenceTimesToAppointments(absenceTimes, end)); - //} - - //ActiveAppointmentViewModel = vm; - - //SchedulerSettings = GetActiveSettings(); - //SchedulerSettings.StartDate = pIntervalEnd; - this.Dispatch(() => { var prefilteredAppointments = appointments.Where(w => (w.EmployeeList.Count == 0 && w.Originator.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) || w.EmployeeList.Count > 0 && w.EmployeeList.Any(a => a.Employee.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid)) || BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) && (!w.EmployeeList.TrueForAll(e2a => e2a.ParticipationAnswer == ParticipationAnswer.Absage) || (w.EmployeeList == null || w.EmployeeList.Count == 0))).ToList(); - var vm = new SchedulerAppointmentListVM(prefilteredAppointments, customers, allEmployees, cats2Res); if (pShouldShowAbsenceTimes) { @@ -1615,7 +1610,7 @@ namespace BeWo.Scheduler.View var testtesttest = ViewModel.ActiveAppointmentViewModel; - updatingViewModel = false; + _UpdatingViewModel = false; WriteToDebugLog("Done"); }); @@ -1882,21 +1877,19 @@ namespace BeWo.Scheduler.View private void DateNavigator_OnSelectedDatesChanged(object sender, EventArgs e) { - WriteToDebugLog("Beginning"); + WriteToDebugLog("Selected dates changed"); - _currentViewType = Scheduler.ActiveViewType; + _CurrentViewType = Scheduler.ActiveViewType; var navigator = (DevExpress.Xpf.Editors.DateNavigator.DateNavigator) sender; var selectedDates = navigator.SelectedDates; - var isSelectedDateFetched = _lastFetchedInterval.ContainsEveryDateFromList(selectedDates); - if(!isSelectedDateFetched && !(_lastFetchedInterval.Start.Equals(new DateTime(1,1,1,0,0,0)) && _lastFetchedInterval.End.Equals(new DateTime(1, 1, 1, 0, 30, 0)))) + var isSelectedDateFetched = _LastFetchedInterval.ContainsEveryDateFromList(selectedDates); + if(!isSelectedDateFetched && !(_LastFetchedInterval.Start.Equals(new DateTime(1,1,1,0,0,0)) && _LastFetchedInterval.End.Equals(new DateTime(1, 1, 1, 0, 30, 0)))) { UpdateVM(); } - - WriteToDebugLog("Done"); } private void MitarbeiterVerfuegbarkeitPruefenButtonItem_OnItemClick(object sender, ItemClickEventArgs e) @@ -1971,16 +1964,35 @@ namespace BeWo.Scheduler.View UpdateVM(true); } - private static void WriteToDebugLog(string message) + private static void WriteToDebugLog(string message, bool isWithoutTimestamp = false) { - var callerName = new StackTrace().GetFrame(1).GetMethod().Name; +#if DEBUG + var callerName2 = new StackTrace().GetFrame(2).GetMethod().Name; + var callerName = new StackTrace().GetFrame(1).GetMethod().Name; + + using(var file = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + @"\scheduler_log.txt", true)) + { + var messageToWrite = isWithoutTimestamp ? message : $"{DateTime.Now:yyyy-MM-dd HH:mm:ss:ffff} {callerName2}->{callerName}: {message}"; + + file.WriteLine(messageToWrite); + } - //using(var file = new StreamWriter(@"C:\Users\Lyndon\Desktop\scheduler_log.txt", true)) - //{ - // file.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss:ffff} {callerName}: {message}"); - //} Debug.WriteLine($"{DateTime.Now:yyyy-MM-dd HH:mm:ss:ffff} {callerName}: {message}"); +#endif + } + + private void Scheduler_OnInplaceEditorShowing(object sender, InplaceEditorEventArgs e) + { + if(_IsNew) + { + var n = SelectedEmployees.Select(item => new Employee2SchedulerAppointmentDC { Employee = item, ParticipationAnswer = ParticipationAnswer.Offen }).ToList(); + e.Appointment.CustomFields["EmployeeList"] = n; + e.Appointment.CustomFields["CustomerList"] = new List(SelectedCustomers); + e.Appointment.CustomFields["ResourceList"] = new List(SelectedResources); + + _IsNew = false; + } } } diff --git a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml index 2ec9def54..8cf44a482 100644 --- a/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml +++ b/BeWo/Scheduler/View/SchedulerAppointmentEditForm.xaml @@ -368,7 +368,7 @@ -