2019-08-09 16:52:55 +02:00
using System ;
using System.Collections.Generic ;
using System.ComponentModel ;
using System.Diagnostics ;
using System.Globalization ;
2019-08-15 11:06:50 +02:00
using System.IO ;
2019-08-09 16:52:55 +02:00
using System.Linq ;
2020-08-17 15:50:00 +02:00
using System.Net ;
2019-08-09 16:52:55 +02:00
using System.Runtime.CompilerServices ;
2020-05-12 14:20:58 +02:00
using System.Security ;
2019-08-09 16:52:55 +02:00
using System.Text ;
using System.Threading ;
using System.Windows ;
using System.Windows.Controls ;
using System.Windows.Controls.Primitives ;
using System.Windows.Data ;
using System.Windows.Documents ;
using System.Windows.Input ;
using System.Windows.Media ;
using System.Windows.Media.Imaging ;
using System.Windows.Navigation ;
using System.Windows.Threading ;
using BeWo.Core ;
using BeWo.ServiceProxy ;
using BeWo.View.Controls ;
using BeWo.View.Detail ;
using BeWo.ViewModel ;
using Blacklight.Wpf.Controls ;
using BS.Shared ;
using BS.Shared.DataContracts ;
using BS.Shared.DataContracts.Compact ;
using BS.Shared.Extensions ;
using BS.Shared.RSS ;
using System.Text.RegularExpressions ;
2019-08-15 11:06:50 +02:00
using System.Windows.Markup ;
using System.Xml ;
2019-08-09 16:52:55 +02:00
using BeWo.Annotations ;
using BeWo.ownChat ;
using BeWo.Scheduler.Utils ;
using BeWo.Scheduler.View ;
using BeWo.View.Master ;
using ChatController.HauptKlassen ;
2019-08-15 11:06:50 +02:00
using DevExpress.Data.Helpers ;
using DevExpress.Xpf.Docking.VisualElements ;
using DevExpress.Xpf.DocumentViewer ;
using DevExpress.Xpf.Printing ;
2019-08-09 16:52:55 +02:00
using DevExpress.XtraScheduler ;
using DevExpress.XtraScheduler.Xml ;
using Brushes = System . Windows . Media . Brushes ;
using Button = System . Windows . Controls . Button ;
using Color = System . Windows . Media . Color ;
using Control = System . Windows . Controls . Control ;
using Image = System . Windows . Controls . Image ;
using ListBox = System . Windows . Controls . ListBox ;
using MessageBox = System . Windows . MessageBox ;
using ScrollBar = System . Windows . Controls . Primitives . ScrollBar ;
namespace BeWo.View
{
/// <summary>
/// Interaction logic for HomeView.xaml
/// </summary>
public partial class HomeView : BeWoView , INotifyPropertyChanged
{
2019-08-13 13:02:03 +02:00
#region Constant Fields
2019-08-15 11:06:50 +02:00
2019-08-13 13:02:03 +02:00
private const int Datebuffer = 14 ;
#endregion
#region Fields
public NewSchedulerView PropertyScheduler ;
public ChatView ServiceChatView ;
public event PropertyChangedEventHandler PropertyChanged ;
protected bool PropertyChatBerechtigung ;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
private readonly Dictionary < string , bool > _NewsItemExpandedState = new Dictionary < string , bool > ( ) ;
private DateTime _BufferDate = DateTime . Today . AddDays ( - 1 * Datebuffer ) ;
private DateTime _CurrentDate = DateTime . Today ;
private List < SchedulerAppointmentDC > _AllSchedulerTasks ;
private List < CompactEmployeeDC > _EmployeesForAppointmentView ;
private CompactEmployeeDC _SelectedEmployeeForAppointments ;
2019-08-09 16:52:55 +02:00
private bool _IsAllowedToSeeMitarbeitertermine ;
2019-08-13 13:02:03 +02:00
private bool _IsShowingAppointments ;
private bool _HasRightsToSeeAppointments ;
2020-11-10 02:25:15 +01:00
private bool _LoadContentinLoadedEvent = false ;
2019-08-13 13:02:03 +02:00
#endregion
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
#region Constructors
2019-08-09 16:52:55 +02:00
public HomeView ( )
{
InitializeComponent ( ) ;
DataContext = this ;
2019-08-15 11:06:50 +02:00
txtHeader . Text = $"{BeWoApp.LoggedOnUser.Employee.FirstName} {BeWoApp.LoggedOnUser.Employee.LastName}" ;
2019-08-09 16:52:55 +02:00
txtVersion . Text = BeWoApp . Version ;
txtLoginTime . Text = string . Empty ;
txtLastLoginTime . Text = string . Empty ;
PasswortSchloss . Text = string . Join ( "" , ( from Match m in Regex . Matches ( "D83DDD12" , @"\S{4}" ) select ( char ) int . Parse ( m . Value , NumberStyles . HexNumber ) ) . ToArray ( ) ) ;
//PreparePanels();
2019-08-15 11:06:50 +02:00
2019-08-09 16:52:55 +02:00
HyperlinkZuPasswortsicherheit . NavigateUri = new Uri ( "http://news.bewoplaner.de/?NewsType=3&NewsCount=1&NewsOID=373457455" ) ;
2019-08-13 13:02:03 +02:00
2019-08-09 16:52:55 +02:00
#if DEBUG
//txtChangePassword.Visibility = Visibility.Visible;
2019-08-13 13:02:03 +02:00
2019-08-09 16:52:55 +02:00
#else
if ( BeWoApp . Tenant = = "demo" | | ! BeWoApp . LoggedOnUser . HasRight ( UserRightType . AllowChangeOwnPassword ) )
{
txtChangePassword . Visibility = Visibility . Collapsed ;
}
#endif
// FillInbox();
// FillOutbox();
2020-11-10 02:25:15 +01:00
_LoadContentinLoadedEvent = false ; // Nicht beim ersten Initialiseren ausführen, da der COntent sonst doppelt geladen wird
2019-08-09 16:52:55 +02:00
Loaded + = HomeDragPanelViewLoaded ;
/ * this . Dispatcher . BeginInvoke (
DispatcherPriority . Normal ,
( Action ) delegate
{
ConnectWithServer ( ) ;
if ( clientSocket . Connected )
MessageBox . Show ( "Verbindung geglückt." , "Info" , MessageBoxButton . OK , MessageBoxImage . Information ) ;
} ) ; * /
2020-11-10 02:25:15 +01:00
if ( BeWoApp . AppSettings . ShowOwnChat )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
var berechtigung = ServiceFacade . DoEmployeeServiceSync ( s = > s . GetAllChatActiveEmployeesCompact ( ) ) ;
if ( berechtigung ! = null )
{
foreach ( var list in berechtigung )
{
if ( list . PersonOid = = BeWoApp . LoggedOnUser . Employee . PersonOid )
{
PropertyChatBerechtigung = true ;
}
}
}
}
#if DEBUG
PropertyChatBerechtigung = true ;
#endif
BewoChat . Visibility = PropertyChatBerechtigung ? Visibility . Visible : Visibility . Hidden ;
PruefePasswortStaerke ( ) ;
2019-08-15 11:06:50 +02:00
2019-08-29 15:43:23 +02:00
//ServiceFacade.DoOperationsServiceAsync(s => s.GetHomeViewPanels(), r => Dispatcher?.Invoke(() => UpdatePanels(r)));
var panels = ServiceFacade . DoOperationsServiceSync ( s = > s . GetHomeViewPanels ( ) ) ;
UpdatePanels ( panels ) ;
2019-08-13 13:02:03 +02:00
}
#endregion
#region Finalizers
#endregion
#region Delegates
#endregion
#region Events
[NotifyPropertyChangedInvocator]
protected virtual void OnPropertyChanged ( [ CallerMemberName ] string propertyName = null )
{
PropertyChanged ? . Invoke ( this , new PropertyChangedEventArgs ( propertyName ) ) ;
}
private void HomeDragPanelViewLoaded ( object o , RoutedEventArgs e )
{
2020-11-10 02:25:15 +01:00
2019-08-29 15:43:23 +02:00
SetMaximizedPanel ( ) ;
2020-11-10 02:25:15 +01:00
if ( _LoadContentinLoadedEvent )
{
LoadContent ( ) ;
}
_LoadContentinLoadedEvent = true ;
2019-08-13 13:02:03 +02:00
//Warum klappt das bei Köln Ring nicht?=
if ( BeWoApp . LoggedOnUser = = null | | BeWoApp . LoggedOnUser . ResetPasswordInfos = = null )
{
return ;
}
if ( ! BeWoApp . LoggedOnUser . ResetPasswordInfos . Any ( a = > a . HasToChangePW ) )
{
return ;
}
var fenster = new PasswortAenderungsView { AbbrechenButton = { IsEnabled = false } } ;
fenster . CommandBindings . Clear ( ) ;
fenster . ShowDialog ( ) ;
}
private void ButtonOpenServiceRecordView_Click ( object sender , RoutedEventArgs e )
{
if ( sender is Button btn & & btn . Tag is CompactSupportConceptDC dc )
{
BeWoApp . MainControl . NavigateToServiceRecordView ( dc . SupportConceptOid ) ;
}
}
private void RadioButton_Checked ( object sender , RoutedEventArgs e )
{
if ( _AllSchedulerTasks ! = null )
{
var controlName = ( ( Control ) e . OriginalSource ) . Name ;
switch ( controlName )
{
case "rb_all" :
_IsShowingAppointments = false ;
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( w = > w . IsTask ) . OrderBy ( i = > i . CompletedDate ? ? i . DueDate ) . ToList ( ) ;
ShowAppointments ( false ) ;
break ;
case "rb_open" :
_IsShowingAppointments = false ;
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( i = > ! i . CompletedDate . HasValue & & i . IsTask ) . OrderBy ( i = > i . DueDate ) . ToList ( ) ;
ShowAppointments ( false ) ;
break ;
case "rb_closed" :
_IsShowingAppointments = false ;
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( i = > i . CompletedDate . HasValue & & i . IsTask ) . OrderByDescending ( i = > i . CompletedDate ) . ToList ( ) ;
ShowAppointments ( false ) ;
break ;
case "rb_appointments" :
_IsShowingAppointments = true ;
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( i = > ! i . IsTask ) . OrderByDescending ( i = > i . EndDate ) . ToList ( ) ;
ShowAppointments ( true ) ;
break ;
}
}
}
public void TimeIntervalBackButtonOnClick ( object sender , EventArgs args )
{
CurrentDate = CurrentDate . AddDays ( - 1 ) ;
UpdateAppointmentDateTextBlock ( _CurrentDate ) ;
}
public void TimeIntervalForwardsButtonOnClick ( object sender , EventArgs args )
{
CurrentDate = CurrentDate . AddDays ( 1 ) ;
UpdateAppointmentDateTextBlock ( _CurrentDate ) ;
}
private void listboxSupportConcepts_MouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
if ( ! IsPartOf ( e . OriginalSource , typeof ( ScrollBar ) ) )
{
var sc = ( ( ListBox ) sender ) . SelectedItem as CompactSupportConceptDC ;
if ( sc ! = null & &
( BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_ViewAllSupportConcepts ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConceptView_View ) ) )
{
VMFactory . CreateSupportConceptVMAsync (
sc . SupportConceptOid ,
cb = > this . Dispatch (
delegate
{
MainControl . NavigateTo ( new SupportConceptView ( cb ) { ParentView = this } ) ;
//new SupportConceptView2(cb)
// {
// ParentView = this
// });
} ) ) ;
}
}
}
private void listboxTasks_MouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
if ( ! IsPartOf ( e . OriginalSource , typeof ( ScrollBar ) ) )
{
if ( ( ( ListBox ) sender ) . SelectedItem is SchedulerAppointmentDC sc & & sc . IsTask & & sc . SupportConceptList . Count = = 1 & &
( BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConcept_ViewAllSupportConcepts ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . SupportConceptView_View ) ) )
{
VMFactory . CreateSupportConceptVMAsync (
sc . SupportConceptList . First ( ) . SupportConceptOid ,
cb = > this . Dispatch (
delegate
{
MainControl . NavigateTo (
new SupportConceptView ( cb , sc )
{
ParentView = this
} ) ;
//new SupportConceptView2(cb)
//{
// ParentView = this
//});
} ) ) ;
}
else if ( ( ( ListBox ) sender ) . SelectedItem is SchedulerAppointmentDC sc2 & & ! sc2 . IsTask & &
( BeWoApp . LoggedOnUser . HasRight ( UserRightType . KalenderAnsehen ) | |
BeWoApp . LoggedOnUser . HasRight ( UserRightType . ViewAll ) ) & & sc2 . StartDate . HasValue )
{
MainControl . NavigateTo ( new SchedulerMasterView ( sc2 . StartDate . Value , sc2 ) { ParentView = this } ) ;
}
}
}
private void Hyperlink_OnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
Process . Start ( new ProcessStartInfo ( ( sender as Hyperlink ) . NavigateUri . ToString ( ) ) ) ;
}
2019-08-15 11:06:50 +02:00
2019-08-13 13:02:03 +02:00
private void PasswortAendernLinkOnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
var pav = new PasswortAenderungsView ( ) ;
pav . ShowDialog ( ) ;
}
private void LinkNewDatenschutz_OnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
Process . Start ( new ProcessStartInfo ( ( sender as Hyperlink ) ? . NavigateUri . ToString ( ) ) ) ;
}
2019-08-15 11:06:50 +02:00
2019-08-13 13:02:03 +02:00
private void BtnCreateNewsItem_OnClick ( object sender , RoutedEventArgs e )
{
TeamNewsItemVM teamVm = ( ( Button ) sender ) . Tag as TeamNewsItemVM ;
if ( teamVm ! = null )
{
NewsItemDC dc = new NewsItemDC ( ) ;
dc . PublishDate = DateTime . Now ;
dc . Team = teamVm . Team ;
NewsItemVM vm = new NewsItemVM ( dc ) ;
var ctrl = new NewsItemEditControl ( vm ) ;
BeWoWindow window = BeWoWpfUtils . CreateBeWoPopupWindow ( 400 , 500 ) ;
window . GroupBoxContent = ctrl ;
window . Height = 400 ;
window . Owner = BeWoApp . CurrentBeWo . MainWindow ;
//ThemeManager.SetTheme(window, Theme.Office2010Black);
ctrl . CancelButtonClicked + = window . Close ;
ctrl . OkButtonClicked + = ( ) = >
{
SaveNewsItem ( vm ) ;
window . Close ( ) ;
} ;
window . rootGroupBox . Header = "Neuer Eintrag" ;
window . Title = "Neuer Eintrag" ;
window . Show ( ) ;
}
}
private void BtnEditNewsItem_OnClick ( object sender , RoutedEventArgs e )
{
NewsItemDC dc = ( ( Button ) sender ) . Tag as NewsItemDC ;
if ( dc ! = null )
{
NewsItemVM vm = new NewsItemVM ( dc ) ;
var ctrl = new NewsItemEditControl ( vm ) ;
BeWoWindow window = BeWoWpfUtils . CreateBeWoPopupWindow ( 400 , 500 ) ;
window . GroupBoxContent = ctrl ;
window . Height = 400 ;
window . Owner = BeWoApp . CurrentBeWo . MainWindow ;
//ThemeManager.SetTheme(window, Theme.Office2010Black);
ctrl . CancelButtonClicked + = window . Close ;
ctrl . OkButtonClicked + = ( ) = >
{
UpdateNewsItem ( vm ) ;
window . Close ( ) ;
} ;
window . rootGroupBox . Header = "Eintrag bearbeiten" ;
window . Title = "Eintrag bearbeiten" ;
window . Show ( ) ;
}
}
private void BtnDeleteNewsItem_OnClick ( object sender , RoutedEventArgs e )
{
NewsItemDC dc = ( ( Button ) sender ) . Tag as NewsItemDC ;
if ( dc ! = null )
{
if ( MessageBox . Show ( "Wollen Sie den Eintrag '" + dc . Title + "' wirklich löschen?" , "Löschen bestätigen" ,
MessageBoxButton . YesNo , MessageBoxImage . Question ) = = MessageBoxResult . Yes )
{
ServiceFacade . DoEmployeeServiceSync (
s = > s . DeleteNewsItem ( dc . NewsItemOid . Value , dc . NewsItemVersion . Value ) ) ;
UpdateInternalNews ( ) ;
}
}
}
2021-03-30 10:58:50 +02:00
private void OpenServiceRecordEditViewTest ( )
2019-08-13 13:02:03 +02:00
{
2021-03-30 10:58:50 +02:00
long oid = 655 ;
var compactCustomer = ServiceFacade . DoCustomerServiceSync ( s = > s . GetCompactCustomerDC ( oid ) ) ;
var stringBuilder = new StringBuilder ( ) ;
stringBuilder . Append ( "TEST" ) ;
var utf8 = Encoding . UTF8 ;
var encodedBytes = utf8 . GetBytes ( stringBuilder . ToString ( ) ) ;
var convertedBytes = Encoding . Convert ( Encoding . UTF8 , Encoding . ASCII , encodedBytes ) ;
var ascii = Encoding . ASCII ;
var finalString = ascii . GetString ( convertedBytes ) ;
var firstTime = DateTime . Now ;
var lastTime = DateTime . Now ;
BeWo . Core . Service . Cache . GetInstance ( ) . GetActiveSupportConceptCostbearer ( scList = >
VMFactory . CreateServiceRecordVMAsync (
BeWoApp . LoggedOnUser . Employee . EmployeeOid ,
vm = > this . Dispatch (
delegate
{
vm . DispatcherObject = this ;
var dc = BeWo . Core . Service . SupportConceptService . ErstelleServiceRecordDC ( firstTime , lastTime , compactCustomer , scList ) ;
if ( vm . PrototypeVM . SortedCategories ! = null & & vm . PrototypeVM . SortedCategories . Count > 0 )
{
var cat1 = vm . PrototypeVM . SortedCategories [ 0 ] ;
dc . ServiceDescription = vm . PrototypeVM . Category2Services [ cat1 ] [ 0 ] ;
}
var serviceRecord = new ServiceRecordVM ( dc , vm . PrototypeVM . Category2Services , vm . PrototypeVM . AllGoalCategories , vm . PrototypeVM . AllGoals )
{
Notice = finalString
} ;
if ( serviceRecord . SupportConcept = = null )
{
return ;
}
serviceRecord . SetInsertedOn ( DateTime . Now ) ;
var newView = new ChatDokumentationsView ( vm , serviceRecord ) ;
newView . ShowDialog ( ) ;
} ) ) ) ;
2019-08-13 13:02:03 +02:00
2021-03-30 10:58:50 +02:00
}
private void HyperlinkChat_OnRequestNavigate ( object sender , RequestNavigateEventArgs e )
{
#if DEBUG
//OpenServiceRecordEditViewTest();
//return;
2021-05-24 21:40:02 +02:00
var kundennummer = "5473568546" ;
//var apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97";
Login _login = new Login ( kundennummer , "kihqx-PiGka" , "cb" , "bewo" , "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97" ) ;
var x1 = _login . AnmeldevorgangDurchFuehren ( ) ;
2019-08-13 13:02:03 +02:00
2021-05-24 21:40:02 +02:00
ServiceChatView = new ChatView ( x1 ) ;
ServiceChatView . Show ( ) ;
2019-08-13 13:02:03 +02:00
2021-05-24 21:40:02 +02:00
return ;
2019-08-13 13:02:03 +02:00
2021-05-24 21:40:02 +02:00
#endif
2019-08-13 13:02:03 +02:00
2021-03-30 10:58:50 +02:00
if ( ServiceChatView ? . Visibility ! = Visibility . Visible )
2019-08-13 13:02:03 +02:00
{
#if DEBUG
2020-05-12 14:20:58 +02:00
if ( true )
2019-08-13 13:02:03 +02:00
{
2021-03-17 18:44:40 +01:00
string _Code = "ZMCKb-BckTt" ;
string _kundennummer = "4368658436" ;
string _benutzername = "muellerp" ;
string _passwort = "F5aTk9Co47JFJCWB2Z7Y" ;
2020-05-12 14:20:58 +02:00
string _apikey ;
2021-05-24 21:40:02 +02:00
2019-08-13 13:02:03 +02:00
#else
2020-05-12 14:20:58 +02:00
var empAppCodes = ServiceFacade . DoEmployeeServiceSync ( r = > r . GetAllEmployeeAppCodes ( BeWoApp . LoggedOnUser . Employee . EmployeeOid ) ) ;
2019-08-13 13:02:03 +02:00
2020-05-12 14:20:58 +02:00
if ( empAppCodes ! = null & & empAppCodes . Count > 0 )
2019-08-13 13:02:03 +02:00
{
string _Code = "" ;
2020-05-12 14:20:58 +02:00
foreach ( var item in empAppCodes )
2019-08-13 13:02:03 +02:00
{
if ( item . EmployeeCode ! = null & & ! item . EmployeeCode . Equals ( "" ) )
_Code = item . EmployeeCode ;
}
//var xxx = empAppCodes.Last();
string _kundennummer = BeWoApp . Tenant ;
string _benutzername = BeWoApp . UserName ;
string _passwort = BeWoApp . UserPassword ;
string _apikey ;
#endif
//string _ChatCode = "";
//if (xxx.EmployeeCode != null && !xxx.EmployeeCode.Equals(""))
//{
// _ChatCode = xxx.EmployeeCode;
//}
2020-05-12 14:20:58 +02:00
_apikey = BeWoApp . Mandator . Apikey ? ? "0000" ;
2019-08-13 13:02:03 +02:00
2020-05-12 14:20:58 +02:00
if ( ! _Code . Equals ( "" ) )
2019-08-13 13:02:03 +02:00
{
2020-05-12 14:20:58 +02:00
var login = new Login ( _kundennummer , _Code , _benutzername , _passwort , _apikey ) ;
2019-08-13 13:02:03 +02:00
2020-04-08 14:44:20 +02:00
var x = login . AnmeldevorgangDurchFuehren ( ) ;
2019-08-13 13:02:03 +02:00
2020-04-08 14:44:20 +02:00
if ( x ! = null )
{
ServiceChatView = new ChatView ( x ) ;
2020-06-17 19:31:17 +02:00
ServiceChatView . Closed + = ServiceChatViewClosed ;
2020-04-08 14:44:20 +02:00
ServiceChatView . Show ( ) ;
}
2019-08-13 13:02:03 +02:00
}
else
{
MessageBox . Show ( "Sie benötigen einen gültigen Chat-Code." , "Info" ) ;
}
}
else
{
MessageBox . Show ( "Sie benötigen einen gültigen Zugang zum Chat. Bitte wenden Sie sich an den Support." , "Info" ) ;
}
}
//else if (ServiceChatView.Visibility == Visibility.Visible)
//{
// ServiceChatView.Visibility = Visibility.Hidden;
//}
//else if (ServiceChatView.Visibility == Visibility.Hidden)
//{
// ServiceChatView.Visibility = Visibility.Visible;
// if (ServiceChatView.WindowState == WindowState.Minimized)
// {
// ServiceChatView.WindowState = WindowState.Normal;
// ServiceChatView.Height = 700;
// ServiceChatView.Width = 900;
// }
// ServiceChatView.Activate();
//}
//#endif
}
2020-06-17 19:31:17 +02:00
private void ServiceChatViewClosed ( object sender , EventArgs e )
{
ServiceChatView = null ;
}
2019-08-13 13:02:03 +02:00
private void ShowAppointmentRequests ( object sender , RequestNavigateEventArgs e )
{
PropertyScheduler . ShowAppointmentRequests ( sender , e ) ;
}
private void EmployeeFilterBox_OnSelectionChanged ( object sender , SelectionChangedEventArgs e )
{
if ( e ? . AddedItems ? . Count > 0 & & _IsShowingAppointments )
{
_SelectedEmployeeForAppointments = ( CompactEmployeeDC ) e . AddedItems [ 0 ] ;
LoadTasksAndAppointments ( false , true ) ;
}
}
private void CreateTestAppointmentsButtonOnClick ( object sender , RoutedEventArgs e )
{
ServiceFacade . DoResourceServiceAsync ( s = >
{
if ( BeWoApp . LoggedOnEmployeeOid ! = null )
{
s . InsertTestAppointments ( BeWoApp . LoggedOnEmployeeOid . Value ) ;
this . Dispatch ( ( ) = >
{
LoadTasksAndAppointments ( false , true ) ;
} ) ;
}
} ) ;
}
private void DeleteTestAppointmentsButtonOnClick ( object sender , RoutedEventArgs e )
{
ServiceFacade . DoResourceServiceAsync ( s = >
{
if ( BeWoApp . LoggedOnEmployeeOid ! = null )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
s . DeleteTestAppointments ( ) ;
this . Dispatch ( ( ) = >
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
LoadTasksAndAppointments ( false , true ) ;
} ) ;
2019-08-09 16:52:55 +02:00
}
2019-08-13 13:02:03 +02:00
} ) ;
}
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#endregion
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#region InterfacesImplementations
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#endregion
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#region Properties
2019-08-09 16:52:55 +02:00
public List < CompactEmployeeDC > EmployeesForAppointmentView
{
get = > _EmployeesForAppointmentView ? ? ( _EmployeesForAppointmentView = new List < CompactEmployeeDC > ( ) ) ;
set
{
_EmployeesForAppointmentView = value ;
OnPropertyChanged ( nameof ( EmployeesForAppointmentView ) ) ;
}
}
2019-08-13 13:02:03 +02:00
public DateTime CurrentDate
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
get = > _CurrentDate ;
set
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
if ( ! Equals ( _CurrentDate , value ) )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
_CurrentDate = value ;
UpdateAppointmentDateTextBlock ( value ) ;
OnPropertyChanged ( nameof ( CurrentDate ) ) ;
}
2019-08-09 16:52:55 +02:00
}
}
2021-03-30 10:58:50 +02:00
#endregion
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#region Indexers
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#endregion
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#region Methods
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
public void UpdateRequestsHyperLink ( )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
if ( PropertyScheduler ! = null )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
PropertyScheduler . UpdateRequestString ( ) ;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
RequestsHyperLinkTextBlock . Text = PropertyScheduler . Requests ;
RequestsHyperlink . IsEnabled = PropertyScheduler . Enabled ;
RequestsTextBlock . IsEnabled = PropertyScheduler . Enabled ;
2019-08-09 16:52:55 +02:00
}
}
public void SaveState ( )
{
var order = new List < DragDockPanel > ( ) ;
DragDockPanel panelWithMaxHeight = null ;
double maxHeight = 0 ;
double normalHeight = 0 ;
var result = new List < DependencyObject > ( ) ;
2019-08-15 11:06:50 +02:00
foreach ( var item in PanelHost . Children )
2019-08-09 16:52:55 +02:00
{
var p = item as DragDockPanel ;
if ( order . Count = = 0 )
{
order . Add ( p ) ;
}
else
{
2019-08-13 13:02:03 +02:00
var newIndex = - 1 ;
var index = 0 ;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
var rect = VisualTreeHelper . GetOffset ( p ) ;
foreach ( var item2 in order )
2019-08-09 16:52:55 +02:00
{
string name1 = p . Name ;
string name2 = item2 . Name ;
2019-08-13 13:02:03 +02:00
var rect2 = VisualTreeHelper . GetOffset ( item2 ) ;
2019-08-09 16:52:55 +02:00
if ( rect . Y < rect2 . Y )
{
newIndex = index ;
continue ;
}
if ( Equals ( rect . Y , rect2 . Y ) & & rect . X < rect2 . X )
{
newIndex = index ;
continue ;
}
index + + ;
}
if ( newIndex < 0 )
{
order . Add ( p ) ;
}
else
{
order . Insert ( newIndex , p ) ;
}
}
if ( p . Height > maxHeight )
{
maxHeight = p . ActualHeight ;
panelWithMaxHeight = p ;
}
else
{
normalHeight = p . ActualHeight ;
}
}
if ( ( maxHeight - normalHeight ) > 1 & & panelWithMaxHeight ! = null )
{
BeWoApp . AppSettings . StartupPanelMaximized = panelWithMaxHeight . Name ;
}
else
{
BeWoApp . AppSettings . StartupPanelMaximized = null ;
}
2019-08-13 13:02:03 +02:00
var panelOrder = order . Select ( item = > item . Name ) . ToList ( ) ;
2019-08-09 16:52:55 +02:00
BeWoApp . AppSettings . StartupPanelOrder = panelOrder ;
}
2019-08-13 13:02:03 +02:00
private static bool IsPartOf ( object p , Type type )
{
if ( p is FrameworkElement fe )
{
if ( fe . GetType ( ) = = type )
return true ;
return IsPartOf ( fe . TemplatedParent , type ) ;
}
return false ;
}
private void PruefePasswortStaerke ( )
2019-08-09 16:52:55 +02:00
{
2019-08-15 11:06:50 +02:00
switch ( BeWoApp . PasswortStrength )
2019-08-13 13:02:03 +02:00
{
2019-08-15 11:06:50 +02:00
case PasswortSecurityStrength . SehrSchwach :
PasswortSchloss . Foreground = new SolidColorBrush ( Colors . Red ) ;
2019-08-13 13:02:03 +02:00
2019-08-15 11:06:50 +02:00
this . Dispatcher . BeginInvoke (
DispatcherPriority . Normal ,
( Action ) delegate
{
if ( BeWoApp . AppSettings . IsPasswordSecurityActiv )
{
MessageBox . Show ( "Sie benutzen ein sehr schwaches Passwort.\nBitte ändern Sie Ihr Passwort, indem Sie im Startbildschirm oben auf \"Passwort ändern\" klicken." , "Achtung!" ,
MessageBoxButton . OK , MessageBoxImage . Information ) ;
}
} ) ;
break ;
case PasswortSecurityStrength . Schwach :
PasswortSchloss . Foreground = new SolidColorBrush ( Colors . OrangeRed ) ;
2019-08-09 16:52:55 +02:00
2019-08-15 11:06:50 +02:00
this . Dispatcher . BeginInvoke (
DispatcherPriority . Normal ,
( Action ) delegate
{
if ( BeWoApp . AppSettings . IsPasswordSecurityActiv )
{
MessageBox . Show ( "Sie benutzen ein schwaches Passwort.\nBitte ändern Sie Ihr Passwort, indem Sie im Startbildschirm oben auf \"Passwort ändern\" klicken." , "Achtung!" ,
MessageBoxButton . OK , MessageBoxImage . Information ) ;
}
} ) ;
break ;
case PasswortSecurityStrength . Mittelmass :
PasswortSchloss . Foreground = new SolidColorBrush ( Colors . Yellow ) ;
break ;
case PasswortSecurityStrength . Stark :
case PasswortSecurityStrength . SehrStark :
PasswortSchloss . Foreground = new SolidColorBrush ( Colors . Green ) ;
break ;
default :
throw new ArgumentOutOfRangeException ( ) ;
2019-08-09 16:52:55 +02:00
}
2019-08-13 13:02:03 +02:00
}
private void InitPanelsCallback ( IList < UiElementDC > elements , object state )
{
Dispatcher ? . BeginInvoke ( DispatcherPriority . Normal ,
( Action ) delegate { InitPanels ( elements ) ; } ) ;
}
private void InitPanels ( IList < UiElementDC > elements )
{
listboxExpiringSupportConcepts . Items . Clear ( ) ;
listboxConferenceDates . Items . Clear ( ) ;
listboxBirthdays . Items . Clear ( ) ;
listboxNews . Items . Clear ( ) ;
listboxTasks . Items . Clear ( ) ;
//ListboxInternalNews.Items.Clear();
InternalNewsGrid . Children . Clear ( ) ;
2019-08-15 11:06:50 +02:00
2019-08-29 15:43:23 +02:00
LoadContent ( ) ;
2019-08-09 16:52:55 +02:00
}
2019-08-29 15:43:23 +02:00
private void LoadBewoNews ( )
2019-08-09 16:52:55 +02:00
{
try
{
if ( BeWoApp . Tenant ! = "demo" )
{
LoadFeed ( ) ;
//LoadFeed("http://www.heise.de/foto/rss/news-atom.xml");
}
}
catch ( Exception )
{
2019-08-13 13:02:03 +02:00
// ignored
2019-08-09 16:52:55 +02:00
}
}
2019-08-29 15:43:23 +02:00
private void LoadBirthdays ( )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
var endOfWeek = DateTime . Now . GetNext ( DayOfWeek . Sunday ) . Date ;
2019-08-09 16:52:55 +02:00
endOfWeek = endOfWeek . AddDays ( 1 ) . GetNext ( DayOfWeek . Sunday ) . Date ;
2019-08-29 15:43:23 +02:00
ServiceFacade . DoAnalysisServiceAsync ( s1 = > s1 . GetPersonsHavingBirthday ( endOfWeek ) , ReloadBirthdays , false ) ;
2019-08-09 16:52:55 +02:00
}
2019-08-29 15:43:23 +02:00
private void LoadContent ( )
2019-08-09 16:52:55 +02:00
{
2019-08-29 15:43:23 +02:00
LoadLoginInfo ( ) ;
2019-08-15 11:06:50 +02:00
2019-08-29 15:43:23 +02:00
if ( IsPanelVisible ( "PanelTasks" ) )
{
LoadTasks ( ) ;
}
2019-08-15 11:06:50 +02:00
2019-08-29 15:43:23 +02:00
if ( IsPanelVisible ( "PanelExpiringSupportConcepts" ) )
{
LoadExpiredSupportConcepts ( ) ;
}
if ( IsPanelVisible ( "PanelConferenceDates" ) )
{
LoadNextConferenceDates ( ) ;
}
if ( IsPanelVisible ( "PanelBirthdates" ) )
{
LoadBirthdays ( ) ;
}
if ( IsPanelVisible ( "PanelInternalNews" ) )
{
UpdateInternalNews ( ) ;
}
if ( IsPanelVisible ( "PanelBeWoNews" ) )
{
LoadBewoNews ( ) ;
}
2019-08-15 11:06:50 +02:00
rb_open . IsChecked = true ;
2019-08-09 16:52:55 +02:00
}
2019-08-29 15:43:23 +02:00
private bool IsPanelVisible ( string test )
{
foreach ( DragDockPanel panel in PanelHost . Children )
{
if ( panel . Name = = test )
{
return true ;
}
}
return true ;
}
private void LoadExpiredSupportConcepts ( )
2019-08-09 16:52:55 +02:00
{
// DateTime endOfWeek = DateTime.Now.GetNext(DayOfWeek.Sunday).Date;
// DateTime endOfWeek2 = endOfWeek.AddDays(8);
2019-08-13 13:02:03 +02:00
var dt = DateTime . Now . AddMonths ( BeWoApp . AppSettings . HilfeplanAuslaufAuswahl ) ;
2019-08-09 16:52:55 +02:00
ServiceFacade . DoAnalysisServiceAsync (
s1 = > s1 . GetExpiringSupportConcepts ( BeWoApp . LoggedOnUser . Employee . EmployeeOid , dt ) ,
2019-08-29 15:43:23 +02:00
ReloadExpiringSupportConcepts , false ) ;
2019-08-09 16:52:55 +02:00
}
2019-08-29 15:43:23 +02:00
private void LoadLoginInfo ( )
2019-08-15 11:06:50 +02:00
{
DateTime endOfWeek = DateTime . Now . GetNext ( DayOfWeek . Sunday ) . Date ;
2019-08-29 15:43:23 +02:00
ServiceFacade . DoAnalysisServiceAsync ( s1 = > s1 . GetLastLogins ( BeWoApp . LoggedOnUser . LoginName ) , ReloadLogins , false ) ;
2019-08-15 11:06:50 +02:00
}
2019-08-29 15:43:23 +02:00
private void LoadNextConferenceDates ( )
2019-08-15 11:06:50 +02:00
{
DateTime endOfWeek = DateTime . Now . GetNext ( DayOfWeek . Sunday ) . Date ;
DateTime endOfWeek2 = endOfWeek . AddDays ( 8 ) ;
ServiceFacade . DoAnalysisServiceAsync (
s1 = > s1 . GetSupportConceptsWithConferenceDate ( BeWoApp . LoggedOnUser . Employee . EmployeeOid , endOfWeek2 ) ,
2019-08-29 15:43:23 +02:00
ReloadConferenceDates , false ) ;
2019-08-15 11:06:50 +02:00
}
2019-08-29 15:43:23 +02:00
private void LoadTasks ( )
2019-08-15 11:06:50 +02:00
{
var test = 0 ;
while ( BeWoApp . LoggedOnEmployee = = null & & test < 50 )
{
Thread . Sleep ( 100 ) ;
test + + ;
}
if ( BeWoApp . LoggedOnEmployee ! = null )
{
var rights = new List < UserRightType > { UserRightType . KalenderAnsehen } ;
_HasRightsToSeeAppointments = BeWoUtils . HasRight ( UserRightType . KalenderAnsehen ) | | BeWoUtils . HasRight ( UserRightType . ViewAll ) ;
var r2 = rights ;
r2 . Add ( UserRightType . KalenderMitarbeitertermineAnsehen ) ;
var r3 = rights ;
r3 . Add ( UserRightType . KalenderKliententermineAlleAnsehen ) ;
var r5 = rights ;
r5 . Add ( UserRightType . KalenderRessourcentermineAnsehen ) ;
_IsAllowedToSeeMitarbeitertermine = r2 . All ( BeWoUtils . HasRight ) | | BeWoUtils . HasRight ( UserRightType . ViewAll ) ;
_IsAllowedToSeeCustomerAppointments = r3 . All ( BeWoUtils . HasRight ) | | BeWoUtils . HasRight ( UserRightType . ViewAll ) ;
_IsAllowedToSeeResourceAppointments = r5 . All ( BeWoUtils . HasRight ) | | BeWoUtils . HasRight ( UserRightType . ViewAll ) ;
if ( _HasRightsToSeeAppointments & & _IsAllowedToSeeMitarbeitertermine )
{
#if DEBUG
TestTermineAnlegenButton . Visibility = Visibility . Visible ;
TestTermineLoeschenButton . Visibility = Visibility . Visible ;
#endif
employeeFilterBox . Visibility = Visibility . Visible ;
ServiceFacade . DoEmployeeServiceAsync ( s = > s . GetAllActiveEmployeesCompact ( ) , cb = >
{
this . Dispatch ( delegate
{
EmployeesForAppointmentView = cb . OrderBy ( o = > o . LastName + ", " + o . FirstName ) . ToList ( ) ;
employeeFilterBox . SelectedItem = BeWoApp . CompactLoggedOnEmployee ;
} ) ;
2019-08-29 15:43:23 +02:00
} , false ) ;
2019-08-15 11:06:50 +02:00
}
else
{
EmployeesForAppointmentView = new List < CompactEmployeeDC > { BeWoApp . CompactLoggedOnEmployee } ;
employeeFilterBox . SelectedItem = BeWoApp . CompactLoggedOnEmployee ;
}
ShowAppointments ( false ) ;
LoadTasksAndAppointments ( true , true ) ;
}
}
2019-08-09 16:52:55 +02:00
private void UpdateInternalNews ( )
{
if ( InternalNewsGrid ! = null )
{
2019-08-13 13:02:03 +02:00
_NewsItemExpandedState . Clear ( ) ;
2019-08-09 16:52:55 +02:00
foreach ( var child in InternalNewsGrid . Children )
{
var rootsp = child as StackPanel ;
if ( rootsp ! = null & & rootsp . Children . Count > 0 )
{
foreach ( var child2 in rootsp . Children )
{
var ex = child2 as Expander ;
if ( ex ! = null )
{
var grid = ex . Header as Grid ;
String text = "" ;
if ( grid ! = null )
{
foreach ( var gridChild in grid . Children )
{
if ( gridChild is TextBlock )
{
var tb = gridChild as TextBlock ;
text = tb . Text ;
}
}
}
2019-08-13 13:02:03 +02:00
if ( ! _NewsItemExpandedState . ContainsKey ( text ) )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
_NewsItemExpandedState . Add ( text , ex . IsExpanded ) ;
2019-08-09 16:52:55 +02:00
}
}
}
}
}
}
var showTeamNews = BeWoApp . AppSettings . ShowTeamNews ;
//ServiceFacade.DoEmployeeServiceAsync(s => s.GetPublishedNewsItems(), cb => this.Dispatch(delegate { listboxInternalNews.ItemsSource = cb.OrderByDescending(i => i.PublishDate).ToList(); }));
ServiceFacade . DoEmployeeServiceAsync (
s = > s . GetPublishedNewsItemsForEmployee ( BeWoApp . LoggedOnUser . Employee . EmployeeOid , showTeamNews ) ,
2019-08-29 15:43:23 +02:00
RefreshInternalNews , false ) ;
2019-08-09 16:52:55 +02:00
}
2019-08-15 11:06:50 +02:00
private void UpdatePanels ( List < HomeViewPanelDC > panels )
{
2019-08-29 15:43:23 +02:00
if ( panels ! = null & & panels . Count > 0 )
{
PanelHost . Children . Clear ( ) ;
2019-08-15 11:06:50 +02:00
2019-08-29 15:43:23 +02:00
var dict = new Dictionary < HomeViewPanelType , DragDockPanel > ( )
2019-08-15 11:06:50 +02:00
{
{ HomeViewPanelType . BeWoNewsPanel , PanelBeWoNews } ,
{ HomeViewPanelType . BirthdatesPanel , PanelBirthdates } ,
{ HomeViewPanelType . ConferenceDatesPanel , PanelConferenceDates } ,
{ HomeViewPanelType . ExpiringSupportConceptsPanel , PanelExpiringSupportConcepts } ,
{ HomeViewPanelType . InternalNewsPanel , PanelInternalNews } ,
{ HomeViewPanelType . TasksPanel , PanelTasks }
} ;
2019-08-29 15:43:23 +02:00
//panels.Add(new HomeViewPanelDC { HeaderTitel = "TestTask", PanelType = HomeViewPanelType.TasksPanel });
//panels.Add(new HomeViewPanelDC { HeaderTitel = "TestNews", PanelType = HomeViewPanelType.BeWoNewsPanel });
//panels.Add(new HomeViewPanelDC { HeaderTitel = "TestDates", PanelType = HomeViewPanelType.ExpiringSupportConceptsPanel });
//panels.Add(new HomeViewPanelDC { HeaderTitel = "Test", PanelType = HomeViewPanelType.TasksPanel });
2019-08-15 11:06:50 +02:00
2019-08-29 15:43:23 +02:00
var save = BeWoApp . AppSettings . StartupPanelOrder ;
if ( save = = null | | save . Count ! = panels . Count )
2019-08-15 11:06:50 +02:00
{
2019-08-29 15:43:23 +02:00
save = panels . Select ( p = > GetDefaultPanelName ( p ) ) . ToList ( ) ;
}
2019-08-15 11:06:50 +02:00
2019-08-29 15:43:23 +02:00
foreach ( var name in save )
{
foreach ( var panelDC in panels )
2019-08-15 11:06:50 +02:00
{
2019-08-29 15:43:23 +02:00
if ( GetDefaultPanelName ( panelDC ) = = name )
2019-08-15 11:06:50 +02:00
{
2019-08-29 15:43:23 +02:00
if ( dict . ContainsKey ( panelDC . PanelType ) )
{
var panel = dict [ panelDC . PanelType ] ;
PanelHost . Children . Add ( panel ) ;
if ( String . IsNullOrEmpty ( panelDC . HeaderTitel ) ) continue ;
foreach ( var child in ( ( StackPanel ) panel . Header ) . Children )
{
if ( child is TextBlock textBlock & & ( string ) textBlock . Tag = = "Titel" )
{
textBlock . Text = panelDC . HeaderTitel ;
}
}
}
else if ( panelDC . PanelType = = HomeViewPanelType . CustomReportPanel )
{
PanelHost . Children . Add ( CreateReportPanel ( panelDC . HeaderTitel , panelDC . Value ) ) ;
}
else if ( panelDC . PanelType = = HomeViewPanelType . CustomXamlPanel )
{
PanelHost . Children . Add ( CreateXamlPanel ( panelDC . HeaderTitel , panelDC . Value ) ) ;
}
else
{
throw new ArgumentOutOfRangeException ( ) ;
}
2019-08-15 11:06:50 +02:00
}
}
}
2019-08-29 15:43:23 +02:00
SetMaximizedPanel ( ) ;
}
else
{
ReorderPanels ( ) ;
2019-08-15 11:06:50 +02:00
}
InitPanels ( null ) ;
}
2019-08-29 15:43:23 +02:00
private string GetDefaultPanelName ( HomeViewPanelDC p )
{
switch ( p . PanelType )
{
case HomeViewPanelType . TasksPanel :
return "PanelTasks" ;
case HomeViewPanelType . ExpiringSupportConceptsPanel :
return "PanelExpiringSupportConcepts" ;
case HomeViewPanelType . ConferenceDatesPanel :
return "PanelConferenceDates" ;
case HomeViewPanelType . BirthdatesPanel :
return "PanelBirthdates" ;
case HomeViewPanelType . InternalNewsPanel :
return "PanelInternalNews" ;
case HomeViewPanelType . BeWoNewsPanel :
return "PanelBeWoNews" ;
}
return p . HeaderTitel ;
}
2019-08-15 11:06:50 +02:00
private DragDockPanel CreateReportPanel ( string title , string reportName )
{
var panel = new DragDockPanel ( )
{
Tag = "CustomReport" ,
Name = title ,
Header = new StackPanel ( )
{
Orientation = Orientation . Horizontal ,
Children =
{
new Image ( )
{
Source = new BitmapImage ( new Uri ( @"..\Ressources\Icons\ChartBarDisabled.png" , UriKind . Relative ) ) ,
Stretch = Stretch . Fill ,
StretchDirection = StretchDirection . Both
} ,
new TextBlock ( )
{
Text = title ? ? "Bericht" ,
TextWrapping = TextWrapping . Wrap ,
FontSize = 16 ,
Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#E0E0E0" ) ) ,
VerticalAlignment = VerticalAlignment . Bottom ,
Margin = new Thickness ( 5 , 0 , 0 , 5 ) ,
Tag = "Titel"
}
}
}
} ;
2019-08-29 15:43:23 +02:00
var ctrl = new DocumentPreviewControl
{
CommandBarStyle = CommandBarStyle . None ,
Margin = new Thickness ( - 3 , - 4 , - 3 , - 3 )
} ;
panel . Content = ctrl ;
2019-08-15 11:06:50 +02:00
panel . Loaded + = ( s , e ) = > LoadReport ( reportName , title , panel ) ;
return panel ;
}
private DragDockPanel CreateXamlPanel ( string title , string xamlString )
{
var panel = new DragDockPanel ( )
{
Tag = "CustomReport" ,
Name = title ,
Header = new StackPanel ( )
{
Orientation = Orientation . Horizontal ,
Children =
{
new Image ( )
{
Source = new BitmapImage ( new Uri ( @"..\Ressources\Icons\ChartBarDisabled.png" , UriKind . Relative ) ) ,
Stretch = Stretch . Fill ,
StretchDirection = StretchDirection . Both
} ,
new TextBlock ( )
{
Text = title ? ? "Bericht" ,
TextWrapping = TextWrapping . Wrap ,
FontSize = 16 ,
Foreground = new SolidColorBrush ( ( Color ) ColorConverter . ConvertFromString ( "#E0E0E0" ) ) ,
VerticalAlignment = VerticalAlignment . Bottom ,
Margin = new Thickness ( 5 , 0 , 0 , 5 ) ,
Tag = "Titel"
}
}
} ,
2019-08-29 15:43:23 +02:00
Content = XamlReader . Parse ( xamlString )
2019-08-15 11:06:50 +02:00
} ;
return panel ;
}
private void LoadReport ( string reportName , string title , DragDockPanel panel )
{
2019-08-29 15:43:23 +02:00
ServiceFacade . DoReportServiceAsync ( s = > s . CreateCustomReport ( BeWoApp . LoggedOnEmployee . EmployeeOid . Value , reportName ) , ms = > SetReportControl ( ms , title , panel ) , false ) ;
2019-08-15 11:06:50 +02:00
}
private void SetReportControl ( MemoryStream ms , string title , DragDockPanel panel )
{
this . Dispatch (
delegate
{
2019-08-29 15:43:23 +02:00
//var grid = new Grid();
//grid.ColumnDefinitions.Add(new ColumnDefinition { Width = new GridLength(1, GridUnitType.Star) });
//grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
//var ctrl = new DocumentPreviewControl
//{
// CommandBarStyle = CommandBarStyle.None
//};
//grid.Margin = new Thickness(-3, -4, -3, -3);
//grid.Children.Add(ctrl);
//panel.Content = grid;
if ( panel . Content is DocumentPreviewControl )
2019-08-15 11:06:50 +02:00
{
2019-08-29 15:43:23 +02:00
BeWoUtils . ShowReportWindow ( ms , title , panel . Content as DocumentPreviewControl ) ;
}
2019-08-15 11:06:50 +02:00
} ) ;
}
2019-08-09 16:52:55 +02:00
private void RefreshInternalNews ( List < NewsItemDC > news )
{
this . Dispatch ( delegate
{
var team2News = new Dictionary < long , TeamNewsItemVM > ( ) ;
var allNews = new TeamNewsItemVM ( ) ;
allNews . Team = new CompactTeamDC ( ) ;
allNews . Team . Name = "Allgemein" ;
allNews . AllowEdit = false ;
allNews . IsTitleVisible = true ;
foreach ( var newsItemDc in news )
{
if ( newsItemDc . Team ! = null )
{
newsItemDc . AllowEdit = true ;
newsItemDc . TitleString = String . Format ( "{0:dd.MM.yyyy}: {1}" , newsItemDc . PublishDate ,
newsItemDc . Title ) ;
if ( ! team2News . ContainsKey ( newsItemDc . Team . TeamOid ) )
{
team2News [ newsItemDc . Team . TeamOid ] = new TeamNewsItemVM ( ) ;
team2News [ newsItemDc . Team . TeamOid ] . Team = newsItemDc . Team ;
team2News [ newsItemDc . Team . TeamOid ] . AllowEdit = true ;
team2News [ newsItemDc . Team . TeamOid ] . IsTitleVisible = true ;
}
if ( newsItemDc . NewsItemOid . HasValue )
{
team2News [ newsItemDc . Team . TeamOid ] . NewsItems . Add ( newsItemDc ) ;
}
}
else
{
newsItemDc . TitleString = newsItemDc . Title ;
allNews . NewsItems . Add ( newsItemDc ) ;
}
}
var list = team2News . Values . OrderBy ( i = > i . Team . Name ) . ToList ( ) ;
if ( list . Count = = 0 )
allNews . IsTitleVisible = false ;
list . Add ( allNews ) ;
InternalNewsGrid . Children . Clear ( ) ;
InternalNewsGrid . Children . Add ( CreateInternalNewsControlList ( list ) ) ;
//ListboxInternalNews.ItemsSource = list;
} ) ;
}
private UIElement CreateInternalNewsControlList ( List < TeamNewsItemVM > list )
{
bool expand = true ;
2019-08-13 13:02:03 +02:00
if ( _NewsItemExpandedState . Count = = 0 )
2019-08-09 16:52:55 +02:00
{
if ( list ! = null & & list . Count > 1 )
{
int count = 0 ;
foreach ( var teamNewsItemVm in list )
{
if ( teamNewsItemVm . NewsItems ! = null )
{
count + = teamNewsItemVm . NewsItems . Count ;
}
}
if ( count > 10 )
{
expand = false ;
}
}
}
StackPanel sp = new StackPanel ( ) ;
foreach ( var teamNewsItemVm in list )
{
sp . Children . Add ( CreateInternalNewsTeamControl ( teamNewsItemVm , expand ) ) ;
}
return sp ;
}
2019-08-15 11:06:50 +02:00
2019-08-09 16:52:55 +02:00
private UIElement CreateInternalNewsTeamControl ( TeamNewsItemVM teamNewsItemVm , bool initExpand )
{
var sp = new StackPanel ( ) ;
foreach ( var newsItem in teamNewsItemVm . NewsItems )
{
sp . Children . Add ( CreateInternalNewsControl ( newsItem ) ) ;
}
if ( teamNewsItemVm . IsTitleVisible )
{
Expander ex = new Expander ( ) ;
ex . Style = ( Style ) FindResource ( "FlatLineExpander" ) ;
bool expanded = initExpand ;
2019-08-13 13:02:03 +02:00
if ( _NewsItemExpandedState . ContainsKey ( teamNewsItemVm . Team . Name ) )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
expanded = _NewsItemExpandedState [ teamNewsItemVm . Team . Name ] ;
2019-08-09 16:52:55 +02:00
}
ex . IsExpanded = expanded ;
ex . Margin = new Thickness ( 0 , 5 , 5 , 5 ) ;
Grid grid = new Grid ( ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Auto ) } ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Star ) } ) ;
TextBlock tb = new TextBlock ( ) ;
tb . FontSize = 14 ;
tb . FontWeight = FontWeights . Bold ;
tb . Text = teamNewsItemVm . Team . Name ;
grid . Children . Add ( tb ) ;
if ( teamNewsItemVm . AllowEdit )
{
Button newBtn = new Button ( ) ;
newBtn . Style = ( Style ) FindResource ( "FlatButton" ) ;
newBtn . SetValue ( Grid . ColumnProperty , 1 ) ;
newBtn . HorizontalAlignment = System . Windows . HorizontalAlignment . Right ;
newBtn . Width = 16 ;
newBtn . Height = 16 ;
newBtn . Click + = BtnCreateNewsItem_OnClick ;
newBtn . Tag = teamNewsItemVm ;
newBtn . Margin = new Thickness ( 0 , 0 , - 10 , 0 ) ;
Image img = new Image ( ) ;
img . Source = new BitmapImage ( new Uri ( @"..\..\Ressources\Icons\new.png" , UriKind . Relative ) ) ;
img . Stretch = Stretch . Uniform ;
newBtn . Content = img ;
grid . Children . Add ( newBtn ) ;
}
ex . Header = grid ;
ex . Content = sp ;
return ex ;
}
return sp ;
}
private UIElement CreateInternalNewsControl ( NewsItemDC newsItem )
{
Grid grid = new Grid ( ) ;
2019-08-13 13:02:03 +02:00
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Star ) } ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Auto ) } ) ;
grid . ColumnDefinitions . Add ( new ColumnDefinition { Width = new GridLength ( 1 , GridUnitType . Auto ) } ) ;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
grid . RowDefinitions . Add ( new RowDefinition { Height = new GridLength ( 25 , GridUnitType . Pixel ) } ) ;
grid . RowDefinitions . Add ( new RowDefinition { Height = new GridLength ( 1 , GridUnitType . Star ) } ) ;
2019-08-09 16:52:55 +02:00
grid . Margin = new Thickness ( 0 , 5 , 0 , 0 ) ;
TextBlock tb = new TextBlock ( ) ;
tb . Margin = new Thickness ( 0 , 5 , 0 , 0 ) ;
tb . Foreground = new SolidColorBrush ( Color . FromRgb ( 43 , 80 , 139 ) ) ;
tb . Text = newsItem . TitleString ;
tb . FontSize = 12 ;
tb . FontWeight = FontWeights . Bold ;
grid . Children . Add ( tb ) ;
tb = new TextBlock ( ) ;
tb . Text = newsItem . Text ;
tb . FontSize = 10 ;
tb . TextWrapping = TextWrapping . Wrap ;
tb . SetValue ( Grid . RowProperty , 1 ) ;
tb . SetValue ( Grid . ColumnSpanProperty , 3 ) ;
grid . Children . Add ( tb ) ;
if ( newsItem . AllowEdit )
{
// <DataTemplate.Triggers>
// <Trigger Property="IsMouseOver" Value="True">
// <Setter Property="Visibility" TargetName="btnEditNewsItem" Value="{Binding Path=AllowEdit, Converter={StaticResource BoolVisibilityConverter}}" />
// <Setter Property="Visibility" TargetName="btnDeleteNewsItem" Value="{Binding Path=AllowEdit, Converter={StaticResource BoolVisibilityConverter}}" />
// </Trigger>
// </DataTemplate.Triggers>
Border b = new Border ( ) ;
b . Background = Brushes . Transparent ;
b . SetValue ( Grid . ColumnProperty , 1 ) ;
grid . Children . Add ( b ) ;
// <Border Grid.Column="1" Background="Transparent">
// </Border>
Button editBtn = new Button ( ) ;
editBtn . BorderThickness = new Thickness ( 1 , 1 , 1 , 1 ) ;
editBtn . Padding = new Thickness ( 1 , 1 , 1 , 1 ) ;
2019-08-13 13:02:03 +02:00
editBtn . Style = ( Style ) FindResource ( "FlatButton" ) ;
2019-08-09 16:52:55 +02:00
editBtn . SetValue ( Grid . ColumnProperty , 1 ) ;
editBtn . VerticalAlignment = VerticalAlignment . Top ;
editBtn . Width = 16 ;
editBtn . Height = 16 ;
editBtn . Click + = BtnEditNewsItem_OnClick ;
editBtn . Tag = newsItem ;
editBtn . Visibility = Visibility . Hidden ;
Image img = new Image ( ) ;
img . Source = new BitmapImage ( new Uri ( @"..\..\Ressources\Icons\edit.png" , UriKind . Relative ) ) ;
img . Stretch = Stretch . Uniform ;
img . Margin = new Thickness ( 1 , 1 , 1 , 1 ) ;
editBtn . Content = img ;
grid . Children . Add ( editBtn ) ;
b = new Border ( ) ;
b . Background = Brushes . Transparent ;
b . SetValue ( Grid . ColumnProperty , 2 ) ;
grid . Children . Add ( b ) ;
Button deleteBtn = new Button ( ) ;
deleteBtn . Padding = new Thickness ( 1 , 1 , 1 , 1 ) ;
2019-08-13 13:02:03 +02:00
deleteBtn . Style = ( Style ) FindResource ( "FlatButton" ) ;
2019-08-09 16:52:55 +02:00
deleteBtn . SetValue ( Grid . ColumnProperty , 2 ) ;
deleteBtn . VerticalAlignment = VerticalAlignment . Top ;
deleteBtn . Width = 16 ;
deleteBtn . Height = 16 ;
deleteBtn . Click + = BtnDeleteNewsItem_OnClick ;
deleteBtn . Tag = newsItem ;
deleteBtn . Visibility = Visibility . Hidden ;
img = new Image ( ) ;
img . Source = new BitmapImage ( new Uri ( @"..\..\Ressources\Icons\delete.png" , UriKind . Relative ) ) ;
img . Stretch = Stretch . Uniform ;
img . Margin = new Thickness ( 1 , 1 , 1 , 1 ) ;
deleteBtn . Content = img ;
grid . Children . Add ( deleteBtn ) ;
grid . MouseEnter + = ( s , e ) = >
{
editBtn . Visibility = Visibility . Visible ;
deleteBtn . Visibility = Visibility . Visible ;
} ;
grid . MouseLeave + = ( s , e ) = >
{
editBtn . Visibility = Visibility . Hidden ;
deleteBtn . Visibility = Visibility . Hidden ;
} ;
}
//<Border Grid.Column="1" Background="Transparent">
//</Border>
//<Button Grid.Column="1" x:Name="btnEditNewsItem" BorderThickness="1,1,1,1" Padding="1,1,1,1" Style="{DynamicResource FlatButton}" Tag="{Binding}" VerticalAlignment="Top"
// Width="16" Height="16" Click="BtnEditNewsItem_OnClick" Visibility="Hidden">
// <Image Source="..\..\Ressources\Icons\edit.png" Stretch="Uniform" Margin="1,1,1,1" />
//</Button>
//<Border Grid.Column="2" Background="Transparent">
//</Border>
//<Button Grid.Column="2" x:Name="btnDeleteNewsItem" BorderThickness="1,1,1,1" Padding="1,1,1,1" Style="{DynamicResource FlatButton}" Tag="{Binding}" VerticalAlignment="Top"
// Width="16" Height="16" Click="BtnDeleteNewsItem_OnClick" Visibility="Hidden">
// <Image Source="..\..\Ressources\Icons\delete.png" Stretch="Uniform" Margin="1,1,1,1" />
//</Button>
return grid ;
}
private void BuildRecurringAppointments ( List < SchedulerAppointmentDC > pRecurringAppointments , DateTime pStartDate , DateTime pEndDate )
{
var patternToExceptions = new List < RecurringAppointment > ( ) ;
var recurrenceInterval = new TimeInterval ( pStartDate , pEndDate - pStartDate ) ;
var scheduler = new SchedulerControl ( ) ;
2019-08-13 13:02:03 +02:00
foreach ( var appointment in pRecurringAppointments . OrderBy ( o = > o . Type ) )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
if ( appointment . Type = = ( int ) AppointmentType . Pattern )
2019-08-09 16:52:55 +02:00
{
var id = Utils . ExtractIdFromRecurrenceInfo ( appointment . RecurrenceInfo ) ;
2020-02-06 18:56:40 +01:00
var dict = new Dictionary < int , SchedulerAppointmentDC > ( ) ;
foreach ( var iapp in pRecurringAppointments . Where ( w = > w . RecurrenceInfo . Contains ( id ) & & w . Type ! = ( int ) AppointmentType . Pattern ) )
{
var idx = Utils . ExtractIndexFromRecurrenceInfo ( iapp . RecurrenceInfo ) ;
if ( ! dict . ContainsKey ( idx ) )
{
dict . Add ( idx , iapp ) ;
}
}
var ra = new RecurringAppointment ( id , dict , appointment ) ;
patternToExceptions . Add ( ra ) ;
2019-08-09 16:52:55 +02:00
}
}
foreach ( var appointment in patternToExceptions )
{
var patternAppointment = appointment . Pattern ;
var recurrenceInfo = RecurrenceInfoXmlPersistenceHelper . ObjectFromXml ( patternAppointment . RecurrenceInfo ) ;
var instance = OccurrenceCalculator . CreateInstance ( recurrenceInfo ) ;
scheduler . Storage = new SchedulerStorage ( ) ;
var pattern = scheduler . Storage . CreateAppointment ( AppointmentType . Pattern , appointment . Pattern . StartDate . Value , appointment . Pattern . EndDate . Value ) ;
var occurrences = instance . CalcOccurrences ( recurrenceInterval , pattern ) ;
2019-08-13 13:02:03 +02:00
foreach ( var devExpressAppointment in occurrences )
2019-08-09 16:52:55 +02:00
{
var index = devExpressAppointment . RecurrenceIndex ;
2019-08-13 13:02:03 +02:00
if ( index = = 0 & & appointment . Occurrences . ContainsKey ( 0 ) )
2019-08-09 16:52:55 +02:00
{
_AllSchedulerTasks . Remove ( appointment . Pattern ) ;
}
var indizes = appointment . Occurrences . Keys . ToList ( ) ;
if ( indizes . Contains ( index ) | | devExpressAppointment . Type = = AppointmentType . Occurrence & & devExpressAppointment . RecurrenceIndex = = 0 )
{
continue ;
}
var occurrence = new SchedulerAppointmentDC
{
CustomerList = patternAppointment . CustomerList ,
AllDay = patternAppointment . AllDay ,
EndDate = devExpressAppointment . End ,
RecurrenceInfo = devExpressAppointment . RecurrenceInfo . ToXml ( ) ,
StartDate = devExpressAppointment . Start ,
2019-08-13 13:02:03 +02:00
Type = ( int ) AppointmentType . Occurrence ,
2019-08-09 16:52:55 +02:00
CompletedDate = patternAppointment . CompletedDate ,
Description = patternAppointment . Description ,
DueDate = patternAppointment . DueDate ,
EmployeeList = patternAppointment . EmployeeList ,
CompletedNotice = patternAppointment . CompletedNotice ,
FormerBookingSequenceOid = patternAppointment . FormerBookingSequenceOid ,
FormerTaskOid = patternAppointment . FormerTaskOid ,
IsPrivate = patternAppointment . IsPrivate ,
IsTeilnahmeBestaetigung = patternAppointment . IsTeilnahmeBestaetigung ,
SupportConceptList = patternAppointment . SupportConceptList ,
TaskDescription = patternAppointment . TaskDescription ,
IsTask = patternAppointment . IsTask ,
ResourceList = patternAppointment . ResourceList ,
Originator = patternAppointment . Originator ,
Subject = patternAppointment . Subject ,
Location = patternAppointment . Location ,
Status = patternAppointment . Status ,
LabelId = patternAppointment . LabelId ,
RecurrenceIndex = devExpressAppointment . RecurrenceIndex ,
RecurrenceId = appointment . RecurrenceId
} ;
_AllSchedulerTasks . Add ( occurrence ) ;
}
}
}
private void LoadFeed ( )
{
String url = BeWoApp . Mandator . RssFeedUrl ;
if ( String . IsNullOrEmpty ( url ) )
{
ServiceFacade . DoDownloadServiceAsync (
dwn = >
{
try
{
return dwn . ReadRssFeed ( null ) ;
}
catch ( Exception )
{
}
return null ;
} ,
ReloadRssFeed ) ;
}
else
2019-08-13 13:02:03 +02:00
{
2020-08-17 15:50:00 +02:00
ServicePointManager . SecurityProtocol = SecurityProtocolType . Tls12 ;
2019-08-13 13:02:03 +02:00
RssFeed feed = new RssFeed ( ) ;
RssManager mgr = new RssManager ( url ) ;
feed . Items = mgr . GetFeed ( ) ;
feed . Title = mgr . FeedTitle ;
feed . Description = mgr . FeedDescription ;
ReloadRssFeed ( feed , false ) ;
2019-08-09 16:52:55 +02:00
}
}
private void ShowAppointments ( bool pShouldShowAppointments )
{
TimeIntervalNavigationStackPanel . Visibility = pShouldShowAppointments ? Visibility . Visible : Visibility . Collapsed ;
TimeIntervalBackButton . Visibility = pShouldShowAppointments ? Visibility . Visible : Visibility . Collapsed ;
AppointmentDateTextBlock . Visibility = pShouldShowAppointments ? Visibility . Visible : Visibility . Collapsed ;
TimeIntervalForwardsButton . Visibility = pShouldShowAppointments ? Visibility . Visible : Visibility . Collapsed ;
2019-08-13 13:02:03 +02:00
if ( pShouldShowAppointments )
2019-08-09 16:52:55 +02:00
{
CurrentDate = DateTime . Today ;
UpdateAppointmentDateTextBlock ( null ) ;
}
}
private void UpdateAppointmentDateTextBlock ( DateTime ? pDate )
{
var date = pDate ? ? DateTime . Today ;
var weekOfYear = date . GetIso8601WeekOfYear ( ) . ToString ( ) ;
var dayOfWeek = date . ToString ( "dddd" ) ;
AppointmentDateTextBlock . Text = $"KW {weekOfYear}, {dayOfWeek} " ;
LoadTasksAndAppointments ( false ) ;
}
private void LoadTasksAndAppointments ( bool pIsShowingTasks , bool pForceUpdate = false )
{
2019-08-13 13:02:03 +02:00
if ( _CurrentDate < _BufferDate | | _CurrentDate > _BufferDate . AddDays ( 3 * Datebuffer ) | | pForceUpdate )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
_BufferDate = _CurrentDate . AddDays ( - 1 * Datebuffer ) ;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
ServiceFacade . DoResourceServiceAsync ( s = > s . LoadTasksAndAppointmentsForEmployee ( BeWoApp . LoggedOnEmployeeOid . Value , _CurrentDate , Datebuffer , _SelectedEmployeeForAppointments ? . EmployeeOid ) , cb = >
2019-08-09 16:52:55 +02:00
{
this . Dispatch ( delegate
{
_AllSchedulerTasks = cb ;
2019-08-13 13:02:03 +02:00
BuildRecurringAppointments ( _AllSchedulerTasks . Where ( w = > w . RecurrenceInfo ! = null ) . ToList ( ) , _CurrentDate , _CurrentDate . AddDays ( 3 * Datebuffer ) ) ;
2019-08-09 16:52:55 +02:00
if ( pIsShowingTasks )
{
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( i = > i . IsTask & & ! i . CompletedDate . HasValue ) . OrderBy ( i = > i . DueDate ) . OrderBy ( o = > o . StartDate ? ? DateTime . MinValue ) . ToList ( ) ;
}
else
{
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( i = > ! i . IsTask & &
i . StartDate . HasValue & & i . StartDate . Value . InBetween ( _CurrentDate , _CurrentDate . AddDays ( 14 ) , true ) & &
i . EndDate . HasValue & & i . EndDate . Value . InBetween ( _CurrentDate , _CurrentDate . AddDays ( 14 ) , true ) & &
2019-08-13 13:02:03 +02:00
i . Type ! = ( int ) AppointmentType . DeletedOccurrence ) . OrderBy ( o = > o . StartDate ? ? DateTime . MinValue ) . ToList ( ) ;
2019-08-09 16:52:55 +02:00
}
} ) ;
2019-08-29 15:43:23 +02:00
} , false ) ;
2019-08-09 16:52:55 +02:00
}
else
{
if ( pIsShowingTasks )
{
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( i = > i . IsTask & & ! i . CompletedDate . HasValue ) . OrderBy ( i = > i . DueDate ) . OrderBy ( o = > o . StartDate ? ? DateTime . MinValue ) . ToList ( ) ;
}
else
{
listboxTasks . ItemsSource = _AllSchedulerTasks . Where ( i = > ! i . IsTask & &
i . StartDate . HasValue & & i . StartDate . Value . InBetween ( _CurrentDate , _CurrentDate . AddDays ( 14 ) , true ) & &
i . EndDate . HasValue & & i . EndDate . Value . InBetween ( _CurrentDate , _CurrentDate . AddDays ( 14 ) , true ) & &
2019-08-13 13:02:03 +02:00
i . Type ! = ( int ) AppointmentType . DeletedOccurrence ) . OrderBy ( o = > o . StartDate ? ? DateTime . MinValue ) . ToList ( ) ;
2019-08-09 16:52:55 +02:00
foreach ( var app in listboxTasks . ItemsSource )
{
var a = ( SchedulerAppointmentDC ) app ;
if ( a . IsTask | | a . RecurrenceInfo = = null )
{
continue ;
}
}
}
}
}
private void ReloadRssFeed ( RssFeed feed )
{
ReloadRssFeed ( feed , true ) ;
}
private void ReloadRssFeed ( RssFeed feed , bool addBeWoParameter )
{
if ( feed ! = null )
{
if ( feed . Items ! = null & & addBeWoParameter )
{
foreach ( RssItem rssItem in feed . Items )
{
if ( ! String . IsNullOrEmpty ( rssItem . Link ) )
{
rssItem . Link + = String . Format ( "&k={0}&s={1}" , BeWoApp . Tenant , BeWoApp . ServerName ) ;
}
}
}
this . Dispatch ( delegate { listboxNews . ItemsSource = feed . Items ; } ) ;
}
}
private void ReloadBirthdays ( List < CompactPersonDC > list )
{
this . Dispatch (
delegate
{
list . Sort ( ( l1 , l2 ) = > l1 . DateOfBirth . Value . DayOfYear . CompareTo ( l2 . DateOfBirth . Value . DayOfYear ) ) ;
listboxBirthdays . ItemsSource = list ;
} ) ;
}
private void ReloadConferenceDates ( List < CompactSupportConceptDC > list )
{
this . Dispatch (
delegate
{
list . Sort ( ( l1 , l2 ) = > l1 . ConferenceDate . Value . CompareTo ( l2 . ConferenceDate . Value ) ) ;
listboxConferenceDates . ItemsSource = list ;
} ) ;
}
private void ReloadExpiringSupportConcepts ( List < CompactSupportConceptDC > list )
{
this . Dispatch (
delegate
{
list . Sort ( ( l1 , l2 ) = > l1 . EndDate . Value . CompareTo ( l2 . EndDate . Value ) ) ;
listboxExpiringSupportConcepts . ItemsSource = list ;
} ) ;
}
private void ReloadLogins ( List < LoginDC > list )
{
this . Dispatch (
delegate
{
// listboxNews.ItemsSource = list;
list . Sort ( ( l1 , l2 ) = > l1 . LoginDate . Value . CompareTo ( l2 . LoginDate . Value ) ) ;
if ( list . Count > 0 )
{
LoginDC last = list [ list . Count - 1 ] ;
txtLoginTime . Text = "Angemeldet seit " + last . LoginDate . Value . ToShortDateString ( ) + " " +
last . LoginDate . Value . ToShortTimeString ( ) ;
if ( list . Count > 1 )
{
LoginDC dc = list [ list . Count - 2 ] ;
txtLastLoginTime . Text = ", zuletzt angemeldet am " + dc . LoginDate . Value . ToShortDateString ( ) +
" " + dc . LoginDate . Value . ToShortTimeString ( ) ;
}
}
} ) ;
}
public void ReorderPanels ( )
{
2019-08-15 11:06:50 +02:00
var save = BeWoApp . AppSettings . StartupPanelOrder ;
var actual = PanelHost . Children . Cast < DragDockPanel > ( ) . Select ( item = > item . Name ) . ToList ( ) ;
2019-08-09 16:52:55 +02:00
2019-08-15 11:06:50 +02:00
if ( save = = null | | save . Count ! = actual . Count | | actual . Except ( save ) . Any ( ) ) return ;
2019-08-09 16:52:55 +02:00
2019-08-15 11:06:50 +02:00
var panels = new Dictionary < string , DragDockPanel > ( ) ;
2019-08-09 16:52:55 +02:00
2019-08-15 11:06:50 +02:00
foreach ( var item in PanelHost . Children )
{
var p = item as DragDockPanel ;
panels . Add ( p . Name , p ) ;
}
2019-08-09 16:52:55 +02:00
2019-08-15 11:06:50 +02:00
PanelHost . Children . Clear ( ) ;
2019-08-09 16:52:55 +02:00
2019-08-15 11:06:50 +02:00
save . DoForEach ( x = > PanelHost . AddPanel ( panels [ x ] ) ) ;
2019-08-29 15:43:23 +02:00
2019-08-09 16:52:55 +02:00
}
2019-08-13 13:02:03 +02:00
private void SetMaximizedPanel ( )
2019-08-09 16:52:55 +02:00
{
2019-08-15 11:06:50 +02:00
if ( ! string . IsNullOrEmpty ( BeWoApp . AppSettings . StartupPanelMaximized ) )
2019-08-09 16:52:55 +02:00
{
2019-08-15 11:06:50 +02:00
foreach ( object item in PanelHost . Children )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
var p = item as DragDockPanel ;
if ( BeWoApp . AppSettings . StartupPanelMaximized . Equals ( p . Name ) )
{
2019-08-29 15:43:23 +02:00
//IEnumerable<DependencyObject> objekts = p.GetAllChildren();
2019-08-09 16:52:55 +02:00
2019-08-29 15:43:23 +02:00
//foreach (DependencyObject child in objekts)
//{
// if (child is ToggleButton btn)
// {
// btn.IsChecked = true;
// }
//}
p . PanelMaximized = true ;
2019-08-13 13:02:03 +02:00
}
2019-08-09 16:52:55 +02:00
}
}
}
2019-08-13 13:02:03 +02:00
private void SaveNewsItem ( NewsItemVM vm )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
ServiceFacade . DoEmployeeServiceSync ( s = > s . InsertNewNewsItem ( vm . CommitToDataContract ( ) ) ) ;
UpdateInternalNews ( ) ;
}
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
private void UpdateNewsItem ( NewsItemVM vm )
{
ServiceFacade . DoEmployeeServiceSync ( s = > s . UpdateNewsItem ( vm . CommitToDataContract ( ) ) ) ;
UpdateInternalNews ( ) ;
}
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#endregion
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#region NotNeeded
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
private delegate void loadFeed ( string url ) ;
private List < TaskDC > _AllTasks ;
private bool _IsAllowedToSeeCustomerAppointments ;
private bool _IsAllowedToSeeResourceAppointments ;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
private void PreparePanels ( )
{
ServiceFacade . DoOperationsServiceAsyncNoWait (
s = > s . GetUiElements ( UiElementType . StartPanel , BeWoApp . LoggedOnUser . Employee . EmployeeOid , null , null ) ,
InitPanelsCallback , null ) ;
}
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
private void FillOutbox ( )
{
// if (BeWoApp.LoggedOnUser.Employee != null)
// {
// BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(
// s => s.GetOutgoingMails(BeWoApp.LoggedOnUser.Employee.EmployeeOid),
// result => this.Dispatcher.BeginInvoke(new Call(delegate()
// {
// outboxList.ItemsSource = result;
// }))
// );
// }
// }
// private void FillInbox()
// {
// if (BeWoApp.LoggedOnUser.Employee != null)
// {
// BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(
// s => s.GetIncomingMails(BeWoApp.LoggedOnUser.Employee.EmployeeOid),
// result => this.Dispatcher.BeginInvoke(new Call(delegate()
// {
// text.Text = GenerateMailText(result);
// inboxList.ItemsSource = result;
// }))
// );
// }
// }
// delegate void Call();
// private static string GenerateMailText(List<MailDC> result)
// {
// //var builder = new StringBuilder();
// //var unreadMails = result.Where(r => r.Status == null || r.Status == Status.unread).Count();
// //builder.AppendLine("Sie haben " + unreadMails + "/" + result.Count + " Mails");
// //foreach (var item in result)
// //{
// // builder.AppendLine(item.Subject);
// //}
// //return builder.ToString();
// var unreadMails = result.Where(r => r.Status == null || r.Status == Status.unread).Count();
// return "Sie haben " + unreadMails + "/" + result.Count + " Mails";
// }
// private void ButtonNew_Click(object sender, RoutedEventArgs e)
// {
// OpenSendMailView();
// // throw new NotImplementedException();
// }
// private void OpenSendMailView()
// {
// BeWoApp.MainControl.NavigateTo(new SendMailView() { ParentView = this });
// //throw new NotImplementedException();
// }
// private void ButtonReplyNew_Click(object sender, RoutedEventArgs e)
// {
// if (boxTabControl.SelectedIndex == 0)
// {
// if (inboxList.SelectedIndex < 0)
// {
// MessageBox.Show("Sie haben keine Nachricht ausgewählt");
// return;
// }
// var mailDC = inboxList.SelectedItem as MailDC;
// BeWoApp.MainControl.NavigateTo(new SendMailView(SendMailView.Mode.Reply, mailDC));
// }
// else
// {
// MessageBox.Show("Sie können nicht auf Ihre eigene Mail antworten");
// }
// }
// private void ButtonForward_Click(object sender, RoutedEventArgs e)
// {
// if (boxTabControl.SelectedIndex == 0)
// {
// if (inboxList.SelectedIndex < 0)
// {
// MessageBox.Show("Sie haben keine Nachricht ausgewählt");
// return;
// }
// var mailDC = inboxList.SelectedItem as MailDC;
// BeWoApp.MainControl.NavigateTo(new SendMailView(SendMailView.Mode.Forward, mailDC));
// }
// else
// {
// MessageBox.Show("Sie können Ihre eigene Mail nicht wieterleiten");
// }
// }
// private void ButtonDelete_Click(object sender, RoutedEventArgs e)
// {
// if (boxTabControl.SelectedIndex == 0)
// {
// if (inboxList.SelectedIndex < 0)
// {
// MessageBox.Show("Sie haben keine Nachricht ausgewählt");
// return;
// }
// var mailDC = inboxList.SelectedItem as MailDC;
// BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(s => s.DeleteMail(BeWoApp.LoggedOnUser.Employee.EmployeeOid, mailDC));
// //inboxList.ItemsSource.RemoveAt(inboxList.SelectedIndex);
// FillInbox();
// }
// else
// {
// MessageBox.Show("Outbox funktioniert noch nicht");
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
// //BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(s => s.DeleteMail(BeWoApp.LoggedOnUser.Employee.EmployeeOid, outboxList.SelectedItem as MailDC);
// }
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
// //throw new NotImplementedException();
// }
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
// private void InboxItem_DoubleClick(object sender, RoutedEventArgs e)
// {
// var listboItem = sender as ListBoxItem;
// var content = listboItem.Content as MailDC;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
// MainControl.NavigateTo(new ViewMailView(content) { ParentView = this });
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
// //throw new NotImplementedException();
// }
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
// private void OutboxItem_DoubleClick(object sender, RoutedEventArgs e)
// {
// var listboItem = sender as ListBoxItem;
// var content = listboItem.Content as MailDC;
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
// MainControl.NavigateTo(new ViewMailView(content) { ParentView = this });
}
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
private void listboxBirthdays_MouseDoubleClick ( object sender , MouseButtonEventArgs e )
{
//if (!IsPartOf(e.OriginalSource, typeof (ScrollBar)))
2019-08-09 16:52:55 +02:00
//{
2019-08-13 13:02:03 +02:00
// var dc = ((ListBox) sender).SelectedItem as CompactPersonDC;
// if (dc != null)
2019-08-09 16:52:55 +02:00
// {
2019-08-13 13:02:03 +02:00
// if (dc.PersonType == PersonType.Customer)
// {
// if (BeWoApp.LoggedOnUser.HasRight(UserRightType.CustomerView_View) ||
// BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll))
// {
// ServiceFacade.DoCustomerServiceAsync(
// s => s.GetCustomerWithPersonOid(dc.PersonOid),
// cb => VMFactory.CreateCustomerVMAsync(
// cb,
// cb2 => this.Dispatch(
// delegate
// {
// MainControl.NavigateTo(
// new CustomerView(cb2)
// {
// ParentView = this
// });
// })));
// }
// }
// else if (dc.PersonType == PersonType.Employee)
// {
// if (BeWoApp.LoggedOnUser.HasRight(UserRightType.EmployeeView_View) ||
// BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll))
// {
// ServiceFacade.DoEmployeeServiceAsync(
// s => s.GetEmployeeWithPersonOid(dc.PersonOid),
// cb => VMFactory.CreateEmployeeVMAsync(
// cb,
// cb2 => this.Dispatch(
// delegate
// {
// MainControl.NavigateTo(
// new EmployeeView(cb2)
// {
// ParentView = this
// });
// })));
// }
// }
// else if (BeWoApp.LoggedOnUser.HasRight(UserRightType.PersonView_View) ||
// BeWoApp.LoggedOnUser.HasRight(UserRightType.ViewAll))
// {
// VMFactory.CreatePersonVMAsync(
// dc.PersonOid,
// cb => this.Dispatch(
// delegate
// {
// MainControl.NavigateTo(
// new PersonView(cb)
// {
// ParentView = this
// });
// }));
// }
2019-08-09 16:52:55 +02:00
// }
//}
}
2021-03-30 10:58:50 +02:00
#endregion
2019-08-13 13:02:03 +02:00
}
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#region Structs
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
public struct RecurringAppointment
{
public string RecurrenceId { get ; set ; }
public Dictionary < int , SchedulerAppointmentDC > Occurrences { get ; set ; }
public SchedulerAppointmentDC Pattern { get ; set ; }
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
public RecurringAppointment ( string pRecurrenceId , Dictionary < int , SchedulerAppointmentDC > pOccurrences , SchedulerAppointmentDC pPattern )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
RecurrenceId = pRecurrenceId ;
Occurrences = pOccurrences ;
Pattern = pPattern ;
2019-08-09 16:52:55 +02:00
}
2019-08-13 13:02:03 +02:00
}
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#endregion
2019-08-09 16:52:55 +02:00
2021-03-30 10:58:50 +02:00
#region Classes
2019-08-13 13:02:03 +02:00
public class TaskDateDescriptionConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
if ( value is SchedulerAppointmentDC task )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
if ( task . CompletedDate . HasValue )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
return $"erledigt am: {task.CompletedDate:d}" ;
}
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
if ( task . DueDate . HasValue & & task . DueDate . Equals ( DateTime . MaxValue ) )
{
return string . Empty ;
2019-08-09 16:52:55 +02:00
}
2019-08-13 13:02:03 +02:00
if ( task . DueDate . HasValue )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
return string . Format ( "bis {0:d} {0:t}" , task . DueDate ) ;
}
2019-08-09 16:52:55 +02:00
2019-08-13 13:02:03 +02:00
if ( task . StartDate . HasValue )
{
return task . AllDay ? $"{task.StartDate:d}" : $"{task.StartDate:d} {task.StartDate:t}" ;
2019-08-09 16:52:55 +02:00
}
2019-08-13 13:02:03 +02:00
}
return string . Empty ;
2019-08-09 16:52:55 +02:00
}
2019-08-13 13:02:03 +02:00
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture ) = > throw new NotImplementedException ( ) ;
2019-08-09 16:52:55 +02:00
}
public class TaskListItemBackgroundConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
{
2019-08-13 13:02:03 +02:00
if ( value is SchedulerAppointmentDC task & & ! task . IsTask )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
if ( parameter ! = null )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
switch ( parameter . ToString ( ) )
2019-08-09 16:52:55 +02:00
{
case "ResourceBackgroundBrush" :
return task . ResourceList ? . Count > 0 ? task . ResourceList . First ( ) . GetBrush ( ) : new SolidColorBrush ( Color . FromArgb ( 0 , 0 , 0 , 0 ) ) ;
case "CustomerBackgroundBrush" :
return new SolidColorBrush ( task . CustomerList ? . Count > 0 ? Color . FromRgb ( 59 , 119 , 153 ) : Color . FromArgb ( 0 , 0 , 0 , 0 ) ) ;
case "EmployeeBackgroundBrush" :
return task . EmployeeList ? . Count > 0 ? task . EmployeeList . First ( ) . Employee . FilterableBrush : task . Originator ? . FilterableBrush ? ? new SolidColorBrush ( Color . FromArgb ( 0 , 0 , 0 , 0 ) ) ;
}
}
return new LinearGradientBrush ( Color . FromRgb ( 192 , 255 , 208 ) , Color . FromRgb ( 192 , 255 , 208 ) , new Point ( 0 , 0 ) , new Point ( 1 , 1 ) ) ;
}
return new LinearGradientBrush ( Color . FromRgb ( 153 , 59 , 59 ) , Color . FromRgb ( 92 , 25 , 25 ) , new Point ( 0 , 0 ) , new Point ( 0 , 1 ) ) ;
}
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture )
{
throw new NotImplementedException ( ) ;
}
}
public class BorderCornerRadiusConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
{
var fallbackCornerRadius = new CornerRadius ( 0 , 5 , 5 , 0 ) ;
2019-08-13 13:02:03 +02:00
if ( value is SchedulerAppointmentDC appointment & & ! appointment . IsTask & & parameter ! = null )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
switch ( parameter . ToString ( ) )
2019-08-09 16:52:55 +02:00
{
case "Customers" :
return appointment . CustomerList ? . Count > 0 & & appointment . ResourceList ? . Count > 0 ? new CornerRadius ( 0 , 5 , 0 , 0 ) : fallbackCornerRadius ;
case "Resources" :
return appointment . CustomerList ? . Count > 0 & & appointment . ResourceList ? . Count > 0 ? new CornerRadius ( 0 , 0 , 5 , 0 ) : fallbackCornerRadius ;
default :
return fallbackCornerRadius ;
}
}
return fallbackCornerRadius ;
}
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture ) = > throw new NotImplementedException ( ) ;
}
public class TaskListItemForegroundConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
{
2019-08-13 13:02:03 +02:00
if ( value is SchedulerAppointmentDC task & & ! task . IsTask )
2019-08-09 16:52:55 +02:00
{
return new SolidColorBrush ( Color . FromRgb ( 0 , 0 , 0 ) ) ;
}
2019-08-13 13:02:03 +02:00
2019-08-09 16:52:55 +02:00
return new SolidColorBrush ( Color . FromRgb ( 201 , 210 , 210 ) ) ;
}
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture )
{
throw new NotImplementedException ( ) ;
}
}
public class TaskAppointmentVisibilityConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
{
2019-08-13 13:02:03 +02:00
if ( value is SchedulerAppointmentDC taskAppointment )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
switch ( parameter ? . ToString ( ) )
2019-08-09 16:52:55 +02:00
{
case "ToolTipTimeVisibility" :
return taskAppointment . IsTask | | taskAppointment . AllDay ? Visibility . Collapsed : Visibility . Visible ;
case "ToolTipTrennstrichVisibility" :
return ! taskAppointment . IsTask & & ( taskAppointment . EmployeeList ? . Count > 0 | | taskAppointment . CustomerList ? . Count > 0 | | taskAppointment . ResourceList ? . Count > 0 ) ? Visibility . Visible : Visibility . Collapsed ;
case "ToolTipResourcesVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . ResourceList ? . Count > 0 ? Visibility . Visible : Visibility . Collapsed ;
case "ToolTipEmployeesVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . EmployeeList ? . Count > 0 ? Visibility . Visible : Visibility . Collapsed ;
case "ToolTipCustomersVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . CustomerList ? . Count > 0 ? Visibility . Visible : Visibility . Collapsed ;
case "ToolTipZusageVisibility" :
return ! taskAppointment . IsTask ? Visibility . Visible : Visibility . Collapsed ;
case "ToolTipCustomerColorVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . CustomerList ? . Count > 0 ? Visibility . Visible : Visibility . Collapsed ;
case "ToolTipResourcesColorVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . ResourceList ? . Count > 0 ? Visibility . Visible : Visibility . Collapsed ;
case "CustomerBorderVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . CustomerList ? . Count > 0 ? Visibility . Visible : Visibility . Collapsed ;
case "ResourceBorderVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . ResourceList ? . Count > 0 ? Visibility . Visible : Visibility . Collapsed ;
2019-08-13 13:02:03 +02:00
case "EmployeeBorderVisibility" :
return ! taskAppointment . IsTask & & taskAppointment . EmployeeList ? . Count > 0 | | taskAppointment . Originator ! = null ? Visibility . Visible : Visibility . Collapsed ;
2019-08-09 16:52:55 +02:00
}
}
return Visibility . Collapsed ;
}
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture ) = > throw new NotImplementedException ( ) ;
}
public class TaskAppointmentToolTipConverter : IValueConverter
{
public object Convert ( object value , Type targetType , object parameter , CultureInfo culture )
{
2019-08-13 13:02:03 +02:00
if ( value is SchedulerAppointmentDC taskAppointment )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
if ( ! taskAppointment . IsTask )
2019-08-09 16:52:55 +02:00
{
var custoemrs = taskAppointment . CustomerList ;
var resources = taskAppointment . ResourceList ;
var toolTip = string . Empty ;
var seperator = "; " ;
var selection = new List < IFilterableDC > ( ) ;
var isResourceOrCustomer = false ;
switch ( parameter ? . ToString ( ) )
{
case "TimeText" :
return $"{taskAppointment.StartDate?.ToString(" HH : mm ")} - {taskAppointment.EndDate?.ToString(" HH : mm ")} Uhr" ;
case "ToolTip" :
return taskAppointment . Subject ;
case "Resources" :
isResourceOrCustomer = true ;
seperator = ", " ;
if ( resources ! = null )
{
selection = resources . Cast < IFilterableDC > ( ) . ToList ( ) ;
}
break ;
case "Employees" :
return taskAppointment . EmployeeList ;
case "Customers" :
isResourceOrCustomer = true ;
if ( custoemrs ! = null )
{
selection = custoemrs . Cast < IFilterableDC > ( ) . ToList ( ) ;
}
break ;
}
2019-08-13 13:02:03 +02:00
if ( isResourceOrCustomer )
2019-08-09 16:52:55 +02:00
{
foreach ( var item in selection )
{
var index = selection . IndexOf ( item ) ;
if ( index % 3 = = 0 & & index < selection . Count - 1 & & index > 0 )
{
toolTip + = "\n" ;
}
toolTip + = item . ToString ( ) ;
if ( index < selection . Count - 1 )
{
toolTip + = seperator ;
}
}
return toolTip ;
}
}
else
{
2019-08-13 13:02:03 +02:00
switch ( parameter ? . ToString ( ) )
2019-08-09 16:52:55 +02:00
{
case "TimeText" :
return string . Empty ;
}
}
2019-08-13 13:02:03 +02:00
if ( parameter ! = null & & parameter . Equals ( "ToolTip" ) )
2019-08-09 16:52:55 +02:00
{
return taskAppointment . IsTask ? taskAppointment . TaskDescription : taskAppointment . Description ;
}
}
2019-08-13 13:02:03 +02:00
2019-08-09 16:52:55 +02:00
return null ;
}
public object ConvertBack ( object value , Type targetType , object parameter , CultureInfo culture ) = > throw new NotImplementedException ( ) ;
}
public class BorderHeightConverter : IMultiValueConverter
{
public object Convert ( object [ ] values , Type targetType , object parameter , CultureInfo culture )
{
const double fallbackValue = 0d ;
2019-08-13 13:02:03 +02:00
if ( values . Length = = 2 )
2019-08-09 16:52:55 +02:00
{
2019-08-13 13:02:03 +02:00
var actualHeight = ( double ) values [ 0 ] ;
var appointment = ( SchedulerAppointmentDC ) values [ 1 ] ;
2019-08-09 16:52:55 +02:00
var newHeight = appointment ? . CustomerList ? . Count > 0 & & appointment . ResourceList ? . Count > 0 ? actualHeight / 2 : actualHeight ;
return newHeight ;
}
return fallbackValue ;
}
public object [ ] ConvertBack ( object value , Type [ ] targetTypes , object parameter , CultureInfo culture ) = > throw new NotImplementedException ( ) ;
}
2021-03-30 10:58:50 +02:00
#endregion
2019-08-09 16:52:55 +02:00
}