Reihenfolge

This commit is contained in:
2024-11-29 14:46:19 +01:00
parent 3d2acddd0b
commit 03ea11fefa
5 changed files with 265 additions and 273 deletions

View File

@@ -75,17 +75,14 @@ namespace BeWo.ServiceProxy
{
DoAsync<AccountingServiceClient, IAccountingService, T>(pFunc, pCallBack, true);
}
public static void DoAccountingServiceAsync(Action<IAccountingService> pAction)
{
DoAsync<AccountingServiceClient, IAccountingService>(pAction, true);
}
public static void DoAccountingServiceAsync(Action<IAccountingService> pAction, Action callback)
{
DoAsync<AccountingServiceClient, IAccountingService>(pAction, callback, true);
}
public static T DoAccountingServiceSync<T>(Func<IAccountingService, T> pFunc)
{
try
@@ -99,19 +96,16 @@ namespace BeWo.ServiceProxy
return default(T);
}
public static void DoAnalysisServiceAsync<T>(Func<IAnalysisService, T> pFunc, Action<T> pCallBack)
{
DoAsync<AnalysisServiceClient, IAnalysisService, T>(pFunc, pCallBack, true);
}
public static void DoAnalysisServiceAsync<T>(Func<IAnalysisService, T> pFunc, Action<T> pCallBack, bool showWaitDialog)
{
DoAsync<AnalysisServiceClient, IAnalysisService, T>(pFunc, pCallBack, showWaitDialog);
}
public static void DoAccountingServiceSync(Action<IAccountingService> pAction)
{
pAction.Invoke(GetInstance<AccountingServiceClient, IAccountingService>());
@@ -806,17 +800,6 @@ namespace BeWo.ServiceProxy
}
}
private static void EndWaiting()
{
Monitor.Enter(_Lock);
if ((--_RunningAsyncs) == 0 && BeWoApp.MainControl != null)
{
BeWoApp.MainControl.EndWaiting();
}
Monitor.Exit(_Lock);
}
private static TInterface GetInstance<TClient, TInterface>()
where TClient : ClientBase<TInterface>, TInterface, new()
where TInterface : class
@@ -878,7 +861,7 @@ namespace BeWo.ServiceProxy
BeWoApp.ShowErrorMessage(e);
}
private static void StartWaiting()
private static void StartWaiting()
{
Monitor.Enter(_Lock);
if ((++_RunningAsyncs) == 1 && BeWoApp.MainControl != null)
@@ -889,5 +872,15 @@ namespace BeWo.ServiceProxy
Monitor.Exit(_Lock);
}
private static void EndWaiting()
{
Monitor.Enter(_Lock);
if ((--_RunningAsyncs) == 0 && BeWoApp.MainControl != null)
{
BeWoApp.MainControl.EndWaiting();
}
Monitor.Exit(_Lock);
}
}
}

View File

