Command + AppError Erklärung

This commit is contained in:
2025-06-23 10:54:30 +02:00
parent 677ef71185
commit 8de37dff41
11 changed files with 87 additions and 79 deletions

View File

@@ -161,9 +161,9 @@ namespace BeWo
AutoLogin = true,
SelectView = UIContext.Finance,
SelectIndex = 7,
DefaultLoginUsername = "m1",
DefaultLoginPassword = "bewobewo",
DefaultProfilename = "5000000000",
//DefaultLoginUsername = "m1",
//DefaultLoginPassword = "bewobewo",
//DefaultProfilename = "5000000000",
EnableAutoRemoteDebugging = true
});

View File

@@ -81,7 +81,8 @@
Margin="3"
HorizontalAlignment="Stretch"
VerticalAlignment="Stretch"
DataSource="{Binding VMList}">
DataSource="{Binding VMList}"
SelectedItem="{Binding SelectedVM}">
<dxg:GridControl.Columns>
<dxg:GridColumn
x:Name="ColumnChecked"
@@ -130,7 +131,8 @@
Margin="1"
Padding="0"
VerticalAlignment="Center"
Click="btn_xRechnung_Click"
Command="{Binding DataContext.ShowXRechnungCommand,
RelativeSource={RelativeSource AncestorType={x:Type dxg:GridControl}}}"
Content="a"
FontFamily="Webdings"
FontSize="13"

View File

@@ -637,35 +637,5 @@ namespace BeWo.View.Detail.Accounting
BeWoApp.MainControl.WindowService.ShowTextViewerWindow("Test", test);
}
private void btn_xRechnung_Click(object sender, RoutedEventArgs e)
{
var vm = this.datagrid_invoices.GetCurrentValue<InvoiceBaseVM>();
if (vm is null)
{
MessageBox.Show("vm is null");
return;
}
var invoice_base_oid = vm.DataContract.InvoiceBaseOid ?? -1;
var invoice_type = (int)vm.DataContract.Type;
var report_link = vm.ReportLink;
ServiceFacade.DoAccountingEnhancedServiceAsnyc<ApiResponse<byte[]>>(
x => x.GetXRechnung(invoice_base_oid, invoice_type, report_link),
response =>
{
if (response.Success)
{
BeWoApp.MainControl.WindowService.ShowERechnungWindow(new MemoryStream(response.Data));
}
else
{
MessageBox.Show(response.ToErrorString());
}
}
);
}
}
}

View File

@@ -1,55 +1,51 @@
using System.Collections.Generic;
using System.ComponentModel;
using System.IO;
using System.Linq;
using System.Windows;
using BeWo.ServiceProxy;
using BS.Shared.Core;
using BS.Shared.DataContracts;
using BS.Shared.Extensions;
using DevExpress.Mvvm;
using DevExpress.Xpf.Layout.Core;
namespace BeWo.ViewModel.ListViewModel
{
public class InvoiceBaseListVM : AbstractDCListMapperVM<InvoiceBaseDC, InvoiceBaseVM>
{
#region Constants and Fields
public static string PropertyName_DateTimeSpanFilter = "DateTimeSpanFilter";
public static string PropertyName_FilterResultAmountSum = "FilterResultAmountSum";
public static string PropertyName_FilterResultAmountNotPaidSum = "FilterResultAmountNotPaidSum";
private DateTimeSpan _DateTimeSpanFilter;
private BindingList<InvoiceBaseVM> _FilteredInvoices;
#endregion
#region Constructors and Destructors
public InvoiceBaseListVM(List<InvoiceBaseDC> pDCs) : base(pDCs)
{
this.VMList.ListChanged += (s, e) => this.FirePropertyChanged(PropertyName_FilterResultAmountSum);
this.VMList.ListChanged += (s, e) => this.FirePropertyChanged(PropertyName_FilterResultAmountNotPaidSum);
}
VMList.ListChanged += (s, e) => FirePropertyChanged(PropertyName_FilterResultAmountSum);
VMList.ListChanged += (s, e) => FirePropertyChanged(PropertyName_FilterResultAmountNotPaidSum);
#endregion
bool canExecute() => SelectedVM is object && true;
ShowXRechnungCommand = new DelegateCommand(ShowXRechnung, canExecute);
}
#region Properties
public DelegateCommand ShowXRechnungCommand { get; set; }
public DateTimeSpan DateTimeSpanFilter
public DateTimeSpan DateTimeSpanFilter
{
get
{
return this._DateTimeSpanFilter;
return _DateTimeSpanFilter;
}
set
{
if (this.AreDifferent(this._DateTimeSpanFilter, value))
if (AreDifferent(_DateTimeSpanFilter, value))
{
this._DateTimeSpanFilter = value;
this.FirePropertyChanged(PropertyName_DateTimeSpanFilter);
_DateTimeSpanFilter = value;
FirePropertyChanged(PropertyName_DateTimeSpanFilter);
}
}
@@ -59,7 +55,7 @@ namespace BeWo.ViewModel.ListViewModel
{
get
{
return this.VMList.Sum(e => e.TotalAmount);
return VMList.Sum(e => e.TotalAmount);
}
}
public decimal? FilterResultAmountNotPaidSum
@@ -67,32 +63,51 @@ namespace BeWo.ViewModel.ListViewModel
get
{
decimal? sum = 0.0m;
foreach (var item in this.VMList)
foreach (var item in VMList)
sum += item.IsPaid ? item.TotalAmount : 0;
return FilterResultAmountSum - sum;
}
}
public void ShowXRechnung()
{
var invoice_base_oid = SelectedVM.DataContract.InvoiceBaseOid ?? -1;
var invoice_type = (int)SelectedVM.DataContract.Type;
var report_link = SelectedVM.ReportLink;
#endregion
ServiceFacade.DoAccountingEnhancedServiceAsnyc(
x => x.GetXRechnung(invoice_base_oid, invoice_type, report_link),
response =>
{
if (response.Success)
{
BeWoApp.MainControl.WindowService.ShowERechnungWindow(new MemoryStream(response.Data));
}
else
{
MessageBox.Show(response.ToErrorString());
}
}
);
}
internal void UpdateList(IList<InvoiceBaseDC> dcList)
{
this.VMList.Clear();
this.VMList.AddRange(dcList.Select(CreateVM));
VMList.Clear();
VMList.AddRange(dcList.Select(CreateVM));
this.FirePropertyChanged(PropertyName_FilterResultAmountSum);
this.FirePropertyChanged(PropertyName_FilterResultAmountNotPaidSum);
FirePropertyChanged(PropertyName_FilterResultAmountSum);
FirePropertyChanged(PropertyName_FilterResultAmountNotPaidSum);
}
internal void UpdateList(IList<InvoiceBaseVM> vmList)
{
this.VMList.Clear();
this.VMList.AddRange(vmList);
VMList.Clear();
VMList.AddRange(vmList);
this.FirePropertyChanged(PropertyName_FilterResultAmountSum);
this.FirePropertyChanged(PropertyName_FilterResultAmountNotPaidSum);
FirePropertyChanged(PropertyName_FilterResultAmountSum);
FirePropertyChanged(PropertyName_FilterResultAmountNotPaidSum);
}
}
}

