From c914642d0892b68d12cae5364cd5d04ca54360d9 Mon Sep 17 00:00:00 2001 From: staccatomamba Date: Wed, 23 Aug 2017 17:17:08 +0200 Subject: [PATCH] Begonnen, AbsenceTimes als Appointments im Kalender anzuzeigen. Diverse Code-Clean-Ups --- BeWo/Scheduler/IBeWoAppointment.cs | 12 +++---- BeWo/Scheduler/View/NewSchedulerView.xaml | 33 ++++++++++--------- BeWo/Scheduler/View/NewSchedulerView.xaml.cs | 25 ++++++++++++-- .../ViewModel/NewSchedulerViewModel.cs | 8 ++--- .../ViewModel/SchedulerAppointmentVM.cs | 9 ++++- BeWo/Styles/OrangeBlack.xaml | 2 +- .../CustomerTeamNavigationView.xaml.cs | 1 + BeWo/ViewModel/VMFactory.cs | 9 ----- Data/Access/SearchDAO.cs | 24 ++++++++++++-- Data/Entities/AbsenceTime.cs | 1 - Data/Entities/SchedulerAppointment.cs | 10 +++--- Data/Entities/Team2Customer.cs | 19 ++++------- Service/ServiceContracts/IResourceService.cs | 5 +++ .../EmployeeServiceImp.cs | 5 ++- .../ResourceServiceImp.cs | 21 ++++++++++-- 15 files changed, 118 insertions(+), 66 deletions(-) diff --git a/BeWo/Scheduler/IBeWoAppointment.cs b/BeWo/Scheduler/IBeWoAppointment.cs index 4ffd5d2b8..fcbe9eeb3 100644 --- a/BeWo/Scheduler/IBeWoAppointment.cs +++ b/BeWo/Scheduler/IBeWoAppointment.cs @@ -5,7 +5,7 @@ namespace BeWo.Scheduler { public interface IBeWoAppointment { - Object Id { get; set; } + object Id { get; set; } DateTime Start { get; set;} @@ -13,18 +13,18 @@ namespace BeWo.Scheduler int LabelId { get; set;} - String Subject { get; set;} + string Subject { get; set;} - String Description { get; set; } + string Description { get; set; } - String Location { get; set; } + string Location { get; set; } bool AllDay { get; set; } int EventType { get; set; } - String RecurrenceInfo { get; set; } + string RecurrenceInfo { get; set; } - Dictionary CustomFields { get; } + Dictionary CustomFields { get; } } } diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml b/BeWo/Scheduler/View/NewSchedulerView.xaml index 6edb6a6c7..0b04f05f2 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml @@ -638,21 +638,24 @@ - - - - - - - - - - - - - + + + + + + + + + + + + + + diff --git a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs index 1d65836f5..77c9f9c10 100644 --- a/BeWo/Scheduler/View/NewSchedulerView.xaml.cs +++ b/BeWo/Scheduler/View/NewSchedulerView.xaml.cs @@ -24,12 +24,14 @@ using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; + using DevExpress.Xpf.Bars; using DevExpress.Xpf.Editors; using DevExpress.Xpf.Scheduler; using DevExpress.Xpf.Scheduler.Drawing; using DevExpress.Xpf.Scheduler.Reporting; using DevExpress.XtraScheduler; + using Appointment = DevExpress.XtraScheduler.Appointment; using ColorConverter = System.Windows.Media.ColorConverter; using SchedulerControl = DevExpress.Xpf.Scheduler.SchedulerControl; @@ -52,6 +54,19 @@ namespace BeWo.Scheduler.View } } + private bool _IsAbsenceTimeVisible; + + public bool IsAbsenceTimeVisible + { + get { return _IsAbsenceTimeVisible; } + + set + { + _IsAbsenceTimeVisible = value; + OnPropertyChanged("IsAbsenceTimeVisible"); + } + } + public bool IsInCustomerViewMode { get; set; } public event PropertyChangedEventHandler PropertyChanged; @@ -65,7 +80,9 @@ namespace BeWo.Scheduler.View { var handler = PropertyChanged; if (handler != null) + { handler(this, new PropertyChangedEventArgs(propertyName)); + } } public bool ZeigeNurMeineTermine @@ -369,8 +386,6 @@ namespace BeWo.Scheduler.View private void ConstructObject() { - //SchedulerWriteLog(); - IsEmployeeBrushVisible = true; if (BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) @@ -1812,6 +1827,12 @@ namespace BeWo.Scheduler.View Scheduler.ActiveView.LayoutChanged(); } + + private void AbwesenheitenEinAusCheckBox_OnChecked(object sender, RoutedEventArgs e) + { + var cb = (CheckBox) sender; + IsAbsenceTimeVisible = cb.IsChecked ?? true; + } } #region Converter diff --git a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs index 2934bd7e6..cd191f93d 100644 --- a/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs +++ b/BeWo/Scheduler/ViewModel/NewSchedulerViewModel.cs @@ -54,6 +54,8 @@ namespace BeWo.Scheduler.ViewModel var appointments = new List(); var allCust = new List(); + var abwesenheiten = new List(); + allEmps = Cache.GetInstance().GetAllActiveEmployeesCompactSync(); if (!BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen)) @@ -61,15 +63,13 @@ namespace BeWo.Scheduler.ViewModel ServiceFacade.DoEmployeeServiceSync(es => allEmps = new List { es.LoadCompactEmployee(BeWoApp.LoggedOnEmployee.EmployeeOid.Value) }); } - //if (mAllCats2ResInDic == null) - //{ - ServiceFacade.DoResourceServiceSync(s => mAllCats2ResInDic = s.GetAllCategories2ResourcesInDictionary()); - //} + ServiceFacade.DoResourceServiceSync(s => mAllCats2ResInDic = s.GetAllCategories2ResourcesInDictionary()); var start = intervalStart - NewSchedulerView.FetchPadding; var end = intervalEnd + NewSchedulerView.FetchPadding; ServiceFacade.DoResourceServiceSync(rs => appointments = rs.GetAllActiveAppointmentsForEmployeeInInterval2(start, end, BeWoApp.LoggedOnEmployee.EmployeeOid.Value, BeWoApp.LoggedOnUser.HasRight(UserRightType.KalenderMitarbeitertermineAnsehen))); + //ServiceFacade.DoResourceServiceSync(rs => abwesenheiten = rs.); allCust = Cache.GetInstance().GetAllActiveCustomersCompactSync(); diff --git a/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs b/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs index ef69e3409..fe2b213de 100644 --- a/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs +++ b/BeWo/Scheduler/ViewModel/SchedulerAppointmentVM.cs @@ -27,6 +27,7 @@ namespace BeWo.Scheduler.ViewModel public static string PropertyName_ResourceList = "ResourceList"; public static string PropertyName_IsPrivate = "IsPrivate"; public static string PropertyName_Originator = "Originator"; + public static string PropertyName_IsAbsenceTime = "IsAbsenceTime"; private bool _AllDay; private string _Description; @@ -43,6 +44,7 @@ namespace BeWo.Scheduler.ViewModel private List _CustomerList; private List _ResourceList; private CompactEmployeeDC _Originator; + private bool _IsAbsenceTime; public object Id { get; set; } public int LabelId { get; set; } @@ -259,7 +261,12 @@ namespace BeWo.Scheduler.ViewModel set { } } - public SchedulerAppointmentVM(SchedulerAppointmentDC pDC) : base(pDC, pDC.SchedulerAppointmentOid == null) { } + public virtual bool IsAbsenceTime + { + get { return _IsAbsenceTime; } + } + + public SchedulerAppointmentVM(SchedulerAppointmentDC pDC) : base(pDC, pDC.SchedulerAppointmentOid == null) {} public void UpdateCustomFields() { diff --git a/BeWo/Styles/OrangeBlack.xaml b/BeWo/Styles/OrangeBlack.xaml index b085df2b8..230ac45a1 100644 --- a/BeWo/Styles/OrangeBlack.xaml +++ b/BeWo/Styles/OrangeBlack.xaml @@ -2136,7 +2136,7 @@ - + diff --git a/BeWo/View/Navigation/CustomerTeamNavigationView.xaml.cs b/BeWo/View/Navigation/CustomerTeamNavigationView.xaml.cs index 09e762dd5..5ee942756 100644 --- a/BeWo/View/Navigation/CustomerTeamNavigationView.xaml.cs +++ b/BeWo/View/Navigation/CustomerTeamNavigationView.xaml.cs @@ -24,6 +24,7 @@ namespace BeWo.View.Navigation { if (refresh || recentList == null) { + } } diff --git a/BeWo/ViewModel/VMFactory.cs b/BeWo/ViewModel/VMFactory.cs index 55c66bc1b..b6239e1a8 100644 --- a/BeWo/ViewModel/VMFactory.cs +++ b/BeWo/ViewModel/VMFactory.cs @@ -4,7 +4,6 @@ using System.Linq; using BeWo.Core.Service; using BeWo.ServiceProxy; -using BeWo.Scheduler.ViewModel; using BeWo.ViewModel.ListViewModel; using BS.Shared; @@ -12,7 +11,6 @@ using BS.Shared.Core; using BS.Shared.DataContracts; using BS.Shared.DataContracts.Compact; using BS.Shared.Extensions; -using DevExpress.XtraPrinting.Native; namespace BeWo.ViewModel @@ -647,8 +645,6 @@ namespace BeWo.ViewModel ServiceFacade.DoValueListServiceAsync(s => s.GetAllValueListEntrysByType(pType), r => pCallBack(new ValueListEntryListVM(pType, r))); } - - public static void CreateGoalCategoryVMAsync(Action pCallBack, bool pIsIncludingIndividualGoals = false) { var typeList = new List { ValueListEntryType.SupportConceptGoalType, ValueListEntryType.SupportConceptGoalCategoryType }; @@ -689,11 +685,6 @@ namespace BeWo.ViewModel cb4 => pCallBack(new CustomerVM(pCustomerDC, cb, cb2, cb3, cb4)))))); } - public static void CreateNewSchedulerAppointmentListVM(Action pCallBack, DateTime intervalStart, DateTime intervalEnd) - { - - } - public static void CreateAppointmentCategoryListVMAsync(Action pCallBack) { ServiceFacade.DoCustomerServiceAsync( diff --git a/Data/Access/SearchDAO.cs b/Data/Access/SearchDAO.cs index 2c6869e9f..ab7269240 100644 --- a/Data/Access/SearchDAO.cs +++ b/Data/Access/SearchDAO.cs @@ -1909,7 +1909,7 @@ namespace BeWo.Data.Access return c.List(); } - public string ToSql(ICriteria criteria) + public static string ToSql(ICriteria criteria) { var c = (CriteriaImpl)criteria; var s = (SessionImpl)c.Session; @@ -2038,7 +2038,6 @@ namespace BeWo.Data.Access return c; } - public IList GetAllPerson2OrganisationRelations(long organisationOid) { @@ -2099,7 +2098,6 @@ namespace BeWo.Data.Access .List().Distinct().ToList(); } - public IList FindQuittierungsCheckWithCustomerOids(List oids) { var c = CreateCriteria() @@ -2120,5 +2118,25 @@ namespace BeWo.Data.Access return c.List(); } + public IEnumerable GetAllAbsenceTimesInIntervalByEmployee(DateTime start, DateTime end, long pEmployeeOid, bool pHasRightToSeeAllEmployeeAppointments) + { + // Wenn das Enddatum null ist, wird das Ende des Intervalls als Enddatum gesetzt (Ist ja eh read-only). + + var criteria = CreateCriteriaIsActive() + .Add(Restrictions.Or + (Restrictions.Or(Restrictions.Or( + Restrictions.And(Restrictions.Ge(AbsenceTime.PropertyName_Start, start), Restrictions.Le(AbsenceTime.PropertyName_Start, end)), + Restrictions.Eq(AbsenceTime.PropertyName_Start, start) + ), Restrictions.And(Restrictions.Le(AbsenceTime.PropertyName_Start, start), Restrictions.IsNull(AbsenceTime.PropertyName_End)) + ), Restrictions.And(Restrictions.Lt(AbsenceTime.PropertyName_Start, start), Restrictions.Gt(AbsenceTime.PropertyName_End, start))) + ); + + if (!pHasRightToSeeAllEmployeeAppointments) + { + criteria.Add(Restrictions.Eq(AbsenceTime.PropertyName_EmployeeOid, pEmployeeOid)); + } + + return criteria.List(); + } } } diff --git a/Data/Entities/AbsenceTime.cs b/Data/Entities/AbsenceTime.cs index 811560e33..640aedd37 100644 --- a/Data/Entities/AbsenceTime.cs +++ b/Data/Entities/AbsenceTime.cs @@ -2,7 +2,6 @@ using BS.Shared; using BS.Shared.Core; -using NHibernate.Mapping; namespace BeWo.Data.Entities { diff --git a/Data/Entities/SchedulerAppointment.cs b/Data/Entities/SchedulerAppointment.cs index b70d3cdcb..eb9df13f4 100644 --- a/Data/Entities/SchedulerAppointment.cs +++ b/Data/Entities/SchedulerAppointment.cs @@ -33,7 +33,7 @@ namespace BeWo.Data.Entities private bool _IsPrivate; private Employee _Originator; private long? _FormerBookingSequenceOid; - private string _Notice2; + private string _Notice2; private string _Notice3; private string _Notice4; private string _Notice5; @@ -65,7 +65,7 @@ namespace BeWo.Data.Entities _IsPrivate = value; } } - public virtual String Location { get; set; } + public virtual string Location { get; set; } public virtual Employee Originator { get { return _Originator; } @@ -75,8 +75,8 @@ namespace BeWo.Data.Entities _Originator = value; } } - public virtual String RecurrenceInfo { get; set; } - public virtual String ReminderInfo { get; set; } + public virtual string RecurrenceInfo { get; set; } + public virtual string ReminderInfo { get; set; } public virtual IList ResourceList { get { return _ResourceList ?? (_ResourceList = new List()); } @@ -99,7 +99,7 @@ namespace BeWo.Data.Entities } public virtual DateTime? StartDate { get; set; } public virtual int Status { get; set; } - public virtual String Subject { get; set; } + public virtual string Subject { get; set; } public virtual int Type { get; set; } public virtual long? FormerBookingSequenceOid diff --git a/Data/Entities/Team2Customer.cs b/Data/Entities/Team2Customer.cs index 5538d801b..b9ea4dfba 100644 --- a/Data/Entities/Team2Customer.cs +++ b/Data/Entities/Team2Customer.cs @@ -7,10 +7,10 @@ namespace BeWo.Data.Entities { public class Team2Customer : BeWoEntityBase { - public static string PropertyName_ValueList = "ValueList"; - public static string PropertyName_Customer = "Customer"; - public static string PropertyName_Team = "Team"; - public static string PropertyName_TeamOid = "TeamOid"; + public static string PropertyName_ValueList = "ValueList"; + public static string PropertyName_Customer = "Customer"; + public static string PropertyName_Team = "Team"; + public static string PropertyName_TeamOid = "TeamOid"; public static string PropertyName_CustomerOid = "CustomerOid"; private IList _ValueList; @@ -28,16 +28,9 @@ namespace BeWo.Data.Entities { if (base.AreDifferent(_Customer, value)) { - _Customer = value; + _Customer = value; - if (_Customer != null) - { - CustomerOid = _Customer.Oid; - } - else - { - CustomerOid = null; - } + CustomerOid = _Customer != null ? _Customer.Oid : null; } } } diff --git a/Service/ServiceContracts/IResourceService.cs b/Service/ServiceContracts/IResourceService.cs index 5e5fbaa50..a7375f1ea 100644 --- a/Service/ServiceContracts/IResourceService.cs +++ b/Service/ServiceContracts/IResourceService.cs @@ -168,5 +168,10 @@ namespace BeWo.Service.ServiceContracts [FaultContract(typeof(BeWoFault))] [OperationContract] List GetAllActiveAppointmentsForEmployeeInInterval2(DateTime start, DateTime end, long pEmployeeOid, bool pHasRightToSeeAllEmployeeAppointments); + + [FaultContract(typeof(BeWoFault))] + [OperationContract] + List GetAllActiveAbsenceTimesInInterval(DateTime pStart, DateTime pEnd, long pEmployeeOid, bool pHasRightToSeeAllEmployeeAppointments); + } } \ No newline at end of file diff --git a/Service/ServiceImplementations/EmployeeServiceImp.cs b/Service/ServiceImplementations/EmployeeServiceImp.cs index 7dab2da07..a0359adbe 100644 --- a/Service/ServiceImplementations/EmployeeServiceImp.cs +++ b/Service/ServiceImplementations/EmployeeServiceImp.cs @@ -420,11 +420,10 @@ namespace BeWo.Service.ServiceImplementations { return MapperFactory.CompactTeamDC_Team.MapToNewDCs(DAOFactory.GenericDAO.GetAllActive()); } + if (Utils.UserHasRight(LoggedInUserOperationContextExt.Current.User, UserRightType.TeamView_ViewMyTeams)) { - var teams = - DAOFactory.SearchDAO.FindAllActiveTeamsOfEmployee( - LoggedInUserOperationContextExt.Current.User.Employee.Oid.Value); + var teams = DAOFactory.SearchDAO.FindAllActiveTeamsOfEmployee(LoggedInUserOperationContextExt.Current.User.Employee.Oid.Value); return MapperFactory.CompactTeamDC_Team.MapToNewDCs(teams); } diff --git a/Service/ServiceImplementations/ResourceServiceImp.cs b/Service/ServiceImplementations/ResourceServiceImp.cs index 5e696d1e4..7dbcc6844 100644 --- a/Service/ServiceImplementations/ResourceServiceImp.cs +++ b/Service/ServiceImplementations/ResourceServiceImp.cs @@ -937,13 +937,13 @@ namespace BeWo.Service.ServiceImplementations return GetAllActiveAppointmentsForEmployeeInInterval2(start, end, pEmployeeOid, false); } - public List GetAllActiveAppointmentsForEmployeeInInterval2(DateTime start, DateTime end, long pEmployeeOid, bool pHasRightToSeeAllEmployeeAppointments) + public List GetAllActiveAppointmentsForEmployeeInInterval2(DateTime pStart, DateTime pEnd, long pEmployeeOid, bool pHasRightToSeeAllEmployeeAppointments) { try { var apps = pHasRightToSeeAllEmployeeAppointments ? - DAOFactory.SearchDAO.GetAllActiveAppointmentsInInterval(start, end) : - DAOFactory.SearchDAO.GetAllActiveAppointmentsForEmployeeInInterval(start, end, pEmployeeOid); + DAOFactory.SearchDAO.GetAllActiveAppointmentsInInterval(pStart, pEnd) : + DAOFactory.SearchDAO.GetAllActiveAppointmentsForEmployeeInInterval(pStart, pEnd, pEmployeeOid); return MapperFactory.SchedulerAppointmentDCSchedulerAppointment.MapToNewDCs(apps).OrderBy(a => a.StartDate).ToList(); } @@ -952,5 +952,20 @@ namespace BeWo.Service.ServiceImplementations throw Utils.CreateBeWoFaultException(e); } } + + public List GetAllActiveAbsenceTimesInInterval(DateTime pStart, DateTime pEnd, long pEmployeeOid, bool pHasRightToSeeAllEmployeeAppointments) + { + try + { + var absenceTimes = DAOFactory.SearchDAO.GetAllAbsenceTimesInIntervalByEmployee(pStart, pEnd, pEmployeeOid, + pHasRightToSeeAllEmployeeAppointments); + + return MapperFactory.AbsenceTimeDC_AbsenceTime.MapToNewDCs(absenceTimes).OrderBy(a => a.Start).ToList(); + } + catch(Exception e) + { + throw Utils.CreateBeWoFaultException(e); + } + } } } \ No newline at end of file