894 lines
38 KiB
C#
894 lines
38 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Collections.ObjectModel;
|
|
using System.ComponentModel;
|
|
using System.Globalization;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Reflection;
|
|
using System.Windows;
|
|
using System.Windows.Controls;
|
|
using System.Windows.Documents;
|
|
using System.Windows.Input;
|
|
using System.Windows.Markup;
|
|
using System.Windows.Media;
|
|
using System.Windows.Threading;
|
|
|
|
using BeWo.Core;
|
|
using BeWo.Core.Config;
|
|
using BeWo.ServiceProxy;
|
|
using BeWo.View;
|
|
using BeWo.View.Navigation;
|
|
using BeWo.View.Navigation.Filter;
|
|
|
|
using BS.Shared;
|
|
using BS.Shared.DataContracts;
|
|
using BS.Shared.DataContracts.Compact;
|
|
using BS.Shared.Extensions;
|
|
using BS.Shared.Core;
|
|
|
|
using ChatController.HauptKlassen;
|
|
using DevExpress.Xpf.Core;
|
|
using DevExpress.Xpf.Grid;
|
|
using BS.SharedLauncher;
|
|
using BS.SharedLauncher.Information;
|
|
|
|
namespace BeWo
|
|
{
|
|
public static class MainSession
|
|
{
|
|
public static string ShortVersion = "3";
|
|
public static string Version = "Version 3.0 TEST";
|
|
public static int RenderTier = 0;
|
|
|
|
private static AppSettings _AppSettings;
|
|
private static CompactEmployeeDC _CompactLoggedOnEmployee;
|
|
private static EmployeeDC _LoggedOnEmployee;
|
|
private static UserDC _LoggedOnUser;
|
|
private static MandatorDC _Mandator;
|
|
private static List<Window> _OpenDevExpressEditForms = new List<Window>();
|
|
private static DocumentWatcher _DocumentWatcher;
|
|
|
|
private static FrameworkElement _lockedContent;
|
|
|
|
private static int _LockUITime = 30;
|
|
|
|
|
|
static MainSession()
|
|
{
|
|
MainSessionSingleton.Instance.LoggedOnUsersRights = LoggedOnUsersRights;
|
|
}
|
|
|
|
public static Dictionary<string, string> ICD10Diagnosis { get; set; }
|
|
public static EmployeeDC LoggedOnEmployee
|
|
{
|
|
get { return _LoggedOnEmployee; }
|
|
|
|
set { _LoggedOnEmployee = value; }
|
|
}
|
|
|
|
public static long? LoggedOnEmployeeOid => _LoggedOnEmployee?.EmployeeOid;
|
|
public static CompactEmployeeDC CompactLoggedOnEmployee
|
|
{
|
|
get => _CompactLoggedOnEmployee;
|
|
|
|
set => _CompactLoggedOnEmployee = value;
|
|
}
|
|
public static ObservableCollection<UserRightType> LoggedOnUsersRights
|
|
{
|
|
get
|
|
{
|
|
if (LoggedOnUser != null)
|
|
return LoggedOnUser.GetGrantedRights().ToObservableCollection();
|
|
return null;
|
|
}
|
|
}
|
|
public static DocumentWatcher DocumentWatcher
|
|
{
|
|
get
|
|
{
|
|
if (_DocumentWatcher == null)
|
|
{
|
|
_DocumentWatcher = new DocumentWatcher();
|
|
}
|
|
|
|
return _DocumentWatcher;
|
|
}
|
|
}
|
|
public static AppSettings AppSettings
|
|
{
|
|
get
|
|
{
|
|
if (_AppSettings == null)
|
|
{
|
|
RestoreAppSettings();
|
|
}
|
|
|
|
return _AppSettings;
|
|
}
|
|
}
|
|
public static UserDC LoggedOnUser
|
|
{
|
|
get => _LoggedOnUser;
|
|
|
|
set
|
|
{
|
|
_LoggedOnUser = value;
|
|
if (_LoggedOnUser != null)
|
|
{
|
|
var settings = _LoggedOnUser.Settings;
|
|
|
|
//Session.BeginInvokeNormal(() =>
|
|
ServiceFacade.DoEmployeeServiceAsync(s => s.LoadEmployee(value.Employee.EmployeeOid),
|
|
r =>
|
|
{
|
|
_LoggedOnEmployee = r;
|
|
|
|
ServiceFacade.DoEmployeeServiceAsync(s => s.LoadCompactEmployee(value.Employee.EmployeeOid), r2 => { _CompactLoggedOnEmployee = r2; });
|
|
|
|
Session.BeginInvokeNormal(() => MainPage.InitOffeneTermine());
|
|
});
|
|
}
|
|
|
|
Session.FirePropertyChanged("LoggedOnUsersRights");
|
|
}
|
|
}
|
|
public static MandatorDC Mandator
|
|
{
|
|
get => _Mandator;
|
|
|
|
set
|
|
{
|
|
_Mandator = value;
|
|
|
|
bool showDatevFields = false;
|
|
bool isServiceRecordNoticeMandatory = true;
|
|
bool isPasswordSecurityActiv = false;
|
|
bool showServiceRecordsDistanceFields = false;
|
|
bool showHilfeplanBezeichnung = false;
|
|
bool showArbeitszeiten = false;
|
|
bool showCustomerDistanceFields = false;
|
|
bool showAdditionalService = false;
|
|
bool showRoundedDurationInEmployeeAnalysis = true;
|
|
bool showTeamNews = false;
|
|
bool showMarker = false;
|
|
bool showAnnualReport = false;
|
|
int maxDaysEditServiceRecordsAllowed = 0;
|
|
int hilfeplanAuslaufAuswahl = 3;
|
|
int anzTageZeiterfassErfolgt = 0;
|
|
int zeiterfassungsSchwellwert = 80;
|
|
bool printerSettingsUseLandscape = false;
|
|
bool printerSettingsUseMargins = false;
|
|
bool printerSettingsUsePaperKind = false;
|
|
var hideServiceRecordInsertedByAndInsertedOn = false;
|
|
bool isEndDateVisible = false;
|
|
bool isOnlyYearMonthVisible = false;
|
|
bool isZeiterfassDateNormal = true;
|
|
bool isZeiterfassungInStdMin = false;
|
|
int lastSelectedStundenkontoIntervall = 3;
|
|
bool showSignatures = false;
|
|
bool showRtfTextfield = false;
|
|
bool showPivotGrid = false;
|
|
bool showUrlaubsplanung = false;
|
|
bool dontShowSpitzabrechnung = false;
|
|
bool showDienstplanung = false;
|
|
|
|
|
|
AppSettings.ShowAdvisedAttendedFlag = false;
|
|
String timeRecordingMenuName = "";
|
|
|
|
if (_Mandator != null)
|
|
{
|
|
string val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowMedication");
|
|
AppSettings.IsMedicationAllowed = val != null && val.Equals("1");
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowScheduler");
|
|
AppSettings.IsSchedulerAllowed = val != null && val.Equals("1");
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowWohnheime");
|
|
AppSettings.IsWohnheimAllowed = val != null && val.Equals("1");
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowChat");
|
|
AppSettings.IsChatAllowed = val != null && val.Equals("1");
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "IsServiceRecordNoticeMandatory");
|
|
if (val != null && val.Equals("0"))
|
|
{
|
|
isServiceRecordNoticeMandatory = false;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "IsPasswordSecurityActiv");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
isPasswordSecurityActiv = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "IsEndDateVisible");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
isEndDateVisible = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "IsOnlyYearMonthVisible");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
isOnlyYearMonthVisible = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "IsZeiterfassungInStdMin");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
isZeiterfassungInStdMin = true;
|
|
}
|
|
if (!isZeiterfassungInStdMin)
|
|
{
|
|
AppSettings.LetzteZeiterfassungsDauer = ZeiterfassungsDauer.Minuten;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "IsZeiterfassDateNormal");
|
|
if (val != null && val.Equals("0"))
|
|
{
|
|
isZeiterfassDateNormal = false;
|
|
}
|
|
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "MaxDaysEditServiceRecordsAllowed");
|
|
int result;
|
|
if (Int32.TryParse(val, out result))
|
|
{
|
|
maxDaysEditServiceRecordsAllowed = result;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "HilfeplanAuslaufAuswahl");
|
|
int resultplan;
|
|
if (Int32.TryParse(val, out resultplan))
|
|
{
|
|
hilfeplanAuslaufAuswahl = resultplan;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "LastSelectedStundenkontoIntervall");
|
|
int resultinterval;
|
|
if (Int32.TryParse(val, out resultinterval))
|
|
{
|
|
lastSelectedStundenkontoIntervall = resultinterval;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "AnzTageZeiterfassErfolgt");
|
|
int resultzeitplan;
|
|
if (Int32.TryParse(val, out resultzeitplan))
|
|
{
|
|
anzTageZeiterfassErfolgt = resultzeitplan;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ZeiterfassungsSchwellwert");
|
|
int resultschwell;
|
|
if (Int32.TryParse(val, out resultschwell))
|
|
{
|
|
zeiterfassungsSchwellwert = resultschwell;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowDistanceFields");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showServiceRecordsDistanceFields = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowHilfeplanBezeichnung");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showHilfeplanBezeichnung = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowArbeitszeiten");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showArbeitszeiten = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowRessources");
|
|
AppSettings.ShowRessources = val != null && val.Equals("1");
|
|
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowTeamNews");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showTeamNews = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowPivotGrid");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showPivotGrid = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowUrlaubsplanung");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showUrlaubsplanung = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "dontShowSpitzabrechnung");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
dontShowSpitzabrechnung = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowDienstplanung");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showDienstplanung = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowMarker");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showMarker = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowAnnualReport");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showAnnualReport = true;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowCustomerDistanceFields");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showCustomerDistanceFields = true;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowAdditionalService");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showAdditionalService = true;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowRoundedDurationInEmployeeAnalysis");
|
|
if (val != null && val.Equals("0"))
|
|
{
|
|
showRoundedDurationInEmployeeAnalysis = false;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowDatevFields");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showDatevFields = true;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "PrinterSettingsUseLandscape");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
printerSettingsUseLandscape = true;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "PrinterSettingsUseMargins");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
printerSettingsUseMargins = true;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "PrinterSettingsUsePaperKind");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
printerSettingsUsePaperKind = true;
|
|
}
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "HideServiceRecordInsertedByAndInsertedOn");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
hideServiceRecordInsertedByAndInsertedOn = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowSignature");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showSignatures = true;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(_Mandator.Settings, "ShowRtfTextfield");
|
|
if (val != null && val.Equals("1"))
|
|
{
|
|
showRtfTextfield = true;
|
|
}
|
|
|
|
|
|
switch (_Mandator.BeWoClientType)
|
|
{
|
|
case 1:
|
|
//Die Kette
|
|
showDatevFields = true;
|
|
AppSettings.ShowAdvisedAttendedFlag = true;
|
|
break;
|
|
case 2:
|
|
//Datev
|
|
showDatevFields = true;
|
|
break;
|
|
case 3:
|
|
////Köln Ring
|
|
showDatevFields = true;
|
|
timeRecordingMenuName = "Dokumentation";
|
|
break;
|
|
case 4:
|
|
//Betreuwo
|
|
break;
|
|
|
|
case 5:
|
|
//Kontakt und Krisenhilfe
|
|
AppSettings.ShowLargeCustomerNotice = true;
|
|
break;
|
|
case 6:
|
|
// Nur Jahresbericht
|
|
break;
|
|
case 7:
|
|
//IBP
|
|
showDatevFields = true;
|
|
break;
|
|
case 8:
|
|
//LH Würzburg
|
|
break;
|
|
case 9:
|
|
//Caritas Frankfurt+Aids Hilfe Gießen + Alle mit Korridor (Kostenträger Hessen)
|
|
break;
|
|
case 10:
|
|
//Integra
|
|
showDatevFields = true;
|
|
break;
|
|
case 11:
|
|
//Hannover
|
|
showDatevFields = true;
|
|
break;
|
|
}
|
|
}
|
|
|
|
AppSettings.ShowDatevFields = showDatevFields;
|
|
AppSettings.IsServiceRecordNoticeMandatory = isServiceRecordNoticeMandatory;
|
|
AppSettings.IsPasswordSecurityActiv = isPasswordSecurityActiv;
|
|
AppSettings.IsEndDateVisible = isEndDateVisible;
|
|
AppSettings.IsOnlyYearMonthVisible = isOnlyYearMonthVisible;
|
|
AppSettings.IsZeiterfassDateNormal = isZeiterfassDateNormal;
|
|
AppSettings.IsZeiterfassungInStdMin = isZeiterfassungInStdMin;
|
|
AppSettings.MaxDaysEditServiceRecordsAllowed = maxDaysEditServiceRecordsAllowed;
|
|
AppSettings.HilfeplanAuslaufAuswahl = hilfeplanAuslaufAuswahl;
|
|
AppSettings.LastSelectedStundenkontoIntervall = lastSelectedStundenkontoIntervall;
|
|
AppSettings.AnzTageZeiterfassErfolgt = anzTageZeiterfassErfolgt;
|
|
AppSettings.ZeiterfassungsSchwellwert = zeiterfassungsSchwellwert;
|
|
AppSettings.TimeRecordingMenuName = timeRecordingMenuName;
|
|
AppSettings.ShowDistanceFields = showServiceRecordsDistanceFields;
|
|
AppSettings.ShowHilfeplanBezeichnung = showHilfeplanBezeichnung;
|
|
AppSettings.ShowArbeitszeiten = showArbeitszeiten;
|
|
AppSettings.ShowSignatures = showSignatures;
|
|
AppSettings.ShowRtfTextfield = showRtfTextfield;
|
|
AppSettings.ShowCustomerDistanceFields = showCustomerDistanceFields;
|
|
AppSettings.ShowAdditionalService = showAdditionalService;
|
|
AppSettings.ShowRoundedDurationInEmployeeAnalysis = showRoundedDurationInEmployeeAnalysis;
|
|
AppSettings.HideServiceRecordInsertedByAndInsertedOn = hideServiceRecordInsertedByAndInsertedOn;
|
|
AppSettings.ShowTeamNews = showTeamNews;
|
|
AppSettings.ShowMarker = showMarker;
|
|
AppSettings.ShowAnnualReport = showAnnualReport;
|
|
AppSettings.PrinterSettingsUseLandscape = printerSettingsUseLandscape;
|
|
AppSettings.PrinterSettingsUseMargins = printerSettingsUseMargins;
|
|
AppSettings.PrinterSettingsUsePaperKind = printerSettingsUsePaperKind;
|
|
AppSettings.ShowPivotGrid = showPivotGrid;
|
|
AppSettings.ShowUrlaubsplanung = showUrlaubsplanung;
|
|
AppSettings.DontShowSpitzabrechnung = dontShowSpitzabrechnung;
|
|
AppSettings.ShowDienstplanung = showDienstplanung;
|
|
|
|
BS.Shared.Settings.ApplicationSettings.SupportConceptExpirationLimitInMonths = AppSettings.HilfeplanAuslaufAuswahl;
|
|
}
|
|
}
|
|
public static int LockUITime
|
|
{
|
|
get
|
|
{
|
|
var lockTime = _Mandator.Settings.SplitToKeyValuePairList(";", "=").FirstOrDefault(f => f.Key.Equals("TimeUntilUILock")).Value;
|
|
|
|
if (_LoggedOnUser != null && lockTime != null)
|
|
{
|
|
return Convert.ToInt32(lockTime);
|
|
}
|
|
|
|
return _LockUITime;
|
|
}
|
|
|
|
set
|
|
{
|
|
_LockUITime = value;
|
|
|
|
if (_LoggedOnUser == null)
|
|
{
|
|
return;
|
|
}
|
|
|
|
AutoLockUI.LockUITime = value;
|
|
AutoLockUI.StopTimer();
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
}
|
|
}
|
|
public static MainPage MainPage { get; set; }
|
|
|
|
|
|
public static string GetAndCreateUserAppDataPath()
|
|
{
|
|
try
|
|
{
|
|
string localAppData = Environment.GetFolderPath(
|
|
Environment.SpecialFolder.LocalApplicationData);
|
|
string companyFilePath
|
|
= Path.Combine(localAppData, "beyondSoft");
|
|
|
|
if (!Directory.Exists(companyFilePath))
|
|
Directory.CreateDirectory(companyFilePath);
|
|
|
|
string bewoFilePath
|
|
= Path.Combine(companyFilePath, "BeWoPlaner");
|
|
|
|
if (!Directory.Exists(bewoFilePath))
|
|
Directory.CreateDirectory(bewoFilePath);
|
|
|
|
return bewoFilePath;
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(
|
|
"Fehler beim Anlegen des Anwendungsordners. Sie besitzen nicht die erforderlichen Rechte, bitte wenden Sie sich an Ihren Systemadministrator.\n" +
|
|
ex.Message, "BeWoPlaner", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
}
|
|
return Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
|
|
}
|
|
internal static bool HasLoggedOnUserRight(UserRightType[] pRight)
|
|
{
|
|
if (LoggedOnUser != null)
|
|
{
|
|
return pRight == null || (pRight.Length == 1 && pRight[0] == UserRightType.None) || LoggedOnUser.GetGrantedRights().Exists(
|
|
right =>
|
|
{
|
|
var rightAsString = pRight.ToString();
|
|
var vals = rightAsString.Split(",");
|
|
|
|
foreach (var urt in pRight)
|
|
{
|
|
if (urt == right)
|
|
{
|
|
return true;
|
|
}
|
|
}
|
|
|
|
return false;
|
|
});
|
|
}
|
|
|
|
return false;
|
|
}
|
|
internal static void SaveAppSettings()
|
|
{
|
|
if (_AppSettings != null && _LoggedOnUser != null && _AppSettings.IsDirty)
|
|
{
|
|
_AppSettings.IsDirty = false;
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "WindowStateType", ((int)_AppSettings.WindowState).ToString(), _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "LastSelectedServiceRecordTimeInterval", ((int)_AppSettings.LastSelectedServiceRecordTimeInterval).ToString(), _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "CustomerFilterInZeiterfassung", ((int)_AppSettings.CustomerFilterInZeiterfassung).ToString(), _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "CustomerFilterSupportConcepts", ((int)_AppSettings.CustomerFilterSupportConcepts).ToString(), _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "CustomerFilterCustomers", ((int)_AppSettings.CustomerFilterCustomers).ToString(), _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "ShowExpiredSupportConcepts", _AppSettings.ShowExpiredSupportConcepts ? "1" : "0", _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "ShowServiceRecordGridControl", _AppSettings.ShowServiceRecordGridControl ? "1" : "0", _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "StartupPanelMaximized", _AppSettings.StartupPanelMaximized, _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "HideServiceRecordInsertedByAndInsertedOn", _AppSettings.HideServiceRecordInsertedByAndInsertedOn ? "1" : "0", _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "DocumentationFontSize", _AppSettings.DocumentationFontSize.ToString(), _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "ZeigeNurMeineTermine", _AppSettings.ZeigeNurMeineTermine ? "1" : "0", _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "LastSelectedServiceRecordTimeIntervalDays", _AppSettings.LastSelectedServiceRecordTimeIntervalDays.ToString(), _LoggedOnUser.Settings);
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "LetzteZeiterfassungsDauer", ((int)_AppSettings.LetzteZeiterfassungsDauer).ToString(), _LoggedOnUser.Settings);
|
|
|
|
string val = string.Empty;
|
|
if (_AppSettings.StartupPanelOrder != null)
|
|
{
|
|
foreach (string item in _AppSettings.StartupPanelOrder)
|
|
{
|
|
if (val.Length > 0)
|
|
{
|
|
val += "|";
|
|
}
|
|
|
|
val += item;
|
|
}
|
|
}
|
|
|
|
UserSettingsUtils.SetSettingValue(SettingsType.ApplicationSettings, "StartupPanelOrder", val, _LoggedOnUser.Settings);
|
|
|
|
ServiceFacade.DoUserServiceAsync(s => s.UpdateUserSettings(_LoggedOnUser.UserOid.Value, _LoggedOnUser.Settings), ReloadSettings, false);
|
|
}
|
|
}
|
|
public static void FirePropertyChanged(string pPropertyName)
|
|
{
|
|
Session.FirePropertyChanged(pPropertyName);
|
|
}
|
|
public static void InitAutoUILocking()
|
|
{
|
|
EventManager.RegisterClassHandler(typeof(Window), UIElement.PreviewMouseDownEvent, new MouseButtonEventHandler(OnPreviewMouseDown));
|
|
EventManager.RegisterClassHandler(typeof(Window), UIElement.PreviewKeyDownEvent, new KeyEventHandler(OnPreviewKeyDown));
|
|
|
|
var settingsKeyValuePairList = _Mandator.Settings.SplitToKeyValuePairList(";", "=").ToList();
|
|
|
|
var x = settingsKeyValuePairList.FirstOrDefault(f => f.Key.Equals("TimeUntilUILock")).Value ?? "NULL";
|
|
|
|
var y = _LockUITime;
|
|
|
|
AutoLockUI.LockUITime = Convert.ToInt32(settingsKeyValuePairList.FirstOrDefault(f => f.Key.Equals("TimeUntilUILock")).Value ?? LockUITime.ToString());
|
|
|
|
|
|
AutoLockUI.DoAutoLockUIEvent += AutoLockUIDoAutoLockUIEvent;
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
}
|
|
private static void ReloadSettings(List<SettingsDC> settings)
|
|
{
|
|
if (_LoggedOnUser != null)
|
|
_LoggedOnUser.Settings = settings;
|
|
}
|
|
private static void RestoreAppSettings()
|
|
{
|
|
if (_LoggedOnUser != null)
|
|
{
|
|
_AppSettings = new AppSettings();
|
|
var settings = _LoggedOnUser.Settings;
|
|
|
|
var val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "WindowStateType", settings);
|
|
if (int.TryParse(val, out var result))
|
|
{
|
|
_AppSettings.WindowState = (AppSettings.WindowStateType)result;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "LastSelectedServiceRecordTimeInterval", settings);
|
|
if (int.TryParse(val, out result))
|
|
{
|
|
_AppSettings.LastSelectedServiceRecordTimeInterval = (ServiceRecordTimeInterval)result;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "CustomerFilterInZeiterfassung", settings);
|
|
if (int.TryParse(val, out result))
|
|
{
|
|
_AppSettings.CustomerFilterInZeiterfassung = (CustomerFilterEnum)result;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "CustomerFilterSupportConcepts", settings);
|
|
if (int.TryParse(val, out result))
|
|
{
|
|
_AppSettings.CustomerFilterSupportConcepts = (CustomerFilterEnum)result;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "CustomerFilterCustomers", settings);
|
|
if (int.TryParse(val, out result))
|
|
{
|
|
_AppSettings.CustomerFilterCustomers = (CustomerFilterEnum)result;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "ShowServiceRecordGridControl", settings);
|
|
_AppSettings.ShowServiceRecordGridControl = val == "1";
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "ShowExpiredSupportConcepts", settings);
|
|
_AppSettings.ShowExpiredSupportConcepts = val != "0";
|
|
|
|
|
|
|
|
_AppSettings.StartupPanelMaximized = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "StartupPanelMaximized", settings);
|
|
|
|
_AppSettings.DocumentationFontSize = Convert.ToDouble(UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "DocumentationFontSize", settings));
|
|
|
|
//val = GetSettingValue(SettingsType.ApplicationSettings, "ZeigeNurMeineTermine");
|
|
//_AppSettings.ZeigeNurMeineTermine = val != "0";
|
|
|
|
_AppSettings.ZeigeNurMeineTermine = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "ZeigeNurMeineTermine", settings) == "1";
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "LastSelectedServiceRecordTimeIntervalDays", settings);
|
|
if (val != null)
|
|
{
|
|
_AppSettings.LastSelectedServiceRecordTimeIntervalDays = Convert.ToInt32(UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "LastSelectedServiceRecordTimeIntervalDays", settings));
|
|
}
|
|
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "LetzteZeiterfassungsDauer", settings);
|
|
if (val != null)
|
|
{
|
|
var x = Convert.ToInt32(UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "LetzteZeiterfassungsDauer", settings));
|
|
_AppSettings.LetzteZeiterfassungsDauer = x == 0 ? ZeiterfassungsDauer.Minuten : ZeiterfassungsDauer.Stunden;
|
|
}
|
|
|
|
val = UserSettingsUtils.GetSettingValue(SettingsType.ApplicationSettings, "StartupPanelOrder", settings);
|
|
if (val != null)
|
|
{
|
|
_AppSettings.StartupPanelOrder = new List<string>();
|
|
var panels = val.Split('|');
|
|
|
|
foreach (var item in panels)
|
|
{
|
|
_AppSettings.StartupPanelOrder.Add(item);
|
|
}
|
|
}
|
|
|
|
_AppSettings.IsDirty = false;
|
|
}
|
|
}
|
|
private static void BtnOpenServiceRecordView_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var btn = sender as Button;
|
|
if (btn == null) return;
|
|
|
|
var dc = btn.Tag as CompactSupportConceptDC;
|
|
|
|
if (dc == null) return;
|
|
|
|
if (MainPage != null)
|
|
MainPage.NavigateToServiceRecordView(dc.SupportConceptOid);
|
|
}
|
|
private static void Togglebutton_maximise_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainPage != null)
|
|
MainPage.Maximize();
|
|
}
|
|
private static void Togglebutton_maximise_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainPage != null)
|
|
MainPage.Minimize();
|
|
}
|
|
private static void TogglebuttonChat_maximise_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainPage.HomeView.ServiceChatView != null)
|
|
MainPage.HomeView.ServiceChatView.Normal();
|
|
}
|
|
private static void TogglebuttonChat_maximise_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainPage.HomeView.ServiceChatView != null)
|
|
MainPage.HomeView.ServiceChatView.Maximize();
|
|
}
|
|
private static void TogglebuttonChat_Minimize_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainPage.HomeView.ServiceChatView != null)
|
|
MainPage.HomeView.ServiceChatView.Minimize();
|
|
}
|
|
private static void FrameLeftMouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
var border = (Border)sender;
|
|
var borderParent = (Grid)border.Parent;
|
|
DependencyObject template = borderParent.TemplatedParent;
|
|
var parent = new Window();
|
|
|
|
var x = (FrameworkElement)template;
|
|
if (x != null)
|
|
{
|
|
var y = new FrameworkElement();
|
|
while (y != null)
|
|
{
|
|
y = (FrameworkElement)x.Parent;
|
|
if (y != null)
|
|
x = y;
|
|
}
|
|
|
|
if (x is Window)
|
|
{
|
|
parent = (Window)x;
|
|
parent.DragMove();
|
|
}
|
|
}
|
|
}
|
|
private static void AutoLockUIDoAutoLockUIEvent()
|
|
{
|
|
if (ConnectionInformation.Username.Equals("BSAdmin"))
|
|
{
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
return;
|
|
}
|
|
|
|
if (MainPage.Content is LockedPage)
|
|
{
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
return;
|
|
}
|
|
|
|
_lockedContent = MainPage.Content as FrameworkElement;
|
|
|
|
var openWindowCollection = Application.Current.Windows;
|
|
foreach (var blubb in openWindowCollection)
|
|
{
|
|
var abc = (Window)blubb;
|
|
|
|
if (!abc.Title.Equals("BeWoPlaner") && blubb.GetType() == typeof(WindowContentHolder))
|
|
{
|
|
abc.Close();
|
|
}
|
|
}
|
|
|
|
MainPage.HideCurrentModalViewWindows();
|
|
|
|
var lockedPage = new LockedPage();
|
|
lockedPage.ButtonLogin.Click += UnlockBeWoPlaner;
|
|
|
|
Application.Current.MainWindow.Content = lockedPage;
|
|
|
|
Application.Current.Dispatcher.Invoke(new Action(() => Application.Current.MainWindow?.Activate()));
|
|
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
}
|
|
|
|
private static void UnlockBeWoPlaner(object sender, RoutedEventArgs e)
|
|
{
|
|
var lbtn = (Button)sender;
|
|
|
|
var lbtnParent = (Grid)lbtn.Parent;
|
|
var mainWindowUIElements = new UIElement[lbtnParent.Children.Count];
|
|
lbtnParent.Children.CopyTo(mainWindowUIElements, 0);
|
|
|
|
var elementList = mainWindowUIElements.ToList();
|
|
var username = ((TextBox)elementList.Where(el => el is TextBox && ((TextBox)el).Name.Equals("TextBoxUsername")).ToList()[0]).Text;
|
|
var password = ((PasswordBox)elementList.Where(el => el is PasswordBox && ((PasswordBox)el).Name.Equals("PasswordBoxPassword")).ToList()[0]).Password;
|
|
|
|
if (string.IsNullOrEmpty(username) || !username.Equals(_LoggedOnUser.LoginName, StringComparison.OrdinalIgnoreCase))
|
|
{
|
|
MessageBox.Show("Das Programm kann nur vom Benutzer '" + _LoggedOnUser.LoginName + "' entsperrt werden.", "Fehler bei der Anmeldung", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
return;
|
|
}
|
|
|
|
username = $"{username}//Version=Sperrung aufgehoben";
|
|
|
|
ServiceFacade.DoUserServiceAsync(u => u.IsUserValid(username, password, ""), r =>
|
|
{
|
|
if (!r.Equals(ServiceProxy.UserValidationResult.UserValid))
|
|
{
|
|
MessageBox.Show("Anmeldeinformationen nicht bekannt. Bitte überprüfen Sie den Benutzernamen und das Passwort!", "Fehler bei der Anmeldung", MessageBoxButton.OK, MessageBoxImage.Exclamation);
|
|
return;
|
|
}
|
|
|
|
AutoLockUI.HasJustBeenUnlocked = true;
|
|
|
|
Application.Current.Dispatcher.Invoke(delegate
|
|
{
|
|
Application.Current.MainWindow.Content = _lockedContent;
|
|
|
|
MainPage.ShowCurrentModalViewWindowsAgain();
|
|
});
|
|
}, true);
|
|
}
|
|
|
|
private static void OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
AutoLockUI.ResetLockUITimer();
|
|
}
|
|
|
|
private static void OnPreviewKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
AutoLockUI.ResetLockUITimer();
|
|
}
|
|
|
|
private static void Hyperlink_Hilfeplan_Reaktivieren_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var scNavView = (SupportConceptNavigationView)MainPage.ActiveView;
|
|
|
|
if (scNavView != null)
|
|
{
|
|
var supportConcept = (CompactSupportConceptDC)((Hyperlink)sender).Tag;
|
|
scNavView.MainNavigationView_OnReactivateObject(supportConcept);
|
|
}
|
|
}
|
|
|
|
public static void GetChatServerUrlAsync(Action<string> callback)
|
|
{
|
|
if (string.IsNullOrWhiteSpace(ConnectionInformation.ServerName))
|
|
{
|
|
var tenant = ConnectionInformation.Tenant;
|
|
|
|
#if DEBUG
|
|
tenant = "5473568546";
|
|
#endif
|
|
|
|
var login = new Login(tenant, serverUrl =>
|
|
{
|
|
if (!string.IsNullOrWhiteSpace(serverUrl))
|
|
{
|
|
callback(serverUrl);
|
|
}
|
|
});
|
|
}
|
|
else
|
|
{
|
|
callback?.Invoke(ConnectionInformation.ChatServerAddress);
|
|
}
|
|
}
|
|
public static void Cleanup()
|
|
{
|
|
_lockedContent = null;
|
|
_AppSettings = null;
|
|
_CompactLoggedOnEmployee = null;
|
|
_LoggedOnEmployee = null;
|
|
_LoggedOnUser = null;
|
|
_Mandator = null;
|
|
}
|
|
}
|
|
} |