View File

@@ -1,4 +1,4 @@
<?xml version="1.0" encoding="utf-8"?>
<?xml version="1.0" encoding="utf-8"?>
<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0">
<PropertyGroup>
<NameOfLastUsedPublishProfile>C:\Projects\Bewo\BeWo - Main\Host\Properties\PublishProfiles\FolderProfile.pubxml</NameOfLastUsedPublishProfile>

View File

@@ -16,7 +16,7 @@
<settings rightToLeft="false" />
<errors callbackErrorRedirectUrl="" />
</devExpress>
<runtime>
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
<dependentAssembly>
@@ -27,6 +27,10 @@
<assemblyIdentity name="System.Buffers" publicKeyToken="cc7b13ffcd2ddd51" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-4.0.2.0" newVersion="4.0.2.0" />
</dependentAssembly>
<dependentAssembly>
<assemblyIdentity name="System.Runtime.CompilerServices.Unsafe" publicKeyToken="b03f5f7f11d50a3a" culture="neutral" />
<bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" />
</dependentAssembly>
</assemblyBinding>
</runtime>
@@ -65,6 +69,7 @@
<system.web>
<customErrors mode="Off" />
<compilation debug="false" defaultLanguage="c#" targetFramework="4.5">
<assemblies>
<add assembly="BeWo.Service, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null" />
@@ -174,6 +179,9 @@
<service behaviorConfiguration="returnFaults" name="BeWo.Service.ServiceImplementations.AccountingServiceImp">
<endpoint behaviorConfiguration="SecurityAndSessionBehavior" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" name="AccountingServiceEndpoint" contract="BeWo.Service.ServiceContracts.IAccountingService" />
</service>
<service behaviorConfiguration="returnFaults" name="BeWo.Service.ServiceImplementations.GkvAccountingServiceImp">
<endpoint behaviorConfiguration="SecurityAndSessionBehavior" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" name="GkvAccountingServiceEndpoint" contract="BeWo.Service.ServiceContracts.IGkvAccountingService" />
</service>
<service behaviorConfiguration="returnFaults" name="BeWo.Service.ServiceImplementations.MailServiceImp">
<endpoint behaviorConfiguration="SecurityAndSessionBehavior" binding="basicHttpBinding" bindingConfiguration="TransportSecurity" name="MailServiceEndpoint" contract="BeWo.Service.ServiceContracts.IMailService" />
</service>
@@ -289,6 +297,7 @@
</extensions>
</system.serviceModel>
<appSettings>
<add key="AdminServiceAPIKey" value="2BOtqzjmVQ1Yrg7NZyvS87JRfppGn02dgBr3us736TUTPamTV6MPokZTxqcSNmWY" />
<add key="AdminServiceEnableStackTrace" value="true" />
<add key="SendMailOnError" value="false" />
@@ -332,7 +341,7 @@
<add key="StoredTenantFilesFolderPath" value="C:\BeWoPlaner\StoredTenantFiles"/>
<add key="StoredFilesFolderPath" value="C:\BeWoPlaner\StoredFiles"/>
<add key="HelloWorldPdfLocation" value="C:\BeWoPlaner\StoredFiles\HelloWorld.pdf"/>
<add key="ServiceLogFilePath" value="C:\BeWoPlaner\logs\server\service.log.txt"/>
<add key="WCFErrorLogFilePath" value="C:\BeWoPlaner\logs\server\wcferror.log.txt"/>
<add key="JsonErrorLogFilePath" value="C:\BeWoPlaner\logs\server\jsonerror.log.txt"/>