@@ -10,194 +10,198 @@ using BS.Shared;
namespace BeWo.View
{
public class BeWoView : UserControl
{
public Action ModalEditViewUpdateCallback;
public class BeWoView : UserControl
{
public Action ModalEditViewUpdateCallback;
public virtual bool IsDoneWithInsertOrUpdate { get; set; }
public virtual bool IsDoneWithInsertOrUpdate { get; set; }
public event EventHandler BlendOutComplete;
public event EventHandler BlendOutComplete;
public virtual bool CanDelete
{
get
{
return false;
}
}
public virtual bool CanDelete
{
get
{
return false;
}
}
public virtual bool CanExcelExport
{
get
{
return false;
}
}
public virtual bool CanExcelExport
{
get
{
return false;
}
}
public virtual bool CanWordExport
{
get
{
return false;
}
}
public virtual bool CanWordExport
{
get
{
return false;
}
}
public virtual bool IsDirty
{
get
{
return false;
}
}
public virtual bool IsDirty
{
get
{
return false;
}
}
public virtual BeWoView ParentView { get; set; }
public virtual BeWoView ParentView { get; set; }
public virtual string SaveObjectName
{
get
{
return this.Title;
}
}
public virtual string SaveObjectName
{
get
{
return this.Title;
}
}
public virtual string Title
{
get
{
return string.Empty;
}
}
public virtual string Title
{
get
{
return string.Empty;
}
}
public virtual bool IsInWindow { get; set; }
public virtual bool IsInWindow { get; set; }
internal virtual DependencyObject ValidationOnSaveRootElement
{
get
{
return this;
}
}
internal virtual DependencyObject ValidationOnSaveRootElement
{
get
{
return this;
}
}
protected MainControl MainControl
{
get
{
return BeWoApp.MainControl;
}
}
protected MainControl MainControl
{
get
{
return BeWoApp.MainControl;
}
}
public void BlendIn()
{
DoubleAnimation lAnim = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.3)));
this.BeginAnimation(OpacityProperty, lAnim);
}
public void BlendIn()
{
DoubleAnimation lAnim = new DoubleAnimation(1, new Duration(TimeSpan.FromSeconds(0.3)));
this.BeginAnimation(OpacityProperty, lAnim);
}
public void BlendOut()
{
DoubleAnimation lAnim = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.3)));
lAnim.Completed += (s, e) =>
{
if (this.BlendOutComplete != null)
{
this.BlendOutComplete(this, e);
}
};
this.BeginAnimation(OpacityProperty, lAnim);
}
public void BlendOut()
{
DoubleAnimation lAnim = new DoubleAnimation(0, new Duration(TimeSpan.FromSeconds(0.3)));
lAnim.Completed += (s, e) =>
{
if (this.BlendOutComplete != null)
{
this.BlendOutComplete(this, e);
}
};
this.BeginAnimation(OpacityProperty, lAnim);
}
public virtual void Delete()
{
}
public virtual void Delete()
{
}
public virtual void ExportToExcel(string pFileID)
{
}
public virtual void ExportToExcel(string pFileID)
{
}
public virtual void ExportToWord(string pFileID)
{
}
public virtual void ExportToWord(string pFileID)
{
}
public virtual void ModalPopUpCloseInvoked()
{
}
public virtual void ModalPopUpCloseInvoked()
{
}
public virtual void ModalPopUpSaveInvoked()
{
}
public virtual void ModalPopUpSaveInvoked()
{
}
public virtual void ChildViewClosed()
{
}
public virtual void ChildViewClosed()
{
}
public bool SaveData()
{
if (!BeWoApp.HasLoggedOnUserRight(this.GetSaveDemands()))
{
MessageBox.Show("Sie besitzen nicht die nötigen Rechte um zu speichern. Bitte wenden Sie sich an den Administrator!", "Autorisierung fehlgeschlagen", MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
public bool SaveData()
{
if (!BeWoApp.HasLoggedOnUserRight(this.GetSaveDemands()))
{
MessageBox.Show("Sie besitzen nicht die nötigen Rechte um zu speichern. Bitte wenden Sie sich an den Administrator!", "Autorisierung fehlgeschlagen", MessageBoxButton.OK, MessageBoxImage.Warning);
return false;
}
var lValid = ValidationTrigger.Validate(this.ValidationOnSaveRootElement);
if (lValid)
{
Save();
}
else
{
MessageBox.Show("Bitte füllen Sie alle Pflichtfelder aus!", "Speichern nicht möglich", MessageBoxButton.OK, MessageBoxImage.Warning);
}
var lValid = ValidationTrigger.Validate(this.ValidationOnSaveRootElement);
if (lValid)
{
Save();
}
else
{
MessageBox.Show("Bitte füllen Sie alle Pflichtfelder aus!", "Speichern nicht möglich", MessageBoxButton.OK, MessageBoxImage.Warning);
}
return lValid;
}
return lValid;
}
public virtual MessageBoxResult ShowSaveQuestion()
{
return string.IsNullOrEmpty(this.SaveObjectName) ? MessageBox.Show("Wollen Sie die Änderungen speichern?", "Änderungen speichern", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) : MessageBox.Show("Wollen Sie die Änderungen an " + this.SaveObjectName + " speichern?", "Änderungen speichern", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
}
public virtual MessageBoxResult ShowSaveQuestion()
{
return string.IsNullOrEmpty(this.SaveObjectName) ? MessageBox.Show("Wollen Sie die Änderungen speichern?", "Änderungen speichern", MessageBoxButton.YesNoCancel, MessageBoxImage.Question) : MessageBox.Show("Wollen Sie die Änderungen an " + this.SaveObjectName + " speichern?", "Änderungen speichern", MessageBoxButton.YesNoCancel, MessageBoxImage.Question);
}
internal virtual bool DoSaveCheck()
{
if (this.IsDirty)
{
MessageBoxResult lResult = this.ShowSaveQuestion();
if (lResult == MessageBoxResult.Cancel)
{
this.Focus();
return false;
}
/// <summary>
/// Gibt false zurück, wenn Speicherfrage abgelehnt wird, sonst true
/// </summary>
/// <returns></returns>
internal virtual bool DoSaveCheck()
{
if (!IsDirty)
return true;
if (lResult == MessageBoxResult.Yes)
{
this.SaveData();
}
}
MessageBoxResult lResult = this.ShowSaveQuestion();
if (lResult == MessageBoxResult.Cancel)
{
this.Focus();
return false;
}
return true;
}
if (lResult == MessageBoxResult.Yes)
{
this.SaveData();
}
protected virtual UserRightType[] GetSaveDemands()
{
return null;
}
return true;
}
protected virtual UserRightType[] GetSaveDemands()
{
return null;
}
protected virtual void Save()
{
}
protected virtual void Save()
{
}
protected bool Validate(DependencyObject lElement)
{
return ValidationTrigger.Validate(lElement);
}
protected bool Validate(DependencyObject lElement)
{
return ValidationTrigger.Validate(lElement);
}
protected virtual void popup_Closed(object sender, EventArgs e)
{
this.MainControl.AnimateOpacity(1, 100);
}
protected virtual void popup_Closed(object sender, EventArgs e)
{
this.MainControl.AnimateOpacity(1, 100);
}
protected virtual void popup_Opened(object sender, EventArgs e)
{
this.MainControl.AnimateOpacity(0.5, 200);
}
}
protected virtual void popup_Opened(object sender, EventArgs e)
{
this.MainControl.AnimateOpacity(0.5, 200);
}
}
}

