diff --git a/BeWo/Scheduler/Utils/Utils.cs b/BeWo/Scheduler/Utils/Utils.cs new file mode 100644 index 000000000..7bc46f6c7 --- /dev/null +++ b/BeWo/Scheduler/Utils/Utils.cs @@ -0,0 +1,29 @@ +using System.Text.RegularExpressions; + +namespace BeWo.Scheduler.Utils +{ + public static class Utils + { + private static readonly Regex indexRegex = new Regex("(?:Index=\"){1}([0-9]+)\"{1}"); + private static readonly Regex idRegex = new Regex("(?:Id=\")(([a-z0-9]{8})-{1}([a-z0-9]{4})-{1}([a-z0-9]{4})-{1}([a-z0-9]{4})-{1}([a-z0-9]{12}))(?=\"{1})"); + + public static string ExtractIdFromRecurrenceInfo(string pRecurrenceInfo) + { + return pRecurrenceInfo != null ? idRegex.Match(pRecurrenceInfo).Groups[1].Value : null; + } + + public static int ExtractIndexFromRecurrenceInfo(string pRecurrenceInfo) + { + if(pRecurrenceInfo != null) + { + var indexString = indexRegex.Match(pRecurrenceInfo).Groups[1].Value; + + var index = !string.IsNullOrEmpty(indexString) ? int.Parse(indexString) : 0; + + return index; + } + + return -1; + } + } +} diff --git a/BeWo/View/HomeDragPanelView.xaml.cs b/BeWo/View/HomeDragPanelView.xaml.cs index d4947d47f..3049d1a39 100644 --- a/BeWo/View/HomeDragPanelView.xaml.cs +++ b/BeWo/View/HomeDragPanelView.xaml.cs @@ -90,7 +90,7 @@ namespace BeWo.View #if DEBUG //txtChangePassword.Visibility = Visibility.Visible; - //TestTermineAnlegenButton.Visibility = Visibility.Visible; + #else if (BeWoApp.Tenant == "demo" || !BeWoApp.LoggedOnUser.HasRight(UserRightType.AllowChangeOwnPassword)) { @@ -756,7 +756,8 @@ namespace BeWo.View if (_HasRightsToSeeAppointments && _IsAllowedToSeeMitarbeitertermine) { #if DEBUG - //TestTermineLoeschenButton.Visibility = Visibility.Visible; + TestTermineAnlegenButton.Visibility = Visibility.Visible; + TestTermineLoeschenButton.Visibility = Visibility.Visible; #endif employeeFilterBox.Visibility = Visibility.Visible; diff --git a/Data/Entities/DeletionHistory.cs b/Data/Entities/DeletionHistory.cs new file mode 100644 index 000000000..4331ed8c3 --- /dev/null +++ b/Data/Entities/DeletionHistory.cs @@ -0,0 +1,18 @@ +using BS.Shared; + +namespace BeWo.Data.Entities +{ + public class DeletionHistory : BeWoEntityBase + { + public DeletionHistory() + { + _Tid = TableID.DeletionHistory; + } + + public virtual string DeletingEmployeeName { get; set; } + + public virtual string DeletedEntityName { get; set; } + + public virtual TableID DeletedEntityTableId { get; set; } + } +} diff --git a/Data/Mappings/DeletionHistory.hbm.xml b/Data/Mappings/DeletionHistory.hbm.xml new file mode 100644 index 000000000..17c7a0999 --- /dev/null +++ b/Data/Mappings/DeletionHistory.hbm.xml @@ -0,0 +1,21 @@ + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/Service/ServiceImplementations/ResourceServiceImp.cs b/Service/ServiceImplementations/ResourceServiceImp.cs index 706a25903..4080693ae 100644 --- a/Service/ServiceImplementations/ResourceServiceImp.cs +++ b/Service/ServiceImplementations/ResourceServiceImp.cs @@ -1589,7 +1589,6 @@ namespace BeWo.Service.ServiceImplementations { try { - // Appointments speichern, dann die Mitarbeiterlisten... CreateTestAppointmentsForEmployee(pEmployeeOid); } catch(Exception e) @@ -1614,10 +1613,29 @@ namespace BeWo.Service.ServiceImplementations var fiveCustomers = customers.TakeWhile((t, i) => i != 5).ToList(); var fiveResources = resources.TakeWhile((t, i) => i != 3).ToList(); - var employeeList = employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + var employeeListIncludingLoggedInEmployee1 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee1.Add(new Employee2SchedulerAppointment(employee)); - var employeeListIncludingLoggedInEmployee = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList();//new List(); - employeeListIncludingLoggedInEmployee.Add(new Employee2SchedulerAppointment(employee)); + var employeeListIncludingLoggedInEmployee2 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee2.Add(new Employee2SchedulerAppointment(employee)); + + var employeeListIncludingLoggedInEmployee3 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee3.Add(new Employee2SchedulerAppointment(employee)); + + var employeeListIncludingLoggedInEmployee4 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee4.Add(new Employee2SchedulerAppointment(employee)); + + var employeeListIncludingLoggedInEmployee5 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee5.Add(new Employee2SchedulerAppointment(employee)); + + var employeeListIncludingLoggedInEmployee6 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee6.Add(new Employee2SchedulerAppointment(employee)); + + var employeeListIncludingLoggedInEmployee7 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee7.Add(new Employee2SchedulerAppointment(employee)); + + var employeeListIncludingLoggedInEmployee8 = employeesWithoutEmployee.TakeWhile((t, i) => i != 4).Select(t => new Employee2SchedulerAppointment(t)).ToList(); + employeeListIncludingLoggedInEmployee8.Add(new Employee2SchedulerAppointment(employee)); var monday = DateTime.Today.FirstDateOfWeek(DateTime.Today.GetIso8601WeekOfYear()); var tuesday = monday.AddDays(1); @@ -1629,23 +1647,23 @@ namespace BeWo.Service.ServiceImplementations //Originator ist angemeldeten Mitarbeiter - GenerateAppointments(monday, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeList, null); + GenerateAppointments(monday, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null); //Termin von anderem Mitarbeiter - GenerateAppointments(tuesday, false, secondEmployee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null); + GenerateAppointments(tuesday, false, secondEmployee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee1, null); //Originator ist angemeldeter Mitarbeiter und in Liste - GenerateAppointments(wednesday, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null); + GenerateAppointments(wednesday, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee2, null); //Originator ist nicht angemeldeter Mitarbeiter und der ist auch nicht in der Liste - GenerateAppointments(thursday, false, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeList, null); + GenerateAppointments(thursday, false, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null); //Private Termine - GenerateAppointments(friday, true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeList, null); - GenerateAppointments(saturday, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeList, null); - GenerateAppointments(sunday, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null); - GenerateAppointments(friday.AddHours(12), true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null); + GenerateAppointments(friday, true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null); + GenerateAppointments(saturday, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null); + GenerateAppointments(sunday, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeListIncludingLoggedInEmployee3, null); + GenerateAppointments(friday.AddHours(12), true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee4, null); //AllDay-Termine ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ @@ -1658,23 +1676,23 @@ namespace BeWo.Service.ServiceImplementations var sun = sunday.AddDays(7); //Originator ist angemeldeten Mitarbeiter - GenerateAppointments(mon, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeList, null, true); + GenerateAppointments(mon, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null, true); //Termin von anderem Mitarbeiter - GenerateAppointments(tue, false, secondEmployee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null, true); + GenerateAppointments(tue, false, secondEmployee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee5, null, true); //Originator ist angemeldeter Mitarbeiter und in Liste - GenerateAppointments(wed, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null, true); + GenerateAppointments(wed, false, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee6, null, true); //Originator ist nicht angemeldeter Mitarbeiter und der ist auch nicht in der Liste - GenerateAppointments(thu, false, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeList, null, true); + GenerateAppointments(thu, false, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null, true); //Private Termine - GenerateAppointments(fri, true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeList, null, true); - GenerateAppointments(sat, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeList, null, true); - GenerateAppointments(sun, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null, true); - GenerateAppointments(fri.AddHours(12), true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee, null, true); + GenerateAppointments(fri, true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null, true); + GenerateAppointments(sat, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeesWithoutEmployee.TakeWhile((t, i) => i != 5).Select(t => new Employee2SchedulerAppointment(t)).ToList(), null, true); + GenerateAppointments(sun, true, secondEmployee, fiveCustomers, fiveOfSecondEmployeesCustomers, fiveResources, employeeListIncludingLoggedInEmployee7, null, true); + GenerateAppointments(fri.AddHours(12), true, employee, fiveCustomers, fiveOfMyOwnCustomers, fiveResources, employeeListIncludingLoggedInEmployee8, null, true); // -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- var mo = mon.AddDays(7); @@ -1819,7 +1837,6 @@ namespace BeWo.Service.ServiceImplementations appointment.Subject += " mit Klienten"; break; case 2: - appointment.EmployeeList = pEmployees; appointment.Subject += " mit Mitarbeitern"; break; case 3: @@ -1828,7 +1845,6 @@ namespace BeWo.Service.ServiceImplementations break; case 4: appointment.CustomerList = pCustomerList; - appointment.EmployeeList = pEmployees; appointment.Subject += " mit Klienten und Mitarbeitern"; break; case 5: @@ -1838,12 +1854,10 @@ namespace BeWo.Service.ServiceImplementations break; case 6: appointment.CustomerList = pCustomerList; - appointment.EmployeeList = pEmployees; appointment.ResourceList = pResourceList; appointment.Subject += " mit Klienten, Mitarbeitern und Ressourcen"; break; case 7: - appointment.EmployeeList = pEmployees; appointment.ResourceList = pResourceList; appointment.Subject += " mit Mitarbeitern und Ressourcen"; break; @@ -1853,7 +1867,6 @@ namespace BeWo.Service.ServiceImplementations break; case 9: appointment.CustomerList = pOwnCustomers; - appointment.EmployeeList = pEmployees; appointment.Subject += " mit eigenen Klienten und Mitarbeitern"; break; case 10: @@ -1863,20 +1876,31 @@ namespace BeWo.Service.ServiceImplementations break; case 11: appointment.CustomerList = pOwnCustomers; - appointment.EmployeeList = pEmployees; appointment.ResourceList = pResourceList; appointment.Subject += " mit eigenen Klienten, Mitarbeitern und Ressourcen"; break; } + appointment.Subject = (pIsPrivate ? "Privat: " : "") + appointment.Subject; + if (pEmployees != null) { DAOFactory.GenericDAO.Insert(pEmployees); + pEmployees = DAOFactory.GenericDAO.LoadByIDs(pEmployees.Where(w => w.Oid.HasValue).Select(s => s.Oid.Value)); + appointment.EmployeeList = pEmployees; } - appointment.Subject = (pIsPrivate ? "Privat: " : "") + appointment.Subject; - DAOFactory.GenericDAO.Insert(appointment); + + if(pEmployees != null) + { + foreach(var abc in appointment.EmployeeList) + { + abc.SchedulerAppointmentOid = appointment.Oid; + } + + DAOFactory.GenericDAO.Update(appointment.EmployeeList); + } } } @@ -2158,7 +2182,6 @@ namespace BeWo.Service.ServiceImplementations Notice = SUtils.TestAppointmentNotice }; - return appointment; }