1023 lines
37 KiB
C#
1023 lines
37 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;
|
|
|
|
namespace BeWo
|
|
{
|
|
/// <summary>
|
|
/// Interaction logic for App.xaml
|
|
/// </summary>
|
|
public partial class BeWoApp : Application, INotifyPropertyChanged
|
|
{
|
|
private static FrameworkElement _lockedContent;
|
|
|
|
public static LoginControl LoginControl;
|
|
|
|
public static MainControl MainControl;
|
|
|
|
public static string Version = "Version 2.4.6 TEST";
|
|
|
|
public static int RenderTier = 0;
|
|
|
|
internal static string IpAddress = string.Empty;
|
|
|
|
internal static string Tenant = string.Empty;
|
|
|
|
internal static string ServerName = string.Empty;
|
|
|
|
internal static string UserName = string.Empty;
|
|
|
|
internal static string UserPassword = string.Empty;
|
|
|
|
internal static string chatServerURL = string.Empty;
|
|
|
|
private static AppSettings _AppSettings;
|
|
|
|
private static CompactEmployeeDC _CompactLoggedOnEmployee;
|
|
private static EmployeeDC _LoggedOnEmployee;
|
|
|
|
private static UserDC _LoggedOnUser;
|
|
|
|
private static MandatorDC _Mandator;
|
|
private static string _ServerAddress;
|
|
private static int _LockUITime = 30;
|
|
private static List<Window> OpenDevExpressEditForms = new List<Window>();
|
|
|
|
private static DocumentWatcher _DocumentWatcher;
|
|
|
|
internal static PasswortSecurityStrength PasswortStrength;
|
|
|
|
public static BeWoApp CurrentBeWo
|
|
{
|
|
get { return Current as BeWoApp; }
|
|
}
|
|
|
|
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 ObservableCollection<UserRightType> LoggedOnUsersRights
|
|
{
|
|
get
|
|
{
|
|
if (LoggedOnUser != null)
|
|
return LoggedOnUser.GetGrantedRights().ToObservableCollection();
|
|
return null;
|
|
}
|
|
}
|
|
|
|
public DocumentWatcher DocumentWatcher
|
|
{
|
|
get
|
|
{
|
|
if (_DocumentWatcher == null)
|
|
{
|
|
_DocumentWatcher = new DocumentWatcher();
|
|
}
|
|
|
|
return _DocumentWatcher;
|
|
}
|
|
}
|
|
|
|
public static string ServerAddress
|
|
{
|
|
get { return _ServerAddress; }
|
|
|
|
set
|
|
{
|
|
//if (_ServerAddress != null && _ServerAddress.Equals(value))
|
|
// return;
|
|
_ServerAddress = value;
|
|
ServiceFacade.UpdateServerAddresses(SiteOfOrigin.ToString());
|
|
}
|
|
}
|
|
|
|
public static AppSettings AppSettings
|
|
{
|
|
get
|
|
{
|
|
if (_AppSettings == null)
|
|
{
|
|
RestoreAppSettings();
|
|
}
|
|
|
|
return _AppSettings;
|
|
}
|
|
}
|
|
|
|
internal static UserDC LoggedOnUser
|
|
{
|
|
get => _LoggedOnUser;
|
|
|
|
set
|
|
{
|
|
_LoggedOnUser = value;
|
|
if (_LoggedOnUser != null)
|
|
{
|
|
var settings = _LoggedOnUser.Settings;
|
|
|
|
ServiceFacade.DoEmployeeServiceAsync(s => s.LoadEmployee(value.Employee.EmployeeOid),
|
|
r =>
|
|
{
|
|
_LoggedOnEmployee = r;
|
|
|
|
ServiceFacade.DoEmployeeServiceAsync(s => s.LoadCompactEmployee(value.Employee.EmployeeOid), r2 => { _CompactLoggedOnEmployee = r2; });
|
|
|
|
MainControl?.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) (() => MainControl.InitOffeneTermine()));
|
|
});
|
|
}
|
|
|
|
CurrentBeWo.FirePropertyChanged("LoggedOnUsersRights");
|
|
}
|
|
}
|
|
|
|
internal 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;
|
|
|
|
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, "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;
|
|
|
|
BS.Shared.Settings.ApplicationSettings.SupportConceptExpirationLimitInMonths = AppSettings.HilfeplanAuslaufAuswahl;
|
|
}
|
|
}
|
|
|
|
internal static Uri SiteOfOrigin
|
|
{
|
|
get
|
|
{
|
|
String url = ServerAddress.ToLower();
|
|
|
|
#if DEBUG
|
|
url = String.Format("http://localhost:3777/Host");
|
|
//return new Uri("https://app4.bewoplaner.de/servicesbd");
|
|
//url = String.Format("app1.bewoplaner.de/service");
|
|
#endif
|
|
|
|
if (url.IndexOf("localhost") < 0)
|
|
{
|
|
int i;
|
|
|
|
if (url.IndexOf("fortis") < 0)
|
|
{
|
|
if (Int32.TryParse(url, out i))
|
|
url = "app" + url;
|
|
|
|
if (url.IndexOf('.') < 0)
|
|
{
|
|
url += ".bewoplaner.de";
|
|
}
|
|
}
|
|
//if (url.IndexOf("/service45") < 0)
|
|
//{
|
|
// url += "/service45";
|
|
//}
|
|
if (url.IndexOf("/servicesbd") < 0)
|
|
{
|
|
url += "/servicesbd";
|
|
}
|
|
|
|
if (ServerAddress == "10.0.116.4") //LH Würzburg
|
|
return new Uri(String.Format("http://{0}", url));
|
|
return new Uri(String.Format("https://{0}", url));
|
|
}
|
|
return new Uri(url);
|
|
}
|
|
}
|
|
|
|
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 event PropertyChangedEventHandler PropertyChanged;
|
|
|
|
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);
|
|
}
|
|
}
|
|
|
|
internal static void ShowError(string message, Exception ex, bool showDetails)
|
|
{
|
|
if (MainControl != null)
|
|
{
|
|
MainControl.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) (() => MainControl.ShowControlAsModalPopup(new ExceptionMessageBox(message, ex, showDetails))));
|
|
}
|
|
else if (LoginControl != null)
|
|
{
|
|
LoginControl.Dispatcher.BeginInvoke(DispatcherPriority.Normal, (Action) (() => LoginControl.ShowControlAsModalPopUp(new ExceptionMessageBox(message, ex, showDetails))));
|
|
}
|
|
else
|
|
{
|
|
MessageBox.Show(message + "\n\n" + ex);
|
|
}
|
|
}
|
|
|
|
internal void FirePropertyChanged(string pPropertyName)
|
|
{
|
|
if (PropertyChanged != null)
|
|
{
|
|
PropertyChanged(this, new PropertyChangedEventArgs(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();
|
|
}
|
|
|
|
protected override void OnStartup(StartupEventArgs e)
|
|
{
|
|
//Licenser.LicenseKey = "DGF20-AUTJ7-3K8MD-DNNA";
|
|
DataControlBase.AllowInfiniteGridSize = true;
|
|
//Timeline.DesiredFrameRateProperty.OverrideMetadata(typeof(Timeline),
|
|
// new FrameworkPropertyMetadata { DefaultValue = 30 });
|
|
|
|
RenderTier = RenderCapability.Tier >> 16;
|
|
|
|
|
|
base.OnStartup(e);
|
|
//AppDomain.CurrentDomain.UnhandledException += (s, ex) => ShowError(null, ex.ExceptionObject as Exception, true);
|
|
|
|
Dispatcher.UnhandledException += (s, ex)
|
|
=>
|
|
{
|
|
if (ex.Exception == null || String.IsNullOrEmpty(ex.Exception.Message) || !ex.Exception.ToString().Contains("DevExpress.Xpf.Bars.Customization.CustomizationControl.OnLoaded") || !ex.Exception.ToString().Contains("DevExpress.Xpf.Grid.Native.SelectionStrategyCellBase.IsCellSelected"))
|
|
|
|
{
|
|
ShowError(null, ex.Exception, true);
|
|
}
|
|
ex.Handled = true;
|
|
};
|
|
|
|
FrameworkElement.LanguageProperty.OverrideMetadata(typeof (FrameworkElement), new FrameworkPropertyMetadata(XmlLanguage.GetLanguage(CultureInfo.CurrentCulture.IetfLanguageTag)));
|
|
}
|
|
|
|
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 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 (MainControl != null)
|
|
MainControl.NavigateToServiceRecordView(dc.SupportConceptOid);
|
|
}
|
|
|
|
private void Togglebutton_maximise_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainControl != null)
|
|
MainControl.Maximize();
|
|
}
|
|
|
|
private void Togglebutton_maximise_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainControl != null)
|
|
MainControl.Minimize();
|
|
}
|
|
|
|
private void TogglebuttonChat_maximise_Unchecked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainControl.HomeView.ServiceChatView != null)
|
|
MainControl.HomeView.ServiceChatView.Normal();
|
|
}
|
|
|
|
private void TogglebuttonChat_maximise_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainControl.HomeView.ServiceChatView != null)
|
|
MainControl.HomeView.ServiceChatView.Maximize();
|
|
}
|
|
|
|
private void TogglebuttonChat_Minimize_Checked(object sender, RoutedEventArgs e)
|
|
{
|
|
if (MainControl.HomeView.ServiceChatView != null)
|
|
MainControl.HomeView.ServiceChatView.Minimize();
|
|
}
|
|
|
|
private 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 (UserName.Equals("BSAdmin"))
|
|
{
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
return;
|
|
}
|
|
|
|
if (CurrentBeWo.MainWindow?.Content is LockedPage)
|
|
{
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
return;
|
|
}
|
|
|
|
_lockedContent = CurrentBeWo.MainWindow?.Content as FrameworkElement;
|
|
|
|
if (_lockedContent is Grid && (_lockedContent as Grid).Children.Contains(LoginControl))
|
|
{
|
|
AutoLockUI.StartAutoLockUIOption();
|
|
return;
|
|
}
|
|
|
|
var openWindowCollection = Current.Windows;
|
|
foreach(var blubb in openWindowCollection)
|
|
{
|
|
var abc = (Window) blubb;
|
|
|
|
if(!abc.Title.Equals("BeWoPlaner") && blubb.GetType() == typeof(WindowContentHolder))
|
|
{
|
|
abc.Close();
|
|
}
|
|
}
|
|
|
|
MainControl.HideCurrentModalViewWindows();
|
|
|
|
var lockedPage = new LockedPage();
|
|
lockedPage.ButtonLogin.Click += UnlockBeWoPlaner;
|
|
|
|
CurrentBeWo.MainWindow.Content = lockedPage;
|
|
|
|
Current.Dispatcher.Invoke(new Action(() => CurrentBeWo.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(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;
|
|
|
|
Current.Dispatcher.Invoke(delegate
|
|
{
|
|
CurrentBeWo.MainWindow.Content = _lockedContent;
|
|
|
|
MainControl.ShowCurrentModalViewWindowsAgain();
|
|
});
|
|
}, true);
|
|
}
|
|
|
|
private static void OnPreviewMouseDown(object sender, MouseButtonEventArgs e)
|
|
{
|
|
AutoLockUI.ResetLockUITimer();
|
|
}
|
|
|
|
private static void OnPreviewKeyDown(object sender, KeyEventArgs e)
|
|
{
|
|
AutoLockUI.ResetLockUITimer();
|
|
}
|
|
|
|
private void Hyperlink_Hilfeplan_Reaktivieren_Click(object sender, RoutedEventArgs e)
|
|
{
|
|
var scNavView = (SupportConceptNavigationView) MainControl.ActiveView;
|
|
|
|
if (scNavView != null)
|
|
{
|
|
var supportConcept = (CompactSupportConceptDC) ((Hyperlink) sender).Tag;
|
|
scNavView.MainNavigationView_OnReactivateObject(supportConcept);
|
|
}
|
|
}
|
|
|
|
public static string GetChatServerURL()
|
|
{
|
|
if (chatServerURL.IsNullOrEmpty())
|
|
{
|
|
#if DEBUG
|
|
Login login = new Login("5473568546");
|
|
#else
|
|
Login login = new Login(BeWoApp.Tenant);
|
|
#endif
|
|
chatServerURL = login.ServerUrl;
|
|
}
|
|
return chatServerURL;
|
|
|
|
}
|
|
|
|
public static void Cleanup()
|
|
{
|
|
_lockedContent = null;
|
|
LoginControl = null;
|
|
MainControl = null;
|
|
_AppSettings = null;
|
|
_CompactLoggedOnEmployee = null;
|
|
_LoggedOnEmployee = null;
|
|
_LoggedOnUser = null;
|
|
_Mandator = null;
|
|
|
|
}
|
|
|
|
public static void InitBlubb()
|
|
{
|
|
var timer = new System.Threading.Timer(
|
|
e => MainControl.AufOffeneTerminePruefen(), null ,TimeSpan.Zero, TimeSpan.FromMinutes(1)
|
|
);
|
|
}
|
|
}
|
|
} |