Termine durch Tippen anlegen

This commit is contained in:
Lyndon
2018-02-09 18:07:10 +01:00
parent c254dece5d
commit ce1de21f90
7 changed files with 324 additions and 414 deletions

View File

@@ -970,21 +970,22 @@
</StackPanel>
<ToggleButton Grid.Column="1" Style="{StaticResource VerticalExpanderLookAlikeToggleBotton}" Width="23" Height="23" Margin="3" Click="LeftExpanderClick" x:Name="LeftExpanderButton" />
<dxsch:SchedulerControl Grid.Column="2" x:Name="Scheduler" dx:ThemeManager.ThemeName="Office2010Black"
FormCustomizationUsingMVVMLocal="False"
GroupType="None"
VerticalAlignment="Stretch"
EditAppointmentFormShowing="Scheduler_EditAppointmentFormShowing"
EditRecurrentAppointmentFormShowing="SchedulerControl_EditRecurrentAppointmentFormShowing"
PopupMenuShowing="Scheduler_PopupMenuShowing"
InitNewAppointment="Scheduler_InitNewAppointment"
FormCustomizationUsingMVVMLocal="False"
InplaceEditorShowing="Scheduler_OnInplaceEditorShowing"
GroupType="None"
VerticalAlignment="Stretch"
EditAppointmentFormShowing="Scheduler_EditAppointmentFormShowing"
EditRecurrentAppointmentFormShowing="SchedulerControl_EditRecurrentAppointmentFormShowing"
PopupMenuShowing="Scheduler_PopupMenuShowing"
InitNewAppointment="Scheduler_InitNewAppointment"
AppointmentViewInfoCustomizing="Scheduler_AppointmentViewInfoCustomizing"
AllowAppointmentDrag="AllowAppointmentAenderung"
AllowAppointmentEdit="AllowAppointmentAenderung"
AllowAppointmentResize="AllowAppointmentAenderung"
AllowAppointmentCreate="AllowAppointmentCreateEvent"
AllowAppointmentDragBetweenResources="AllowAppointmentAenderung"
AllowAppointmentDelete="AllowAppointmentAenderung"
ActiveViewType="WorkWeek">
AllowAppointmentDrag="AllowAppointmentAenderung"
AllowAppointmentEdit="AllowAppointmentAenderung"
AllowAppointmentResize="AllowAppointmentAenderung"
AllowAppointmentCreate="AllowAppointmentCreateEvent"
AllowAppointmentDragBetweenResources="AllowAppointmentAenderung"
AllowAppointmentDelete="AllowAppointmentAenderung"
ActiveViewType="WorkWeek">
<dxsch:SchedulerControl.DayView>
<dxsch:DayView AppointmentToolTipContentTemplate="{StaticResource {dxscht:SchedulerViewThemeKey ResourceKey=AppointmentToolTipContentTemplate}}" />
</dxsch:SchedulerControl.DayView>

View File