View File

@@ -391,11 +391,11 @@
<add key="StoredFilesFolderPath" value="C:\StoredFiles"/>
<add key="StoredTenantFilesFolderPath" value="C:\StoredTenantFiles"/>
<add key="HelloWorldPdfLocation" value="C:\StoredFiles\HelloWorld.pdf"/>
<add key="ServiceLogFilePath" value=""/>
<add key="WCFErrorLogFilePath" value=""/>
<add key="JsonErrorLogFilePath" value=""/>
<add key="ApiServiceTestFilePath" value=""/>
<add key="ServiceLogFilePath" value="C:\BeWoPlaner\logs\server\service.log.txt"/>
<add key="WCFErrorLogFilePath" value="C:\BeWoPlaner\logs\server\wcferror.log.txt"/>
<add key="JsonErrorLogFilePath" value="C:\BeWoPlaner\logs\server\jsonerror.log.txt"/>
<add key="ApiServiceTestFilePath" value="C:\BeWoPlaner\logs\server\apiservice.test.txt"/>
</appSettings>
<!-- <> <> <> Appsettings <> <> <> -->
</configuration>

View File

@@ -22,7 +22,7 @@ namespace BeWo.Service.Core
public FileLogger(string filePath, LogLevel minimumLevel = LogLevel.Debug)
{
if(filePath == null) throw new ArgumentNullException(nameof(filePath));
if(!File.Exists(filePath)) throw new BeWoInvalidOperationException(AppError.LoggerFileDoNotExist);
if(!Directory.Exists(Path.GetDirectoryName(filePath))) throw new BeWoInvalidOperationException(AppError.LoggerPathDoNotExist);
_filePath = filePath;
_minimumLevel = minimumLevel;

View File

@@ -13,8 +13,8 @@ namespace BeWo.Service.Core
public static class ServiceHelper
{
public static FileLogger CoreLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.ServiceLogFilePath));
public static FileLogger WCFErrorLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.ServiceLogFilePath));
public static FileLogger JsonErrorLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.ServiceLogFilePath));
public static FileLogger WCFErrorLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.WCFErrorLogFilePath));
public static FileLogger JsonErrorLogger { get; } = new FileLogger(MergedConfig.GetSetting(WebConfigSetting.JsonErrorLogFilePath));
public static Tuple<string, string> GetInterfaceAndMethodWCF(Message request, IClientChannel channel)
{

View File

@@ -48,10 +48,10 @@ namespace BeWo.Service.Core
if (authentification is null)
return;
if (authentification.IPAddressList is IPAddressList ipAddressList && ipAddressList != default)
if (authentification.IPAddressList is IPAddressList ipAddressList && ipAddressList != IPAddressList.None)
ValidateIP(ref request, channel, ipAddressList);
if (authentification.ApiKeyName is WebSecretConfigSetting secret && secret != default)
if (authentification.ApiKeyName is WebSecretConfigSetting secret && secret != WebSecretConfigSetting.None)
ValidateMethodApiKey(ref request, channel, secret);
}

View File

@@ -31,10 +31,22 @@ namespace BS.Shared.Core
}
//public static readonly AppError Example = new AppError("Code", "Message");
// Muster:
// - public static readonly AppError Example = new AppError("Code", "Message");
// - Usage: var error = AppError.Example;
// Oder mit Abhängigkeit:
// - public static Func<object1, object2, ..., AppError> ExampleFunc = (obj1, obj2, ...) => new AppError(...);
// - Usage: var error = AppError.ExampleFunc(obj1, obj2, ...);
/// <summary>
/// Tenant ist in Anfrage null oder unbekannt
/// </summary>
public static AppError MultitenancyOperationTenantUnknown => new AppError("SERV.HLP.10001", "Tenant unbekannt");
public static AppError LoggerFileDoNotExist => new AppError("SERV.LOG.10001", "Server falsch konfiguriert");
/// <summary>
/// Logger Ordner kann nicht gefunden werden. Hinweis: Web.config
/// </summary>
public static AppError LoggerPathDoNotExist => new AppError("SERV.LOG.10002", "Server falsch konfiguriert");
public static AppError FileNameInvalidChar => new AppError("DATA.LFS.60001", "Fehler beim Speichern");
public static AppError FileNameNotEqFilePath => new AppError("DATA.LFS.60002", "Fehler beim Speichern");