diff --git a/BeWo/Scheduler/Utils/AppointmentExtensions.cs b/BeWo/Scheduler/Utils/AppointmentExtensions.cs index 890ae78d8..81baae06e 100644 --- a/BeWo/Scheduler/Utils/AppointmentExtensions.cs +++ b/BeWo/Scheduler/Utils/AppointmentExtensions.cs @@ -95,8 +95,13 @@ namespace BeWo.Scheduler.Utils return appointment.GetCustomFieldStorage()?.HasServiceRecordEntry ?? false; } - - + public static bool CF_CanBeEdited(this Appointment appointment) + { + return appointment.GetCustomFieldStorage()?.CanBeEdited ?? false; + } + + + public static void CF_IsTask(this Appointment appointment, bool pIsTask) { appointment.GetCustomFieldStorage().IsTask = pIsTask; diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml b/BeWo/Scheduler/View/NewSchedulerView.xaml index 04b8147ca..623d4f8fd 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml @@ -70,7 +70,7 @@ Visibility="{Binding ViewInfo.View.AppointmentToolTipVisibility, RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource ToolTipVisibilityConverter}}"> - + @@ -310,6 +310,8 @@ + + @@ -353,7 +355,6 @@ - @@ -364,7 +365,11 @@ - + + + + + diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs index d6a2c195c..2f8dff693 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs @@ -1536,7 +1536,7 @@ namespace BeWo.Scheduler.View var mitarbeiterliste = appointment.CF_EmployeeList(); var istErsteller = ersteller?.EmployeeOid.Equals(BeWoApp.LoggedOnEmployee.EmployeeOid) ?? false; - if(!istErsteller && appointment.CF_IsPrivate() && !mitarbeiterliste.Any(a => Equals(a.Employee, BeWoApp.CompactLoggedOnEmployee))) + if(!istErsteller && appointment.CF_IsPrivate() && !mitarbeiterliste.Any(a => Equals(a.Employee, BeWoApp.CompactLoggedOnEmployee)) || !appointment.CF_CanBeEdited()) { darfTerminDetailsSehen = false; } diff --git a/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs b/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs index 1c43a142b..bfd9ada68 100644 --- a/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs +++ b/BeWo/Scheduler/ViewModel/CustomFieldStorage.cs @@ -73,6 +73,8 @@ namespace BeWo.Scheduler.ViewModel public InternalInfo InternalInfo { get; set; } + public bool CanBeEdited { get; set; } + public CustomFieldStorage() { @@ -107,6 +109,7 @@ namespace BeWo.Scheduler.ViewModel _AbsenceTimeEnd = pAppointment.AbsenceTimeEnd; HasServiceRecordEntry = pAppointment.HasServiceRecordEntry; + CanBeEdited = pAppointment.CanBeEdited; } public CustomFieldStorage(SchedulerAppointmentDC pAppointment) @@ -135,6 +138,8 @@ namespace BeWo.Scheduler.ViewModel RecurrenceIndex = pAppointment.RecurrenceIndex; HasServiceRecordEntry = pAppointment.HasServiceRecordEntry; + + CanBeEdited = pAppointment.CanBeEdited; } public CustomFieldStorage(ObservableCollection pEmployees, List pCustomers, List pResources, CompactEmployeeDC pOriginator, bool pIsPrivate, bool pIsTask, string pTaskDescription, DateTime? pDueDate, DateTime? pCompletedDate, string pCompletedNotice, List pSupportConcepts, string pSubject, bool pIsAllDay) diff --git a/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs b/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs index 4f286e01e..d2a4a4e7a 100644 --- a/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs +++ b/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs @@ -550,10 +550,14 @@ namespace BeWo.Scheduler.ViewModel public int RecurrenceIndex => BS.Shared.Core.Utils.GetRecurrenceIndexFromRecurrenceInfo(RecurrenceInfo); - public SchedulerAppointmentVM(SchedulerAppointmentDC pDC) : base(pDC, pDC.SchedulerAppointmentOid == null) + public bool CanBeEdited { get; set; } = true; + + + public SchedulerAppointmentVM(SchedulerAppointmentDC pDC) : base(pDC, pDC.SchedulerAppointmentOid == null) { IsTeilnahmeBestaetigung = pDC.IsTeilnahmeBestaetigung; - } + CanBeEdited = pDC.CanBeEdited; + } // Wird für Abwesenheiten genutzt public SchedulerAppointmentVM(bool pAllDay, string pSubject, DateTime pStart, DateTime pEnd, CompactEmployeeDC pOriginator, DateTime? absenceTimeStart, DateTime? absenceTimeEnd) @@ -604,6 +608,7 @@ namespace BeWo.Scheduler.ViewModel _HasServiceRecordEntry = pDataContract.HasServiceRecordEntry; _IsArchived = pDataContract.ActivationType == ActivationTypeId.Archived; + CanBeEdited = pDataContract.CanBeEdited; if(pDataContract.DueDate.HasValue) diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs index 2714beae3..bb86963d0 100644 --- a/Data/Access/SearchDAO.cs +++ b/Data/Access/SearchDAO.cs @@ -2631,6 +2631,7 @@ namespace BeWo.Data.Access return c.List(); } + // KALENDER public IList LoadFilteredAppointments(bool pHasRightToSeeAllEmployeeAppointments, long pEmployeeOid, DateTime pIntervalStart, DateTime pIntervalEnd, List pSelectedEmployees, List pSelectedCustomers, List pSelectedResources, bool pEmployeesOnly, bool pCustomersOnly, bool pResourcesOnly, bool pPrivateAppointmentsOnly, bool pOnlyMyAppointments, bool pIncludeInactiveOnes) { var recurrenceBetween = Format("'{0:yyyy-MM-dd} 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')", pIntervalStart, SchedulerAppointment.PropertyName_RecurrenceInfo); @@ -2729,6 +2730,7 @@ namespace BeWo.Data.Access return criteria.List(); } + // KALENDER public IEnumerable LoadFilteredAppointmentsForEmployee(bool pHasRightToSeeAllEmployeeAppointments, long? pEmployeeOid, DateTime pIntervalStart, DateTime pIntervalEnd, List pSelectedEmployees, List pSelectedCustomers, List pSelectedResources, bool pEmployeesOnly, bool pCustomersOnly, bool pResourcesOnly, bool pPrivateAppointmentsOnly, bool pOnlyMyAppointments, bool pIncludeInactiveOnes) { var mainCriteria = CreateRecurrenceCriteria(pIntervalStart, pIntervalEnd, pIncludeInactiveOnes); diff --git a/Data/DefaultHibernateSessionManager.cs b/Data/DefaultHibernateSessionManager.cs index 953a5738d..15d38ac70 100644 --- a/Data/DefaultHibernateSessionManager.cs +++ b/Data/DefaultHibernateSessionManager.cs @@ -78,8 +78,8 @@ namespace BeWo.Data { //String path = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionFactoryError.txt"); //System.IO.File.AppendAllText(path, String.Format("{0:dd.MM.yyyy HH:mm:ss}", DateTime.Now) + "\n" + e.Message + "\n" + e.StackTrace); - Debug.WriteLine("<<<<< " + e.StackTrace + (e.InnerException != null ? e.InnerException.Message : string.Empty)); - throw new FaultException(e.StackTrace + e.InnerException != null ? e.InnerException.Message : string.Empty); + Debug.WriteLine("<<<<< " + e.StackTrace + e.InnerException?.Message ?? string.Empty); + throw new FaultException(e.StackTrace + e.InnerException?.Message ?? string.Empty); } finally { @@ -170,7 +170,7 @@ namespace BeWo.Data } catch (Exception e) { - throw new FaultException(e.StackTrace + e.InnerException != null ? e.InnerException.Message : string.Empty); + throw new FaultException(e.StackTrace + e.InnerException?.Message ?? string.Empty); } } diff --git a/Data/WCFHibernateSessionManager.cs b/Data/WCFHibernateSessionManager.cs index e13a9acae..c8bb089a9 100644 --- a/Data/WCFHibernateSessionManager.cs +++ b/Data/WCFHibernateSessionManager.cs @@ -157,7 +157,7 @@ namespace BeWo.Data } catch (Exception e) { - throw new FaultException(e.StackTrace + e.InnerException != null ? e.InnerException.Message : string.Empty); + throw new FaultException(e.StackTrace + e.InnerException?.Message ?? string.Empty); } } diff --git a/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs b/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs index e8bea457a..bc84033e4 100644 --- a/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs +++ b/Service/DCEntityMapper/CompactEmployeeDC_Employee.cs @@ -19,6 +19,7 @@ namespace BeWo.Service.DCEntityMapper pDataContract.ActivationType = pEntity.IsActive; pDataContract.ValueListEntries = pEntity.ValueList.ToDictionary(i => i.Entry.Oid.Value, i => i.Entry.Type); pDataContract.EmployeeColor = pEntity.EmployeeColor; + pDataContract.RelatedCustomerOIDList = pEntity.Employee2CustomerList.Where(w => w.CustomerOid.HasValue).Select(s => s.CustomerOid.Value).ToList(); return pDataContract; } diff --git a/Service/DCEntityMapper/SchedulerAppointmentDC_SchedulerAppointment.cs b/Service/DCEntityMapper/SchedulerAppointmentDC_SchedulerAppointment.cs index ed05926e7..2a5dcc597 100644 --- a/Service/DCEntityMapper/SchedulerAppointmentDC_SchedulerAppointment.cs +++ b/Service/DCEntityMapper/SchedulerAppointmentDC_SchedulerAppointment.cs @@ -51,6 +51,8 @@ namespace BeWo.Service.DCEntityMapper pDataContract.ActivationType = pEntity.IsActive; + pDataContract.CanBeEdited = true; + return pDataContract; } diff --git a/Service/ServiceImplementations/ResourceServiceImp.cs b/Service/ServiceImplementations/ResourceServiceImp.cs index 748a84e72..409ed2a2a 100644 --- a/Service/ServiceImplementations/ResourceServiceImp.cs +++ b/Service/ServiceImplementations/ResourceServiceImp.cs @@ -1236,13 +1236,29 @@ namespace BeWo.Service.ServiceImplementations if(user != null) { - result = result.Where(w => BS.Shared.Core.Utils.CheckSchedulerRights(w, SchedulerRightsCheckType.View, user)).ToList(); + var appointmentsToCheckForAnonymization = pSelectedResources.Any() || pResourcesOnly ? result.Where(w => w.ResourceList.Any() && false == SUtils.CheckSchedulerRights(w, SchedulerRightsCheckType.View, user)).ToList() : new List(); + + if(appointmentsToCheckForAnonymization.Any()) + { + foreach(var a in appointmentsToCheckForAnonymization) + { + a.Subject = "Anonymisiert"; + a.Location = "Anonymisiert"; + a.Description = "Anonymisiert"; + a.CanBeEdited = false; + a.CustomerList.Clear(); + a.EmployeeList.Clear(); + } + } + + result = result.Where(w => (!w.ResourceList.Any() || SUtils.CheckSchedulerRights(w, SchedulerRightsCheckType.View, user)) && !appointmentsToCheckForAnonymization.Any(a => a.SchedulerAppointmentOid == w.SchedulerAppointmentOid)).ToList(); + + result.AddRange(appointmentsToCheckForAnonymization); } // Aufgaben laden ConvertOldTasks(pEmployeeOid); - var taskAppointmentDCs = MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDCs(DAOFactory.SearchDAO.LoadTaskAppointmentsForEmployee(pEmployeeOid, true)); result.AddRangeIfElementsNotIn(taskAppointmentDCs); @@ -1410,10 +1426,12 @@ namespace BeWo.Service.ServiceImplementations private static List FilterAppointments(IEnumerable pAppointments, long pEmployeeOid, ICollection pFilteredEmployeeOids, ICollection pSelectedCustomers, ICollection pSelectedResources, bool pCustomersOnly, bool pResourcesOnly, bool pShowTasks = false) { var result = new List(); - + foreach(var app in pAppointments) { var add = true; + + if(app.Originator != null && app.Originator.EmployeeOid == pEmployeeOid) { if(app.EmployeeList != null && app.EmployeeList.Count > 0) @@ -1429,6 +1447,7 @@ namespace BeWo.Service.ServiceImplementations } } + // ToDo: Nicht herausnehmen, wenn Ressource in SelectedResources vorhanden ist. //Prüfe Klientenfilter if(!add) { @@ -1478,6 +1497,11 @@ namespace BeWo.Service.ServiceImplementations add = false; } + if(app.SchedulerAppointmentOid == 21852) + { + + } + if(add) { result.Add(app); diff --git a/Shared/Core/Utils.cs b/Shared/Core/Utils.cs index 1914923c1..71df92aec 100644 --- a/Shared/Core/Utils.cs +++ b/Shared/Core/Utils.cs @@ -668,6 +668,8 @@ namespace BS.Shared.Core public static bool CheckSchedulerRights(List pCustomerList, List pResourceList, List pEmployeeList, CompactEmployeeDC pOriginator, bool pIsNew, SchedulerRightsCheckType pCheckType, UserDC pLoggedOnUser) { + // ToDo: Ressourcentermine anzeigen und gegebenenfalls zensieren, falls eine Ressource daraus in der Auswahlliste ist. + var loggedInEmployee = pLoggedOnUser.Employee; var isAllowedToViewEverything = pLoggedOnUser.HasRight(UserRightType.ViewAll); @@ -679,23 +681,24 @@ namespace BS.Shared.Core pLoggedOnUser.HasRight(UserRightType.Customer_ViewMyCustomers); var isAllowedToViewAllCustomerAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderKliententermineAlleAnsehen); - var isAllowedToCreateCustomerAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderKliententermineAnlegen); - var isAllowedToEditCustomerAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderKliententermineAendern); + var isAllowedToCreateCustomerAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderKliententermineAnlegen); + var isAllowedToEditCustomerAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderKliententermineAendern); - var isAllowedToViewEmployeeAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen); + var isAllowedToViewEmployeeAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen); var isAllowedToCreateEmployeeAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnlegen); - var isAllowedToEditEmployeeAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAendern); + var isAllowedToEditEmployeeAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAendern); - var isAllowedToViewResourceAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAnsehen); - var isAllowedToCreateResourceAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAnlegen); - var isAllowedToEditResourceAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAendern); + var isAllowedToViewResourceAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAnsehen); + var isAllowedToCreateResourceAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAnlegen); + var isAllowedToEditResourceAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAendern); var isAllowedToEditOtherEmployeesResourceAppointments = pLoggedOnUser.HasRight(UserRightType.KalenderRessourcentermineAndererAendern); var hasEmployees = pEmployeeList?.Count > 0; var hasCustomers = pCustomerList?.Count > 0; var hasResources = pResourceList?.Count > 0; - var hasOnlyOwnCustomers = pCustomerList?.All(c => c.IsRelatedToEmployee) ?? false; + // Prüfen, ob die Klienten alle in der Liste des Employees sind! + var hasOnlyOwnCustomers = pCustomerList?.All(c => loggedInEmployee.RelatedCustomerOIDList.Contains(c.CustomerOid)) ?? false; var isOwnAppointment = Equals(pOriginator, loggedInEmployee); var employeeListOnlyContainsEmployee = pEmployeeList?.Count == 1 && pEmployeeList[0].Employee.Equals(loggedInEmployee); diff --git a/Shared/DataContracts/SchedulerAppointmentDC.cs b/Shared/DataContracts/SchedulerAppointmentDC.cs index 301330b1a..da60dd153 100644 --- a/Shared/DataContracts/SchedulerAppointmentDC.cs +++ b/Shared/DataContracts/SchedulerAppointmentDC.cs @@ -101,6 +101,8 @@ namespace BS.Shared.DataContracts [DataMember] public bool HasServiceRecordEntry { get; set; } + [DataMember] + public bool CanBeEdited { get; set; } = true; public override bool Equals(object obj) {