@@ -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<CompactEmployeeDC> _allEmployees;
private List<CompactEmployeeDC> _AllEmployees;
public List<CompactEmployeeDC> AllEmployees
{
get => _allEmployees ?? (_allEmployees = new List<CompactEmployeeDC>());
get => _AllEmployees ?? (_AllEmployees = new List<CompactEmployeeDC>());
set
{
if(!ListEquals(_allEmployees, value))
if(!ListEquals(_AllEmployees, value))
{
_allEmployees = value;
_AllEmployees = value;
OnPropertyChanged(nameof(AllEmployees));
}
}
}
private List<CompactEmployeeDC> _gefilterteMitarbeiter;
private List<CompactEmployeeDC> _GefilterteMitarbeiter;
public List<CompactEmployeeDC> GefilterteMitarbeiter
{
get => _gefilterteMitarbeiter ?? (_gefilterteMitarbeiter = new List<CompactEmployeeDC>(AllEmployees));
get => _GefilterteMitarbeiter ?? (_GefilterteMitarbeiter = new List<CompactEmployeeDC>(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<CompactCustomerDC> _gefilterteKlienten;
private List<CompactCustomerDC> _GefilterteKlienten;
public List<CompactCustomerDC> GefilterteKlienten
{
get => _gefilterteKlienten ?? (_gefilterteKlienten = new List<CompactCustomerDC>(AllCustomers));
get => _GefilterteKlienten ?? (_GefilterteKlienten = new List<CompactCustomerDC>(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<CompactCustomerDC> _allCustomers;
private List<CompactCustomerDC> _AllCustomers;
public List<CompactCustomerDC> AllCustomers
{
get => _allCustomers ?? (_allCustomers = new List<CompactCustomerDC>());
get => _AllCustomers ?? (_AllCustomers = new List<CompactCustomerDC>());
set
{
if(!ListEquals(_allCustomers, value))
if(!ListEquals(_AllCustomers, value))
{
_allCustomers = value;
_AllCustomers = value;
OnPropertyChanged(nameof(AllCustomers));
}
}
}
private List<ResourceDC> _allResources;
private List<ResourceDC> _AllResources;
public List<ResourceDC> AllResources
{
get => _allResources ?? (_allResources = new List<ResourceDC>());
get => _AllResources ?? (_AllResources = new List<ResourceDC>());
set
{
if(!ListEquals(_allResources, value))
if(!ListEquals(_AllResources, value))
{
_allResources = value;
_AllResources = value;
OnPropertyChanged(nameof(AllResources));
}
}
}
private List<CompactCustomerDC> _customerList;
private List<CompactCustomerDC> _CustomerList;
public List<CompactCustomerDC> CustomerList
{
get => _customerList ?? (_customerList = new List<CompactCustomerDC>());
get => _CustomerList ?? (_CustomerList = new List<CompactCustomerDC>());
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<ValueListEntryDC, List<ResourceDC>> _category2ResourcesDictionary;
private Dictionary<ValueListEntryDC, List<ResourceDC>> _Category2ResourcesDictionary;
public Dictionary<ValueListEntryDC, List<ResourceDC>> Category2ResourcesDictionary
{
get => _category2ResourcesDictionary ?? (_category2ResourcesDictionary = new Dictionary<ValueListEntryDC, List<ResourceDC>>());
get => _Category2ResourcesDictionary ?? (_Category2ResourcesDictionary = new Dictionary<ValueListEntryDC, List<ResourceDC>>());
set
{
if(!CheckCats2ResourcesForEqualitiy(value))
{
_category2ResourcesDictionary = value;
_Category2ResourcesDictionary = value;
AllResources = new List<ResourceDC>();
value.DoForEach(d => AllResources.AddRange(d.Value));
@@ -217,12 +218,12 @@ namespace BeWo.Scheduler.View
private bool CheckCats2ResourcesForEqualitiy(Dictionary<ValueListEntryDC, List<ResourceDC>> 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<T>(IReadOnlyCollection<T> list1, List<T> list2)
@@ -240,19 +241,19 @@ namespace BeWo.Scheduler.View
return list1.Count == list2.Count && list1.All(list2.Contains);
}
private List<CompactEmployeeDC> _selectedEmployees = new List<CompactEmployeeDC>();
private List<CompactCustomerDC> _selectedCustomers = new List<CompactCustomerDC>();
private List<ResourceDC> _selectedResources = new List<ResourceDC>();
private List<CompactEmployeeDC> _SelectedEmployees = new List<CompactEmployeeDC>();
private List<CompactCustomerDC> _SelectedCustomers = new List<CompactCustomerDC>();
private List<ResourceDC> _SelectedResources = new List<ResourceDC>();
public List<CompactEmployeeDC> 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<CompactCustomerDC> 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<ResourceDC> 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<CompactTeamDC> _employeesTeams = new List<CompactTeamDC>();
private List<CompactTeamDC> _EmployeesTeams = new List<CompactTeamDC>();
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<long>();
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<SchedulerAppointmentDC> Liste = new List<SchedulerAppointmentDC>();
private List<SchedulerAppointmentDC> _Liste = new List<SchedulerAppointmentDC>();
private void NewSchedulerStorage_AppointmentsChanged(object sender, PersistentObjectsEventArgs e)
{
WriteToDebugLog("Beginning");
if (IgnoreChangeEvents)
{
WriteToDebugLog("Aborting");
return;
}
var appList = e.Objects.Cast<Appointment>().ToList();
WriteToDebugLog("Appointment chaning...");
var appList = e.Objects.Cast<Appointment>().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<Appointment>().ToList();
WriteToDebugLog("Appointments inserted");
var appList = e.Objects.Cast<Appointment>().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<CompactCustomerDC>(SelectedCustomers);
e.Appointment.CustomFields["ResourceList"] = new List<ResourceDC>(SelectedResources);
_IsNew = false;
}
}
}

View File

@@ -368,7 +368,7 @@
<!-- Region Buttons -->
<UniformGrid Grid.Column="0" Grid.Row="14" Grid.ColumnSpan="5" Columns="3" Rows="1" HorizontalAlignment="Right">
<Button Margin="3" Click="OkButtonClick" x:Name="OKButton" Content="OK" Height="25" Width="80" />
<Button Margin="3" Click="OkButtonClick" x:Name="OkButton" Content="OK" Height="25" Width="80" />
<Button Margin="3" Click="CancelButtonClick" Content="Abbrechen" Height="25" Width="80" />
<!--<Button Margin="3" Click="button_CreatZeiterfassung_Click" x:Name="ZeiterfassButton" Content="Zeiterfassung" Height="25" Width="80" />-->
<Button Margin="3" Click="DeleteButtonClick" x:Name="DeleteButton" Content="Löschen" Height="25" Width="80" />

View File

@@ -12,7 +12,6 @@ using BeWo.Annotations;
using BeWo.Core;
using BeWo.Scheduler.ViewModel;
using BeWo.ServiceProxy;
using BeWo.View;
using BeWo.View.Search;
using BS.Shared;
@@ -31,18 +30,18 @@ namespace BeWo.Scheduler.View
{
public bool IsInCustomerViewMode { get; set; }
private List<ValueListEntryDC> categories;
private List<ValueListEntryDC> _Categories;
public List<ValueListEntryDC> Categories
{
get { return categories; }
set { categories = value; OnPropertyChanged(nameof(Categories)); }
get => _Categories;
set { _Categories = value; OnPropertyChanged(nameof(Categories)); }
}
private List<ResourceDC> resourceList;
private List<ResourceDC> _ResourceList;
public List<ResourceDC> ResourceList
{
get { return resourceList; }
set { resourceList = value; OnPropertyChanged(nameof(ResourceList)); }
get => _ResourceList;
set { _ResourceList = value; OnPropertyChanged(nameof(ResourceList)); }
}
public SchedulerAppointmentListVM ViewModel { get; set; }
@@ -52,48 +51,45 @@ namespace BeWo.Scheduler.View
LocalizeVisualChild(sender as DependencyObject);
}
public NewSchedulerAppointmentFormController NewSchedulerAppointmentFormController { get { return Controller as NewSchedulerAppointmentFormController; } }
public NewSchedulerAppointmentFormController NewSchedulerAppointmentFormController => Controller as NewSchedulerAppointmentFormController;
private ObservableCollection<ResourceDC> selectedResources;
private ObservableCollection<ResourceDC> _SelectedResources;
public ObservableCollection<ResourceDC> SelectedResources
{
get { return selectedResources ?? (selectedResources = new ObservableCollection<ResourceDC>(NewSchedulerAppointmentFormController.ResourceList ?? new List<ResourceDC>())); }
set
get => _SelectedResources ?? (_SelectedResources = new ObservableCollection<ResourceDC>(NewSchedulerAppointmentFormController.ResourceList ?? new List<ResourceDC>()));
set
{
selectedResources = value;
_SelectedResources = value;
SelectedResources.CollectionChanged += SelectedResourcesCollectionChanged;
NewSchedulerAppointmentFormController.ResourceList = value.ToList();
OnPropertyChanged(nameof(SelectedResources));
}
}
private ObservableCollection<Employee2SchedulerAppointmentDC> selectedEmployees;
private ObservableCollection<Employee2SchedulerAppointmentDC> _SelectedEmployees;
public ObservableCollection<Employee2SchedulerAppointmentDC> SelectedEmployees
{
get { return selectedEmployees ?? (selectedEmployees = new ObservableCollection<Employee2SchedulerAppointmentDC>(NewSchedulerAppointmentFormController.EmployeeList ?? new List<Employee2SchedulerAppointmentDC>())); }
set
get => _SelectedEmployees ?? (_SelectedEmployees = new ObservableCollection<Employee2SchedulerAppointmentDC>(NewSchedulerAppointmentFormController.EmployeeList ?? new List<Employee2SchedulerAppointmentDC>()));
set
{
if (selectedEmployees.Equals(value)) return;
if (_SelectedEmployees.Equals(value)) return;
selectedEmployees = value;
_SelectedEmployees = value;
SelectedEmployees.CollectionChanged += SelectedEmployeesCollectionChanged;
NewSchedulerAppointmentFormController.EmployeeList = value.ToList();
OnPropertyChanged(nameof(SelectedEmployees));
}
}
private ObservableCollection<CompactCustomerDC> selectedCustomers;
private ObservableCollection<CompactCustomerDC> _SelectedCustomers;
public ObservableCollection<CompactCustomerDC> SelectedCustomers
{
get
get => _SelectedCustomers ?? (_SelectedCustomers = new ObservableCollection<CompactCustomerDC>(NewSchedulerAppointmentFormController.CustomerList ?? new List<CompactCustomerDC>()));
set
{
return selectedCustomers ?? (selectedCustomers = new ObservableCollection<CompactCustomerDC>(NewSchedulerAppointmentFormController.CustomerList ?? new List<CompactCustomerDC>()));
}
set
{
if (selectedCustomers.Equals(value)) return;
if (_SelectedCustomers.Equals(value)) return;
selectedCustomers = value;
_SelectedCustomers = value;
SelectedCustomers.CollectionChanged += SelectedCustomersCollectionChanged;
NewSchedulerAppointmentFormController.CustomerList = value.ToList();
OnPropertyChanged(nameof(SelectedCustomers));
@@ -187,7 +183,7 @@ namespace BeWo.Scheduler.View
return;
}
OKButton.Visibility = Visibility.Hidden;
OkButton.Visibility = Visibility.Hidden;
DeleteButton.Visibility = Visibility.Hidden;
}
@@ -231,7 +227,7 @@ namespace BeWo.Scheduler.View
protected void OnPropertyChanged(string propertyName)
{
var handler = PropertyChanged;
if (handler != null) handler(this, new PropertyChangedEventArgs(propertyName));
handler?.Invoke(this, new PropertyChangedEventArgs(propertyName));
}
private void EmployeePopupClick(object sender, RoutedEventArgs e)
@@ -241,7 +237,7 @@ namespace BeWo.Scheduler.View
private void CustomerPopUpEditClick(object sender, RoutedEventArgs e)
{
ResourcesTreeSearchView.AusgewaehlteRessourcen = selectedResources.ToList();
ResourcesTreeSearchView.AusgewaehlteRessourcen = _SelectedResources.ToList();
PopupCustomer.IsOpen = true;
}
@@ -367,25 +363,14 @@ namespace BeWo.Scheduler.View
var endDate = EndDate.DateTime;
var endTime = DateTime.Parse(EndTime.Text);
DateTime start = new DateTime(startDate.Year, startDate.Month, startDate.Day, startTime.Hour, startTime.Minute, startTime.Second);
DateTime end = new DateTime(endDate.Year, endDate.Month, endDate.Day, endTime.Hour, endTime.Minute, endTime.Second);
var start = new DateTime(startDate.Year, startDate.Month, startDate.Day, startTime.Hour, startTime.Minute, startTime.Second);
var end = new DateTime(endDate.Year, endDate.Month, endDate.Day, endTime.Hour, endTime.Minute, endTime.Second);
List<CompactCustomerDC> customerlist = new List<CompactCustomerDC>();
List<CompactEmployeeDC> employeelist = new List<CompactEmployeeDC>();
var employeelist = (from Employee2SchedulerAppointmentDC xy in employ select xy.Employee).ToList();
foreach (var employee in employ)
{
var xy = (Employee2SchedulerAppointmentDC)employee;
employeelist.Add(xy.Employee);
}
var customerlist = y.Cast<CompactCustomerDC>().ToList();
foreach (var klient in y)
{
var s = (CompactCustomerDC)klient;
customerlist.Add(s);
}
BeWoUtils.CreateZeiterfassung(start, end, customerlist, employeelist, Notice.Text);
BeWoUtils.CreateZeiterfassung(start, end, customerlist, employeelist, Notice.Text);
}
}
@@ -393,25 +378,26 @@ namespace BeWo.Scheduler.View
{
var obj = ((Button) sender).Tag;
var res = obj as ResourceDC;
if (res != null)
{
SelectedResources.Remove(res);
OnPropertyChanged("CountSelectedResources");
}
switch(obj)
{
case ResourceDC res:
SelectedResources.Remove(res);
OnPropertyChanged(nameof(CountSelectedResources));
break;
case CompactCustomerDC cus:
SelectedCustomers.Remove(cus);
OnPropertyChanged(nameof(CountSelectedCustomers));
break;
}
var cus = obj as CompactCustomerDC;
if (cus != null)
{
SelectedCustomers.Remove(cus);
OnPropertyChanged("CountSelectedCustomers");
}
if (!(obj is Employee2SchedulerAppointmentDC))
{
return;
}
if (!(obj is Employee2SchedulerAppointmentDC)) return;
var emp = (Employee2SchedulerAppointmentDC) obj;
var emp = (Employee2SchedulerAppointmentDC) obj;
SelectedEmployees.Remove(emp);
OnPropertyChanged("CountSelectedEmployees");
OnPropertyChanged(nameof(CountSelectedEmployees));
}
private void ResourcesTreeSearchView_OnSelectionChanged(object sender, RoutedEventArgs e)
@@ -420,11 +406,13 @@ namespace BeWo.Scheduler.View
var resOC = resourcesTreeSearchView.SelectedResources.ToObservableCollection();
foreach (var res in resOC.Where(res => !SelectedResources.Contains(res)))
SelectedResources.Add(res);
{
SelectedResources.Add(res);
}
SelectedResources = SelectedResources.Except(SelectedResources.Where(sr => !resOC.Contains(sr)).ToList()).ToObservableCollection();
OnPropertyChanged("CountSelectedResources");
OnPropertyChanged(nameof(CountSelectedResources));
}
private void MultiEmployeeSearch_OnSelectionChanged(object sender, RoutedEventArgs e)
@@ -433,14 +421,16 @@ namespace BeWo.Scheduler.View
var empOC = multiEmployeeSearch.SelectedEmployees.ToObservableCollection();
foreach (var emp in empOC.Where(emp => !SelectedEmployees.Any(se => se.Employee.Equals(emp))))
SelectedEmployees.Add(new Employee2SchedulerAppointmentDC { Employee = emp, ParticipationAnswer = ParticipationAnswer.Offen });
{
SelectedEmployees.Add(new Employee2SchedulerAppointmentDC { Employee = emp, ParticipationAnswer = ParticipationAnswer.Offen });
}
var ex = SelectedEmployees.Where(se => !empOC.Contains(se.Employee));
var ab = SelectedEmployees.Except(ex);
var cd = ab.ToObservableCollection();
SelectedEmployees = cd;
OnPropertyChanged("CountSelectedEmployees");
OnPropertyChanged(nameof(CountSelectedEmployees));
}
private void MultiCustomerSearch_OnSelectionChanged(object sender, RoutedEventArgs e)
@@ -448,77 +438,81 @@ namespace BeWo.Scheduler.View
var multiCustomerSearchView = (MultiCustomerSearchView)e.Source;
SelectedCustomers = multiCustomerSearchView.SelectedCustomers.ToObservableCollection();
OnPropertyChanged("CountSelectedCustomers");
OnPropertyChanged(nameof(CountSelectedCustomers));
}
}
public class NewSchedulerAppointmentFormController : AppointmentFormController
{
List<ResourceDC> SourceResourceList
private List<ResourceDC> SourceResourceList
{
get { return (List<ResourceDC>)SourceAppointment.CustomFields["ResourceList"]; }
set { SourceAppointment.CustomFields["ResourceList"] = value; }
get => (List<ResourceDC>)SourceAppointment.CustomFields["ResourceList"];
set => SourceAppointment.CustomFields["ResourceList"] = value;
}
public List<ResourceDC> ResourceList
{
get { return (List<ResourceDC>)EditedAppointmentCopy.CustomFields["ResourceList"]; }
set { EditedAppointmentCopy.CustomFields["ResourceList"] = value; }
get => (List<ResourceDC>)EditedAppointmentCopy.CustomFields["ResourceList"];
set => EditedAppointmentCopy.CustomFields["ResourceList"] = value;
}
List<Employee2SchedulerAppointmentDC> SourceEmployeeList
private List<Employee2SchedulerAppointmentDC> SourceEmployeeList
{
get { return (List<Employee2SchedulerAppointmentDC>)SourceAppointment.CustomFields["EmployeeList"]; }
set { SourceAppointment.CustomFields["EmployeeList"] = value; }
}
get => (List<Employee2SchedulerAppointmentDC>)SourceAppointment.CustomFields["EmployeeList"];
set => SourceAppointment.CustomFields["EmployeeList"] = value;
}
public List<Employee2SchedulerAppointmentDC> EmployeeList
{
get { return (List<Employee2SchedulerAppointmentDC>)EditedAppointmentCopy.CustomFields["EmployeeList"]; }
set { EditedAppointmentCopy.CustomFields["EmployeeList"] = value; }
get => (List<Employee2SchedulerAppointmentDC>)EditedAppointmentCopy.CustomFields["EmployeeList"];
set => EditedAppointmentCopy.CustomFields["EmployeeList"] = value;
}
List<CompactCustomerDC> SourceCustomerList
private List<CompactCustomerDC> SourceCustomerList
{
get { return (List<CompactCustomerDC>)SourceAppointment.CustomFields["CustomerList"]; }
set { SourceAppointment.CustomFields["CustomerList"] = value; }
}
get => (List<CompactCustomerDC>)SourceAppointment.CustomFields["CustomerList"];
set => SourceAppointment.CustomFields["CustomerList"] = value;
}
public List<CompactCustomerDC> CustomerList
{
get { return (List<CompactCustomerDC>)EditedAppointmentCopy.CustomFields["CustomerList"]; }
set { EditedAppointmentCopy.CustomFields["CustomerList"] = value; }
get => (List<CompactCustomerDC>)EditedAppointmentCopy.CustomFields["CustomerList"];
set => EditedAppointmentCopy.CustomFields["CustomerList"] = value;
}
CompactEmployeeDC SourceOriginator
private CompactEmployeeDC SourceOriginator
{
get { return (CompactEmployeeDC)SourceAppointment.CustomFields["Originator"]; }
set { SourceAppointment.CustomFields["Originator"] = value; }
}
get => (CompactEmployeeDC)SourceAppointment.CustomFields["Originator"];
set => SourceAppointment.CustomFields["Originator"] = value;
}
public CompactEmployeeDC Originator
{
get { return (CompactEmployeeDC)EditedAppointmentCopy.CustomFields["Originator"]; }
set { EditedAppointmentCopy.CustomFields["Originator"] = value; }
get => (CompactEmployeeDC)EditedAppointmentCopy.CustomFields["Originator"];
set => EditedAppointmentCopy.CustomFields["Originator"] = value;
}
bool SourceIsPrivate
private bool SourceIsPrivate
{
get { return (bool)SourceAppointment.CustomFields["IsPrivate"]; }
set { SourceAppointment.CustomFields["IsPrivate"] = value; }
get => (bool)SourceAppointment.CustomFields["IsPrivate"];
set => SourceAppointment.CustomFields["IsPrivate"] = value;
}
public bool IsPrivate
{
get { return (bool)EditedAppointmentCopy.CustomFields["IsPrivate"]; }
set { EditedAppointmentCopy.CustomFields["IsPrivate"] = value; }
get => (bool)EditedAppointmentCopy.CustomFields["IsPrivate"];
set => EditedAppointmentCopy.CustomFields["IsPrivate"] = value;
}
public override bool IsAppointmentChanged()
{
if (base.IsAppointmentChanged())
return true;
{
return true;
}
if (SourceResourceList != null && ResourceList != null ||
SourceEmployeeList != null && EmployeeList != null ||
SourceCustomerList != null && CustomerList != null ||
SourceOriginator != null && Originator != null)
return false;
{
return false;
}
var resourceListsAreEqual = SourceResourceList == null || ResourceList == null || !Equals(SourceResourceList, ResourceList);
var employeeListsAreEqual = SourceEmployeeList == null || EmployeeList == null || !Equals(SourceEmployeeList, EmployeeList);

View File

@@ -41,31 +41,31 @@ namespace BeWo.Scheduler.ViewModel
return settings;
}
private BindingList<IBeWoAppointment> _appointmentList;
private BindingList<IBeWoAppointment> _AppointmentList;
public BindingList<IBeWoAppointment> Appointments
{
get
{
if (_appointmentList != null)
if (_AppointmentList != null)
{
return _appointmentList;
return _AppointmentList;
}
_appointmentList = new BindingList<IBeWoAppointment>();
_appointmentList.AddingNew += AppointmentListAddingNew;
_AppointmentList = new BindingList<IBeWoAppointment>();
_AppointmentList.AddingNew += AppointmentListAddingNew;
foreach (var item in VMList)
{
_appointmentList.Add(item);
_AppointmentList.Add(item);
}
return _appointmentList;
return _AppointmentList;
}
}
private readonly List<CompactCustomerDC> _allCustomers;
private readonly List<CompactEmployeeDC> _allEmployees;
private readonly Dictionary<ValueListEntryDC, List<ResourceDC>> _categories2Resources;
private readonly List<CompactCustomerDC> _AllCustomers;
private readonly List<CompactEmployeeDC> _AllEmployees;
private readonly Dictionary<ValueListEntryDC, List<ResourceDC>> _Categories2Resources;
private static void AppointmentListAddingNew(object sender, AddingNewEventArgs e)
{
@@ -82,22 +82,22 @@ namespace BeWo.Scheduler.ViewModel
e.NewObject = neu;
}
private Dictionary<Guid, Dictionary<string, Dictionary<string, object>>> _changedOccurencyCustomFields;
private Dictionary<Guid, Dictionary<string, Dictionary<string, object>>> _ChangedOccurencyCustomFields;
public Dictionary<Guid, Dictionary<string, Dictionary<string, object>>> ChangedOccurencyCustomFields { get; }
public List<CompactCustomerDC> AllCustomers => _allCustomers;
public List<CompactCustomerDC> AllCustomers => _AllCustomers;
public List<CompactEmployeeDC> AllEmployees => _allEmployees;
public List<CompactEmployeeDC> AllEmployees => _AllEmployees;
public Dictionary<ValueListEntryDC, List<ResourceDC>> Categories2Resources => _categories2Resources;
public Dictionary<ValueListEntryDC, List<ResourceDC>> Categories2Resources => _Categories2Resources;
private Appointment _geoeffneterTermin;
private Appointment _GeoeffneterTermin;
public SchedulerAppointmentListVM(List<SchedulerAppointmentDC> appList, List<CompactCustomerDC> allCustomers, List<CompactEmployeeDC> allEmployees, Dictionary<ValueListEntryDC, List<ResourceDC>> lCategoriesToResources) : base(appList)
{
_categories2Resources = lCategoriesToResources;
_allCustomers = allCustomers;
_allEmployees = allEmployees;
_Categories2Resources = lCategoriesToResources;
_AllCustomers = allCustomers;
_AllEmployees = allEmployees;
InitChangedOccurrencyCustomFields(appList.Where(t => t.Type == 3).ToList());
@@ -185,9 +185,9 @@ namespace BeWo.Scheduler.ViewModel
}
}
if (item.Type.Equals(AppointmentType.ChangedOccurrence) && _geoeffneterTermin != null)
if (item.Type.Equals(AppointmentType.ChangedOccurrence) && _GeoeffneterTermin != null)
{
sindGleich = _geoeffneterTermin.Equals(item);
sindGleich = _GeoeffneterTermin.Equals(item);
}
if(!sindGleich)
@@ -341,16 +341,16 @@ namespace BeWo.Scheduler.ViewModel
var id = new Guid(app.RecurrenceInfo.Id.ToString());
if (_changedOccurencyCustomFields.ContainsKey(id) && _changedOccurencyCustomFields[id].ContainsKey(index))
if (_ChangedOccurencyCustomFields.ContainsKey(id) && _ChangedOccurencyCustomFields[id].ContainsKey(index))
{
if (app.Type.Equals(AppointmentType.ChangedOccurrence))
{
app.CustomFields[CustomField_EmployeeList] = _changedOccurencyCustomFields[id][index][CustomField_EmployeeList];
app.CustomFields[CustomField_CustomerList] = _changedOccurencyCustomFields[id][index][CustomField_CustomerList];
app.CustomFields[CustomField_ResourceList] = _changedOccurencyCustomFields[id][index][CustomField_ResourceList];
app.CustomFields[CustomField_Originator] = _changedOccurencyCustomFields[id][index][CustomField_Originator];
app.CustomFields[CustomField_IsPrivate] = _changedOccurencyCustomFields[id][index][CustomField_IsPrivate];
app.CustomFields[CustomField_IsAbsenceTime] = _changedOccurencyCustomFields[id][index][CustomField_IsAbsenceTime];
app.CustomFields[CustomField_EmployeeList] = _ChangedOccurencyCustomFields[id][index][CustomField_EmployeeList];
app.CustomFields[CustomField_CustomerList] = _ChangedOccurencyCustomFields[id][index][CustomField_CustomerList];
app.CustomFields[CustomField_ResourceList] = _ChangedOccurencyCustomFields[id][index][CustomField_ResourceList];
app.CustomFields[CustomField_Originator] = _ChangedOccurencyCustomFields[id][index][CustomField_Originator];
app.CustomFields[CustomField_IsPrivate] = _ChangedOccurencyCustomFields[id][index][CustomField_IsPrivate];
app.CustomFields[CustomField_IsAbsenceTime] = _ChangedOccurencyCustomFields[id][index][CustomField_IsAbsenceTime];
}
}
}
@@ -360,52 +360,52 @@ namespace BeWo.Scheduler.ViewModel
AbstractAppointmentEditForm ISchedulerViewModel.GetEditAppointmentForm(SchedulerControl control, Appointment appointment)
{
_geoeffneterTermin = control.Storage.CreateAppointment(AppointmentType.Normal);
_geoeffneterTermin.AllDay = appointment.AllDay;
_geoeffneterTermin.Start = appointment.Start;
_geoeffneterTermin.End = appointment.End;
_geoeffneterTermin.Description = appointment.Description;
_GeoeffneterTermin = control.Storage.CreateAppointment(AppointmentType.Normal);
_GeoeffneterTermin.AllDay = appointment.AllDay;
_GeoeffneterTermin.Start = appointment.Start;
_GeoeffneterTermin.End = appointment.End;
_GeoeffneterTermin.Description = appointment.Description;
foreach (CustomField cf in appointment.CustomFields)
{
_geoeffneterTermin.CustomFields[cf.Name] = cf.Value;
_GeoeffneterTermin.CustomFields[cf.Name] = cf.Value;
}
if (!appointment.Type.Equals(AppointmentType.ChangedOccurrence))
{
return new SchedulerAppointmentEditForm(this, control, appointment, _allEmployees, _allCustomers, _categories2Resources);
return new SchedulerAppointmentEditForm(this, control, appointment, _AllEmployees, _AllCustomers, _Categories2Resources);
}
var index = appointment.RecurrenceIndex;
var id = new Guid(appointment.RecurrenceInfo.Id.ToString());
if (_changedOccurencyCustomFields.ContainsKey(id) && _changedOccurencyCustomFields[id].ContainsKey(index.ToString()))
if (_ChangedOccurencyCustomFields.ContainsKey(id) && _ChangedOccurencyCustomFields[id].ContainsKey(index.ToString()))
{
var specialCustomFields = _changedOccurencyCustomFields[id][index.ToString()];
var specialCustomFields = _ChangedOccurencyCustomFields[id][index.ToString()];
foreach (var cf in specialCustomFields)
{
appointment.CustomFields[cf.Key] = cf.Value;
_geoeffneterTermin.CustomFields[cf.Key] = cf.Value;
_GeoeffneterTermin.CustomFields[cf.Key] = cf.Value;
}
}
return new SchedulerAppointmentEditForm(this, control, appointment, _allEmployees, _allCustomers, _categories2Resources);
return new SchedulerAppointmentEditForm(this, control, appointment, _AllEmployees, _AllCustomers, _Categories2Resources);
}
public void ApplyChangesToChangedOccurencyCustomFields(List<Employee2SchedulerAppointmentDC> employees, List<CompactCustomerDC> customers, List<ResourceDC> resources, CompactEmployeeDC originator, bool isPrivate, string index, Guid id)
{
if (!_changedOccurencyCustomFields.ContainsKey(id) || !_changedOccurencyCustomFields[id].ContainsKey(index))
if (!_ChangedOccurencyCustomFields.ContainsKey(id) || !_ChangedOccurencyCustomFields[id].ContainsKey(index))
{
return;
}
_changedOccurencyCustomFields[id][index][CustomField_EmployeeList] = employees;
_changedOccurencyCustomFields[id][index][CustomField_CustomerList] = customers;
_changedOccurencyCustomFields[id][index][CustomField_ResourceList] = resources;
_changedOccurencyCustomFields[id][index][CustomField_Originator] = originator;
_changedOccurencyCustomFields[id][index][CustomField_IsPrivate] = isPrivate;
_ChangedOccurencyCustomFields[id][index][CustomField_EmployeeList] = employees;
_ChangedOccurencyCustomFields[id][index][CustomField_CustomerList] = customers;
_ChangedOccurencyCustomFields[id][index][CustomField_ResourceList] = resources;
_ChangedOccurencyCustomFields[id][index][CustomField_Originator] = originator;
_ChangedOccurencyCustomFields[id][index][CustomField_IsPrivate] = isPrivate;
}
public void AddCustomFieldsMapping(SchedulerStorage schedulerStorage)
@@ -519,8 +519,8 @@ namespace BeWo.Scheduler.ViewModel
var istEigen = ersteller.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid);
var mVorhanden = appEList.Any(a2app => _allEmployees.Contains(a2app.Employee));
var kVorhanden = customerList.Any(_allCustomers.Contains);
var mVorhanden = appEList.Any(a2app => _AllEmployees.Contains(a2app.Employee));
var kVorhanden = customerList.Any(_AllCustomers.Contains);
wirdAngezeigt = liste[0] && mVorhanden || liste[1] && resourceList.Any() || liste[2] && kVorhanden;
@@ -548,7 +548,7 @@ namespace BeWo.Scheduler.ViewModel
public void InitChangedOccurrencyCustomFields(IEnumerable<SchedulerAppointmentDC> appList)
{
_changedOccurencyCustomFields = new Dictionary<Guid, Dictionary<string, Dictionary<string, object>>>();
_ChangedOccurencyCustomFields = new Dictionary<Guid, Dictionary<string, Dictionary<string, object>>>();
foreach (var termin in appList)
{
@@ -580,17 +580,17 @@ namespace BeWo.Scheduler.ViewModel
var id = new Guid(ri.Id.ToString());
if(!_changedOccurencyCustomFields.ContainsKey(id))
if(!_ChangedOccurencyCustomFields.ContainsKey(id))
{
_changedOccurencyCustomFields.Add(id, new Dictionary<string, Dictionary<string, object>> { { index, customFieldCollection } });
_ChangedOccurencyCustomFields.Add(id, new Dictionary<string, Dictionary<string, object>> { { index, customFieldCollection } });
}
else if(!_changedOccurencyCustomFields[id].ContainsKey(index))
else if(!_ChangedOccurencyCustomFields[id].ContainsKey(index))
{
_changedOccurencyCustomFields[id].Add(index, customFieldCollection);
_ChangedOccurencyCustomFields[id].Add(index, customFieldCollection);
}
else
{
_changedOccurencyCustomFields[id][index] = customFieldCollection;
_ChangedOccurencyCustomFields[id][index] = customFieldCollection;
}
}
}

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using BeWoPlanerMobil.Models;