View File

@@ -111,10 +111,11 @@ namespace BeWo.View.Detail
{
invoiceNumberList.Add(ivm.CommitToDataContract());
}
ServiceFacade.DoAccountingServiceAsync(
s => s.UpdateInvoiceNumberList(invoiceNumberList),
inl => ServiceFacade.DoOperationsServiceAsync(
s => s.UpdateMandator(this.ViewModel.CommitToDataContract()),
s => s.UpdateMandator(ViewModel.CommitToDataContract()),
m => this.Dispatch(
delegate
{
@@ -147,8 +148,7 @@ namespace BeWo.View.Detail
else
{
ViewModel.EinheitZeiterfassung = "0";
}
}
}
}
}

View File

@@ -13,7 +13,8 @@
Height="Auto"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
Focusable="True">
Focusable="True"
Loaded="AdministrationView_Loaded">
<Grid>
<uc:ShadowChrome>
<GroupBox Style="{StaticResource MainContentGroupBoxStyle}">

View File

@@ -31,11 +31,6 @@ namespace BeWo.View.Master
InitializeComponent();
//GenerateNewView(TabitemMandator);
this.Loaded += AdministrationView_Loaded;
MouseMove += (s, e) =>
{
var p = e.GetPosition(btnSave);
@@ -110,11 +105,99 @@ namespace BeWo.View.Master
}
public override bool IsDirty => SelectedView != null &&
SelectedView.IsDirty;
public BeWoView SelectedView
{
get => _SelectedView;
set
{
if (value == null) return;
_SelectedView = value;
ContentBorder.Child = value;
}
}
public MandatorVM MandatorVM
{
get => _MandatorVM;
set
{
_MandatorVM = value;
if (_OpenViews.TryGetValue(TabitemMandator.Header.ToString(), out var cachedView) && cachedView is MandatorView mandatorView)
{
mandatorView.ViewModel = value;
}
if (_OpenViews.TryGetValue(TabitemSozioTherapie.Header.ToString(), out var cachedView2) && cachedView2 is SoziotherapieSettingsView soziotherapieSettingsView)
{
soziotherapieSettingsView.ViewModel = value;
}
}
}
internal override DependencyObject ValidationOnSaveRootElement =>
SelectedView.ValidationOnSaveRootElement;
private void AdministrationView_Loaded(object sender, RoutedEventArgs e)
{
ExpandItems();
}
private void Tabitem_Selected(object sender, RoutedEventArgs e)
{
if (!(sender is AccordionItem selectedAccordionItem))
return;
var header = selectedAccordionItem.Header.ToString();
if (_OpenViews.TryGetValue(header, out var view))
{
if(view is object)
SetView(_OpenViews[header]);
}
else
GenerateNewView(selectedAccordionItem);
BeWoApp.AppSettings.SelectedAdministrationItem = header;
}
internal override bool DoSaveCheck()
{
BeWoApp.AppSettings.ExpandedAdministrationItems = "";
if (Root != null)
{
foreach (AccordionItem ai in Root.Items)
{
if (ai.IsExpanded)
{
BeWoApp.AppSettings.ExpandedAdministrationItems += ":" + ai.Header;
}
}
}
if (SelectedView is null)
return true;
var lDoSave = SelectedView.DoSaveCheck();
// Speicheranfrage abgelehnt
if (!lDoSave)
return false;
// Synchron gespeichert
if (!IsDirty)
return true;
// Keine Änderungen, asynchron gespeichert oder verworfen
_OpenViews.Remove(((AccordionItem)Root.SelectedItem).Header.ToString());
return true;
}
protected override void Save()
{
SelectedView.SaveData();
}
private void ExpandItems()
{
if (!String.IsNullOrEmpty(BeWoApp.AppSettings.ExpandedAdministrationItems))
@@ -147,91 +230,6 @@ namespace BeWo.View.Master
}
}
private void Tabitem_Selected(object sender, RoutedEventArgs e)
{
if (!(sender is AccordionItem selectedAccordionItem))
return;
var header = selectedAccordionItem.Header.ToString();
if (_OpenViews.TryGetValue(header, out var view))
{
if(view is object)
SetView(_OpenViews[header]);
}
else
GenerateNewView(selectedAccordionItem);
BeWoApp.AppSettings.SelectedAdministrationItem = header;
}
public override bool IsDirty => SelectedView != null &&
SelectedView.IsDirty;
public BeWoView SelectedView
{
get => _SelectedView;
set
{
if (value == null) return;
_SelectedView = value;
ContentBorder.Child = value;
}
}
public MandatorVM MandatorVM
{
get => _MandatorVM;
set
{
_MandatorVM = value;
if (_OpenViews.TryGetValue(TabitemMandator.Header.ToString(), out var cachedView) && cachedView is MandatorView mandatorView)
{
mandatorView.ViewModel = value;
}
if (_OpenViews.TryGetValue(TabitemSozioTherapie.Header.ToString(), out var cachedView2) && cachedView2 is SoziotherapieSettingsView soziotherapieSettingsView)
{
soziotherapieSettingsView.ViewModel = value;
}
}
}
internal override DependencyObject ValidationOnSaveRootElement =>
SelectedView.ValidationOnSaveRootElement;
internal override bool DoSaveCheck()
{
BeWoApp.AppSettings.ExpandedAdministrationItems = "";
if (Root != null)
{
foreach (AccordionItem ai in Root.Items)
{
if (ai.IsExpanded)
{
BeWoApp.AppSettings.ExpandedAdministrationItems += ":" + ai.Header;
}
}
}
if (!(Root.SelectedItem is AccordionItem item) || !_OpenViews.ContainsKey(item.Header.ToString())) return true;
var lDoSave = SelectedView.DoSaveCheck();
if (!lDoSave || !IsDirty) return lDoSave;
_OpenViews.Remove(((AccordionItem)Root.SelectedItem).Header.ToString());
return true;
}
protected override void Save()
{
SelectedView.SaveData();
}
private void AddView(AccordionItem pTabItem, BeWoView pView)
{
pView.VerticalAlignment = VerticalAlignment.Top;
@@ -244,7 +242,6 @@ namespace BeWo.View.Master
_OpenViews[pTabItem.Header.ToString()] = pView;
SetView(pView);
}
private void SetView(BeWoView newView)
{
if (newView == null || Equals(newView, SelectedView)) return;
@@ -256,7 +253,6 @@ namespace BeWo.View.Master
SelectedView = newView;
}
}
private void GenerateNewView(AccordionItem accordionItem)
{
if (accordionItem == null)
@@ -458,7 +454,6 @@ namespace BeWo.View.Master
throw new ArgumentOutOfRangeException(nameof(accordionItem));
}
private void CheckMandatorVM(Action callbackAddView)
{
if (MandatorVM is object)
@@ -496,7 +491,6 @@ namespace BeWo.View.Master
return null;
}
private AccordionItem searchAccordionItem(AccordionItem accordion, string header)
{
if (accordion is null)