2429 lines
95 KiB
C#
2429 lines
95 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Diagnostics;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Runtime.CompilerServices;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
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;
|
|
using System.Windows.Markup;
|
|
using BeWo.Annotations;
|
|
using BeWo.ownChat;
|
|
using BeWo.Scheduler.Utils;
|
|
using BeWo.Scheduler.View;
|
|
using BeWo.View.Master;
|
|
using ChatController.HauptKlassen;
|
|
using DevExpress.Xpf.DocumentViewer;
|
|
using DevExpress.Xpf.Printing;
|
|
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
|
|
{
|
|
#region Constant Fields
|
|
|
|
private const int Datebuffer = 14;
|
|
|
|
#endregion
|
|
|
|
#region Fields
|
|
|
|
public NewSchedulerView PropertyScheduler;
|
|
public ChatView ServiceChatView;
|
|
public event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
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;
|
|
private bool _IsAllowedToSeeMitarbeitertermine;
|
|
private bool _IsShowingAppointments;
|
|
private bool _HasRightsToSeeAppointments;
|
|
private bool _LoadContentinLoadedEvent = false;
|
|
#endregion
|
|
|
|
#region Constructors
|
|
|
|
public HomeView()
|
|
{
|
|
InitializeComponent();
|
|
|
|
DataContext = this;
|
|
|
|
txtHeader.Text = $"{BeWoApp.LoggedOnUser.Employee.FirstName} {BeWoApp.LoggedOnUser.Employee.LastName}";
|
|
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();
|
|
|
|
|
|
HyperlinkZuPasswortsicherheit.NavigateUri = new Uri("http://news.bewoplaner.de/?NewsType=3&NewsCount=1&NewsOID=373457455");
|
|
|
|
|
|
#if DEBUG
|
|
//txtChangePassword.Visibility = Visibility.Visible;
|
|
|
|
#else
|
|
if (BeWoApp.Tenant == "demo" || !BeWoApp.LoggedOnUser.HasRight(UserRightType.AllowChangeOwnPassword))
|
|
{
|
|
txtChangePassword.Visibility = Visibility.Collapsed;
|
|
}
|
|
#endif
|
|
// FillInbox();
|
|
// FillOutbox();
|
|
_LoadContentinLoadedEvent = false; // Nicht beim ersten Initialiseren ausführen, da der COntent sonst doppelt geladen wird
|
|
Loaded += HomeDragPanelViewLoaded;
|
|
|
|
/*this.Dispatcher.BeginInvoke(
|
|
DispatcherPriority.Normal,
|
|
(Action)delegate
|
|
{
|
|
ConnectWithServer();
|
|
if(clientSocket.Connected)
|
|
MessageBox.Show("Verbindung geglückt.", "Info", MessageBoxButton.OK,MessageBoxImage.Information);
|
|
});*/
|
|
|
|
if (BeWoApp.AppSettings.ShowOwnChat)
|
|
{
|
|
var empAppCodes = ServiceFacade.DoEmployeeServiceSync(r => r.GetAllEmployeeAppCodes(BeWoApp.LoggedOnUser.Employee.EmployeeOid));
|
|
|
|
if (empAppCodes != null && empAppCodes.Count > 0)
|
|
{
|
|
foreach (var item in empAppCodes)
|
|
{
|
|
if (item.EmployeeCode != null && !item.EmployeeCode.Equals(""))
|
|
BeWoApp.LoggedOnEmployeeOwnChatCode = item.EmployeeCode;
|
|
}
|
|
}
|
|
|
|
}
|
|
#if DEBUG
|
|
BeWoApp.LoggedOnEmployeeOwnChatCode = "TEST";
|
|
#endif
|
|
|
|
BewoChat.Visibility = !String.IsNullOrEmpty(BeWoApp.LoggedOnEmployeeOwnChatCode) ? Visibility.Visible : Visibility.Hidden;
|
|
|
|
PruefePasswortStaerke();
|
|
|
|
//ServiceFacade.DoOperationsServiceAsync(s => s.GetHomeViewPanels(), r => Dispatcher?.Invoke(() => UpdatePanels(r)));
|
|
|
|
var panels = ServiceFacade.DoOperationsServiceSync(s => s.GetHomeViewPanels());
|
|
UpdatePanels(panels);
|
|
}
|
|
|
|
#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)
|
|
{
|
|
|
|
|
|
SetMaximizedPanel();
|
|
|
|
if (_LoadContentinLoadedEvent)
|
|
{
|
|
LoadContent();
|
|
}
|
|
_LoadContentinLoadedEvent = true;
|
|
//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)
|
|
{
|
|
#if DEBUG
|
|
MainControl.NavigateTo(new SchedulingMasterView(sc2.StartDate.Value, sc2) { ParentView = this });
|
|
#else
|
|
MainControl.NavigateTo(new SchedulerMasterView(sc2.StartDate.Value, sc2) { ParentView = this });
|
|
#endif
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
private void Hyperlink_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
|
{
|
|
Process.Start(new ProcessStartInfo((sender as Hyperlink).NavigateUri.ToString()));
|
|
}
|
|
|
|
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()));
|
|
}
|
|
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
|
|
private void OpenServiceRecordEditViewTest()
|
|
{
|
|
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);
|
|
serviceRecord.EditAlwaysAllowed = true;
|
|
var newView = new ChatDokumentationsView(vm, serviceRecord);
|
|
newView.ShowDialog();
|
|
})));
|
|
|
|
}
|
|
|
|
private void HyperlinkChat_OnRequestNavigate(object sender, RequestNavigateEventArgs e)
|
|
{
|
|
#if DEBUG
|
|
//OpenServiceRecordEditViewTest();
|
|
//return;
|
|
var kundennummer = "5473568546";
|
|
//var apikey = "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97";
|
|
|
|
var _login = new Login(kundennummer, "kihqx-PiGka", "cb", "bewo", "0b50c09aff87f20d9ced75340e04e5ccaa11dd3e7bcf25e9c4f94dc20d3cbb97");
|
|
|
|
var ownChatTextFilePath = "C:\\Users\\Lyndon Jetten\\Desktop\\ownchat.txt";
|
|
if(File.Exists(ownChatTextFilePath))
|
|
{
|
|
var lines = new List<string>();
|
|
|
|
using(var streamReader = new StreamReader(ownChatTextFilePath))
|
|
{
|
|
var line = streamReader.ReadLine();
|
|
lines.Add(line);
|
|
while(!(line is null))
|
|
{
|
|
line = streamReader.ReadLine();
|
|
lines.Add(line);
|
|
}
|
|
}
|
|
|
|
if(lines.Count > 5)
|
|
{
|
|
var tenant = lines[0];
|
|
var chatCode = lines[1];
|
|
var userName = lines[2];
|
|
var password = lines[3];
|
|
var apiKey = lines[4];
|
|
|
|
_login = new Login(tenant, chatCode, userName, password, apiKey);
|
|
}
|
|
}
|
|
|
|
//_login = new Login("4368658436", "B7x0b-FhhJA", "jettenl", "", "0000");
|
|
//_login = new Login("3629696651", "2qsJH-qXBh3", "m59", "test123!", "C4UtAx8itmba2OZ2HKzYuK3F9jV3bEQbkRL6hNxvZGGFtFs1CgWWGRLFKYvEBmo6");
|
|
var loginControl = new ChatController.LoginControl();
|
|
|
|
loginControl.OnLogin += (c) =>
|
|
{
|
|
var containingGrid = (Grid) loginControl.Parent;
|
|
var owningWindow = (Window)containingGrid.Parent;
|
|
owningWindow.Close();
|
|
ServiceChatView = new ChatView(c);
|
|
ServiceChatView.Show();
|
|
};
|
|
|
|
var loginWindow = new Window
|
|
{
|
|
WindowStartupLocation = WindowStartupLocation.CenterScreen,
|
|
ResizeMode = ResizeMode.NoResize,
|
|
Title = "ownSoft Testlogin",
|
|
Height = 500,
|
|
Width = 700
|
|
};
|
|
|
|
var grid = new Grid();
|
|
|
|
grid.AddChild(loginControl);
|
|
|
|
loginWindow.Content = grid;
|
|
|
|
loginWindow.Show();
|
|
|
|
return;
|
|
#endif
|
|
|
|
if (ServiceChatView?.Visibility != Visibility.Visible)
|
|
{
|
|
#if DEBUG
|
|
|
|
BeWoApp.LoggedOnEmployeeOwnChatCode = "ZMCKb-BckTt";
|
|
string _kundennummer = "4368658436";
|
|
string _benutzername = "muellerp";
|
|
string _passwort = "F5aTk9Co47JFJCWB2Z7Y";
|
|
string _apikey;
|
|
|
|
#else
|
|
|
|
//var xxx = empAppCodes.Last();
|
|
|
|
string _kundennummer = BeWoApp.Tenant;
|
|
string _benutzername = BeWoApp.UserName;
|
|
string _passwort = BeWoApp.UserPassword;
|
|
string _apikey;
|
|
#endif
|
|
|
|
_apikey = BeWoApp.Mandator.Apikey ?? "0000";
|
|
|
|
if(!String.IsNullOrEmpty(BeWoApp.LoggedOnEmployeeOwnChatCode))
|
|
{
|
|
var login = new Login(_kundennummer, BeWoApp.LoggedOnEmployeeOwnChatCode, _benutzername, _passwort, _apikey);
|
|
|
|
var x = login.AnmeldevorgangDurchFuehren();
|
|
|
|
if(x != null)
|
|
{
|
|
ServiceChatView = new ChatView(x);
|
|
ServiceChatView.Closed += ServiceChatViewClosed;
|
|
ServiceChatView.Show();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show("Sie benötigen einen gültigen Chat-Code.", "Info");
|
|
}
|
|
}
|
|
}
|
|
|
|
private void ServiceChatViewClosed(object sender, EventArgs e)
|
|
{
|
|
ServiceChatView = null;
|
|
}
|
|
|
|
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)
|
|
{
|
|
s.DeleteTestAppointments();
|
|
|
|
this.Dispatch(() =>
|
|
{
|
|
LoadTasksAndAppointments(false, true);
|
|
});
|
|
}
|
|
});
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region InterfacesImplementations
|
|
|
|
#endregion
|
|
|
|
#region Properties
|
|
|
|
public List<CompactEmployeeDC> EmployeesForAppointmentView
|
|
{
|
|
get => _EmployeesForAppointmentView ?? (_EmployeesForAppointmentView = new List<CompactEmployeeDC>());
|
|
|
|
set
|
|
{
|
|
_EmployeesForAppointmentView = value;
|
|
OnPropertyChanged(nameof(EmployeesForAppointmentView));
|
|
}
|
|
}
|
|
|
|
public DateTime CurrentDate
|
|
{
|
|
get => _CurrentDate;
|
|
set
|
|
{
|
|
if (!Equals(_CurrentDate, value))
|
|
{
|
|
_CurrentDate = value;
|
|
UpdateAppointmentDateTextBlock(value);
|
|
OnPropertyChanged(nameof(CurrentDate));
|
|
}
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Indexers
|
|
|
|
#endregion
|
|
|
|
#region Methods
|
|
|
|
public void UpdateRequestsHyperLink()
|
|
{
|
|
if (PropertyScheduler != null)
|
|
{
|
|
PropertyScheduler.UpdateRequestString();
|
|
|
|
RequestsHyperLinkTextBlock.Text = PropertyScheduler.Requests;
|
|
RequestsHyperlink.IsEnabled = PropertyScheduler.Enabled;
|
|
RequestsTextBlock.IsEnabled = PropertyScheduler.Enabled;
|
|
}
|
|
}
|
|
|
|
public void SaveState()
|
|
{
|
|
var order = new List<DragDockPanel>();
|
|
DragDockPanel panelWithMaxHeight = null;
|
|
double maxHeight = 0;
|
|
double normalHeight = 0;
|
|
|
|
var result = new List<DependencyObject>();
|
|
|
|
foreach (var item in PanelHost.Children)
|
|
{
|
|
var p = item as DragDockPanel;
|
|
|
|
if (order.Count == 0)
|
|
{
|
|
order.Add(p);
|
|
}
|
|
else
|
|
{
|
|
var newIndex = -1;
|
|
var index = 0;
|
|
|
|
var rect = VisualTreeHelper.GetOffset(p);
|
|
foreach (var item2 in order)
|
|
{
|
|
string name1 = p.Name;
|
|
string name2 = item2.Name;
|
|
|
|
var rect2 = VisualTreeHelper.GetOffset(item2);
|
|
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;
|
|
}
|
|
|
|
var panelOrder = order.Select(item => item.Name).ToList();
|
|
|
|
BeWoApp.AppSettings.StartupPanelOrder = panelOrder;
|
|
}
|
|
|
|
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()
|
|
{
|
|
switch (BeWoApp.PasswortStrength)
|
|
{
|
|
case PasswortSecurityStrength.SehrSchwach:
|
|
PasswortSchloss.Foreground = new SolidColorBrush(Colors.Red);
|
|
|
|
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);
|
|
|
|
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();
|
|
}
|
|
}
|
|
|
|
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();
|
|
|
|
|
|
LoadContent();
|
|
}
|
|
|
|
private void LoadBewoNews()
|
|
{
|
|
try
|
|
{
|
|
if (BeWoApp.Tenant != "demo")
|
|
{
|
|
LoadFeed();
|
|
|
|
//LoadFeed("http://www.heise.de/foto/rss/news-atom.xml");
|
|
}
|
|
}
|
|
catch (Exception)
|
|
{
|
|
// ignored
|
|
}
|
|
}
|
|
|
|
private void LoadBirthdays()
|
|
{
|
|
var endOfWeek = DateTime.Now.GetNext(DayOfWeek.Sunday).Date;
|
|
endOfWeek = endOfWeek.AddDays(1).GetNext(DayOfWeek.Sunday).Date;
|
|
ServiceFacade.DoAnalysisServiceAsync(s1 => s1.GetPersonsHavingBirthday(endOfWeek), ReloadBirthdays, false);
|
|
}
|
|
|
|
private void LoadContent()
|
|
{
|
|
LoadLoginInfo();
|
|
|
|
if (IsPanelVisible("PanelTasks"))
|
|
{
|
|
LoadTasks();
|
|
}
|
|
|
|
if (IsPanelVisible("PanelExpiringSupportConcepts"))
|
|
{
|
|
LoadExpiredSupportConcepts();
|
|
}
|
|
|
|
if (IsPanelVisible("PanelConferenceDates"))
|
|
{
|
|
LoadNextConferenceDates();
|
|
}
|
|
|
|
if (IsPanelVisible("PanelBirthdates"))
|
|
{
|
|
LoadBirthdays();
|
|
}
|
|
|
|
if (IsPanelVisible("PanelInternalNews"))
|
|
{
|
|
UpdateInternalNews();
|
|
}
|
|
|
|
if (IsPanelVisible("PanelBeWoNews"))
|
|
{
|
|
LoadBewoNews();
|
|
}
|
|
|
|
|
|
rb_open.IsChecked = true;
|
|
}
|
|
|
|
private bool IsPanelVisible(string test)
|
|
{
|
|
foreach (DragDockPanel panel in PanelHost.Children)
|
|
{
|
|
if (panel.Name == test)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void LoadExpiredSupportConcepts()
|
|
{
|
|
// DateTime endOfWeek = DateTime.Now.GetNext(DayOfWeek.Sunday).Date;
|
|
// DateTime endOfWeek2 = endOfWeek.AddDays(8);
|
|
var dt = DateTime.Now.AddMonths(BeWoApp.AppSettings.HilfeplanAuslaufAuswahl);
|
|
ServiceFacade.DoAnalysisServiceAsync(
|
|
s1 => s1.GetExpiringSupportConcepts(BeWoApp.LoggedOnUser.Employee.EmployeeOid, dt),
|
|
ReloadExpiringSupportConcepts, false);
|
|
}
|
|
|
|
private void LoadLoginInfo()
|
|
{
|
|
DateTime endOfWeek = DateTime.Now.GetNext(DayOfWeek.Sunday).Date;
|
|
|
|
ServiceFacade.DoAnalysisServiceAsync(s1 => s1.GetLastLogins(BeWoApp.LoggedOnUser.LoginName), ReloadLogins, false);
|
|
}
|
|
|
|
private void LoadNextConferenceDates()
|
|
{
|
|
DateTime endOfWeek = DateTime.Now.GetNext(DayOfWeek.Sunday).Date;
|
|
DateTime endOfWeek2 = endOfWeek.AddDays(8);
|
|
|
|
ServiceFacade.DoAnalysisServiceAsync(
|
|
s1 => s1.GetSupportConceptsWithConferenceDate(BeWoApp.LoggedOnUser.Employee.EmployeeOid, endOfWeek2),
|
|
ReloadConferenceDates, false);
|
|
}
|
|
|
|
private void LoadTasks()
|
|
{
|
|
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;
|
|
});
|
|
}, false);
|
|
}
|
|
else
|
|
{
|
|
EmployeesForAppointmentView = new List<CompactEmployeeDC> { BeWoApp.CompactLoggedOnEmployee };
|
|
employeeFilterBox.SelectedItem = BeWoApp.CompactLoggedOnEmployee;
|
|
}
|
|
|
|
ShowAppointments(false);
|
|
LoadTasksAndAppointments(true, true);
|
|
}
|
|
}
|
|
|
|
private void UpdateInternalNews()
|
|
{
|
|
if (InternalNewsGrid != null)
|
|
{
|
|
_NewsItemExpandedState.Clear();
|
|
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;
|
|
}
|
|
}
|
|
}
|
|
if (!_NewsItemExpandedState.ContainsKey(text))
|
|
{
|
|
_NewsItemExpandedState.Add(text, ex.IsExpanded);
|
|
}
|
|
|
|
}
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
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),
|
|
RefreshInternalNews, false);
|
|
}
|
|
|
|
private void UpdatePanels(List<HomeViewPanelDC> panels)
|
|
{
|
|
if (panels != null && panels.Count > 0)
|
|
{
|
|
PanelHost.Children.Clear();
|
|
|
|
var dict = new Dictionary<HomeViewPanelType, DragDockPanel>()
|
|
{
|
|
{HomeViewPanelType.BeWoNewsPanel, PanelBeWoNews},
|
|
{HomeViewPanelType.BirthdatesPanel, PanelBirthdates},
|
|
{HomeViewPanelType.ConferenceDatesPanel, PanelConferenceDates},
|
|
{HomeViewPanelType.ExpiringSupportConceptsPanel, PanelExpiringSupportConcepts},
|
|
{HomeViewPanelType.InternalNewsPanel, PanelInternalNews},
|
|
{HomeViewPanelType.TasksPanel, PanelTasks}
|
|
};
|
|
|
|
|
|
//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 });
|
|
|
|
var save = BeWoApp.AppSettings.StartupPanelOrder;
|
|
if (save == null || save.Count != panels.Count)
|
|
{
|
|
save = panels.Select(p => GetDefaultPanelName(p)).ToList();
|
|
}
|
|
|
|
foreach (var name in save)
|
|
{
|
|
foreach (var panelDC in panels)
|
|
{
|
|
if (GetDefaultPanelName(panelDC) == name)
|
|
{
|
|
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();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
SetMaximizedPanel();
|
|
}
|
|
else
|
|
{
|
|
|
|
ReorderPanels();
|
|
}
|
|
InitPanels(null);
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
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"
|
|
}
|
|
}
|
|
}
|
|
};
|
|
var ctrl = new DocumentPreviewControl
|
|
{
|
|
CommandBarStyle = CommandBarStyle.None,
|
|
Margin = new Thickness(-3, -4, -3, -3)
|
|
};
|
|
panel.Content = ctrl;
|
|
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"
|
|
}
|
|
}
|
|
},
|
|
Content = XamlReader.Parse(xamlString)
|
|
};
|
|
|
|
return panel;
|
|
}
|
|
|
|
private void LoadReport(string reportName, string title, DragDockPanel panel)
|
|
{
|
|
ServiceFacade.DoReportServiceAsync(s => s.CreateCustomReport(BeWoApp.LoggedOnEmployee.EmployeeOid.Value, reportName), ms => SetReportControl(ms, title, panel), false);
|
|
}
|
|
|
|
private void SetReportControl(MemoryStream ms, string title, DragDockPanel panel)
|
|
{
|
|
this.Dispatch(
|
|
delegate
|
|
{
|
|
//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)
|
|
{
|
|
BeWoUtils.ShowReportWindow(ms, title, panel.Content as DocumentPreviewControl);
|
|
}
|
|
});
|
|
|
|
}
|
|
|
|
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;
|
|
|
|
if (_NewsItemExpandedState.Count == 0)
|
|
{
|
|
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;
|
|
}
|
|
|
|
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;
|
|
|
|
if (_NewsItemExpandedState.ContainsKey(teamNewsItemVm.Team.Name))
|
|
{
|
|
expanded = _NewsItemExpandedState[teamNewsItemVm.Team.Name];
|
|
}
|
|
|
|
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();
|
|
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) });
|
|
|
|
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(25, GridUnitType.Pixel) });
|
|
grid.RowDefinitions.Add(new RowDefinition { Height = new GridLength(1, GridUnitType.Star) });
|
|
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);
|
|
editBtn.Style = (Style)FindResource("FlatButton");
|
|
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);
|
|
deleteBtn.Style = (Style)FindResource("FlatButton");
|
|
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();
|
|
|
|
foreach (var appointment in pRecurringAppointments.OrderBy(o => o.Type))
|
|
{
|
|
if (appointment.Type == (int)AppointmentType.Pattern)
|
|
{
|
|
var id = Utils.ExtractIdFromRecurrenceInfo(appointment.RecurrenceInfo);
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
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);
|
|
|
|
foreach (var devExpressAppointment in occurrences)
|
|
{
|
|
var index = devExpressAppointment.RecurrenceIndex;
|
|
|
|
if (index == 0 && appointment.Occurrences.ContainsKey(0))
|
|
{
|
|
_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,
|
|
Type = (int)AppointmentType.Occurrence,
|
|
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,
|
|
LabelKey = patternAppointment.LabelKey,
|
|
RecurrenceIndex = devExpressAppointment.RecurrenceIndex,
|
|
RecurrenceId = appointment.RecurrenceId,
|
|
ServiceRecordList = new List<ServiceRecordDC>()
|
|
};
|
|
|
|
_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
|
|
{
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
|
|
RssFeed feed = new RssFeed();
|
|
|
|
RssManager mgr = new RssManager(url);
|
|
feed.Items = mgr.GetFeed();
|
|
feed.Title = mgr.FeedTitle;
|
|
feed.Description = mgr.FeedDescription;
|
|
|
|
ReloadRssFeed(feed, false);
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
if (pShouldShowAppointments)
|
|
{
|
|
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)
|
|
{
|
|
if (_CurrentDate < _BufferDate || _CurrentDate > _BufferDate.AddDays(3 * Datebuffer) || pForceUpdate)
|
|
{
|
|
_BufferDate = _CurrentDate.AddDays(-1 * Datebuffer);
|
|
|
|
ServiceFacade.DoResourceServiceAsync(s => s.LoadTasksAndAppointmentsForEmployee(BeWoApp.LoggedOnEmployeeOid.Value, _CurrentDate, Datebuffer, _SelectedEmployeeForAppointments?.EmployeeOid), cb =>
|
|
{
|
|
this.Dispatch(delegate
|
|
{
|
|
_AllSchedulerTasks = cb;
|
|
|
|
//BuildRecurringAppointments(_AllSchedulerTasks.Where(w => w.RecurrenceInfo != null).ToList(), _CurrentDate, _CurrentDate.AddDays(3 * Datebuffer));
|
|
|
|
if (pIsShowingTasks)
|
|
{
|
|
var list = _AllSchedulerTasks.Where(i => i.IsTask && !i.CompletedDate.HasValue).OrderBy(i => i.DueDate).OrderBy(o => o.StartDate ?? DateTime.MinValue).ToList();
|
|
listboxTasks.ItemsSource = list;
|
|
if (list.Count == 0 && rb_appointments.IsVisible)
|
|
{
|
|
//Zeige standardmäßig Termine, falls keine Aufgaben vorhanden sind.
|
|
rb_appointments.IsChecked = true;
|
|
}
|
|
|
|
}
|
|
else
|
|
listboxTasks.ItemsSource = _AllSchedulerTasks.Where(i => !i.IsTask).ToList();
|
|
// Filtern der Termine nach Zeitraum wird für April 2025 Release auf Server verlagert
|
|
//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) &&
|
|
// i.Type != (int)AppointmentType.DeletedOccurrence).OrderBy(o => o.StartDate ?? DateTime.MinValue).ToList();
|
|
//}
|
|
|
|
|
|
});
|
|
}, false);
|
|
}
|
|
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
|
|
{
|
|
ServiceFacade.DoResourceServiceAsync(s => s.LoadTasksAndAppointmentsForEmployee(BeWoApp.LoggedOnEmployeeOid.Value, _CurrentDate, Datebuffer, _SelectedEmployeeForAppointments?.EmployeeOid), l =>
|
|
{
|
|
this.Dispatch(delegate
|
|
{
|
|
_AllSchedulerTasks = l;
|
|
//BuildRecurringAppointments(_AllSchedulerTasks.Where(w => w.RecurrenceInfo != null).ToList(), _CurrentDate, _CurrentDate.AddDays(3 * Datebuffer));
|
|
listboxTasks.ItemsSource = _AllSchedulerTasks.Where(i => !i.IsTask).ToList();
|
|
|
|
});
|
|
});
|
|
|
|
|
|
//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) &&
|
|
// i.Type != (int)AppointmentType.DeletedOccurrence).OrderBy(o => o.StartDate ?? DateTime.MinValue).ToList();
|
|
|
|
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()
|
|
{
|
|
var save = BeWoApp.AppSettings.StartupPanelOrder;
|
|
var actual = PanelHost.Children.Cast<DragDockPanel>().Select(item => item.Name).ToList();
|
|
|
|
if (save == null || save.Count != actual.Count || actual.Except(save).Any()) return;
|
|
|
|
var panels = new Dictionary<string, DragDockPanel>();
|
|
|
|
foreach (var item in PanelHost.Children)
|
|
{
|
|
var p = item as DragDockPanel;
|
|
panels.Add(p.Name, p);
|
|
}
|
|
|
|
PanelHost.Children.Clear();
|
|
|
|
save.DoForEach(x => PanelHost.AddPanel(panels[x]));
|
|
|
|
|
|
}
|
|
|
|
private void SetMaximizedPanel()
|
|
{
|
|
if (!string.IsNullOrEmpty(BeWoApp.AppSettings.StartupPanelMaximized))
|
|
{
|
|
foreach (object item in PanelHost.Children)
|
|
{
|
|
var p = item as DragDockPanel;
|
|
if (BeWoApp.AppSettings.StartupPanelMaximized.Equals(p.Name))
|
|
{
|
|
//IEnumerable<DependencyObject> objekts = p.GetAllChildren();
|
|
|
|
//foreach (DependencyObject child in objekts)
|
|
//{
|
|
// if (child is ToggleButton btn)
|
|
// {
|
|
// btn.IsChecked = true;
|
|
// }
|
|
//}
|
|
p.PanelMaximized = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
private void SaveNewsItem(NewsItemVM vm)
|
|
{
|
|
ServiceFacade.DoEmployeeServiceSync(s => s.InsertNewNewsItem(vm.CommitToDataContract()));
|
|
UpdateInternalNews();
|
|
}
|
|
|
|
private void UpdateNewsItem(NewsItemVM vm)
|
|
{
|
|
ServiceFacade.DoEmployeeServiceSync(s => s.UpdateNewsItem(vm.CommitToDataContract()));
|
|
UpdateInternalNews();
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region NotNeeded
|
|
|
|
private delegate void loadFeed(string url);
|
|
private List<TaskDC> _AllTasks;
|
|
private bool _IsAllowedToSeeCustomerAppointments;
|
|
private bool _IsAllowedToSeeResourceAppointments;
|
|
|
|
private void PreparePanels()
|
|
{
|
|
ServiceFacade.DoOperationsServiceAsyncNoWait(
|
|
s => s.GetUiElements(UiElementType.StartPanel, BeWoApp.LoggedOnUser.Employee.EmployeeOid, null, null),
|
|
InitPanelsCallback, null);
|
|
}
|
|
|
|
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");
|
|
|
|
// //BeWo.ServiceProxy.ServiceFacade.DoMailServiceAsync(s => s.DeleteMail(BeWoApp.LoggedOnUser.Employee.EmployeeOid, outboxList.SelectedItem as MailDC);
|
|
// }
|
|
|
|
// //throw new NotImplementedException();
|
|
// }
|
|
|
|
// private void InboxItem_DoubleClick(object sender, RoutedEventArgs e)
|
|
// {
|
|
// var listboItem = sender as ListBoxItem;
|
|
// var content = listboItem.Content as MailDC;
|
|
|
|
// MainControl.NavigateTo(new ViewMailView(content) { ParentView = this });
|
|
|
|
// //throw new NotImplementedException();
|
|
// }
|
|
|
|
// private void OutboxItem_DoubleClick(object sender, RoutedEventArgs e)
|
|
// {
|
|
// var listboItem = sender as ListBoxItem;
|
|
// var content = listboItem.Content as MailDC;
|
|
|
|
// MainControl.NavigateTo(new ViewMailView(content) { ParentView = this });
|
|
}
|
|
|
|
private void listboxBirthdays_MouseDoubleClick(object sender, MouseButtonEventArgs e)
|
|
{
|
|
//if (!IsPartOf(e.OriginalSource, typeof (ScrollBar)))
|
|
//{
|
|
// var dc = ((ListBox) sender).SelectedItem as CompactPersonDC;
|
|
|
|
// if (dc != null)
|
|
// {
|
|
// 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
|
|
// });
|
|
// }));
|
|
// }
|
|
// }
|
|
//}
|
|
}
|
|
|
|
#endregion
|
|
}
|
|
|
|
#region Structs
|
|
|
|
public struct RecurringAppointment
|
|
{
|
|
public string RecurrenceId { get; set; }
|
|
public Dictionary<int, SchedulerAppointmentDC> Occurrences { get; set; }
|
|
public SchedulerAppointmentDC Pattern { get; set; }
|
|
|
|
public RecurringAppointment(string pRecurrenceId, Dictionary<int, SchedulerAppointmentDC> pOccurrences, SchedulerAppointmentDC pPattern)
|
|
{
|
|
RecurrenceId = pRecurrenceId;
|
|
Occurrences = pOccurrences;
|
|
Pattern = pPattern;
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
|
|
#region Classes
|
|
|
|
public class TaskDateDescriptionConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if(value is SchedulerAppointmentDC task && task.IsTask)
|
|
{
|
|
if(task.CompletedDate.HasValue)
|
|
{
|
|
return $"erledigt am: {task.CompletedDate:d}";
|
|
}
|
|
|
|
if(task.DueDate.HasValue && task.DueDate.Equals(DateTime.MaxValue))
|
|
{
|
|
return string.Empty;
|
|
}
|
|
|
|
if(task.DueDate.HasValue)
|
|
{
|
|
return string.Format("bis {0:d} {0:t}", task.DueDate);
|
|
}
|
|
|
|
if(task.StartDate.HasValue)
|
|
{
|
|
return task.AllDay ? $"{task.StartDate:d}" : $"{task.StartDate:d} {task.StartDate:t}";
|
|
}
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) => throw new NotImplementedException();
|
|
}
|
|
|
|
public class TaskListItemBackgroundConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if (value is SchedulerAppointmentDC task && !task.IsTask)
|
|
{
|
|
if (parameter != null)
|
|
{
|
|
switch (parameter.ToString())
|
|
{
|
|
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);
|
|
|
|
if (value is SchedulerAppointmentDC appointment && !appointment.IsTask && parameter != null)
|
|
{
|
|
switch (parameter.ToString())
|
|
{
|
|
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)
|
|
{
|
|
if (value is SchedulerAppointmentDC task && !task.IsTask)
|
|
{
|
|
return new SolidColorBrush(Color.FromRgb(0, 0, 0));
|
|
}
|
|
|
|
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)
|
|
{
|
|
if (value is SchedulerAppointmentDC taskAppointment)
|
|
{
|
|
switch (parameter?.ToString())
|
|
{
|
|
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;
|
|
case "EmployeeBorderVisibility":
|
|
return !taskAppointment.IsTask && taskAppointment.EmployeeList?.Count > 0 || taskAppointment.Originator != null ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
}
|
|
|
|
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)
|
|
{
|
|
if (value is SchedulerAppointmentDC taskAppointment)
|
|
{
|
|
if (!taskAppointment.IsTask)
|
|
{
|
|
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;
|
|
}
|
|
|
|
if (isResourceOrCustomer)
|
|
{
|
|
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
|
|
{
|
|
switch (parameter?.ToString())
|
|
{
|
|
case "TimeText":
|
|
return string.Empty;
|
|
}
|
|
}
|
|
|
|
if (parameter != null && parameter.Equals("ToolTip"))
|
|
{
|
|
return taskAppointment.IsTask ? taskAppointment.TaskDescription : taskAppointment.Description;
|
|
}
|
|
}
|
|
|
|
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;
|
|
|
|
if (values.Length == 2)
|
|
{
|
|
var actualHeight = (double)values[0];
|
|
var appointment = (SchedulerAppointmentDC)values[1];
|
|
|
|
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();
|
|
}
|
|
|
|
public class AptToServRecsIconVisibilityConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if(value is SchedulerAppointmentDC appointment)
|
|
{
|
|
return appointment.HasServiceRecordEntry || appointment.ServiceRecordList.Any() ? Visibility.Visible : Visibility.Collapsed;
|
|
}
|
|
|
|
return Visibility.Collapsed;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
public class SubjectTextConverter : IValueConverter
|
|
{
|
|
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
if(value is SchedulerAppointmentDC appointment)
|
|
{
|
|
return appointment.IsTask ? appointment.Subject : $"{(appointment.AllDay ? $"{appointment.StartDate:d}" : $"{appointment.StartDate:d} {appointment.StartDate:t}")}: {appointment.Subject}";
|
|
}
|
|
|
|
return string.Empty;
|
|
}
|
|
|
|
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
|
|
{
|
|
throw new NotImplementedException();
|
|
}
|
|
}
|
|
|
|
#endregion
|
|
} |