View File

@@ -1170,7 +1170,6 @@ namespace BeWo.Data.Access
return c.List<ApplicationUser>().Count > 0;
}
//TODO: Hier vielleicht die neue CreateRecurrenceCriteria-Methode benutzen?
public bool OverlappingAppointmentsExist(DateTime start, DateTime end, IEnumerable<long> employees, IEnumerable<long> customers, IEnumerable<long> resources, long originator, long? appointmentOid, string recurrenceId = "", int occurrenceIndex = 0)
{
var criteria = CreateCriteria<SchedulerAppointment>()
@@ -1199,67 +1198,6 @@ namespace BeWo.Data.Access
)
);
// TODO: nicht wichtig - ignorieren
// TODO: RecurrenceInfo in die Parameter aufnehmen (wie beim Laden der Termine)
// TODO: Periodicity beachten! OR RecurrenceInfo NOT LIKE '%Range%' AND RecurrenceInfo NOT LIKE '%Index%'
// OR RecurrenceInfo NOT LIKE '%Range%' AND RecurrenceInfo NOT LIKE '%Index%'
//var recurrenceBetween = String.Format(
// "'{0} 00:00:00' BETWEEN STR_TO_DATE(SUBSTRING({1}, 24, 19), '%m/%d/%Y %H:%i:%s') AND STR_TO_DATE(SUBSTRING({1}, 50, 19), '%m/%d/%Y %H:%i:%s') " +
// "AND(" +
// "(" +
// "(" +
// "TIME({5}) > '{2}' AND TIME({5}) < '{3}'" +
// ") " +
// "OR(" +
// "TIME({4}) > '{2}' AND TIME({4}) < '{3}'" +
// ")" +
// ") " +
// "OR (" +
// "(" +
// "TIME({4}) > '{2}' AND TIME({5}) < '{2}'" +
// ") " +
// "OR(" +
// "TIME({4}) > '{2}' AND TIME({5}) < '{3}'" +
// ")" +
// ")" +
// ") OR {1} NOT LIKE '%Range=\"%' AND Type <> 3 AND Type <> 4",
// start.ToString("yyyy-MM-dd"),
// SchedulerAppointment.PropertyName_RecurrenceInfo,
// start.ToString("HH:mm:ss"),
// end.ToString("HH:mm:ss"),
// SchedulerAppointment.PropertyName_StartDate,
// SchedulerAppointment.PropertyName_EndDate);
//criteria = CreateCriteria<SchedulerAppointment>()
// .Add(Restrictions.Eq(BeWoEntityBase.PropertyName_IsActive, ActivationTypeId.Active))
// .Add(Restrictions.Or(
// Restrictions.Or(
// Restrictions.Or(
// Restrictions.And(
// Restrictions.Gt(SchedulerAppointment.PropertyName_EndDate, start),
// Restrictions.Lt(SchedulerAppointment.PropertyName_EndDate, end)
// ),
// Restrictions.And(
// Restrictions.Gt(SchedulerAppointment.PropertyName_StartDate, start),
// Restrictions.Lt(SchedulerAppointment.PropertyName_StartDate, end)
// )
// ),
// Restrictions.Or(
// Restrictions.And(
// Restrictions.Lt(SchedulerAppointment.PropertyName_StartDate, start),
// Restrictions.Gt(SchedulerAppointment.PropertyName_EndDate, start)
// ),
// Restrictions.And(
// Restrictions.Eq(SchedulerAppointment.PropertyName_StartDate, start),
// Restrictions.Eq(SchedulerAppointment.PropertyName_EndDate, end)
// )
// )
// ),
// Expression.Sql(new SqlString(recurrenceBetween))
// )
// );
if (appointmentOid != null)
{
criteria.Add(Restrictions.Not(Restrictions.Eq(BeWoEntityBase.PropertyName_Oid, appointmentOid)));
@@ -1399,38 +1337,6 @@ namespace BeWo.Data.Access
return c.List<ServiceRecord>();
}
// Veraltet. Wird nicht mehr benutzt
public IEnumerable<SchedulerAppointment> FindAppointmentsForPrintingForEmployee(long employeeOid, List<DateTime> selectedDates, List<UserRightType> userRights)
{
var abfrage = "SELECT Oid FROM newschedulerappointment WHERE IsActive = 1 AND ";
var or = string.Empty;
foreach (var d in selectedDates)
{
// TODO: RecurrenceInfo hat nicht immer ein Enddatum
or += string.Format("StartDate LIKE '{0}%' OR RecurrenceInfo IS NOT NULL AND '{0} 00:00:00' BETWEEN STR_TO_DATE(SUBSTRING({1}, 24, 19), '%m/%d/%Y %H:%i:%s') AND STR_TO_DATE(SUBSTRING({1}, 50, 19), '%m/%d/%Y %H:%i:%s')", d.ToString("yyyy-MM-dd"), SchedulerAppointment.PropertyName_RecurrenceInfo);
if (selectedDates.IndexOf(d) < selectedDates.Count - 1)
{
or += " OR ";
}
}
abfrage += or;
var sa = Session.CreateSQLQuery(abfrage);
var l = sa.List<long>().ToList();
var c = CreateCriteria<SchedulerAppointment>()
.Add(Restrictions.Eq(BeWoEntityBase.PropertyName_IsActive, ActivationTypeId.Active))
.Add(Restrictions.In(BeWoEntityBase.PropertyName_Oid, l));
c.CreateCriteria(SchedulerAppointment.PropertyName_EmployeeList)
.Add(Restrictions.And(
Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_Employee + ".Oid", employeeOid),
Restrictions.Not(Restrictions.Eq(Employee2SchedulerAppointment.PropertyName_ParticipationAnswer, ParticipationAnswer.Absage))));
return c.List<SchedulerAppointment>();
}
public IEnumerable<TextModule> GetActiveTextModuleByServiceCategory(long pServiceCategoryOid)
{
var c = CreateCriteriaIsActive<TextModule>();
@@ -1724,7 +1630,6 @@ namespace BeWo.Data.Access
return c.List<ChatMessage>();
}
public IEnumerable<Employee> FindAllChatActiveEmployees()
{
@@ -2038,10 +1943,9 @@ namespace BeWo.Data.Access
return c;
}
public ServiceRecord FindServiceRecordforHistory(long? ServiceRecordOid)
public ServiceRecord FindServiceRecordforHistory(long? pServiceRecordOid)
{
var c =
CreateCriteria<ServiceRecord>().Add(Restrictions.Eq(ServiceRecord.PropertyName_Oid, ServiceRecordOid));
var c = CreateCriteria<ServiceRecord>().Add(Restrictions.Eq(BeWoEntityBase.PropertyName_Oid, pServiceRecordOid));
return c.UniqueResult<ServiceRecord>();
}