Compare commits
32
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3e9b40ddd7 | ||
|
|
4d201aed99 | ||
|
|
6b5756a1c1 | ||
|
|
089ac3ce85 | ||
|
|
f1e8907d40 | ||
|
|
51a05fe4db | ||
|
|
a012a54362 | ||
|
|
f1eb26d01d | ||
|
|
cc6da2f257 | ||
|
|
065fbc2eea | ||
|
|
bc419ce57a | ||
|
|
4bb13dbb06 | ||
|
|
f388ddbe41 | ||
|
|
d05f1408af | ||
|
|
2cc58f8df6 | ||
|
|
9e110a467a | ||
|
|
2406f58a91 | ||
|
|
bc47bcc784 | ||
|
|
b8b86ef7ec | ||
|
|
d91e8c7e99 | ||
|
|
09642e643c | ||
|
|
b262e17293 | ||
|
|
4f4d026b7b | ||
|
|
abb9e5a577 | ||
|
|
0e586cc438 | ||
|
|
829ad106cf | ||
|
|
ba7c37fd70 | ||
|
|
66a1185dc3 | ||
|
|
db8afa59b7 | ||
|
|
3d96c31a70 | ||
|
|
a18d687f18 | ||
|
|
5f2788eb9e |
No files matched your search
+481
-401
File diff suppressed because it is too large.
Load diff
@@ -7,12 +7,6 @@
|
|||||||
<ctrl:BoolToStringConverter x:Key="BoolToStarConverter" FalseValue="" TrueValue="*"/>
|
<ctrl:BoolToStringConverter x:Key="BoolToStarConverter" FalseValue="" TrueValue="*"/>
|
||||||
<ctrl:WidthToMarginConverter x:Key="WidthToMarginConverter"/>
|
<ctrl:WidthToMarginConverter x:Key="WidthToMarginConverter"/>
|
||||||
|
|
||||||
<DataTemplate x:Key="PostalDestTemplate">
|
|
||||||
<StackPanel Orientation="Horizontal">
|
|
||||||
<TextBlock Text="{Binding Dest}"/>
|
|
||||||
<TextBlock Text="{Binding Ort.Name, StringFormat='{} ({0})'}"/>
|
|
||||||
</StackPanel>
|
|
||||||
</DataTemplate>
|
|
||||||
<DataTemplate x:Key="KgNrTemplate">
|
<DataTemplate x:Key="KgNrTemplate">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Name}"/>
|
<TextBlock Text="{Binding Name}"/>
|
||||||
|
|||||||
+31
-34
@@ -24,8 +24,7 @@ using System.Windows.Threading;
|
|||||||
namespace Elwig {
|
namespace Elwig {
|
||||||
public partial class App : Application {
|
public partial class App : Application {
|
||||||
|
|
||||||
public static App CurrentApp;
|
public static new App Current => (App)Application.Current;
|
||||||
public static int NumWindows => CurrentApp.Windows.Count;
|
|
||||||
public static bool ForceShutdown { get; set; } = false;
|
public static bool ForceShutdown { get; set; } = false;
|
||||||
|
|
||||||
private readonly DispatcherTimer _autoUpdateTimer = new() { Interval = TimeSpan.FromHours(1) };
|
private readonly DispatcherTimer _autoUpdateTimer = new() { Interval = TimeSpan.FromHours(1) };
|
||||||
@@ -42,8 +41,8 @@ namespace Elwig {
|
|||||||
public static Version Version { get; private set; } = new();
|
public static Version Version { get; private set; } = new();
|
||||||
|
|
||||||
public static int BranchNum { get; private set; }
|
public static int BranchNum { get; private set; }
|
||||||
public static string ZwstId { get; private set; }
|
public static string ZwstId { get; private set; } = "?";
|
||||||
public static string BranchName { get; private set; }
|
public static string BranchName { get; private set; } = "Unbekannt";
|
||||||
public static int? BranchPlz { get; private set; }
|
public static int? BranchPlz { get; private set; }
|
||||||
public static string? BranchLocation { get; private set; }
|
public static string? BranchLocation { get; private set; }
|
||||||
public static string? BranchAddress { get; private set; }
|
public static string? BranchAddress { get; private set; }
|
||||||
@@ -54,9 +53,8 @@ namespace Elwig {
|
|||||||
public static IList<IScale> Scales { get; private set; } = [];
|
public static IList<IScale> Scales { get; private set; } = [];
|
||||||
public static IList<ICommandScale> CommandScales => [.. Scales.Where(s => s is ICommandScale).Cast<ICommandScale>()];
|
public static IList<ICommandScale> CommandScales => [.. Scales.Where(s => s is ICommandScale).Cast<ICommandScale>()];
|
||||||
public static IList<IEventScale> EventScales => [.. Scales.Where(s => s is IEventScale).Cast<IEventScale>()];
|
public static IList<IEventScale> EventScales => [.. Scales.Where(s => s is IEventScale).Cast<IEventScale>()];
|
||||||
public static ClientParameters Client { get; set; }
|
public static ClientParameters Client { get; set; } = new();
|
||||||
|
|
||||||
public static Dispatcher MainDispatcher { get; private set; }
|
|
||||||
private DateTime LastChanged;
|
private DateTime LastChanged;
|
||||||
private static DateTime CurrentLastWrite => File.GetLastWriteTime(Config.DatabaseFile);
|
private static DateTime CurrentLastWrite => File.GetLastWriteTime(Config.DatabaseFile);
|
||||||
private readonly DispatcherTimer ContextTimer = new() { Interval = TimeSpan.FromSeconds(2) };
|
private readonly DispatcherTimer ContextTimer = new() { Interval = TimeSpan.FromSeconds(2) };
|
||||||
@@ -66,9 +64,7 @@ namespace Elwig {
|
|||||||
Directory.CreateDirectory(TempPath);
|
Directory.CreateDirectory(TempPath);
|
||||||
Directory.CreateDirectory(DataPath);
|
Directory.CreateDirectory(DataPath);
|
||||||
Directory.CreateDirectory(MailsPath);
|
Directory.CreateDirectory(MailsPath);
|
||||||
MainDispatcher = Dispatcher;
|
|
||||||
Scales = [];
|
Scales = [];
|
||||||
CurrentApp = this;
|
|
||||||
Utils.OverrideCulture();
|
Utils.OverrideCulture();
|
||||||
|
|
||||||
var args = Environment.GetCommandLineArgs();
|
var args = Environment.GetCommandLineArgs();
|
||||||
@@ -86,7 +82,7 @@ namespace Elwig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static void OnContextChanged() {
|
private static void OnContextChanged() {
|
||||||
MainDispatcher.BeginInvoke(HintContextChange);
|
Current.Dispatcher.BeginInvoke(HintContextChange);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override async void OnStartup(StartupEventArgs evt) {
|
protected override async void OnStartup(StartupEventArgs evt) {
|
||||||
@@ -259,21 +255,21 @@ namespace Elwig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void HintContextChange() {
|
public static void HintContextChange() {
|
||||||
if (CurrentApp == null) return;
|
if (Current == null) return;
|
||||||
var ch = CurrentLastWrite;
|
var ch = CurrentLastWrite;
|
||||||
if (ch > CurrentApp.LastChanged)
|
if (ch > Current.LastChanged)
|
||||||
CurrentApp.LastChanged = ch;
|
Current.LastChanged = ch;
|
||||||
MainDispatcher.Invoke(() => {
|
Current.Dispatcher.Invoke(() => {
|
||||||
foreach (Window w in CurrentApp.Windows) {
|
foreach (Window w in Current.Windows) {
|
||||||
if (w is not ContextWindow c) continue;
|
if (w is not ContextWindow c) continue;
|
||||||
MainDispatcher.Invoke(c.HintContextChange);
|
Current.Dispatcher.Invoke(c.HintContextChange);
|
||||||
MainDispatcher.BeginInvoke(c.TryContextReload);
|
Current.Dispatcher.BeginInvoke(c.TryContextReload);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void OnAutoUpdateTimer(object? sender, EventArgs? evt) {
|
private void OnAutoUpdateTimer(object? sender, EventArgs? evt) {
|
||||||
foreach (Window w in CurrentApp.Windows) {
|
foreach (Window w in Current.Windows) {
|
||||||
if (w is UpdateDialog) return;
|
if (w is UpdateDialog) return;
|
||||||
}
|
}
|
||||||
if (Utils.HasInternetConnectivity()) {
|
if (Utils.HasInternetConnectivity()) {
|
||||||
@@ -330,7 +326,7 @@ namespace Elwig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void UpdateScales() {
|
public static void UpdateScales() {
|
||||||
foreach (Window w in CurrentApp.Windows) {
|
foreach (Window w in Current.Windows) {
|
||||||
if (w is DeliveryAdminWindow t && t.ViewModel.IsReceipt) {
|
if (w is DeliveryAdminWindow t && t.ViewModel.IsReceipt) {
|
||||||
t.UpdateScales();
|
t.UpdateScales();
|
||||||
}
|
}
|
||||||
@@ -339,27 +335,28 @@ namespace Elwig {
|
|||||||
|
|
||||||
public static async Task CheckForUpdates(bool showAlert = false) {
|
public static async Task CheckForUpdates(bool showAlert = false) {
|
||||||
if (Config.UpdateUrl == null) return;
|
if (Config.UpdateUrl == null) return;
|
||||||
var latest = await Utils.GetLatestInstallerUrl(Config.UpdateUrl);
|
try {
|
||||||
if (latest != null && new Version(latest.Value.Version) > Version) {
|
var latest = await Utils.GetLatestInstallerUrl(Config.UpdateUrl);
|
||||||
await MainDispatcher.BeginInvoke(() => {
|
if (new Version(latest.Version) > Version) {
|
||||||
var d = new UpdateDialog(latest.Value.Version, latest.Value.Url, latest.Value.Size);
|
await Current.Dispatcher.BeginInvoke(() => {
|
||||||
if (d.ShowDialog() == true) {
|
var d = new UpdateDialog(latest.Version, latest.Url, latest.Size);
|
||||||
ShutdownNow();
|
if (d.ShowDialog() == true) {
|
||||||
}
|
ShutdownNow();
|
||||||
});
|
}
|
||||||
} else if (showAlert) {
|
});
|
||||||
if (latest == null) {
|
} else if (showAlert) {
|
||||||
InteractionService.ShowError("Nach Updates suchen", "Informationen konnten nicht abgerufen werden!");
|
InteractionService.ShowInformation("Nach Updates suchen", $"Elwig ist auf dem aktuellsten Stand! (Version: {latest.Version})");
|
||||||
} else {
|
|
||||||
InteractionService.ShowInformation("Nach Updates suchen", $"Elwig ist auf dem aktuellsten Stand! (Version: {latest.Value.Version})");
|
|
||||||
}
|
}
|
||||||
|
} catch (Exception exc) {
|
||||||
|
if (showAlert)
|
||||||
|
InteractionService.ShowException("Nach Updates suchen", $"Informationen konnten nicht abgerufen werden!", exc);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ReplaceDatabase(string filename) {
|
public static async Task ReplaceDatabase(string filename, IEnumerable<ReadOnlyMemory<char>>? keys = null) {
|
||||||
try {
|
try {
|
||||||
await Task.Run(async () => {
|
await Task.Run(async () => {
|
||||||
await Database.Import(filename);
|
await Database.Import(filename, keys);
|
||||||
});
|
});
|
||||||
InteractionService.ShowInformation("Datenbank ersetzen", "Das Ersetzen war erfolgreich!\n\nBitte starten Sie Elwig neu!");
|
InteractionService.ShowInformation("Datenbank ersetzen", "Das Ersetzen war erfolgreich!\n\nBitte starten Sie Elwig neu!");
|
||||||
ShutdownNow();
|
ShutdownNow();
|
||||||
@@ -369,7 +366,7 @@ namespace Elwig {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static T FocusWindow<T>(Func<T> constructor, Predicate<T>? selector = null) where T : Window {
|
private static T FocusWindow<T>(Func<T> constructor, Predicate<T>? selector = null) where T : Window {
|
||||||
foreach (Window w in CurrentApp.Windows) {
|
foreach (Window w in Current.Windows) {
|
||||||
if (w is T t && (selector == null || selector(t))) {
|
if (w is T t && (selector == null || selector(t))) {
|
||||||
if (t.WindowState == WindowState.Minimized)
|
if (t.WindowState == WindowState.Minimized)
|
||||||
t.WindowState = WindowState.Normal;
|
t.WindowState = WindowState.Normal;
|
||||||
|
|||||||
@@ -4,10 +4,10 @@ using System.Globalization;
|
|||||||
|
|
||||||
namespace Elwig.Controls {
|
namespace Elwig.Controls {
|
||||||
public class BoolToValueConverter<T> : IValueConverter {
|
public class BoolToValueConverter<T> : IValueConverter {
|
||||||
public T FalseValue { get; set; }
|
public required T FalseValue { get; set; }
|
||||||
public T TrueValue { get; set; }
|
public required T TrueValue { get; set; }
|
||||||
|
|
||||||
public object Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
public object? Convert(object value, Type targetType, object parameter, CultureInfo culture) {
|
||||||
return (bool)value ? TrueValue : FalseValue;
|
return (bool)value ? TrueValue : FalseValue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ namespace Elwig.Controls {
|
|||||||
|
|
||||||
private bool _viewHandled;
|
private bool _viewHandled;
|
||||||
private bool _modelHandled;
|
private bool _modelHandled;
|
||||||
private TextBlock _textBox;
|
private TextBlock? _textBox;
|
||||||
|
|
||||||
public CheckComboBox() {
|
public CheckComboBox() {
|
||||||
SelectionMode = SelectionMode.Multiple;
|
SelectionMode = SelectionMode.Multiple;
|
||||||
@@ -131,11 +131,11 @@ namespace Elwig.Controls {
|
|||||||
AllItemsSelected = null;
|
AllItemsSelected = null;
|
||||||
}
|
}
|
||||||
if (SelectedItems.Count > 1 && SelectedItems.Count == ItemsSource.Cast<object>().Count() && AllItemsSelectedContent != null) {
|
if (SelectedItems.Count > 1 && SelectedItems.Count == ItemsSource.Cast<object>().Count() && AllItemsSelectedContent != null) {
|
||||||
_textBox.Text = AllItemsSelectedContent;
|
_textBox?.Text = AllItemsSelectedContent;
|
||||||
} else if (SelectedItems.Count == 0) {
|
} else if (SelectedItems.Count == 0) {
|
||||||
_textBox.Text = "";
|
_textBox?.Text = "";
|
||||||
} else {
|
} else {
|
||||||
_textBox.Text = string.Join(Delimiter,
|
_textBox?.Text = string.Join(Delimiter,
|
||||||
dmp == null ? SelectedItems.Cast<object>() :
|
dmp == null ? SelectedItems.Cast<object>() :
|
||||||
SelectedItems.Cast<object>()
|
SelectedItems.Cast<object>()
|
||||||
.Select(i => i.GetType().GetProperty(dmp)?.GetValue(i))
|
.Select(i => i.GetType().GetProperty(dmp)?.GetValue(i))
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ namespace Elwig.Dialogs {
|
|||||||
public bool DeletePaymentData { get; set; }
|
public bool DeletePaymentData { get; set; }
|
||||||
|
|
||||||
public DeleteMemberDialog(int mgnr, string name, int numAreaCmts, int numDeliveries, int numCredits) {
|
public DeleteMemberDialog(int mgnr, string name, int numAreaCmts, int numDeliveries, int numCredits) {
|
||||||
NameParts = name.ToLower().Split(' ').Where(p => p.Length > 0).Append($"{mgnr}").ToArray();
|
NameParts = [.. name.ToLower().Split(' ', System.StringSplitOptions.RemoveEmptyEntries), $"{mgnr}"];
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Title += " - " + name;
|
Title += " - " + name;
|
||||||
AreaCmtInput.IsEnabled = numAreaCmts != 0;
|
AreaCmtInput.IsEnabled = numAreaCmts != 0;
|
||||||
|
|||||||
@@ -74,7 +74,7 @@
|
|||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<TextBlock Text="{Binding Part.DPNr}" Width="20" TextAlignment="Right"
|
<TextBlock Text="{Binding Part.DPNr}" Width="20" TextAlignment="Right"
|
||||||
VerticalAlignment="Center" Margin="0,0,5,0" FontSize="14"/>
|
VerticalAlignment="Center" Margin="0,0,5,0" FontSize="14"/>
|
||||||
<TextBlock Text="{Binding Part.SortId}" Width="40" TextAlignment="Center"
|
<TextBlock Text="{Binding Part.SortId}" Foreground="{Binding Part.Variety.Color}" Width="40" TextAlignment="Center"
|
||||||
VerticalAlignment="Center" Margin="0,0,0,0" FontSize="14"/>
|
VerticalAlignment="Center" Margin="0,0,0,0" FontSize="14"/>
|
||||||
<TextBlock Text="{Binding Part.Kmw, StringFormat='{}{0:N1}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"
|
<TextBlock Text="{Binding Part.Kmw, StringFormat='{}{0:N1}°'}" Width="40" TextAlignment="Right" Padding="0,0,10,0"
|
||||||
VerticalAlignment="Center"/>
|
VerticalAlignment="Center"/>
|
||||||
|
|||||||
@@ -2,7 +2,6 @@ using Elwig.Helpers;
|
|||||||
using Elwig.Models.Entities;
|
using Elwig.Models.Entities;
|
||||||
using Elwig.Windows;
|
using Elwig.Windows;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
using System;
|
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
@@ -14,7 +13,7 @@ namespace Elwig.Dialogs {
|
|||||||
public partial class DeliverySplittingDialog : ContextWindow {
|
public partial class DeliverySplittingDialog : ContextWindow {
|
||||||
|
|
||||||
public class Row {
|
public class Row {
|
||||||
public DeliveryPart Part { get; set; }
|
public required DeliveryPart Part { get; set; }
|
||||||
public bool SplitCompletely { get; set; }
|
public bool SplitCompletely { get; set; }
|
||||||
public string? SplitWeightString { get; set; }
|
public string? SplitWeightString { get; set; }
|
||||||
public int? SplitWeight {
|
public int? SplitWeight {
|
||||||
@@ -28,18 +27,18 @@ namespace Elwig.Dialogs {
|
|||||||
|
|
||||||
public int? MgNr { get; set; }
|
public int? MgNr { get; set; }
|
||||||
public string? LsNr { get; set; }
|
public string? LsNr { get; set; }
|
||||||
public int[]? Weights => DeliveryParts.Select(r => r.SplitCompletely ? r.Part.Weight : r.SplitWeight ?? 0).ToArray();
|
public int[]? Weights => [.. DeliveryParts.Select(r => r.SplitCompletely ? r.Part.Weight : r.SplitWeight ?? 0)];
|
||||||
|
|
||||||
public ObservableCollection<Row> DeliveryParts { get; set; }
|
public ObservableCollection<Row> DeliveryParts { get; set; }
|
||||||
|
|
||||||
public DeliverySplittingDialog(Delivery d) {
|
public DeliverySplittingDialog(Delivery d) {
|
||||||
_delivery = d;
|
_delivery = d;
|
||||||
DeliveryParts = new(d.Parts.Select(p => new Row {
|
DeliveryParts = [with([.. d.Parts.Select(p => new Row {
|
||||||
Part = p,
|
Part = p,
|
||||||
SplitCompletely = false,
|
SplitCompletely = false,
|
||||||
SplitWeight = null,
|
SplitWeight = null,
|
||||||
SplitWeightEnabled = true,
|
SplitWeightEnabled = true,
|
||||||
}).ToList());
|
})])];
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -343,22 +343,17 @@ namespace Elwig.Documents {
|
|||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
|
|
||||||
private class EventHandler : AbstractPdfDocumentEventHandler {
|
private class EventHandler(Document doc) : AbstractPdfDocumentEventHandler {
|
||||||
|
|
||||||
private const float _fontSize = 10;
|
private const float _fontSize = 10;
|
||||||
private const float _placeholderWidth = 50 * PtInMM;
|
private const float _placeholderWidth = 50 * PtInMM;
|
||||||
|
|
||||||
private readonly Document _doc;
|
private readonly Document _doc = doc;
|
||||||
private readonly List<PdfFormXObject> _pageNumPlaceholders;
|
private readonly List<PdfFormXObject> _pageNumPlaceholders = [];
|
||||||
|
|
||||||
|
|
||||||
public int NumberOfPages { get; private set; }
|
public int NumberOfPages { get; private set; }
|
||||||
|
|
||||||
public EventHandler(Document doc) {
|
|
||||||
_doc = doc;
|
|
||||||
_pageNumPlaceholders = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void OnAcceptedEvent(AbstractPdfDocumentEvent evt) {
|
protected override void OnAcceptedEvent(AbstractPdfDocumentEvent evt) {
|
||||||
if (evt.GetType() == PdfDocumentEvent.START_PAGE) {
|
if (evt.GetType() == PdfDocumentEvent.START_PAGE) {
|
||||||
OnPageStart((PdfDocumentEvent)evt);
|
OnPageStart((PdfDocumentEvent)evt);
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ namespace Elwig.Documents {
|
|||||||
doc.Add(new KernedParagraph(12).Add(Bold($"Flächenbindungen per {Date:dd.MM.yyyy}")).SetMargins(firstOnPage ? 0 : 24, 0, 6, 0));
|
doc.Add(new KernedParagraph(12).Add(Bold($"Flächenbindungen per {Date:dd.MM.yyyy}")).SetMargins(firstOnPage ? 0 : 24, 0, 6, 0));
|
||||||
doc.Add(NewAreaCmtTable(ActiveAreaCommitments));
|
doc.Add(NewAreaCmtTable(ActiveAreaCommitments));
|
||||||
}
|
}
|
||||||
if (App.Client.EnableMemberHistory) {
|
if (App.Client.EnableMemberHistory && App.Client.ModeMemberDataSheetShares > 0) {
|
||||||
bool firstOnPage = false;
|
bool firstOnPage = false;
|
||||||
if (pdf.GetNumberOfPages() == 1) {
|
if (pdf.GetNumberOfPages() == 1) {
|
||||||
doc.Add(new AreaBreak(AreaBreakType.NEXT_PAGE));
|
doc.Add(new AreaBreak(AreaBreakType.NEXT_PAGE));
|
||||||
@@ -274,11 +274,11 @@ namespace Elwig.Documents {
|
|||||||
.AddCells(NewBusinessSharesCells(new()));
|
.AddCells(NewBusinessSharesCells(new()));
|
||||||
}
|
}
|
||||||
|
|
||||||
var recorded = history.Aggregate(new MemberHistoryPoint(), (s, h) => new(
|
var recorded = history.Aggregate(new MemberHistoryPoint(), (s, h) => new(
|
||||||
s.Shares + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.Normal ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.Normal ? h.Shares : 0),
|
s.Shares + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.Normal ? h.Shares : 0) - (h.ToMgNr == h.FromMgNr && h.ToType == BusinessShareType.Normal && h.FromType == BusinessShareType.Normal ? 0 : h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.Normal ? h.Shares : 0),
|
||||||
s.SharesRed + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.Red ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.Red ? h.Shares : 0),
|
s.SharesRed + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.Red ? h.Shares : 0) - (h.ToMgNr == h.FromMgNr && h.ToType == BusinessShareType.Red && h.FromType == BusinessShareType.Red ? 0 : h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.Red ? h.Shares : 0),
|
||||||
s.SharesWhite + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.White ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.White ? h.Shares : 0),
|
s.SharesWhite + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.White ? h.Shares : 0) - (h.ToMgNr == h.FromMgNr && h.ToType == BusinessShareType.White && h.FromType == BusinessShareType.White ? 0 : h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.White ? h.Shares : 0),
|
||||||
s.SharesDormant + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.Dormant ? h.Shares : 0) - (h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.Dormant ? h.Shares : 0)));
|
s.SharesDormant + (h.ToMgNr == Member.MgNr && h.ToType == BusinessShareType.Dormant ? h.Shares : 0) - (h.ToMgNr == h.FromMgNr && h.ToType == BusinessShareType.Dormant && h.FromType == BusinessShareType.Dormant ? 0 : h.FromMgNr == Member.MgNr && h.FromType == BusinessShareType.Dormant ? h.Shares : 0)));
|
||||||
var cur = new MemberHistoryPoint(Member.Shares - recorded.Shares, Member.SharesRed - recorded.SharesRed, Member.SharesWhite - recorded.SharesWhite, Member.SharesDormant - recorded.SharesDormant);
|
var cur = new MemberHistoryPoint(Member.Shares - recorded.Shares, Member.SharesRed - recorded.SharesRed, Member.SharesWhite - recorded.SharesWhite, Member.SharesDormant - recorded.SharesDormant);
|
||||||
|
|
||||||
if (cur.Shares != 0 || cur.SharesRed != 0 || cur.SharesWhite != 0 || cur.SharesDormant != 0) {
|
if (cur.Shares != 0 || cur.SharesRed != 0 || cur.SharesWhite != 0 || cur.SharesDormant != 0) {
|
||||||
@@ -297,7 +297,7 @@ namespace Elwig.Documents {
|
|||||||
DateOnly? lastDate = null;
|
DateOnly? lastDate = null;
|
||||||
foreach (var row in history) {
|
foreach (var row in history) {
|
||||||
int s = 0, r = 0, w = 0, d = 0;
|
int s = 0, r = 0, w = 0, d = 0;
|
||||||
if (row.FromMgNr == Member.MgNr) {
|
if (row.FromMgNr == Member.MgNr && !(row.FromMgNr == row.ToMgNr && row.FromType == row.ToType)) {
|
||||||
switch (row.FromType) {
|
switch (row.FromType) {
|
||||||
case BusinessShareType.Normal: s -= row.Shares; break;
|
case BusinessShareType.Normal: s -= row.Shares; break;
|
||||||
case BusinessShareType.Red: r -= row.Shares; break;
|
case BusinessShareType.Red: r -= row.Shares; break;
|
||||||
|
|||||||
+14
-14
@@ -2,14 +2,14 @@
|
|||||||
|
|
||||||
<PropertyGroup>
|
<PropertyGroup>
|
||||||
<OutputType>WinExe</OutputType>
|
<OutputType>WinExe</OutputType>
|
||||||
<TargetFramework>net10.0-windows</TargetFramework>
|
<TargetFramework>net11.0-windows</TargetFramework>
|
||||||
<PlatformTarget>x64</PlatformTarget>
|
<PlatformTarget>x64</PlatformTarget>
|
||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<UseWPF>true</UseWPF>
|
<UseWPF>true</UseWPF>
|
||||||
<UseWindowsForms>true</UseWindowsForms>
|
<UseWindowsForms>true</UseWindowsForms>
|
||||||
<PreserveCompilationContext>true</PreserveCompilationContext>
|
<PreserveCompilationContext>true</PreserveCompilationContext>
|
||||||
<ApplicationIcon>Resources\Images\Elwig.ico</ApplicationIcon>
|
<ApplicationIcon>Resources\Images\Elwig.ico</ApplicationIcon>
|
||||||
<Version>1.1.2.2</Version>
|
<Version>1.2.1.0</Version>
|
||||||
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
|
<SatelliteResourceLanguages>de-AT</SatelliteResourceLanguages>
|
||||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||||
<ApplicationManifest>App.manifest</ApplicationManifest>
|
<ApplicationManifest>App.manifest</ApplicationManifest>
|
||||||
@@ -23,21 +23,21 @@
|
|||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<PackageReference Include="bblanchon.PDFium.Win32" Version="156.0.8076" />
|
<PackageReference Include="bblanchon.PDFium.Win32" Version="160.0.8179" />
|
||||||
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
<PackageReference Include="CommunityToolkit.Mvvm" Version="8.4.2" />
|
||||||
<PackageReference Include="itext" Version="9.7.0" />
|
<PackageReference Include="itext" Version="9.8.1.1" />
|
||||||
<PackageReference Include="itext.bouncy-castle-adapter" Version="9.7.0" />
|
<PackageReference Include="itext.bouncy-castle-adapter" Version="9.8.1.1" />
|
||||||
<PackageReference Include="LinqKit" Version="1.3.11" />
|
<PackageReference Include="LinqKit" Version="1.4.2" />
|
||||||
<PackageReference Include="MailKit" Version="4.18.1" />
|
<PackageReference Include="MailKit" Version="5.0.0" />
|
||||||
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="10.0.12" />
|
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="11.0.0" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="10.0.12" />
|
<PackageReference Include="Microsoft.Extensions.Configuration.Ini" Version="11.0.0" />
|
||||||
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.4258.31" />
|
<PackageReference Include="Microsoft.Web.WebView2" Version="1.0.4370.26" />
|
||||||
<PackageReference Include="NJsonSchema" Version="11.6.1" />
|
<PackageReference Include="NJsonSchema" Version="11.6.2" />
|
||||||
<PackageReference Include="ScottPlot.WPF" Version="5.1.59" />
|
<PackageReference Include="ScottPlot.WPF" Version="5.1.59" />
|
||||||
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="3.0.5" />
|
<PackageReference Include="SQLitePCLRaw.bundle_e_sqlite3" Version="3.0.5" />
|
||||||
<PackageReference Include="System.IO.Hashing" Version="10.0.12" />
|
<PackageReference Include="System.IO.Hashing" Version="11.0.0" />
|
||||||
<PackageReference Include="System.IO.Ports" Version="10.0.12" />
|
<PackageReference Include="System.IO.Ports" Version="11.0.0" />
|
||||||
<PackageReference Include="System.Management" Version="10.0.12" />
|
<PackageReference Include="System.Management" Version="11.0.0" />
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
</Project>
|
</Project>
|
||||||
@@ -2,14 +2,10 @@ using System;
|
|||||||
using System.Windows.Input;
|
using System.Windows.Input;
|
||||||
|
|
||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
public class ActionCommand : ICommand {
|
public class ActionCommand(Action action) : ICommand {
|
||||||
|
|
||||||
public event EventHandler? CanExecuteChanged;
|
public event EventHandler? CanExecuteChanged;
|
||||||
private readonly Action Action;
|
private readonly Action Action = action;
|
||||||
|
|
||||||
public ActionCommand(Action action) {
|
|
||||||
Action = action;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Execute(object? parameter) {
|
public void Execute(object? parameter) {
|
||||||
Action();
|
Action();
|
||||||
|
|||||||
@@ -1,3 +1,4 @@
|
|||||||
|
using Elwig.Models;
|
||||||
using Elwig.Models.Dtos;
|
using Elwig.Models.Dtos;
|
||||||
using Elwig.Models.Entities;
|
using Elwig.Models.Entities;
|
||||||
using Elwig.Services;
|
using Elwig.Services;
|
||||||
@@ -110,7 +111,7 @@ namespace Elwig.Helpers {
|
|||||||
private static readonly Func<AppDbContext, bool, IAsyncEnumerable<WineQualLevel>> _compiledQueryWineQualityLevels =
|
private static readonly Func<AppDbContext, bool, IAsyncEnumerable<WineQualLevel>> _compiledQueryWineQualityLevels =
|
||||||
EF.CompileAsyncQuery<AppDbContext, bool, WineQualLevel>((ctx, includePredicate) => ctx.WineQualityLevels
|
EF.CompileAsyncQuery<AppDbContext, bool, WineQualLevel>((ctx, includePredicate) => ctx.WineQualityLevels
|
||||||
.Where(l => includePredicate || !l.IsPredicate)
|
.Where(l => includePredicate || !l.IsPredicate)
|
||||||
.OrderBy(l => l.MinKmw));
|
.OrderBy(l => l.IsPredicate).ThenBy(l => l.MinKmw));
|
||||||
|
|
||||||
private static readonly Func<AppDbContext, int?, bool, IAsyncEnumerable<Modifier>> _compiledQueryModifiers =
|
private static readonly Func<AppDbContext, int?, bool, IAsyncEnumerable<Modifier>> _compiledQueryModifiers =
|
||||||
EF.CompileAsyncQuery<AppDbContext, int?, bool, Modifier>((ctx, year, incudeNotActive) => ctx.Modifiers
|
EF.CompileAsyncQuery<AppDbContext, int?, bool, Modifier>((ctx, year, incudeNotActive) => ctx.Modifiers
|
||||||
@@ -216,6 +217,8 @@ namespace Elwig.Helpers {
|
|||||||
modelBuilder.Entity<BillingAddr>().Navigation(a => a.PostalDest).AutoInclude();
|
modelBuilder.Entity<BillingAddr>().Navigation(a => a.PostalDest).AutoInclude();
|
||||||
modelBuilder.Entity<Modifier>().Navigation(m => m.Season).AutoInclude();
|
modelBuilder.Entity<Modifier>().Navigation(m => m.Season).AutoInclude();
|
||||||
modelBuilder.Entity<Season>().Navigation(s => s.Currency).AutoInclude();
|
modelBuilder.Entity<Season>().Navigation(s => s.Currency).AutoInclude();
|
||||||
|
modelBuilder.Entity<WineAttr>().Navigation(s => s.MinQualityLevel).AutoInclude();
|
||||||
|
modelBuilder.Entity<WineAttr>().Navigation(s => s.MaxQualityLevel).AutoInclude();
|
||||||
modelBuilder.Entity<PaymentVar>().Navigation(v => v.Season).AutoInclude();
|
modelBuilder.Entity<PaymentVar>().Navigation(v => v.Season).AutoInclude();
|
||||||
modelBuilder.Entity<PaymentDeliveryPart>().Navigation(p => p.Variant).AutoInclude();
|
modelBuilder.Entity<PaymentDeliveryPart>().Navigation(p => p.Variant).AutoInclude();
|
||||||
modelBuilder.Entity<Credit>().Navigation(c => c.Payment).AutoInclude();
|
modelBuilder.Entity<Credit>().Navigation(c => c.Payment).AutoInclude();
|
||||||
@@ -531,6 +534,44 @@ namespace Elwig.Helpers {
|
|||||||
return _memberHistory[year].GetValueOrDefault(mgnr, new());
|
return _memberHistory[year].GetValueOrDefault(mgnr, new());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public async Task<Dictionary<int, SortedDictionary<DateOnly, MemberHistoryPoint>>> GetMemberHistory() {
|
||||||
|
var today = DateOnly.FromDateTime(DateTime.Today).AddDays(1);
|
||||||
|
var history = new Dictionary<int, SortedDictionary<DateOnly, MemberHistoryPoint>>();
|
||||||
|
|
||||||
|
var members = await Members.ToListAsync();
|
||||||
|
foreach (var m in members) {
|
||||||
|
history[m.MgNr] = new() {
|
||||||
|
[today] = new(m.Shares, m.SharesRed, m.SharesWhite, m.SharesDormant),
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var hist = await MemberHistory.OrderByDescending(h => h.DateNoticeString).ToListAsync();
|
||||||
|
foreach (var h in hist) {
|
||||||
|
if (h.FromMgNr is int from) {
|
||||||
|
var latest = history[from].Last().Value;
|
||||||
|
switch (h.FromType) {
|
||||||
|
case BusinessShareType.Normal: latest.Shares += h.Shares; break;
|
||||||
|
case BusinessShareType.Red: latest.SharesRed += h.Shares; break;
|
||||||
|
case BusinessShareType.White: latest.SharesWhite += h.Shares; break;
|
||||||
|
case BusinessShareType.Dormant: latest.SharesDormant += h.Shares; break;
|
||||||
|
}
|
||||||
|
history[from][h.DateNotice] = latest;
|
||||||
|
}
|
||||||
|
if (h.ToMgNr is int to) {
|
||||||
|
var latest = history[to].Last().Value;
|
||||||
|
switch (h.ToType) {
|
||||||
|
case BusinessShareType.Normal: latest.Shares -= h.Shares; break;
|
||||||
|
case BusinessShareType.Red: latest.SharesRed -= h.Shares; break;
|
||||||
|
case BusinessShareType.White: latest.SharesWhite -= h.Shares; break;
|
||||||
|
case BusinessShareType.Dormant: latest.SharesDormant -= h.Shares; break;
|
||||||
|
}
|
||||||
|
history[to][h.DateNotice] = latest;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return history;
|
||||||
|
}
|
||||||
|
|
||||||
public async Task<Dictionary<string, AreaCmtBucket>> GetMemberAreaCommitmentBuckets(int year, int mgnr, SqliteConnection? cnx = null) {
|
public async Task<Dictionary<string, AreaCmtBucket>> GetMemberAreaCommitmentBuckets(int year, int mgnr, SqliteConnection? cnx = null) {
|
||||||
if (!_memberAreaCommitmentBuckets.ContainsKey(year))
|
if (!_memberAreaCommitmentBuckets.ContainsKey(year))
|
||||||
await FetchMemberAreaCommitmentBuckets(year, cnx);
|
await FetchMemberAreaCommitmentBuckets(year, cnx);
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ namespace Elwig.Helpers {
|
|||||||
public static class AppDbUpdater {
|
public static class AppDbUpdater {
|
||||||
|
|
||||||
// Don't forget to update value in Tests/fetch-resources.bat!
|
// Don't forget to update value in Tests/fetch-resources.bat!
|
||||||
public static readonly int RequiredSchemaVersion = 42;
|
public static readonly int RequiredSchemaVersion = 43;
|
||||||
|
|
||||||
private static int VersionOffset = 0;
|
private static int VersionOffset = 0;
|
||||||
|
|
||||||
|
|||||||
@@ -179,7 +179,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
} else {
|
} else {
|
||||||
throw new InvalidOperationException();
|
throw new InvalidOperationException();
|
||||||
}
|
}
|
||||||
var ctrd = obj["contracted"] ?? obj["geb"];
|
var ctrd = obj["ctrd"] ?? obj["geb"];
|
||||||
if (ctrd is JsonObject) {
|
if (ctrd is JsonObject) {
|
||||||
c2 = GetCurveData(ctrd.AsObject(), cMode);
|
c2 = GetCurveData(ctrd.AsObject(), cMode);
|
||||||
} else if (ctrd?.AsValue().TryGetValue(out decimal v) == true) {
|
} else if (ctrd?.AsValue().TryGetValue(out decimal v) == true) {
|
||||||
@@ -251,23 +251,23 @@ namespace Elwig.Helpers.Billing {
|
|||||||
|
|
||||||
try {
|
try {
|
||||||
return new JsonObject() {
|
return new JsonObject() {
|
||||||
["15kmw"] = Math.Round(y.Distinct().Single(), prec)
|
["15kmw"] = Math.Round((decimal)y.Distinct().Single(), prec)
|
||||||
};
|
};
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
var data = new JsonObject();
|
var data = new JsonObject();
|
||||||
if (y[0] != y[1]) {
|
if (y[0] != y[1]) {
|
||||||
data[$"{x[0]}{mode}"] = Math.Round(y[0], prec);
|
data[$"{x[0]}{mode}"] = Math.Round((decimal)y[0], prec);
|
||||||
}
|
}
|
||||||
for (int i = 1; i < x.Length - 1; i++) {
|
for (int i = 1; i < x.Length - 1; i++) {
|
||||||
var d1 = Math.Round(y[i] - y[i - 1], prec);
|
var d1 = Math.Round((decimal)(y[i] - y[i - 1]), prec);
|
||||||
var d2 = Math.Round(y[i + 1] - y[i], prec);
|
var d2 = Math.Round((decimal)(y[i + 1] - y[i]), prec);
|
||||||
if (d1 != d2) {
|
if (d1 != d2) {
|
||||||
data[$"{x[i]}{mode}"] = Math.Round(y[i], prec);
|
data[$"{x[i]}{mode}"] = Math.Round((decimal)y[i], prec);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (y[^1] != y[^2]) {
|
if (y[^1] != y[^2]) {
|
||||||
data[$"{x[^1]}{mode}"] = Math.Round(y[^1], prec);
|
data[$"{x[^1]}{mode}"] = Math.Round((decimal)y[^1], prec);
|
||||||
}
|
}
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
@@ -275,7 +275,7 @@ namespace Elwig.Helpers.Billing {
|
|||||||
protected static JsonNode GraphEntryToJson(GraphEntry entry) {
|
protected static JsonNode GraphEntryToJson(GraphEntry entry) {
|
||||||
try {
|
try {
|
||||||
if (entry.ContractedFlatBonus == null) {
|
if (entry.ContractedFlatBonus == null) {
|
||||||
return JsonValue.Create((decimal)entry.DataGraph.DataY.Distinct().Single());
|
return JsonValue.Create(Math.Round((decimal)entry.DataGraph.DataY.Distinct().Single(), entry.DataGraph.Precision));
|
||||||
}
|
}
|
||||||
} catch { }
|
} catch { }
|
||||||
|
|
||||||
@@ -287,11 +287,9 @@ namespace Elwig.Helpers.Billing {
|
|||||||
curve["data"] = GraphToJson(entry.DataGraph, entry.Mode.ToString().ToLower());
|
curve["data"] = GraphToJson(entry.DataGraph, entry.Mode.ToString().ToLower());
|
||||||
|
|
||||||
if (entry.ContractedFlatBonus != null) {
|
if (entry.ContractedFlatBonus != null) {
|
||||||
curve["contracted"] = (decimal)entry.ContractedFlatBonus;
|
curve["ctrd"] = Math.Round((decimal)entry.ContractedFlatBonus, entry.ContractedGraph?.Precision ?? entry.DataGraph.Precision);
|
||||||
curve.Remove("geb");
|
|
||||||
} else if (entry.ContractedGraph != null) {
|
} else if (entry.ContractedGraph != null) {
|
||||||
curve["contracted"] = GraphToJson(entry.ContractedGraph, entry.Mode.ToString().ToLower());
|
curve["ctrd"] = GraphToJson(entry.ContractedGraph, entry.Mode.ToString().ToLower());
|
||||||
curve.Remove("geb");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return curve;
|
return curve;
|
||||||
|
|||||||
@@ -63,9 +63,9 @@ namespace Elwig.Helpers.Billing {
|
|||||||
((Variety != null || Attribute != null) && Cultivation != null ? " " : "") + $"{Cultivation?.Name}";
|
((Variety != null || Attribute != null) && Cultivation != null ? " " : "") + $"{Cultivation?.Name}";
|
||||||
|
|
||||||
public Varibute(RawVaribute raw) :
|
public Varibute(RawVaribute raw) :
|
||||||
this(raw.SortId != null ? new WineVar(raw.SortId, raw.SortId) : null,
|
this(raw.SortId != null ? new WineVar { SortId = raw.SortId, Name = raw.SortId, MaxQualId = "QUW", Type = "?" } : null,
|
||||||
raw.AttrId != null ? new WineAttr() { AttrId = raw.AttrId, Name = raw.AttrId } : null,
|
raw.AttrId != null ? new WineAttr { AttrId = raw.AttrId, Name = raw.AttrId } : null,
|
||||||
raw.CultId != null ? new WineCult() { CultId = raw.CultId, Name = raw.CultId } : null) {
|
raw.CultId != null ? new WineCult { CultId = raw.CultId, Name = raw.CultId } : null) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Varibute(RawVaribute raw, Dictionary<string, WineVar> vars, Dictionary<string, WineAttr> attrs, Dictionary<string, WineCult> cults) :
|
public Varibute(RawVaribute raw, Dictionary<string, WineVar> vars, Dictionary<string, WineAttr> attrs, Dictionary<string, WineCult> cults) :
|
||||||
|
|||||||
@@ -61,6 +61,7 @@ namespace Elwig.Helpers {
|
|||||||
public int ModeBusinessShares;
|
public int ModeBusinessShares;
|
||||||
public bool HasRedWhite => ModeBusinessShares == 1;
|
public bool HasRedWhite => ModeBusinessShares == 1;
|
||||||
|
|
||||||
|
public int ModeMemberDataSheetShares;
|
||||||
public int ModeDeliveryNoteStats;
|
public int ModeDeliveryNoteStats;
|
||||||
public int ModeWineQualityStatistics;
|
public int ModeWineQualityStatistics;
|
||||||
public int OrderingMemberList;
|
public int OrderingMemberList;
|
||||||
@@ -80,9 +81,27 @@ namespace Elwig.Helpers {
|
|||||||
public int ExportEbicsVersion;
|
public int ExportEbicsVersion;
|
||||||
public int ExportEbicsAddress;
|
public int ExportEbicsAddress;
|
||||||
|
|
||||||
|
public string? ReceiptMaxQualId;
|
||||||
|
|
||||||
public (int? AllowanceKg, double? AllowanceShares, int? AllowanceKgPerShare, double? AllowancePercent, int? MinShares) AutoAdjustShares;
|
public (int? AllowanceKg, double? AllowanceShares, int? AllowanceKgPerShare, double? AllowancePercent, int? MinShares) AutoAdjustShares;
|
||||||
|
|
||||||
public ClientParameters(AppDbContext ctx) : this(ctx.ClientParameters.ToDictionary(e => e.Param, e => e.Value)) { }
|
public static readonly Dictionary<string, string?> DefaultParameters = new() {
|
||||||
|
{ "CLIENT_NAME_TOKEN", "XXX" },
|
||||||
|
{ "CLIENT_NAME_SHORT", "Unbekannt" },
|
||||||
|
{ "CLIENT_NAME", "Unbekannt" },
|
||||||
|
{ "CLIENT_NAME_TYPE", "Unbekannt" },
|
||||||
|
{ "CLIENT_PLZ", "9999" },
|
||||||
|
{ "CLIENT_ORT", "Unbekannt" },
|
||||||
|
{ "CLIENT_ADDRESS", "Unbekannt" },
|
||||||
|
};
|
||||||
|
|
||||||
|
public ClientParameters() :
|
||||||
|
this(DefaultParameters) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClientParameters(AppDbContext ctx) :
|
||||||
|
this(ctx.ClientParameters.ToDictionary(e => e.Param, e => e.Value)) {
|
||||||
|
}
|
||||||
|
|
||||||
public ClientParameters(Dictionary<string, string?> parameters) {
|
public ClientParameters(Dictionary<string, string?> parameters) {
|
||||||
try {
|
try {
|
||||||
@@ -127,6 +146,10 @@ namespace Elwig.Helpers {
|
|||||||
case "SIMPLE": ModeBusinessShares = 0; break;
|
case "SIMPLE": ModeBusinessShares = 0; break;
|
||||||
case "RED_WHITE": ModeBusinessShares = 1; break;
|
case "RED_WHITE": ModeBusinessShares = 1; break;
|
||||||
}
|
}
|
||||||
|
switch (parameters.GetValueOrDefault("MODE_MEMBERDATASHEET_SHARES", "FULL")?.ToUpper()) {
|
||||||
|
case "NONE": ModeMemberDataSheetShares = 0; break;
|
||||||
|
case "FULL": ModeMemberDataSheetShares = 1; break;
|
||||||
|
}
|
||||||
switch (parameters.GetValueOrDefault("MODE_DELIVERYNOTE_STATS", "SHORT")?.ToUpper()) {
|
switch (parameters.GetValueOrDefault("MODE_DELIVERYNOTE_STATS", "SHORT")?.ToUpper()) {
|
||||||
case "NONE": ModeDeliveryNoteStats = 0; break;
|
case "NONE": ModeDeliveryNoteStats = 0; break;
|
||||||
case "GA_ONLY": ModeDeliveryNoteStats = 1; break;
|
case "GA_ONLY": ModeDeliveryNoteStats = 1; break;
|
||||||
@@ -190,6 +213,11 @@ namespace Elwig.Helpers {
|
|||||||
case "FULL": ExportEbicsAddress = 2; break;
|
case "FULL": ExportEbicsAddress = 2; break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ReceiptMaxQualId = parameters.GetValueOrDefault("RECEIPT_MAX_QUALID", "QUW")?.ToUpper();
|
||||||
|
if (ReceiptMaxQualId?.Length != 3 || !ReceiptMaxQualId.All(char.IsAsciiLetter)) {
|
||||||
|
ReceiptMaxQualId = null;
|
||||||
|
}
|
||||||
|
|
||||||
var autoAdjust = (parameters.GetValueOrDefault("AUTOADJUST_BUSINESSSHARES") ?? "").Split(';');
|
var autoAdjust = (parameters.GetValueOrDefault("AUTOADJUST_BUSINESSSHARES") ?? "").Split(';');
|
||||||
AutoAdjustShares = autoAdjust.Length == 5 ? (
|
AutoAdjustShares = autoAdjust.Length == 5 ? (
|
||||||
int.TryParse(autoAdjust[0], out var v1) ? v1 : null,
|
int.TryParse(autoAdjust[0], out var v1) ? v1 : null,
|
||||||
@@ -209,6 +237,11 @@ namespace Elwig.Helpers {
|
|||||||
case 0: businessShares = "SIMPLE"; break;
|
case 0: businessShares = "SIMPLE"; break;
|
||||||
case 1: businessShares = "RED_WHITE"; break;
|
case 1: businessShares = "RED_WHITE"; break;
|
||||||
}
|
}
|
||||||
|
string memberDataSheetShares = "FULL";
|
||||||
|
switch (ModeMemberDataSheetShares) {
|
||||||
|
case 0: memberDataSheetShares = "NONE"; break;
|
||||||
|
case 1: memberDataSheetShares = "FULL"; break;
|
||||||
|
}
|
||||||
string deliveryNoteStats = "SHORT";
|
string deliveryNoteStats = "SHORT";
|
||||||
switch (ModeDeliveryNoteStats) {
|
switch (ModeDeliveryNoteStats) {
|
||||||
case 0: deliveryNoteStats = "NONE"; break;
|
case 0: deliveryNoteStats = "NONE"; break;
|
||||||
@@ -279,6 +312,7 @@ namespace Elwig.Helpers {
|
|||||||
("CLIENT_ORGANIC_AUTHORITYCODE", OrganicAuthorityCode),
|
("CLIENT_ORGANIC_AUTHORITYCODE", OrganicAuthorityCode),
|
||||||
("ENABLE_MEMBERHISTORY", EnableMemberHistory ? "YES" : "NO"),
|
("ENABLE_MEMBERHISTORY", EnableMemberHistory ? "YES" : "NO"),
|
||||||
("MODE_BUSINESSSHARES", businessShares),
|
("MODE_BUSINESSSHARES", businessShares),
|
||||||
|
("MODE_MEMBERDATASHEET_SHARES", memberDataSheetShares),
|
||||||
("MODE_DELIVERYNOTE_STATS", deliveryNoteStats),
|
("MODE_DELIVERYNOTE_STATS", deliveryNoteStats),
|
||||||
("MODE_WINEQUALITYSTATISTICS", modeWineQualityStatistics),
|
("MODE_WINEQUALITYSTATISTICS", modeWineQualityStatistics),
|
||||||
("ORDERING_MEMBERLIST", orderingMemberList),
|
("ORDERING_MEMBERLIST", orderingMemberList),
|
||||||
@@ -295,6 +329,7 @@ namespace Elwig.Helpers {
|
|||||||
("MAIL_ORDERING", mailOrdering),
|
("MAIL_ORDERING", mailOrdering),
|
||||||
("EXPORT_EBICS_VERSION", ExportEbicsVersion.ToString()),
|
("EXPORT_EBICS_VERSION", ExportEbicsVersion.ToString()),
|
||||||
("EXPORT_EBICS_ADDRESS", exportEbicsAddress),
|
("EXPORT_EBICS_ADDRESS", exportEbicsAddress),
|
||||||
|
("RECEIPT_MAX_QUALID", ReceiptMaxQualId),
|
||||||
("AUTOADJUST_BUSINESSSHARES", autoAdjust),
|
("AUTOADJUST_BUSINESSSHARES", autoAdjust),
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|||||||
+17
-6
@@ -2,6 +2,7 @@ using System;
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Windows;
|
||||||
using Microsoft.Extensions.Configuration;
|
using Microsoft.Extensions.Configuration;
|
||||||
|
|
||||||
namespace Elwig.Helpers {
|
namespace Elwig.Helpers {
|
||||||
@@ -55,24 +56,32 @@ namespace Elwig.Helpers {
|
|||||||
public int BackupRetainDays = 8;
|
public int BackupRetainDays = 8;
|
||||||
public int BackupRetainWeeks = 6;
|
public int BackupRetainWeeks = 6;
|
||||||
public int BackupRetainMonths = 18;
|
public int BackupRetainMonths = 18;
|
||||||
|
private string[] _backupKeys = [];
|
||||||
|
public ReadOnlyMemory<char>[] BackupDecryptionKeys => [.. _backupKeys.Select(k => k.AsMemory())];
|
||||||
|
public ReadOnlyMemory<char> BackupEncryptionKey => _backupKeys.Length == 0 ? null : _backupKeys[0].AsMemory();
|
||||||
|
|
||||||
public string? UpdateUrl = null;
|
public string? UpdateUrl = null;
|
||||||
public bool UpdateAuto = false;
|
public bool UpdateAuto = false;
|
||||||
|
|
||||||
public string? SyncUrl = null;
|
public string? SyncUrl = null;
|
||||||
public string SyncUsername = "";
|
public string SyncUsername = "";
|
||||||
public string SyncPassword = "";
|
private string _syncPassword = "";
|
||||||
|
public ReadOnlyMemory<char> SyncPassword => _syncPassword.AsMemory();
|
||||||
public bool SyncMain = false;
|
public bool SyncMain = false;
|
||||||
|
private string[] _syncKeys = [];
|
||||||
|
public ReadOnlyMemory<char>[] SyncDecryptionKeys => [.. _syncKeys.Select(k => k.AsMemory())];
|
||||||
|
public ReadOnlyMemory<char> SyncEncryptionKey => _syncKeys.Length == 0 ? null : _syncKeys[0].AsMemory();
|
||||||
|
|
||||||
public string? SmtpHost = null;
|
public string? SmtpHost = null;
|
||||||
public int? SmtpPort = null;
|
public int? SmtpPort = null;
|
||||||
public string? SmtpMode = null;
|
public string? SmtpMode = null;
|
||||||
public string? SmtpUsername = null;
|
public string? SmtpUsername = null;
|
||||||
public string? SmtpPassword = null;
|
private string? _smtpPassword = null;
|
||||||
|
public ReadOnlyMemory<char> SmtpPassword => _smtpPassword.AsMemory();
|
||||||
public string? SmtpFrom = null;
|
public string? SmtpFrom = null;
|
||||||
public double SmtpWait = 0;
|
public double SmtpWait = 0;
|
||||||
public (string Host, int Port, string Mode, string Username, string Password, string From, double Wait)? Smtp =>
|
public (string Host, int Port, string Mode, string Username, ReadOnlyMemory<char> Password, string From, double Wait)? Smtp =>
|
||||||
SmtpHost == null || SmtpPort == null || SmtpMode == null || SmtpUsername == null || SmtpPassword == null || SmtpFrom == null ?
|
SmtpHost == null || SmtpPort == null || SmtpMode == null || SmtpUsername == null || !SmtpPassword.IsEmpty || SmtpFrom == null ?
|
||||||
null : (SmtpHost, (int)SmtpPort, SmtpMode, SmtpUsername, SmtpPassword, SmtpFrom, SmtpWait);
|
null : (SmtpHost, (int)SmtpPort, SmtpMode, SmtpUsername, SmtpPassword, SmtpFrom, SmtpWait);
|
||||||
|
|
||||||
public IList<ScaleConfig> Scales;
|
public IList<ScaleConfig> Scales;
|
||||||
@@ -101,20 +110,22 @@ namespace Elwig.Helpers {
|
|||||||
BackupRetainDays = int.TryParse(config["backup:retain_days"], out var days) ? days : 8;
|
BackupRetainDays = int.TryParse(config["backup:retain_days"], out var days) ? days : 8;
|
||||||
BackupRetainWeeks = int.TryParse(config["backup:retain_weeks"], out var weeks) ? weeks : 6;
|
BackupRetainWeeks = int.TryParse(config["backup:retain_weeks"], out var weeks) ? weeks : 6;
|
||||||
BackupRetainMonths = int.TryParse(config["backup:retain_months"], out var months) ? months : 18;
|
BackupRetainMonths = int.TryParse(config["backup:retain_months"], out var months) ? months : 18;
|
||||||
|
_backupKeys = config["backup:key"]?.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) ?? [];
|
||||||
|
|
||||||
UpdateUrl = config["update:url"];
|
UpdateUrl = config["update:url"];
|
||||||
UpdateAuto = TrueValues.Contains(config["update:auto"]?.ToLower());
|
UpdateAuto = TrueValues.Contains(config["update:auto"]?.ToLower());
|
||||||
|
|
||||||
SyncUrl = config["sync:url"];
|
SyncUrl = config["sync:url"];
|
||||||
SyncUsername = config["sync:username"] ?? "";
|
SyncUsername = config["sync:username"] ?? "";
|
||||||
SyncPassword = config["sync:password"] ?? "";
|
_syncPassword = config["sync:password"] ?? "";
|
||||||
SyncMain = TrueValues.Contains(config["sync:main"]?.ToLower());
|
SyncMain = TrueValues.Contains(config["sync:main"]?.ToLower());
|
||||||
|
_syncKeys = config["sync:key"]?.Split(',', StringSplitOptions.RemoveEmptyEntries | StringSplitOptions.TrimEntries) ?? [];
|
||||||
|
|
||||||
SmtpHost = config["smtp:host"];
|
SmtpHost = config["smtp:host"];
|
||||||
SmtpPort = config["smtp:port"]?.All(char.IsAsciiDigit) == true && config["smtp:port"]?.Length > 0 ? int.Parse(config["smtp:port"]!) : null;
|
SmtpPort = config["smtp:port"]?.All(char.IsAsciiDigit) == true && config["smtp:port"]?.Length > 0 ? int.Parse(config["smtp:port"]!) : null;
|
||||||
SmtpMode = config["smtp:mode"];
|
SmtpMode = config["smtp:mode"];
|
||||||
SmtpUsername = config["smtp:username"];
|
SmtpUsername = config["smtp:username"];
|
||||||
SmtpPassword = config["smtp:password"];
|
_smtpPassword = config["smtp:password"];
|
||||||
SmtpFrom = config["smtp:from"];
|
SmtpFrom = config["smtp:from"];
|
||||||
SmtpWait = double.TryParse(config["smtp:wait"], out var res) ? res : 0;
|
SmtpWait = double.TryParse(config["smtp:wait"], out var res) ? res : 0;
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
using Row = Tuple<(string?, string?, string?, string?, string, int, string, bool, int), (string, int, string, string, string, int, string, double, double)>;
|
using Row = Tuple<(string?, string?, string?, string?, string, int, string, bool, int), (string, int, string, string, string, int, string, double, double)>;
|
||||||
|
|
||||||
public class Bki : Csv<Row> {
|
public class Bki : CsvFile<Row> {
|
||||||
|
|
||||||
private readonly string _clientData;
|
private readonly string _clientData;
|
||||||
|
|
||||||
@@ -46,10 +46,6 @@ namespace Elwig.Helpers.Export {
|
|||||||
await ExportAsync(rows);
|
await ExportAsync(rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Export(int year) {
|
|
||||||
ExportAsync(year).GetAwaiter().GetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string FormatRow(Row row) {
|
public override string FormatRow(Row row) {
|
||||||
var (member, delivery) = row;
|
var (member, delivery) = row;
|
||||||
var (lfBisNr, familyName, name, billingName, address, plz, ort, vollablieferer, area) = member;
|
var (lfBisNr, familyName, name, billingName, address, plz, ort, vollablieferer, area) = member;
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ using System.Text;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Elwig.Helpers.Export {
|
namespace Elwig.Helpers.Export {
|
||||||
public abstract class Csv<T> : IExporter<T> {
|
public abstract class CsvFile<T> : IExporter<T> {
|
||||||
|
|
||||||
public static string FileExtension => "csv";
|
public static string FileExtension => "csv";
|
||||||
|
|
||||||
@@ -15,11 +15,11 @@ namespace Elwig.Helpers.Export {
|
|||||||
protected readonly char Separator;
|
protected readonly char Separator;
|
||||||
protected string? Header;
|
protected string? Header;
|
||||||
|
|
||||||
public Csv(string filename, char separator = ';') :
|
public CsvFile(string filename, char separator = ';') :
|
||||||
this(filename, separator, Utils.UTF8) {
|
this(filename, separator, Utils.UTF8) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public Csv(string filename, char separator, Encoding encoding) {
|
public CsvFile(string filename, char separator, Encoding encoding) {
|
||||||
_writer = new StreamWriter(filename, false, encoding);
|
_writer = new StreamWriter(filename, false, encoding);
|
||||||
Separator = separator;
|
Separator = separator;
|
||||||
}
|
}
|
||||||
@@ -29,11 +29,6 @@ namespace Elwig.Helpers.Export {
|
|||||||
_writer.Dispose();
|
_writer.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueTask DisposeAsync() {
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
return _writer.DisposeAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExportAsync(IEnumerable<T> data, IProgress<double>? progress = null) {
|
public async Task ExportAsync(IEnumerable<T> data, IProgress<double>? progress = null) {
|
||||||
progress?.Report(0.0);
|
progress?.Report(0.0);
|
||||||
int count = data.Count() + 2, i = 0;
|
int count = data.Count() + 2, i = 0;
|
||||||
@@ -50,10 +45,6 @@ namespace Elwig.Helpers.Export {
|
|||||||
progress?.Report(100.0);
|
progress?.Report(100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Export(IEnumerable<T> data, IProgress<double>? progress = null) {
|
|
||||||
ExportAsync(data, progress).GetAwaiter().GetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public string FormatRow(IEnumerable row) {
|
public string FormatRow(IEnumerable row) {
|
||||||
return string.Join(Separator, row);
|
return string.Join(Separator, row);
|
||||||
}
|
}
|
||||||
@@ -61,7 +52,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
public abstract string FormatRow(T row);
|
public abstract string FormatRow(T row);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class CsvSimple : Csv<IEnumerable<object?>> {
|
public class CsvSimple : CsvFile<IEnumerable<object?>> {
|
||||||
|
|
||||||
public CsvSimple(string filename, char separator, Encoding encoding) :
|
public CsvSimple(string filename, char separator, Encoding encoding) :
|
||||||
base(filename, separator, encoding) {
|
base(filename, separator, encoding) {
|
||||||
@@ -17,21 +17,21 @@ namespace Elwig.Helpers.Export {
|
|||||||
return (applId, userVers != null ? $"{userVers >> 24}.{(userVers >> 16) & 0xFF}.{(userVers >> 8) & 0xFF}.{userVers & 0xFF}" : null, schemaVers, size);
|
return (applId, userVers != null ? $"{userVers >> 24}.{(userVers >> 16) & 0xFF}.{(userVers >> 8) & 0xFF}.{userVers & 0xFF}" : null, schemaVers, size);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ExportSqlite(string filename, bool zipFile) {
|
public static async Task ExportSqlite(string filename, bool zipFile, ReadOnlyMemory<char> password = default) {
|
||||||
var tmp = filename + ".tmp";
|
var tmp = filename + ".tmp";
|
||||||
try {
|
try {
|
||||||
File.Delete(tmp);
|
File.Delete(tmp);
|
||||||
if (zipFile) {
|
if (zipFile) {
|
||||||
using var zip = ZipFile.Open(tmp, ZipArchiveMode.Create);
|
using var zip = await ZipFile.OpenAsync(tmp, ZipArchiveMode.Create);
|
||||||
|
|
||||||
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
|
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
|
||||||
using (var writer = new StreamWriter(version.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await version.OpenAsync(), Utils.UTF8)) {
|
||||||
await writer.WriteAsync("elwig:1");
|
await writer.WriteAsync("elwig:1");
|
||||||
}
|
}
|
||||||
|
|
||||||
var (applId, userVers, schemaVers, size) = await GetMeta();
|
var (applId, userVers, schemaVers, size) = await GetMeta();
|
||||||
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
|
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
|
||||||
using (var writer = new StreamWriter(meta.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await meta.OpenAsync(), Utils.UTF8)) {
|
||||||
var obj = new JsonObject {
|
var obj = new JsonObject {
|
||||||
["timestamp"] = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}",
|
["timestamp"] = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}",
|
||||||
["zwstid"] = App.ZwstId,
|
["zwstid"] = App.ZwstId,
|
||||||
@@ -46,7 +46,9 @@ namespace Elwig.Helpers.Export {
|
|||||||
await writer.WriteAsync(obj.ToJsonString(Utils.JsonOpts));
|
await writer.WriteAsync(obj.ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
|
|
||||||
var db = zip.CreateEntryFromFile(App.Config.DatabaseFile, "database.sqlite3", CompressionLevel.SmallestSize);
|
var db = password.IsEmpty ?
|
||||||
|
zip.CreateEntryFromFile(App.Config.DatabaseFile, "database.sqlite3", CompressionLevel.SmallestSize) :
|
||||||
|
zip.CreateEntryFromFile(App.Config.DatabaseFile, "database.sqlite3", CompressionLevel.SmallestSize, password.Span, ZipEncryptionMethod.Aes256);
|
||||||
} else {
|
} else {
|
||||||
File.Copy(App.Config.DatabaseFile, tmp);
|
File.Copy(App.Config.DatabaseFile, tmp);
|
||||||
}
|
}
|
||||||
@@ -56,21 +58,21 @@ namespace Elwig.Helpers.Export {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ExportSql(string filename, bool zipFile) {
|
public static async Task ExportSql(string filename, bool zipFile, ReadOnlyMemory<char> password = default) {
|
||||||
var tmp = filename + ".tmp";
|
var tmp = filename + ".tmp";
|
||||||
try {
|
try {
|
||||||
File.Delete(tmp);
|
File.Delete(tmp);
|
||||||
if (zipFile) {
|
if (zipFile) {
|
||||||
using var zip = ZipFile.Open(tmp, ZipArchiveMode.Create);
|
using var zip = await ZipFile.OpenAsync(tmp, ZipArchiveMode.Create);
|
||||||
|
|
||||||
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
|
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
|
||||||
using (var writer = new StreamWriter(version.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await version.OpenAsync(), Utils.UTF8)) {
|
||||||
await writer.WriteAsync("elwig:1");
|
await writer.WriteAsync("elwig:1");
|
||||||
}
|
}
|
||||||
|
|
||||||
var (applId, userVers, schemaVers, size) = await GetMeta();
|
var (applId, userVers, schemaVers, size) = await GetMeta();
|
||||||
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
|
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
|
||||||
using (var writer = new StreamWriter(meta.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await meta.OpenAsync(), Utils.UTF8)) {
|
||||||
var obj = new JsonObject {
|
var obj = new JsonObject {
|
||||||
["timestamp"] = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}",
|
["timestamp"] = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}",
|
||||||
["zwstid"] = App.ZwstId,
|
["zwstid"] = App.ZwstId,
|
||||||
@@ -85,8 +87,10 @@ namespace Elwig.Helpers.Export {
|
|||||||
await writer.WriteAsync(obj.ToJsonString(Utils.JsonOpts));
|
await writer.WriteAsync(obj.ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
|
|
||||||
var sql = zip.CreateEntry("database.sql", CompressionLevel.SmallestSize);
|
var sql = password.IsEmpty ?
|
||||||
using (var writer = new StreamWriter(sql.Open(), Utils.UTF8)) {
|
zip.CreateEntry("database.sql", CompressionLevel.SmallestSize) :
|
||||||
|
zip.CreateEntry("database.sql", CompressionLevel.SmallestSize, password.Span, ZipEncryptionMethod.Aes256);
|
||||||
|
using (var writer = new StreamWriter(await sql.OpenAsync(), Utils.UTF8)) {
|
||||||
await ExportSql(writer);
|
await ExportSql(writer);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
@@ -178,27 +182,27 @@ namespace Elwig.Helpers.Export {
|
|||||||
await writer.WriteLineAsync("VACUUM;");
|
await writer.WriteLineAsync("VACUUM;");
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task Import(string filename) {
|
public static async Task Import(string filename, IEnumerable<ReadOnlyMemory<char>>? passwords = null) {
|
||||||
if (filename.EndsWith(".sql")) {
|
if (filename.EndsWith(".sql")) {
|
||||||
await ImportSql(filename, false);
|
await ImportSql(filename, false);
|
||||||
} else if (filename.EndsWith(".sql.zip")) {
|
} else if (filename.EndsWith(".sql.zip")) {
|
||||||
await ImportSql(filename, true);
|
await ImportSql(filename, true, passwords);
|
||||||
} else if (filename.EndsWith(".sqlite3")) {
|
} else if (filename.EndsWith(".sqlite3")) {
|
||||||
await ImportSqlite(filename, false);
|
await ImportSqlite(filename, false);
|
||||||
} else if (filename.EndsWith(".sqlite3.zip")) {
|
} else if (filename.EndsWith(".sqlite3.zip")) {
|
||||||
await ImportSqlite(filename, true);
|
await ImportSqlite(filename, true, passwords);
|
||||||
} else {
|
} else {
|
||||||
throw new ArgumentException($"Unknown file extension for importing: '{filename}'");
|
throw new ArgumentException($"Unknown file extension for importing: '{filename}'");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ImportSql(string filename, bool zipFile = false) {
|
public static async Task ImportSql(string filename, bool zipFile = false, IEnumerable<ReadOnlyMemory<char>>? passwords = null) {
|
||||||
if (zipFile) {
|
if (zipFile) {
|
||||||
using var zip = ZipFile.Open(filename, ZipArchiveMode.Read);
|
using var zip = await ZipFile.OpenAsync(filename, ZipArchiveMode.Read);
|
||||||
await zip.CheckIntegrity();
|
var password = await zip.CheckIntegrity(passwords ?? []);
|
||||||
foreach (var entry in zip.Entries) {
|
foreach (var entry in zip.Entries) {
|
||||||
if (entry.Name.EndsWith(".sql")) {
|
if (entry.Name.EndsWith(".sql")) {
|
||||||
using var stream = entry.Open();
|
using var stream = await entry.OpenAsync(password.Span);
|
||||||
using var reader = new StreamReader(stream, Utils.UTF8);
|
using var reader = new StreamReader(stream, Utils.UTF8);
|
||||||
await ImportSql(reader);
|
await ImportSql(reader);
|
||||||
return;
|
return;
|
||||||
@@ -212,15 +216,15 @@ namespace Elwig.Helpers.Export {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task ImportSqlite(string filename, bool zipFile = false, bool keepSource = true) {
|
public static async Task ImportSqlite(string filename, bool zipFile = false, IEnumerable<ReadOnlyMemory<char>>? passwords = null, bool keepSource = true) {
|
||||||
if (zipFile) {
|
if (zipFile) {
|
||||||
var newName = Path.ChangeExtension(App.Config.DatabaseFile, ".new.sqlite3");
|
var newName = Path.ChangeExtension(App.Config.DatabaseFile, ".new.sqlite3");
|
||||||
try {
|
try {
|
||||||
using var zip = ZipFile.Open(filename, ZipArchiveMode.Read);
|
using var zip = await ZipFile.OpenAsync(filename, ZipArchiveMode.Read);
|
||||||
await zip.CheckIntegrity();
|
var password = await zip.CheckIntegrity(passwords ?? []);
|
||||||
foreach (var entry in zip.Entries) {
|
foreach (var entry in zip.Entries) {
|
||||||
if (entry.Name.EndsWith(".sqlite3")) {
|
if (entry.Name.EndsWith(".sqlite3")) {
|
||||||
entry.ExtractToFile(newName);
|
entry.ExtractToFile(newName, new ZipExtractionOptions { Password = password });
|
||||||
await ImportSqlite(newName, keepSource: false);
|
await ImportSqlite(newName, keepSource: false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ using System.Security;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Elwig.Helpers.Export {
|
namespace Elwig.Helpers.Export {
|
||||||
public class Ebics(PaymentVar variant, string filename, int version, Ebics.AddressMode mode = Ebics.AddressMode.Full) : IBankingExporter {
|
public class Ebics(PaymentVar variant, string filename, int version, Ebics.AddressMode mode = Ebics.AddressMode.Full) : IExporter<Transaction> {
|
||||||
|
|
||||||
public enum AddressMode { Omit = 0, Lines = 1, Full = 2 }
|
public enum AddressMode { Omit = 0, Lines = 1, Full = 2 }
|
||||||
|
|
||||||
@@ -28,15 +28,6 @@ namespace Elwig.Helpers.Export {
|
|||||||
Writer.Dispose();
|
Writer.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueTask DisposeAsync() {
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
return Writer.DisposeAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Export(IEnumerable<Transaction> transactions, IProgress<double>? progress = null) {
|
|
||||||
ExportAsync(transactions, progress).GetAwaiter().GetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExportAsync(IEnumerable<Transaction> transactions, IProgress<double>? progress = null) {
|
public async Task ExportAsync(IEnumerable<Transaction> transactions, IProgress<double>? progress = null) {
|
||||||
if (transactions.Any(tx => tx.Amount < 0)) {
|
if (transactions.Any(tx => tx.Amount < 0)) {
|
||||||
throw new ArgumentException("Tranaction amount may not be negative");
|
throw new ArgumentException("Tranaction amount may not be negative");
|
||||||
|
|||||||
@@ -1,15 +0,0 @@
|
|||||||
using Elwig.Models.Dtos;
|
|
||||||
using System;
|
|
||||||
|
|
||||||
namespace Elwig.Helpers.Export {
|
|
||||||
public class Elba : Csv<Transaction>, IBankingExporter {
|
|
||||||
|
|
||||||
public static new string FileExtension => "elba";
|
|
||||||
|
|
||||||
public Elba(string filename) : base(filename) { }
|
|
||||||
|
|
||||||
public override string FormatRow(Transaction row) {
|
|
||||||
throw new NotImplementedException();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -30,9 +30,9 @@ namespace Elwig.Helpers.Export {
|
|||||||
await File.AppendAllLinesAsync(ImportedTxt, filenames, Utils.UTF8);
|
await File.AppendAllLinesAsync(ImportedTxt, filenames, Utils.UTF8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task Import(string filename, ImportMode mode) => Import([filename], mode);
|
public static Task Import(string filename, ImportMode mode, IEnumerable<ReadOnlyMemory<char>>? passwords = null) => Import([filename], mode, passwords);
|
||||||
|
|
||||||
public static async Task Import(IEnumerable<string> filenames, ImportMode mode) {
|
public static async Task Import(IEnumerable<string> filenames, ImportMode mode, IEnumerable<ReadOnlyMemory<char>>? passwords = null) {
|
||||||
try {
|
try {
|
||||||
Dictionary<string, Branch> branches;
|
Dictionary<string, Branch> branches;
|
||||||
Dictionary<int, AT_Kg> kgs;
|
Dictionary<int, AT_Kg> kgs;
|
||||||
@@ -89,20 +89,19 @@ namespace Elwig.Helpers.Export {
|
|||||||
})));
|
})));
|
||||||
var r = data[^1];
|
var r = data[^1];
|
||||||
|
|
||||||
// TODO read encrypted files
|
using var zip = await ZipFile.OpenReadAsync(filename);
|
||||||
using var zip = ZipFile.Open(filename, ZipArchiveMode.Read);
|
var password = await zip.CheckIntegrity(passwords ?? []);
|
||||||
await zip.CheckIntegrity();
|
|
||||||
|
|
||||||
string[] acceptableVersions = ["1", "2"];
|
string[] acceptableVersions = ["1", "2"];
|
||||||
var version = zip.GetEntry("version");
|
var version = zip.GetEntry("version");
|
||||||
using (var reader = new StreamReader(version!.Open(), Utils.UTF8)) {
|
using (var reader = new StreamReader(await version!.OpenAsync(), Utils.UTF8)) {
|
||||||
var v = await reader.ReadToEndAsync();
|
var v = await reader.ReadToEndAsync();
|
||||||
if (!v.StartsWith("elwig:") || !acceptableVersions.Contains(v[6..]))
|
if (!v.StartsWith("elwig:") || !acceptableVersions.Contains(v[6..]))
|
||||||
throw new FileFormatException($"Ungültige Elwig-Export-Datei ({filename})");
|
throw new FileFormatException($"Ungültige Elwig-Export-Datei ({filename})");
|
||||||
}
|
}
|
||||||
|
|
||||||
var metaJson = zip.GetEntry("meta.json");
|
var metaJson = zip.GetEntry("meta.json");
|
||||||
var meta = await JsonNode.ParseAsync(metaJson!.Open());
|
var meta = await JsonNode.ParseAsync(await metaJson!.OpenAsync());
|
||||||
var memberCount = meta!["members"]?["count"]?.AsValue().GetValue<int>();
|
var memberCount = meta!["members"]?["count"]?.AsValue().GetValue<int>();
|
||||||
var memberFilters = meta!["members"]?["filters"]?.AsArray().Select(f => f!.AsValue().GetValue<string>()).ToArray();
|
var memberFilters = meta!["members"]?["filters"]?.AsArray().Select(f => f!.AsValue().GetValue<string>()).ToArray();
|
||||||
var areaCmtCount = meta!["area_commitment_contracts"]?["count"]?.AsValue().GetValue<int>();
|
var areaCmtCount = meta!["area_commitment_contracts"]?["count"]?.AsValue().GetValue<int>();
|
||||||
@@ -117,7 +116,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
var wbKgsJson = zip.GetEntry("wb_kgs.json");
|
var wbKgsJson = zip.GetEntry("wb_kgs.json");
|
||||||
if (wbKgsJson != null) {
|
if (wbKgsJson != null) {
|
||||||
using var reader = new StreamReader(wbKgsJson.Open(), Utils.UTF8);
|
using var reader = new StreamReader(await wbKgsJson.OpenAsync(password.Span), Utils.UTF8);
|
||||||
string? line;
|
string? line;
|
||||||
while ((line = await reader.ReadLineAsync()) != null) {
|
while ((line = await reader.ReadLineAsync()) != null) {
|
||||||
var obj = JsonNode.Parse(line)!.AsObject();
|
var obj = JsonNode.Parse(line)!.AsObject();
|
||||||
@@ -125,7 +124,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
r.WbKgs.Add(k);
|
r.WbKgs.Add(k);
|
||||||
currentWbKgs[k.KgNr] = k;
|
currentWbKgs[k.KgNr] = k;
|
||||||
if (g != null) {
|
if (g != null) {
|
||||||
currentWbGls[g.GlNr] = g;
|
currentWbGls.Add(g);
|
||||||
r.WbGls.Add(g);
|
r.WbGls.Add(g);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,7 +132,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
var membersJson = zip.GetEntry("members.json");
|
var membersJson = zip.GetEntry("members.json");
|
||||||
if (membersJson != null) {
|
if (membersJson != null) {
|
||||||
using var reader = new StreamReader(membersJson.Open(), Utils.UTF8);
|
using var reader = new StreamReader(await membersJson.OpenAsync(password.Span), Utils.UTF8);
|
||||||
string? line;
|
string? line;
|
||||||
while ((line = await reader.ReadLineAsync()) != null) {
|
while ((line = await reader.ReadLineAsync()) != null) {
|
||||||
var obj = JsonNode.Parse(line)!.AsObject();
|
var obj = JsonNode.Parse(line)!.AsObject();
|
||||||
@@ -149,7 +148,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
var historyJson = zip.GetEntry("member_history.json");
|
var historyJson = zip.GetEntry("member_history.json");
|
||||||
if (historyJson != null) {
|
if (historyJson != null) {
|
||||||
using var reader = new StreamReader(historyJson.Open(), Utils.UTF8);
|
using var reader = new StreamReader(await historyJson.OpenAsync(password.Span), Utils.UTF8);
|
||||||
string? line;
|
string? line;
|
||||||
while ((line = await reader.ReadLineAsync()) != null) {
|
while ((line = await reader.ReadLineAsync()) != null) {
|
||||||
var obj = JsonNode.Parse(line)!.AsObject();
|
var obj = JsonNode.Parse(line)!.AsObject();
|
||||||
@@ -161,7 +160,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
// legacy area commitments
|
// legacy area commitments
|
||||||
var areaCmtsJson = zip.GetEntry("area_commitments.json");
|
var areaCmtsJson = zip.GetEntry("area_commitments.json");
|
||||||
if (areaCmtsJson != null) {
|
if (areaCmtsJson != null) {
|
||||||
using var reader = new StreamReader(areaCmtsJson.Open(), Utils.UTF8);
|
using var reader = new StreamReader(await areaCmtsJson.OpenAsync(password.Span), Utils.UTF8);
|
||||||
string? line;
|
string? line;
|
||||||
while ((line = await reader.ReadLineAsync()) != null) {
|
while ((line = await reader.ReadLineAsync()) != null) {
|
||||||
var obj = JsonNode.Parse(line)!.AsObject();
|
var obj = JsonNode.Parse(line)!.AsObject();
|
||||||
@@ -180,7 +179,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
var contractsJson = zip.GetEntry("area_commitment_contracts.json");
|
var contractsJson = zip.GetEntry("area_commitment_contracts.json");
|
||||||
if (contractsJson != null) {
|
if (contractsJson != null) {
|
||||||
using var reader = new StreamReader(contractsJson.Open(), Utils.UTF8);
|
using var reader = new StreamReader(await contractsJson.OpenAsync(password.Span), Utils.UTF8);
|
||||||
string? line;
|
string? line;
|
||||||
while ((line = await reader.ReadLineAsync()) != null) {
|
while ((line = await reader.ReadLineAsync()) != null) {
|
||||||
var obj = JsonNode.Parse(line)!.AsObject();
|
var obj = JsonNode.Parse(line)!.AsObject();
|
||||||
@@ -201,7 +200,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
var deliveriesJson = zip.GetEntry("deliveries.json");
|
var deliveriesJson = zip.GetEntry("deliveries.json");
|
||||||
if (deliveriesJson != null) {
|
if (deliveriesJson != null) {
|
||||||
using var reader = new StreamReader(deliveriesJson.Open(), Utils.UTF8);
|
using var reader = new StreamReader(await deliveriesJson.OpenAsync(password.Span), Utils.UTF8);
|
||||||
string? line;
|
string? line;
|
||||||
while ((line = await reader.ReadLineAsync()) != null) {
|
while ((line = await reader.ReadLineAsync()) != null) {
|
||||||
var obj = JsonNode.Parse(line)!.AsObject();
|
var obj = JsonNode.Parse(line)!.AsObject();
|
||||||
@@ -450,14 +449,14 @@ namespace Elwig.Helpers.Export {
|
|||||||
$"Flächenbindungen: {importedAreaCmts.Sum(d => d.New + d.Overwritten)}",
|
$"Flächenbindungen: {importedAreaCmts.Sum(d => d.New + d.Overwritten)}",
|
||||||
..importedAreaCmts.Select(d =>
|
..importedAreaCmts.Select(d =>
|
||||||
$" {d.FileName} ({d.New + d.Overwritten})\n" +
|
$" {d.FileName} ({d.New + d.Overwritten})\n" +
|
||||||
$" ({d.New} importiert, {d.Overwritten} überschreiben, {d.NotImported} nicht importiert)\n" +
|
$" ({d.New} neu, {d.Overwritten} überschrieben, {d.NotImported} nicht importiert)\n" +
|
||||||
$" Zweigstelle: {branches[d.ZwstId].Name} (Gerät {d.Device})\n" +
|
$" Zweigstelle: {branches[d.ZwstId].Name} (Gerät {d.Device})\n" +
|
||||||
$" Filter: {d.Filters}"),
|
$" Filter: {d.Filters}"),
|
||||||
$"Lieferungen: {importedDeliveries.Sum(d => d.New + d.Overwritten)}",
|
$"Lieferungen: {importedDeliveries.Sum(d => d.New + d.Overwritten)}",
|
||||||
..importedDeliveries.Select(d =>
|
..importedDeliveries.Select(d =>
|
||||||
$" {d.FileName} ({d.New + d.Overwritten})\n" +
|
$" {d.FileName} ({d.New + d.Overwritten})\n" +
|
||||||
$" ({d.New} neu, {d.Overwritten} überschr., {d.NotImported} nicht importiert)\n" +
|
$" ({d.New} neu, {d.Overwritten} überschrieben, {d.NotImported} nicht importiert)\n" +
|
||||||
$" Zwst.: {branches[d.ZwstId].Name} (Gerät {d.Device})\n" +
|
$" Zweigstelle: {branches[d.ZwstId].Name} (Gerät {d.Device})\n" +
|
||||||
$" Filter: {d.Filters}")
|
$" Filter: {d.Filters}")
|
||||||
]));
|
]));
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
@@ -473,28 +472,28 @@ namespace Elwig.Helpers.Export {
|
|||||||
$"{branch} (Gerät {device}) {(duplicate ? "überschrieben" : "importiert")} werden?", true);
|
$"{branch} (Gerät {device}) {(duplicate ? "überschrieben" : "importiert")} werden?", true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task Export(string filename, IEnumerable<Member> members, IEnumerable<MemberHistory> history, IEnumerable<WbKg> wbKgs, IEnumerable<string> filters) {
|
public static Task Export(string filename, IEnumerable<Member> members, IEnumerable<MemberHistory> history, IEnumerable<WbKg> wbKgs, IEnumerable<string> filters, ReadOnlyMemory<char> password = default) {
|
||||||
return new ElwigExport {
|
return new ElwigExport {
|
||||||
Members = (members, filters),
|
Members = (members, filters),
|
||||||
History = (history, ["von exportierten Mitgliedern"]),
|
History = (history, ["von exportierten Mitgliedern"]),
|
||||||
WbKgs = (wbKgs, ["von exportierten Mitgliedern"]),
|
WbKgs = (wbKgs, ["von exportierten Mitgliedern"]),
|
||||||
}.Export(filename);
|
}.Export(filename, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task Export(string filename, IEnumerable<Member> members, IEnumerable<MemberHistory> history, IEnumerable<AreaCmtContract> areaCmts, IEnumerable<WbKg> wbKgs, IEnumerable<string> filters) {
|
public static Task Export(string filename, IEnumerable<Member> members, IEnumerable<MemberHistory> history, IEnumerable<AreaCmtContract> areaCmts, IEnumerable<WbKg> wbKgs, IEnumerable<string> filters, ReadOnlyMemory<char> password = default) {
|
||||||
return new ElwigExport {
|
return new ElwigExport {
|
||||||
Members = (members, filters),
|
Members = (members, filters),
|
||||||
History = (history, ["von exportierten Mitgliedern"]),
|
History = (history, ["von exportierten Mitgliedern"]),
|
||||||
AreaCmts = (areaCmts, ["von exportierten Mitgliedern"]),
|
AreaCmts = (areaCmts, ["von exportierten Mitgliedern"]),
|
||||||
WbKgs = (wbKgs, ["von exportierten Mitgliedern und Flächenbindungen"]),
|
WbKgs = (wbKgs, ["von exportierten Mitgliedern und Flächenbindungen"]),
|
||||||
}.Export(filename);
|
}.Export(filename, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Task Export(string filename, IEnumerable<Delivery> deliveries, IEnumerable<WbKg> wbKgs, IEnumerable<string> filters) {
|
public static Task Export(string filename, IEnumerable<Delivery> deliveries, IEnumerable<WbKg> wbKgs, IEnumerable<string> filters, ReadOnlyMemory<char> password = default) {
|
||||||
return new ElwigExport {
|
return new ElwigExport {
|
||||||
Deliveries = (deliveries, filters),
|
Deliveries = (deliveries, filters),
|
||||||
WbKgs = (wbKgs, ["von exportierten Lieferungen"]),
|
WbKgs = (wbKgs, ["von exportierten Lieferungen"]),
|
||||||
}.Export(filename);
|
}.Export(filename, password);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class ElwigExport {
|
public class ElwigExport {
|
||||||
@@ -504,17 +503,17 @@ namespace Elwig.Helpers.Export {
|
|||||||
public (IEnumerable<AreaCmtContract> AreaCmts, IEnumerable<string> Filters)? AreaCmts { get; set; }
|
public (IEnumerable<AreaCmtContract> AreaCmts, IEnumerable<string> Filters)? AreaCmts { get; set; }
|
||||||
public (IEnumerable<Delivery> Deliveries, IEnumerable<string> Filters)? Deliveries { get; set; }
|
public (IEnumerable<Delivery> Deliveries, IEnumerable<string> Filters)? Deliveries { get; set; }
|
||||||
|
|
||||||
public async Task Export(string filename) {
|
public async Task Export(string filename, ReadOnlyMemory<char> password = default) {
|
||||||
File.Delete(filename);
|
File.Delete(filename);
|
||||||
using var zip = ZipFile.Open(filename, ZipArchiveMode.Create);
|
using var zip = await ZipFile.OpenAsync(filename, ZipArchiveMode.Create);
|
||||||
|
|
||||||
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
|
var version = zip.CreateEntry("version", CompressionLevel.NoCompression);
|
||||||
using (var writer = new StreamWriter(version.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await version.OpenAsync(), Utils.UTF8)) {
|
||||||
await writer.WriteAsync("elwig:2");
|
await writer.WriteAsync("elwig:2");
|
||||||
}
|
}
|
||||||
|
|
||||||
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
|
var meta = zip.CreateEntry("meta.json", CompressionLevel.NoCompression);
|
||||||
using (var writer = new StreamWriter(meta.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await meta.OpenAsync(), Utils.UTF8)) {
|
||||||
var obj = new JsonObject {
|
var obj = new JsonObject {
|
||||||
["timestamp"] = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}",
|
["timestamp"] = $"{DateTime.UtcNow:yyyy-MM-ddTHH:mm:ssZ}",
|
||||||
["zwstid"] = App.ZwstId,
|
["zwstid"] = App.ZwstId,
|
||||||
@@ -550,38 +549,47 @@ namespace Elwig.Helpers.Export {
|
|||||||
await writer.WriteAsync(obj.ToJsonString(Utils.JsonOpts));
|
await writer.WriteAsync(obj.ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO encrypt files
|
|
||||||
if (WbKgs != null) {
|
if (WbKgs != null) {
|
||||||
var json = zip.CreateEntry("wb_kgs.json", CompressionLevel.SmallestSize);
|
var json = password.IsEmpty ?
|
||||||
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
|
zip.CreateEntry("wb_kgs.json", CompressionLevel.SmallestSize) :
|
||||||
|
zip.CreateEntry("wb_kgs.json", CompressionLevel.SmallestSize, password.Span, ZipEncryptionMethod.Aes256);
|
||||||
|
using var writer = new StreamWriter(await json.OpenAsync(), Utils.UTF8);
|
||||||
foreach (var k in WbKgs.Value.WbKgs) {
|
foreach (var k in WbKgs.Value.WbKgs) {
|
||||||
await writer.WriteLineAsync(k.ToJson().ToJsonString(Utils.JsonOpts));
|
await writer.WriteLineAsync(k.ToJson().ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Members != null) {
|
if (Members != null) {
|
||||||
var json = zip.CreateEntry("members.json", CompressionLevel.SmallestSize);
|
var json = password.IsEmpty ?
|
||||||
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
|
zip.CreateEntry("members.json", CompressionLevel.SmallestSize) :
|
||||||
|
zip.CreateEntry("members.json", CompressionLevel.SmallestSize, password.Span, ZipEncryptionMethod.Aes256);
|
||||||
|
using var writer = new StreamWriter(await json.OpenAsync(), Utils.UTF8);
|
||||||
foreach (var m in Members.Value.Members) {
|
foreach (var m in Members.Value.Members) {
|
||||||
await writer.WriteLineAsync(m.ToJson().ToJsonString(Utils.JsonOpts));
|
await writer.WriteLineAsync(m.ToJson().ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (History != null) {
|
if (History != null) {
|
||||||
var json = zip.CreateEntry("member_history.json", CompressionLevel.SmallestSize);
|
var json = password.IsEmpty ?
|
||||||
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
|
zip.CreateEntry("member_history.json", CompressionLevel.SmallestSize) :
|
||||||
|
zip.CreateEntry("member_history.json", CompressionLevel.SmallestSize, password.Span, ZipEncryptionMethod.Aes256);
|
||||||
|
using var writer = new StreamWriter(await json.OpenAsync(), Utils.UTF8);
|
||||||
foreach (var h in History.Value.History) {
|
foreach (var h in History.Value.History) {
|
||||||
await writer.WriteLineAsync(h.ToJson().ToJsonString(Utils.JsonOpts));
|
await writer.WriteLineAsync(h.ToJson().ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (AreaCmts != null) {
|
if (AreaCmts != null) {
|
||||||
var json = zip.CreateEntry("area_commitment_contracts.json", CompressionLevel.SmallestSize);
|
var json = password.IsEmpty ?
|
||||||
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
|
zip.CreateEntry("area_commitment_contracts.json", CompressionLevel.SmallestSize) :
|
||||||
|
zip.CreateEntry("area_commitment_contracts.json", CompressionLevel.SmallestSize, password.Span, ZipEncryptionMethod.Aes256);
|
||||||
|
using var writer = new StreamWriter(await json.OpenAsync(), Utils.UTF8);
|
||||||
foreach (var c in AreaCmts.Value.AreaCmts) {
|
foreach (var c in AreaCmts.Value.AreaCmts) {
|
||||||
await writer.WriteLineAsync(c.ToJson().ToJsonString(Utils.JsonOpts));
|
await writer.WriteLineAsync(c.ToJson().ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (Deliveries != null) {
|
if (Deliveries != null) {
|
||||||
var json = zip.CreateEntry("deliveries.json", CompressionLevel.SmallestSize);
|
var json = password.IsEmpty ?
|
||||||
using var writer = new StreamWriter(json.Open(), Utils.UTF8);
|
zip.CreateEntry("deliveries.json", CompressionLevel.SmallestSize) :
|
||||||
|
zip.CreateEntry("deliveries.json", CompressionLevel.SmallestSize, password.Span, ZipEncryptionMethod.Aes256);
|
||||||
|
using var writer = new StreamWriter(await json.OpenAsync(), Utils.UTF8);
|
||||||
foreach (var d in Deliveries.Value.Deliveries) {
|
foreach (var d in Deliveries.Value.Deliveries) {
|
||||||
await writer.WriteLineAsync(d.ToJson().ToJsonString(Utils.JsonOpts));
|
await writer.WriteLineAsync(d.ToJson().ToJsonString(Utils.JsonOpts));
|
||||||
}
|
}
|
||||||
@@ -608,7 +616,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
GlNr = (gls.Count == 0 ? 1 : gls.Max(g => g.GlNr)) + 1,
|
GlNr = (gls.Count == 0 ? 1 : gls.Max(g => g.GlNr)) + 1,
|
||||||
Name = grosslage,
|
Name = grosslage,
|
||||||
};
|
};
|
||||||
gls[gl.GlNr] = gl;
|
gls.Add(gl);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return (new WbKg {
|
return (new WbKg {
|
||||||
|
|||||||
@@ -1,8 +0,0 @@
|
|||||||
using Elwig.Models.Dtos;
|
|
||||||
|
|
||||||
namespace Elwig.Helpers.Export {
|
|
||||||
/// <summary>
|
|
||||||
/// Interface for exporting banking data
|
|
||||||
/// </summary>
|
|
||||||
public interface IBankingExporter : IExporter<Transaction> { }
|
|
||||||
}
|
|
||||||
@@ -3,7 +3,7 @@ using System.Collections.Generic;
|
|||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
namespace Elwig.Helpers.Export {
|
namespace Elwig.Helpers.Export {
|
||||||
public interface IExporter<T> : IDisposable, IAsyncDisposable {
|
public interface IExporter<T> : IDisposable {
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The default file extension of the exported files to be used (whithout a preceding ".")
|
/// The default file extension of the exported files to be used (whithout a preceding ".")
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -14,7 +14,9 @@ namespace Elwig.Helpers.Export {
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="data">The data to be exported</param>
|
/// <param name="data">The data to be exported</param>
|
||||||
/// <param name="progress">The progress object to report to</param>
|
/// <param name="progress">The progress object to report to</param>
|
||||||
void Export(IEnumerable<T> data, IProgress<double>? progress = null);
|
void Export(IEnumerable<T> data, IProgress<double>? progress = null) {
|
||||||
|
ExportAsync(data, progress).GetAwaiter().GetResult();
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Asynchronosly export the given data to the given file.
|
/// Asynchronosly export the given data to the given file.
|
||||||
|
|||||||
@@ -32,12 +32,12 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
private async Task AddHeader() {
|
private async Task AddHeader() {
|
||||||
var mimetype = ZipArchive.CreateEntry("mimetype", CompressionLevel.NoCompression);
|
var mimetype = ZipArchive.CreateEntry("mimetype", CompressionLevel.NoCompression);
|
||||||
using (var writer = new StreamWriter(mimetype.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await mimetype.OpenAsync(), Utils.UTF8)) {
|
||||||
await writer.WriteAsync("application/vnd.oasis.opendocument.spreadsheet");
|
await writer.WriteAsync("application/vnd.oasis.opendocument.spreadsheet");
|
||||||
}
|
}
|
||||||
|
|
||||||
var manifest = ZipArchive.CreateEntry("META-INF/manifest.xml");
|
var manifest = ZipArchive.CreateEntry("META-INF/manifest.xml");
|
||||||
using (var writer = new StreamWriter(manifest.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await manifest.OpenAsync(), Utils.UTF8)) {
|
||||||
await writer.WriteAsync("""
|
await writer.WriteAsync("""
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.3">
|
<manifest:manifest xmlns:manifest="urn:oasis:names:tc:opendocument:xmlns:manifest:1.0" manifest:version="1.3">
|
||||||
@@ -52,7 +52,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var styles = ZipArchive.CreateEntry("styles.xml");
|
var styles = ZipArchive.CreateEntry("styles.xml");
|
||||||
using (var writer = new StreamWriter(styles.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await styles.OpenAsync(), Utils.UTF8)) {
|
||||||
await writer.WriteAsync("""
|
await writer.WriteAsync("""
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3">
|
<office:document-styles xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3">
|
||||||
@@ -62,7 +62,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var meta = ZipArchive.CreateEntry("meta.xml");
|
var meta = ZipArchive.CreateEntry("meta.xml");
|
||||||
using (var writer = new StreamWriter(meta.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await meta.OpenAsync(), Utils.UTF8)) {
|
||||||
var now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
var now = DateTime.UtcNow.ToString("yyyy-MM-ddTHH:mm:ssZ");
|
||||||
await writer.WriteAsync($"""
|
await writer.WriteAsync($"""
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
@@ -80,7 +80,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
}
|
}
|
||||||
|
|
||||||
var content = ZipArchive.CreateEntry("content.xml");
|
var content = ZipArchive.CreateEntry("content.xml");
|
||||||
Content = new StreamWriter(content.Open(), Utils.UTF8);
|
Content = new StreamWriter(await content.OpenAsync(), Utils.UTF8);
|
||||||
await Content.WriteAsync("""
|
await Content.WriteAsync("""
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<office:document-content xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" office:version="1.3">
|
<office:document-content xmlns:table="urn:oasis:names:tc:opendocument:xmlns:table:1.0" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" xmlns:text="urn:oasis:names:tc:opendocument:xmlns:text:1.0" xmlns:style="urn:oasis:names:tc:opendocument:xmlns:style:1.0" xmlns:fo="urn:oasis:names:tc:opendocument:xmlns:xsl-fo-compatible:1.0" xmlns:calcext="urn:org:documentfoundation:names:experimental:calc:xmlns:calcext:1.0" xmlns:number="urn:oasis:names:tc:opendocument:xmlns:datastyle:1.0" office:version="1.3">
|
||||||
@@ -109,8 +109,13 @@ namespace Elwig.Helpers.Export {
|
|||||||
<style:paragraph-properties fo:text-align="center"/>
|
<style:paragraph-properties fo:text-align="center"/>
|
||||||
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
|
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
|
||||||
</style:style>
|
</style:style>
|
||||||
|
<style:style style:name="sectionheader" style:family="table-cell" style:parent-style-name="default">
|
||||||
|
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false"/>
|
||||||
|
<style:paragraph-properties fo:text-align="left"/>
|
||||||
|
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold" fo:font-size="14pt"/>
|
||||||
|
</style:style>
|
||||||
<style:style style:name="th" style:family="table-cell" style:parent-style-name="default">
|
<style:style style:name="th" style:family="table-cell" style:parent-style-name="default">
|
||||||
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false" style:vertical-align="middle"/>
|
<style:table-cell-properties style:text-align-source="fix" style:repeat-content="false" style:vertical-align="middle" fo:wrap-option="wrap"/>
|
||||||
<style:paragraph-properties fo:text-align="center"/>
|
<style:paragraph-properties fo:text-align="center"/>
|
||||||
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
|
<style:text-properties fo:font-weight="bold" style:font-weight-asian="bold" style:font-weight-complex="bold"/>
|
||||||
</style:style>
|
</style:style>
|
||||||
@@ -163,7 +168,7 @@ namespace Elwig.Helpers.Export {
|
|||||||
Content = null;
|
Content = null;
|
||||||
|
|
||||||
var settings = ZipArchive.CreateEntry("settings.xml");
|
var settings = ZipArchive.CreateEntry("settings.xml");
|
||||||
using (var writer = new StreamWriter(settings.Open(), Utils.UTF8)) {
|
using (var writer = new StreamWriter(await settings.OpenAsync(), Utils.UTF8)) {
|
||||||
await writer.WriteAsync("""
|
await writer.WriteAsync("""
|
||||||
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
|
||||||
<office:document-settings xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3">
|
<office:document-settings xmlns:config="urn:oasis:names:tc:opendocument:xmlns:config:1.0" xmlns:xlink="http://www.w3.org/1999/xlink" xmlns:ooo="http://openoffice.org/2004/office" xmlns:office="urn:oasis:names:tc:opendocument:xmlns:office:1.0" office:version="1.3">
|
||||||
@@ -211,35 +216,59 @@ namespace Elwig.Helpers.Export {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
await Content.WriteAsync(
|
await Content.WriteAsync($"""
|
||||||
$" <table:table-row>\r\n" +
|
<table:table-row>
|
||||||
FormatCell(table.FullName, colSpan: totalSpan, style: "header") +
|
{FormatCell(table.FullName, colSpan: totalSpan, style: "header")}
|
||||||
$" </table:table-row>\r\n" +
|
</table:table-row>
|
||||||
$" <table:table-row>\r\n" +
|
<table:table-row>
|
||||||
FormatCell(table.Subtitle, colSpan: totalSpan, style: "subheader") +
|
{FormatCell(table.Subtitle, colSpan: totalSpan, style: "subheader")}
|
||||||
$" </table:table-row>\r\n" +
|
</table:table-row>
|
||||||
$" <table:table-row>\r\n" +
|
<table:table-row>
|
||||||
$" <table:table-cell table:number-columns-repeated=\"{totalSpan}\"/>\r\n" +
|
<table:table-cell table:number-columns-repeated="{totalSpan}"/>
|
||||||
$" </table:table-row>\r\n" +
|
</table:table-row>
|
||||||
$" <table:table-row>\r\n");
|
""");
|
||||||
foreach (var (name, span, units) in table.ColumnNames.Zip(table.ColumnSpans, table.ColumnUnits)) {
|
|
||||||
var hasUnits = units.Length > 0;
|
|
||||||
await Content.WriteAsync(FormatCell(name, colSpan: span, rowSpan: hasUnits ? 1 : 2, style: "th"));
|
|
||||||
}
|
|
||||||
await Content.WriteAsync(" </table:table-row>\r\n <table:table-row>\r\n");
|
|
||||||
foreach (var (span, units) in table.ColumnSpans.Zip(table.ColumnUnits)) {
|
|
||||||
if (units.Length == 0) {
|
|
||||||
await Content.WriteAsync($" <table:covered-table-cell table:number-columns-repeated=\"{span}\"/>\r\n");
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
foreach (var u in units) {
|
|
||||||
await Content.WriteAsync(FormatCell(u == null ? null : $"[{u}]", style: "th"));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
await Content.WriteAsync(" </table:table-row>\r\n");
|
|
||||||
|
|
||||||
foreach (var row in table.GetData()) {
|
var firstSection = true;
|
||||||
await FormatRow(row, table.ColumnUnits, mergeSubRowCells);
|
foreach (var sec in table.GetData()) {
|
||||||
|
if (!firstSection) {
|
||||||
|
await Content.WriteAsync($"""
|
||||||
|
<table:table-row>
|
||||||
|
<table:table-cell table:number-columns-repeated="{totalSpan}"/>
|
||||||
|
</table:table-row>
|
||||||
|
<table:table-row>
|
||||||
|
<table:table-cell table:number-columns-repeated="{totalSpan}"/>
|
||||||
|
</table:table-row>
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
if (sec.Name != null) {
|
||||||
|
await Content.WriteAsync($"""
|
||||||
|
<table:table-row>
|
||||||
|
{FormatCell(sec.Name, colSpan: totalSpan, style: "sectionheader")}
|
||||||
|
</table:table-row>
|
||||||
|
""");
|
||||||
|
}
|
||||||
|
|
||||||
|
await Content.WriteAsync(" <table:table-row>\r\n");
|
||||||
|
foreach (var (name, span, units) in table.ColumnNames.Zip(table.ColumnSpans, table.ColumnUnits)) {
|
||||||
|
var hasUnits = units.Length > 0;
|
||||||
|
await Content.WriteAsync(FormatCell(name, colSpan: span, rowSpan: hasUnits ? 1 : 2, style: "th"));
|
||||||
|
}
|
||||||
|
await Content.WriteAsync(" </table:table-row>\r\n <table:table-row>\r\n");
|
||||||
|
foreach (var (span, units) in table.ColumnSpans.Zip(table.ColumnUnits)) {
|
||||||
|
if (units.Length == 0) {
|
||||||
|
await Content.WriteAsync($" <table:covered-table-cell table:number-columns-repeated=\"{span}\"/>\r\n");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
foreach (var u in units) {
|
||||||
|
await Content.WriteAsync(FormatCell(u == null ? null : $"[{u}]", style: "th"));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
await Content.WriteAsync(" </table:table-row>\r\n");
|
||||||
|
|
||||||
|
foreach (var row in sec.Rows) {
|
||||||
|
await FormatRow(row, table.ColumnUnits, mergeSubRowCells);
|
||||||
|
}
|
||||||
|
firstSection = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
await Content.WriteAsync(" </table:table>\r\n");
|
await Content.WriteAsync(" </table:table>\r\n");
|
||||||
@@ -314,7 +343,8 @@ namespace Elwig.Helpers.Export {
|
|||||||
}
|
}
|
||||||
c = $"<{ct} office:value-type=\"float\" calcext:value-type=\"float\" office:value=\"{v.ToString(CultureInfo.InvariantCulture)}\"{add}><text:p>{data}</text:p></{ct}>";
|
c = $"<{ct} office:value-type=\"float\" calcext:value-type=\"float\" office:value=\"{v.ToString(CultureInfo.InvariantCulture)}\"{add}><text:p>{data}</text:p></{ct}>";
|
||||||
} else {
|
} else {
|
||||||
c = $"<{ct} office:value-type=\"string\" calcext:value-type=\"string\"{add}><text:p>{SecurityElement.Escape(data.ToString())}</text:p></{ct}>";
|
var lines = string.Join("", data.ToString()?.Split('\n').Select(l => $"<text:p>{SecurityElement.Escape(l)}</text:p>") ?? []);
|
||||||
|
c = $"<{ct} office:value-type=\"string\" calcext:value-type=\"string\"{add}>{lines}</{ct}>";
|
||||||
}
|
}
|
||||||
|
|
||||||
return $" {c}\r\n" + (colSpan > 1 ? $" <table:covered-table-cell table:number-columns-repeated=\"{colSpan - 1}\"/>\r\n" : "");
|
return $" {c}\r\n" + (colSpan > 1 ? $" <table:covered-table-cell table:number-columns-repeated=\"{colSpan - 1}\"/>\r\n" : "");
|
||||||
@@ -13,7 +13,9 @@ namespace Elwig.Helpers.Export {
|
|||||||
|
|
||||||
private readonly StreamWriter _writer;
|
private readonly StreamWriter _writer;
|
||||||
|
|
||||||
public VCard(string filename) : this(filename, Utils.UTF8) { }
|
public VCard(string filename) :
|
||||||
|
this(filename, Utils.UTF8) {
|
||||||
|
}
|
||||||
|
|
||||||
public VCard(string filename, Encoding encoding) {
|
public VCard(string filename, Encoding encoding) {
|
||||||
_writer = new StreamWriter(filename, false, encoding);
|
_writer = new StreamWriter(filename, false, encoding);
|
||||||
@@ -24,11 +26,6 @@ namespace Elwig.Helpers.Export {
|
|||||||
_writer.Dispose();
|
_writer.Dispose();
|
||||||
}
|
}
|
||||||
|
|
||||||
public ValueTask DisposeAsync() {
|
|
||||||
GC.SuppressFinalize(this);
|
|
||||||
return _writer.DisposeAsync();
|
|
||||||
}
|
|
||||||
|
|
||||||
public async Task ExportAsync(IEnumerable<Member> data, IProgress<double>? progress = null) {
|
public async Task ExportAsync(IEnumerable<Member> data, IProgress<double>? progress = null) {
|
||||||
progress?.Report(0.0);
|
progress?.Report(0.0);
|
||||||
int count = data.Count() + 1, i = 0;
|
int count = data.Count() + 1, i = 0;
|
||||||
@@ -58,10 +55,6 @@ namespace Elwig.Helpers.Export {
|
|||||||
progress?.Report(100.0);
|
progress?.Report(100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Export(IEnumerable<Member> data, IProgress<double>? progress = null) {
|
|
||||||
ExportAsync(data, progress).GetAwaiter().GetResult();
|
|
||||||
}
|
|
||||||
|
|
||||||
private static string? Escape(string? text) {
|
private static string? Escape(string? text) {
|
||||||
return text?.Replace("\\", "\\\\").Replace(",", "\\,").Replace(";", "\\;").Replace("\n", "\\n").Replace("\r", "");
|
return text?.Replace("\\", "\\\\").Replace(",", "\\,").Replace(";", "\\;").Replace("\n", "\\n").Replace("\r", "");
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,7 +62,7 @@ namespace Elwig.Helpers {
|
|||||||
var buf = new char[512];
|
var buf = new char[512];
|
||||||
int bufSize = 0;
|
int bufSize = 0;
|
||||||
var tmpBuf = new char[1];
|
var tmpBuf = new char[1];
|
||||||
while (!reader.EndOfStream && bufSize < buf.Length - 1) {
|
while (bufSize < buf.Length - 1) {
|
||||||
if ((await reader.ReadAsync(tmpBuf, 0, 1)) != 1)
|
if ((await reader.ReadAsync(tmpBuf, 0, 1)) != 1)
|
||||||
return null;
|
return null;
|
||||||
buf[bufSize++] = tmpBuf[0];
|
buf[bufSize++] = tmpBuf[0];
|
||||||
@@ -106,14 +106,30 @@ namespace Elwig.Helpers {
|
|||||||
progress.Report(100.0);
|
progress.Report(100.0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task CheckIntegrity(this ZipArchive zip) {
|
public static async Task<ReadOnlyMemory<char>> FindPassword(this ZipArchive zip, IEnumerable<ReadOnlyMemory<char>> passwords) {
|
||||||
var crc = new Crc32();
|
foreach (var pwd in passwords) {
|
||||||
|
try {
|
||||||
|
await zip.CheckIntegrity(pwd);
|
||||||
|
return pwd;
|
||||||
|
} catch { }
|
||||||
|
}
|
||||||
|
throw new InvalidDataException("No matching password found");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task<ReadOnlyMemory<char>> CheckIntegrity(this ZipArchive zip, IEnumerable<ReadOnlyMemory<char>> passwords) {
|
||||||
|
if (zip.Entries.Any(e => e.IsEncrypted)) {
|
||||||
|
return await zip.FindPassword(passwords);
|
||||||
|
} else {
|
||||||
|
await zip.CheckIntegrity();
|
||||||
|
return default;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static async Task CheckIntegrity(this ZipArchive zip, ReadOnlyMemory<char> password = default) {
|
||||||
|
byte[] buffer = new byte[8192];
|
||||||
foreach (var entry in zip.Entries) {
|
foreach (var entry in zip.Entries) {
|
||||||
crc.Reset();
|
using var stream = await entry.OpenAsync(password.Span);
|
||||||
using var stream = entry.Open();
|
while (await stream.ReadAsync(buffer) > 0);
|
||||||
await crc.AppendAsync(stream);
|
|
||||||
if (crc.GetCurrentHashAsUInt32() != entry.Crc32)
|
|
||||||
throw new InvalidDataException($"CRC-32 mismatch in '{entry.FullName}'");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -15,14 +15,14 @@ namespace Elwig.Helpers.Printing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static void Show(TempFile file, string title) {
|
public static void Show(TempFile file, string title) {
|
||||||
App.MainDispatcher.BeginInvoke(() => {
|
App.Current.Dispatcher.BeginInvoke(() => {
|
||||||
var w = new DocumentViewerWindow(title, file);
|
var w = new DocumentViewerWindow(title, file);
|
||||||
w.Show();
|
w.Show();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void Show(string path, string title) {
|
public static void Show(string path, string title) {
|
||||||
App.MainDispatcher.BeginInvoke(() => {
|
App.Current.Dispatcher.BeginInvoke(() => {
|
||||||
var w = new DocumentViewerWindow(title, path);
|
var w = new DocumentViewerWindow(title, path);
|
||||||
w.Show();
|
w.Show();
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnDeviceArrived(object sender, EventArrivedEventArgs evt) {
|
private void OnDeviceArrived(object sender, EventArrivedEventArgs evt) {
|
||||||
App.MainDispatcher.Invoke(() => {
|
App.Current.Dispatcher.Invoke(() => {
|
||||||
// "synchronized"
|
// "synchronized"
|
||||||
string[] currentPorts = SerialPort.GetPortNames();
|
string[] currentPorts = SerialPort.GetPortNames();
|
||||||
var newPorts = currentPorts.Except(_knownPorts).ToArray();
|
var newPorts = currentPorts.Except(_knownPorts).ToArray();
|
||||||
@@ -37,7 +37,7 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void OnDeviceRemoved(object sender, EventArrivedEventArgs evt) {
|
private void OnDeviceRemoved(object sender, EventArrivedEventArgs evt) {
|
||||||
App.MainDispatcher.Invoke(() => {
|
App.Current.Dispatcher.Invoke(() => {
|
||||||
// "synchronized"
|
// "synchronized"
|
||||||
string[] currentPorts = SerialPort.GetPortNames();
|
string[] currentPorts = SerialPort.GetPortNames();
|
||||||
var removedPorts = _knownPorts.Except(currentPorts).ToArray();
|
var removedPorts = _knownPorts.Except(currentPorts).ToArray();
|
||||||
|
|||||||
@@ -38,9 +38,9 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void Delete() {
|
private void Delete() {
|
||||||
if (FilePath == null) return;
|
if (Usages < 0) return;
|
||||||
File.Delete(FilePath);
|
File.Delete(FilePath);
|
||||||
FilePath = null;
|
Usages = -1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+30
-29
@@ -74,6 +74,9 @@ namespace Elwig.Helpers {
|
|||||||
private static partial Regex GeneratedInvalidFileNamePartsRegex();
|
private static partial Regex GeneratedInvalidFileNamePartsRegex();
|
||||||
public static readonly Regex InvalidFileNamePartsRegex = GeneratedInvalidFileNamePartsRegex();
|
public static readonly Regex InvalidFileNamePartsRegex = GeneratedInvalidFileNamePartsRegex();
|
||||||
|
|
||||||
|
[GeneratedRegex(".{4}")]
|
||||||
|
private static partial Regex IbanRegex { get; }
|
||||||
|
|
||||||
public static readonly string GroupSeparator = "\u202F";
|
public static readonly string GroupSeparator = "\u202F";
|
||||||
public static readonly string UnitSeparator = "\u00A0";
|
public static readonly string UnitSeparator = "\u00A0";
|
||||||
|
|
||||||
@@ -206,7 +209,7 @@ namespace Elwig.Helpers {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static string FormatIban(string iban) {
|
public static string FormatIban(string iban) {
|
||||||
return Regex.Replace(iban.Trim(), ".{4}", "$0 ").Trim();
|
return IbanRegex.Replace(iban.Trim(), "$0 ").Trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void RunBackground(string title, Func<Task> function) {
|
public static void RunBackground(string title, Func<Task> function) {
|
||||||
@@ -322,15 +325,10 @@ namespace Elwig.Helpers {
|
|||||||
return new Footer(lineBreak, separator);
|
return new Footer(lineBreak, separator);
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Footer {
|
public class Footer(string lineBreak, string separator) {
|
||||||
private readonly List<List<List<object>>> Items = [[[]]];
|
private readonly List<List<List<object>>> Items = [[[]]];
|
||||||
private readonly string LineBreak;
|
private readonly string LineBreak = lineBreak;
|
||||||
private readonly string Separator;
|
private readonly string Separator = separator;
|
||||||
|
|
||||||
public Footer(string lineBreak, string separator) {
|
|
||||||
LineBreak = lineBreak;
|
|
||||||
Separator = separator;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Footer Item(object? text) {
|
public Footer Item(object? text) {
|
||||||
if (text == null) return this;
|
if (text == null) return this;
|
||||||
@@ -483,35 +481,38 @@ namespace Elwig.Helpers {
|
|||||||
return InternetGetConnectedState(out var _, 0);
|
return InternetGetConnectedState(out var _, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpClient GetHttpClient(string? username = null, string? password = null, string? accept = null) {
|
public static string ReplaceUmlaute(string s) {
|
||||||
|
return s
|
||||||
|
.Replace("ä", "ae").Replace("Ä", "Ae")
|
||||||
|
.Replace("ö", "oe").Replace("Ö", "Oe")
|
||||||
|
.Replace("ü", "ue").Replace("Ü", "Ue")
|
||||||
|
.Replace("ß", "ss").Replace("ẞ", "SS");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static HttpClient GetHttpClient(string? username = null, ReadOnlyMemory<char> password = default, string? accept = null) {
|
||||||
var client = new HttpClient() {
|
var client = new HttpClient() {
|
||||||
Timeout = TimeSpan.FromSeconds(5),
|
Timeout = TimeSpan.FromSeconds(5),
|
||||||
};
|
};
|
||||||
client.DefaultRequestHeaders.UserAgent.Clear();
|
client.DefaultRequestHeaders.UserAgent.Clear();
|
||||||
client.DefaultRequestHeaders.UserAgent.ParseAdd($"Elwig/{App.Version} ({App.Client?.NameToken}, {App.BranchName}, {Environment.MachineName}, {Environment.OSVersion})");
|
client.DefaultRequestHeaders.UserAgent.ParseAdd($"Elwig/{App.Version} ({App.Client.NameToken}, {ReplaceUmlaute(App.BranchName)}, {Environment.MachineName}, {Environment.OSVersion})");
|
||||||
client.DefaultRequestHeaders.Accept.Clear();
|
client.DefaultRequestHeaders.Accept.Clear();
|
||||||
if (accept != null)
|
if (accept != null)
|
||||||
client.DefaultRequestHeaders.Accept.Add(new(accept));
|
client.DefaultRequestHeaders.Accept.Add(new(accept));
|
||||||
if (username != null || password != null)
|
if (username != null || !password.IsEmpty)
|
||||||
client.DefaultRequestHeaders.Authorization = new("Basic", Convert.ToBase64String(Utils.UTF8.GetBytes($"{username}:{password}")));
|
client.DefaultRequestHeaders.Authorization = new("Basic", Convert.ToBase64String(Utils.UTF8.GetBytes($"{username}:{password}")));
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<(string Version, string Url, long Size)?> GetLatestInstallerUrl(string url) {
|
public static async Task<(string Version, string Url, long Size)> GetLatestInstallerUrl(string url) {
|
||||||
try {
|
using var client = GetHttpClient(accept: "application/json");
|
||||||
using var client = GetHttpClient(accept: "application/json");
|
using var res = await client.GetAsync(url);
|
||||||
using var res = await client.GetAsync(url);
|
res.EnsureSuccessStatusCode();
|
||||||
if (!res.IsSuccessStatusCode)
|
var resJson = JsonNode.Parse(await res.Content.ReadAsStringAsync());
|
||||||
return null;
|
var data = resJson!["data"]!.AsArray()[^1]!;
|
||||||
var resJson = JsonNode.Parse(await res.Content.ReadAsStringAsync());
|
return ((string)data["version"]!, (string)data["url"]!, (long)data["size"]!);
|
||||||
var data = resJson!["data"]!.AsArray()[^1]!;
|
|
||||||
return ((string)data["version"]!, (string)data["url"]!, (long)data["size"]!);
|
|
||||||
} catch {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task UploadExportData(string zip, string url, string username, string password) {
|
public static async Task UploadExportData(string zip, string url, string username, ReadOnlyMemory<char> password) {
|
||||||
if (url.StartsWith("https://elwig.at/clients/"))
|
if (url.StartsWith("https://elwig.at/clients/"))
|
||||||
url = "https://sync.elwig.at/" + url[25..];
|
url = "https://sync.elwig.at/" + url[25..];
|
||||||
if (!url.EndsWith('/')) url += "/";
|
if (!url.EndsWith('/')) url += "/";
|
||||||
@@ -522,7 +523,7 @@ namespace Elwig.Helpers {
|
|||||||
res.EnsureSuccessStatusCode();
|
res.EnsureSuccessStatusCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<JsonArray> GetExportMetaData(string url, string username, string password) {
|
public static async Task<JsonArray> GetExportMetaData(string url, string username, ReadOnlyMemory<char> password) {
|
||||||
if (url.StartsWith("https://elwig.at/clients/"))
|
if (url.StartsWith("https://elwig.at/clients/"))
|
||||||
url = "https://sync.elwig.at/" + url[25..];
|
url = "https://sync.elwig.at/" + url[25..];
|
||||||
using var client = GetHttpClient(username, password, accept: "application/json");
|
using var client = GetHttpClient(username, password, accept: "application/json");
|
||||||
@@ -550,7 +551,7 @@ namespace Elwig.Helpers {
|
|||||||
var (host, port, mode, username, password, _, _) = App.Config.Smtp.Value;
|
var (host, port, mode, username, password, _, _) = App.Config.Smtp.Value;
|
||||||
var client = new SmtpClient();
|
var client = new SmtpClient();
|
||||||
await client.ConnectAsync(host, port, mode == "starttls" ? SecureSocketOptions.StartTls : SecureSocketOptions.None);
|
await client.ConnectAsync(host, port, mode == "starttls" ? SecureSocketOptions.StartTls : SecureSocketOptions.None);
|
||||||
await client.AuthenticateAsync(username, password);
|
await client.AuthenticateAsync(username, password.ToString());
|
||||||
return client;
|
return client;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -576,7 +577,7 @@ namespace Elwig.Helpers {
|
|||||||
body.Add(doc.AsEmailAttachment($"{name}.pdf"));
|
body.Add(doc.AsEmailAttachment($"{name}.pdf"));
|
||||||
}
|
}
|
||||||
msg.Body = body;
|
msg.Body = body;
|
||||||
await client!.SendAsync(msg);
|
await client!.SendAsync(new SmtpSendRequest(msg));
|
||||||
await AddSentMails([(
|
await AddSentMails([(
|
||||||
"email", member.MgNr, member.AdministrativeName,
|
"email", member.MgNr, member.AdministrativeName,
|
||||||
member.EmailAddresses.OrderBy(a => a.Nr).Select(a => a.Address).ToArray(),
|
member.EmailAddresses.OrderBy(a => a.Nr).Select(a => a.Address).ToArray(),
|
||||||
@@ -654,7 +655,7 @@ namespace Elwig.Helpers {
|
|||||||
} else if (obj is IEnumerable list && obj is not string) {
|
} else if (obj is IEnumerable list && obj is not string) {
|
||||||
var arr = list.Cast<object>().Select(GetEntityIdentifier).ToArray();
|
var arr = list.Cast<object>().Select(GetEntityIdentifier).ToArray();
|
||||||
return ((IStructuralEquatable)arr).GetHashCode(EqualityComparer<int?>.Default);
|
return ((IStructuralEquatable)arr).GetHashCode(EqualityComparer<int?>.Default);
|
||||||
} else if (obj.GetType().GetCustomAttribute(typeof(PrimaryKeyAttribute), true) is PrimaryKeyAttribute pkAttr) {
|
} else if (obj.GetType().GetCustomAttribute<PrimaryKeyAttribute>(true) is PrimaryKeyAttribute pkAttr) {
|
||||||
var pk = pkAttr.PropertyNames.Select(name => obj.GetType().GetProperty(name)!.GetValue(obj)?.GetHashCode() ?? 0).ToArray();
|
var pk = pkAttr.PropertyNames.Select(name => obj.GetType().GetProperty(name)!.GetValue(obj)?.GetHashCode() ?? 0).ToArray();
|
||||||
return ((IStructuralEquatable)pk).GetHashCode(EqualityComparer<int>.Default);
|
return ((IStructuralEquatable)pk).GetHashCode(EqualityComparer<int>.Default);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Reflection;
|
using System.Reflection;
|
||||||
|
|
||||||
@@ -9,13 +10,14 @@ namespace Elwig.Models.Dtos {
|
|||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string FullName { get; set; }
|
public string FullName { get; set; }
|
||||||
public string? Subtitle { get; set; }
|
public string? Subtitle { get; set; }
|
||||||
public IEnumerable<T> Rows { get; private set; }
|
public IEnumerable<(string? Name, IEnumerable<T> Rows)> Sections { get; private set; }
|
||||||
|
public IEnumerable<T> Rows => Sections.SelectMany(s => s.Rows);
|
||||||
public int RowNum => Rows.Count();
|
public int RowNum => Rows.Count();
|
||||||
public int ColNum => ColumnNames.Count();
|
public int ColNum => ColumnNames.Count();
|
||||||
|
|
||||||
public IEnumerable<(string, Type?)> ColumnDefs => _map.Select(m => (m.Item1, m.Item2?.PropertyType ?? m.Item3?.FieldType));
|
public IEnumerable<(string Name, Type? Type)> ColumnDefs => _map.Select(m => (m.Name, m.PInfo?.PropertyType ?? m.FInfo?.FieldType));
|
||||||
public IEnumerable<string> ColumnNames => ColumnDefs.Select(m => m.Item1);
|
public IEnumerable<string> ColumnNames => ColumnDefs.Select(m => m.Name);
|
||||||
public IEnumerable<Type?> ColumnTypes => ColumnDefs.Select(m => m.Item2);
|
public IEnumerable<Type?> ColumnTypes => ColumnDefs.Select(m => m.Type);
|
||||||
public IEnumerable<Type?> ColumnFlatTypes { get; private set; }
|
public IEnumerable<Type?> ColumnFlatTypes { get; private set; }
|
||||||
public IEnumerable<int> ColumnSpans { get; private set; }
|
public IEnumerable<int> ColumnSpans { get; private set; }
|
||||||
public IEnumerable<int?> ColumnWidths { get; private set; }
|
public IEnumerable<int?> ColumnWidths { get; private set; }
|
||||||
@@ -23,70 +25,87 @@ namespace Elwig.Models.Dtos {
|
|||||||
|
|
||||||
private readonly PropertyInfo[] _properties;
|
private readonly PropertyInfo[] _properties;
|
||||||
private readonly FieldInfo[] _fields;
|
private readonly FieldInfo[] _fields;
|
||||||
private readonly (string, PropertyInfo?, FieldInfo?)[] _map;
|
private readonly (string Name, PropertyInfo? PInfo, FieldInfo? FInfo)[] _map;
|
||||||
|
|
||||||
public DataTable(string name, string fullName, string subtitle, IEnumerable<T> rows, IEnumerable<(string, string, string?, int?)>? colNames = null) :
|
public DataTable(string name, string fullName, string subtitle, IEnumerable<(string? Name, IEnumerable<T> Rows)> sections, IEnumerable<(string Property, string Name, string? Unit, int? Width)>? colNames = null) :
|
||||||
this(name, fullName, rows, colNames) {
|
this(name, fullName, sections, colNames) {
|
||||||
Subtitle = subtitle;
|
Subtitle = subtitle;
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTable(string name, string fullName, IEnumerable<T> rows, IEnumerable<(string, string, string?, int?)>? colNames = null) {
|
public DataTable(string name, string fullName, string subtitle, IEnumerable<T> rows, IEnumerable<(string Property, string Name, string? Unit, int? Width)>? colNames = null) :
|
||||||
|
this(name, fullName, subtitle, [(null, rows)], colNames) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTable(string name, string fullName, IEnumerable<(string? Name, IEnumerable<T> Rows)> sections, IEnumerable<(string Property, string Name, string? Unit, int? Width)>? colNames = null) {
|
||||||
_fields = typeof(T).GetFields();
|
_fields = typeof(T).GetFields();
|
||||||
_properties = typeof(T).GetProperties();
|
_properties = typeof(T).GetProperties();
|
||||||
colNames ??= _properties.Select(p => p.Name).Union(_fields.Select(f => f.Name)).Select(i => (i, i, (string?)null, (int?)null)).ToList();
|
colNames ??= [.. _properties.Select(p => p.Name).Union(_fields.Select(f => f.Name)).Select(i => (i, i, (string?)null, (int?)null))];
|
||||||
_map = colNames.Select(n => (n.Item2, _properties.FirstOrDefault(p => p?.Name == n.Item1, null), _fields.FirstOrDefault(f => f?.Name == n.Item1, null))).ToArray();
|
_map = [.. colNames.Select(n => (n.Name, _properties.FirstOrDefault(p => p?.Name == n.Property, null), _fields.FirstOrDefault(f => f?.Name == n.Property, null)))];
|
||||||
Name = name;
|
Name = name;
|
||||||
FullName = fullName;
|
FullName = fullName;
|
||||||
Rows = rows;
|
Sections = sections;
|
||||||
ColumnFlatTypes = ColumnTypes.SelectMany(type => {
|
ColumnFlatTypes = [.. ColumnTypes.SelectMany(type => {
|
||||||
var elType = type?.GetElementType();
|
var elType = type?.GetElementType();
|
||||||
return type != null && type.IsValueType && type.Name.StartsWith("ValueTuple") ? type.GetFields().Select(f => f.FieldType) :
|
return type != null && type.IsValueType && type.Name.StartsWith("ValueTuple") ? type.GetFields().Select(f => (Type?)f.FieldType) :
|
||||||
type != null && elType != null && type.IsArray && elType.IsValueType && elType.Name.StartsWith("ValueTuple") ? elType.GetFields().Select(f => f.FieldType) :
|
type != null && elType != null && type.IsArray && elType.IsValueType && elType.Name.StartsWith("ValueTuple") ? elType.GetFields().Select(f => (Type?)f.FieldType) :
|
||||||
[type];
|
[type];
|
||||||
}).ToList();
|
})];
|
||||||
ColumnSpans = ColumnTypes.Select(type => {
|
ColumnSpans = [.. ColumnTypes.Select(type => {
|
||||||
var elType = type?.GetElementType();
|
var elType = type?.GetElementType();
|
||||||
return type != null && type.IsValueType && type.Name.StartsWith("ValueTuple") ? type.GetFields().Length :
|
return type != null && type.IsValueType && type.Name.StartsWith("ValueTuple") ? type.GetFields().Length :
|
||||||
type != null && elType != null && type.IsArray && elType.IsValueType && elType.Name.StartsWith("ValueTuple") ? elType.GetFields().Length : 1;
|
type != null && elType != null && type.IsArray && elType.IsValueType && elType.Name.StartsWith("ValueTuple") ? elType.GetFields().Length :
|
||||||
}).ToList();
|
1;
|
||||||
ColumnWidths = colNames.Select(c => c.Item4).ToList();
|
})];
|
||||||
ColumnUnits = colNames.Select(c => c.Item3?.Split("|").Select(p => p.Length == 0 ? null : p).ToArray() ?? []).ToList();
|
ColumnWidths = [.. colNames.Select(c => c.Width)];
|
||||||
|
ColumnUnits = [.. colNames.Select(c => c.Unit?.Split("|").Select(p => p.Length == 0 ? null : p).ToArray() ?? [])];
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTable(string name, string fullName, IEnumerable<T> rows, IEnumerable<(string, string, string?)>? colNames = null) :
|
public DataTable(string name, string fullName, IEnumerable<T> rows, IEnumerable<(string Property, string Name, string? Unit, int? Width)>? colNames = null) :
|
||||||
this(name, fullName, rows, colNames?.Select(c => (c.Item1, c.Item2, c.Item3, (int?)null))) {
|
this(name, fullName, [(null, rows)], colNames) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTable(string name, IEnumerable<T> rows, IEnumerable<(string, string, string?)>? colNames = null) :
|
public DataTable(string name, string fullName, IEnumerable<T> rows, IEnumerable<(string Property, string Name, string? Unit)>? colNames = null) :
|
||||||
|
this(name, fullName, rows, colNames?.Select(c => (c.Property, c.Name, c.Unit, (int?)null))) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTable(string name, string fullName, IEnumerable<T> rows, IEnumerable<(string Property, string Name, string? Unit, int Width)>? colNames = null) :
|
||||||
|
this(name, fullName, rows, colNames?.Select(c => (c.Property, c.Name, c.Unit, (int?)c.Width))) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public DataTable(string name, IEnumerable<T> rows, IEnumerable<(string Property, string Name, string? Unit, int? Width)>? colNames = null) :
|
||||||
this(name, name, rows, colNames) {
|
this(name, name, rows, colNames) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTable(string name, IEnumerable<T> rows, IEnumerable<(string, string, string?, int?)>? colNames = null) :
|
public DataTable(string name, IEnumerable<T> rows, IEnumerable<(string Property, string Name, string? Unit)>? colNames = null) :
|
||||||
this(name, name, rows, colNames) {
|
this(name, name, rows, colNames) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTable(string name, IEnumerable<T> rows, IEnumerable<(string, string, string?, int)>? colNames = null) :
|
public DataTable(string name, IEnumerable<T> rows, IEnumerable<(string Property, string Name, string? Unit, int Width)>? colNames = null) :
|
||||||
this(name, name, rows, colNames) {
|
this(name, name, rows, colNames) {
|
||||||
}
|
}
|
||||||
|
|
||||||
public DataTable(string name, string fullName, IEnumerable<T> rows, IEnumerable<(string, string, string?, int)>? colNames = null) :
|
public DataTable(string name, string fullName, IEnumerable<(string? Name, IEnumerable<T> Rows)> sections, IEnumerable<(string Property, string Name, string? Unit)>? colNames = null) :
|
||||||
this(name, fullName, rows, colNames?.Select(c => (c.Item1, c.Item2, c.Item3, (int?)c.Item4))) {
|
this(name, fullName, sections, colNames?.Select(c => (c.Property, c.Name, c.Unit, (int?)null))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IEnumerable<(string, object?)> GetNamedRowData(T row) {
|
public DataTable(string name, string fullName, IEnumerable<(string? Name, IEnumerable<T> Rows)> sections, IEnumerable<(string Property, string Name, string? Unit, int Width)>? colNames = null) :
|
||||||
return _map.Select(i => (i.Item1, i.Item2?.GetValue(row) ?? i.Item3?.GetValue(row)));
|
this(name, fullName, sections, colNames?.Select(c => (c.Property, c.Name, c.Unit, (int?)c.Width))) {
|
||||||
}
|
}
|
||||||
|
|
||||||
protected IEnumerable<object?> GetRowData(T row) {
|
protected IEnumerable<(string Name, object? Value)> GetNamedRowValues(T row) {
|
||||||
return GetNamedRowData(row).Select(i => i.Item2);
|
return _map.Select(i => (i.Name, i.PInfo?.GetValue(row) ?? i.FInfo?.GetValue(row)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IEnumerable<object?>> GetData() {
|
protected IEnumerable<object?> GetRowValues(T row) {
|
||||||
return Rows.Select(GetRowData);
|
return GetNamedRowValues(row).Select(i => i.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<IEnumerable<(string, object?)>> GetNamedData() {
|
public IEnumerable<(string? Name, IEnumerable<IEnumerable<object?>> Rows)> GetData() {
|
||||||
return Rows.Select(GetNamedRowData);
|
return Sections.Select(s => (s.Name, s.Rows.Select(GetRowValues)));
|
||||||
|
}
|
||||||
|
|
||||||
|
public IEnumerable<(string? Name, IEnumerable<IEnumerable<(string Name, object? Value)>> Rows)> GetNamedData() {
|
||||||
|
return Sections.Select(s => (s.Name, s.Rows.Select(GetNamedRowValues)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -45,8 +45,6 @@ namespace Elwig.Models.Dtos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<IEnumerable<DeliveryPart>> FromDbSet(DbSet<DeliveryPart> table, int? year = null, int? mgnr = null) {
|
private static async Task<IEnumerable<DeliveryPart>> FromDbSet(DbSet<DeliveryPart> table, int? year = null, int? mgnr = null) {
|
||||||
var y = year?.ToString() ?? "NULL";
|
|
||||||
var m = mgnr?.ToString() ?? "NULL";
|
|
||||||
IQueryable<DeliveryPart> q = table;
|
IQueryable<DeliveryPart> q = table;
|
||||||
if (year != null) q = q.Where(p => p.Year == year);
|
if (year != null) q = q.Where(p => p.Year == year);
|
||||||
if (mgnr != null) q = q.Where(p => p.Delivery.MgNr == mgnr);
|
if (mgnr != null) q = q.Where(p => p.Delivery.MgNr == mgnr);
|
||||||
@@ -55,11 +53,11 @@ namespace Elwig.Models.Dtos {
|
|||||||
.Include(p => p.Buckets)
|
.Include(p => p.Buckets)
|
||||||
.Include(p => p.PartModifiers).ThenInclude(m => m.Modifier)
|
.Include(p => p.PartModifiers).ThenInclude(m => m.Modifier)
|
||||||
.LoadAsync();
|
.LoadAsync();
|
||||||
return await table.FromSqlRaw($"""
|
return await table.FromSql($"""
|
||||||
SELECT p.*
|
SELECT p.*
|
||||||
FROM v_delivery v
|
FROM v_delivery v
|
||||||
JOIN delivery_part p ON (p.year, p.did, p.dpnr) = (v.year, v.did, v.dpnr)
|
JOIN delivery_part p ON (p.year, p.did, p.dpnr) = (v.year, v.did, v.dpnr)
|
||||||
WHERE (p.year = {y} OR {y} IS NULL) AND (v.mgnr = {m} OR {m} IS NULL)
|
WHERE (p.year = {year} OR {year} IS NULL) AND (v.mgnr = {mgnr} OR {mgnr} IS NULL)
|
||||||
ORDER BY p.year, v.mgnr, v.sortid, v.abgewertet ASC, v.attribute_prio DESC, COALESCE(v.attrid, '~'), v.kmw DESC, v.lsnr, v.dpnr
|
ORDER BY p.year, v.mgnr, v.sortid, v.abgewertet ASC, v.attribute_prio DESC, COALESCE(v.attrid, '~'), v.kmw DESC, v.lsnr, v.dpnr
|
||||||
""").IgnoreAutoIncludes().ToListAsync();
|
""").IgnoreAutoIncludes().ToListAsync();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,142 @@
|
|||||||
|
using Elwig.Helpers;
|
||||||
|
using Elwig.Models.Entities;
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
|
||||||
|
namespace Elwig.Models.Dtos {
|
||||||
|
public class MemberMovementData : DataTable<MemberMovementDataRow> {
|
||||||
|
|
||||||
|
private static readonly (string, string, string?, int)[] FieldNames = [
|
||||||
|
("Type", "\u2026 durch", null, 30),
|
||||||
|
("MgNr", "MgNr.", null, 12),
|
||||||
|
("Name1", "Name", null, 40),
|
||||||
|
("Name2", "Vorname", null, 25),
|
||||||
|
("Address", "Adresse", null, 50),
|
||||||
|
("Plz", "PLZ", null, 10),
|
||||||
|
("Locality", "Ort", null, 50),
|
||||||
|
("Date", "Datum", null, 20),
|
||||||
|
("SharesOld", "GA\nalt", null, 10),
|
||||||
|
("SharesDiff", "GA\nDiff.", null, 10),
|
||||||
|
("SharesNew", "GA\nneu", null, 10),
|
||||||
|
("Costs", "Kosten", "€", 15),
|
||||||
|
];
|
||||||
|
|
||||||
|
private MemberMovementData(string name, IEnumerable<(string? Name, IEnumerable<MemberMovementDataRow> Rows)> sections) :
|
||||||
|
base("Mitgl.-Bewegungen", name, sections, FieldNames) {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static MemberMovementData FromMemberHistory(string name, IEnumerable<MemberHistory> rows, Dictionary<int, SortedDictionary<DateOnly, MemberHistoryPoint>> history) {
|
||||||
|
(string? Name, List<MemberMovementDataRow> Rows)[] sections = [
|
||||||
|
("Beitritt", []),
|
||||||
|
("Nachzeichnung (GA)", []),
|
||||||
|
("Überschreibung", []),
|
||||||
|
("Kündigung (GA)", []),
|
||||||
|
("Austritt", []),
|
||||||
|
];
|
||||||
|
foreach (var h in rows.OrderBy(r => r.DateNotice).ThenBy(r => r.ToMgNr).ThenBy(r => r.FromMgNr)) {
|
||||||
|
|
||||||
|
int cat;
|
||||||
|
if (h.ToMgNr == h.FromMgNr) {
|
||||||
|
// Umwandlung
|
||||||
|
if (h.ToType == BusinessShareType.Dormant) {
|
||||||
|
// Kündigung (GA)
|
||||||
|
cat = 3;
|
||||||
|
} else if (h.FromType == h.ToType) {
|
||||||
|
// Überschreibung
|
||||||
|
cat = 2;
|
||||||
|
} else {
|
||||||
|
throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
} else if (h.DateNotice <= h.ToMember?.EntryDate && h.DateNotice >= h.FromMember?.ExitDate) {
|
||||||
|
// Überschreibung
|
||||||
|
cat = 2;
|
||||||
|
} else if (h.DateNotice <= h.ToMember?.EntryDate) {
|
||||||
|
// Beitritt
|
||||||
|
cat = 0;
|
||||||
|
} else if (h.DateNotice >= h.FromMember?.ExitDate) {
|
||||||
|
// Austritt
|
||||||
|
cat = 4;
|
||||||
|
} else if (h.ToMember == null) {
|
||||||
|
// Auszahlung
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
// Nachzeichnung (GA)
|
||||||
|
cat = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
Member a;
|
||||||
|
Member? b = null;
|
||||||
|
if (h.FromMember != null && h.ToMember != null) {
|
||||||
|
if (cat <= 1) {
|
||||||
|
a = h.ToMember;
|
||||||
|
b = h.FromMember;
|
||||||
|
} else {
|
||||||
|
a = h.FromMember;
|
||||||
|
b = h.ToMember;
|
||||||
|
}
|
||||||
|
} else if (h.FromMember != null) {
|
||||||
|
a = h.FromMember;
|
||||||
|
} else if (h.ToMember != null) {
|
||||||
|
a = h.ToMember;
|
||||||
|
} else {
|
||||||
|
throw new ArgumentException();
|
||||||
|
}
|
||||||
|
|
||||||
|
var oldA = history[a.MgNr].GetValueOrDefault(h.DateNotice);
|
||||||
|
var d = new MemberMovementDataRow {
|
||||||
|
Type = [h.ReasonPretty],
|
||||||
|
|
||||||
|
MgNr = [a.MgNr],
|
||||||
|
Name1 = [a.Name],
|
||||||
|
Name2 = [a.AdministrativeName2],
|
||||||
|
Address = [a.Address],
|
||||||
|
Plz = [a.PostalDest.AtPlz!.Plz],
|
||||||
|
Locality = [a.PostalDest.AtPlz.Ort.Name],
|
||||||
|
|
||||||
|
Date = h.DateNotice,
|
||||||
|
SharesOld = [oldA.Shares + oldA.SharesRed + oldA.SharesWhite],
|
||||||
|
SharesDiff = [cat != 3 && a == h.ToMember ? h.Shares : -h.Shares],
|
||||||
|
Costs = [h.FromMember == null ? h.TotalValue : null],
|
||||||
|
};
|
||||||
|
d.SharesNew = [d.SharesOld[^1] + (h.FromMgNr == h.ToMgNr ? 0 : d.SharesDiff[^1])];
|
||||||
|
|
||||||
|
if (b != null) {
|
||||||
|
var oldB = history[b.MgNr].GetValueOrDefault(h.DateNotice);
|
||||||
|
d.Type = [..d.Type, "\u2026 " + (cat <= 1 ? "von" : "an")];
|
||||||
|
|
||||||
|
d.MgNr = [.. d.MgNr, b.MgNr];
|
||||||
|
d.Name1 = [.. d.Name1, b.Name];
|
||||||
|
d.Name2 = [.. d.Name2, b.AdministrativeName2];
|
||||||
|
d.Address = [.. d.Address, b.Address];
|
||||||
|
d.Plz = [.. d.Plz, b.PostalDest.AtPlz!.Plz];
|
||||||
|
d.Locality = [.. d.Locality, b.PostalDest.AtPlz.Ort.Name];
|
||||||
|
|
||||||
|
d.SharesOld = [.. d.SharesOld, oldB.Shares + oldB.SharesRed + oldB.SharesWhite];
|
||||||
|
d.SharesDiff = [.. d.SharesDiff, b == h.ToMember ? h.Shares : -h.Shares];
|
||||||
|
d.SharesNew = [.. d.SharesNew, d.SharesOld[^1] + d.SharesDiff[^1]];
|
||||||
|
}
|
||||||
|
|
||||||
|
sections[cat].Rows.Add(d);
|
||||||
|
}
|
||||||
|
return new MemberMovementData($"Mitglieder-Bewegungen {name}", sections.Select(s => (s.Name, (IEnumerable<MemberMovementDataRow>)s.Rows)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class MemberMovementDataRow {
|
||||||
|
public string[] Type = [];
|
||||||
|
|
||||||
|
public int[] MgNr = [];
|
||||||
|
public string[] Name1 = [];
|
||||||
|
public string?[] Name2 = [];
|
||||||
|
public string[] Address = [];
|
||||||
|
public int[] Plz = [];
|
||||||
|
public string[] Locality = [];
|
||||||
|
|
||||||
|
public DateOnly Date;
|
||||||
|
public int?[] SharesOld = [];
|
||||||
|
public int[] SharesDiff = [];
|
||||||
|
public int?[] SharesNew = [];
|
||||||
|
public decimal?[] Costs = [];
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -26,8 +26,7 @@ namespace Elwig.Models.Dtos {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async Task<IEnumerable<WeightBreakdownRow>> FromDbSet(DbSet<WeightBreakdownRow> table, int year, string? zwstid) {
|
private static async Task<IEnumerable<WeightBreakdownRow>> FromDbSet(DbSet<WeightBreakdownRow> table, int year, string? zwstid) {
|
||||||
zwstid = zwstid == null ? "NULL" : $"'{zwstid}'";
|
return await table.FromSql($"""
|
||||||
return await table.FromSqlRaw($"""
|
|
||||||
SELECT type, sortid, attrid, cultid, v.qualid, contracted, SUM(weight) AS weight
|
SELECT type, sortid, attrid, cultid, v.qualid, contracted, SUM(weight) AS weight
|
||||||
FROM v_stat_total v
|
FROM v_stat_total v
|
||||||
LEFT JOIN wine_quality_level q ON q.qualid = v.qualid
|
LEFT JOIN wine_quality_level q ON q.qualid = v.qualid
|
||||||
|
|||||||
@@ -6,15 +6,15 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("AT_gem"), PrimaryKey("Gkz")]
|
[Table("AT_gem"), PrimaryKey("Gkz")]
|
||||||
public class AT_Gem {
|
public class AT_Gem {
|
||||||
[Column("gkz")]
|
[Column("gkz")]
|
||||||
public int Gkz { get; private set; }
|
public int Gkz { get; init; }
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
[InverseProperty(nameof(AT_Kg.Gem))]
|
[InverseProperty(nameof(AT_Kg.Gem))]
|
||||||
public virtual ICollection<AT_Kg> Kgs { get; private set; } = null!;
|
public virtual ICollection<AT_Kg> Kgs { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(WbGem.AtGem))]
|
[InverseProperty(nameof(WbGem.AtGem))]
|
||||||
public virtual WbGem? WbGem { get; private set; }
|
public virtual WbGem? WbGem { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,18 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("AT_kg"), PrimaryKey("KgNr")]
|
[Table("AT_kg"), PrimaryKey("KgNr")]
|
||||||
public class AT_Kg {
|
public class AT_Kg {
|
||||||
[Column("kgnr")]
|
[Column("kgnr")]
|
||||||
public int KgNr { get; private set; }
|
public int KgNr { get; init; }
|
||||||
|
|
||||||
[Column("gkz")]
|
[Column("gkz")]
|
||||||
public int Gkz { get; private set; }
|
public int Gkz { get; init; }
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
[ForeignKey("Gkz")]
|
[ForeignKey("Gkz")]
|
||||||
public virtual AT_Gem Gem { get; private set; } = null!;
|
public virtual AT_Gem Gem { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(WbKg.AtKg))]
|
[InverseProperty(nameof(WbKg.AtKg))]
|
||||||
public virtual WbKg? WbKg { get; private set; }
|
public virtual WbKg? WbKg { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,21 +5,21 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("AT_ort"), PrimaryKey("Okz")]
|
[Table("AT_ort"), PrimaryKey("Okz")]
|
||||||
public class AT_Ort {
|
public class AT_Ort {
|
||||||
[Column("okz")]
|
[Column("okz")]
|
||||||
public int Okz { get; private set; }
|
public int Okz { get; init; }
|
||||||
|
|
||||||
[Column("gkz")]
|
[Column("gkz")]
|
||||||
public int Gkz { get; private set; }
|
public int Gkz { get; init; }
|
||||||
|
|
||||||
[Column("kgnr")]
|
[Column("kgnr")]
|
||||||
public int? KgNr { get; private set; }
|
public int? KgNr { get; init; }
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
[ForeignKey("Gkz")]
|
[ForeignKey("Gkz")]
|
||||||
public virtual AT_Gem Gem { get; private set; } = null!;
|
public virtual AT_Gem Gem { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("KgNr")]
|
[ForeignKey("KgNr")]
|
||||||
public virtual AT_Kg? Kg { get; private set; }
|
public virtual AT_Kg? Kg { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,27 +6,27 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("AT_plz"), PrimaryKey("Plz")]
|
[Table("AT_plz"), PrimaryKey("Plz")]
|
||||||
public class AT_Plz {
|
public class AT_Plz {
|
||||||
[Column("plz")]
|
[Column("plz")]
|
||||||
public int Plz { get; private set; }
|
public int Plz { get; init; }
|
||||||
|
|
||||||
[Column("ort")]
|
[Column("ort")]
|
||||||
public string Ort { get; private set; } = null!;
|
public required string Ort { get; init; }
|
||||||
|
|
||||||
[Column("blnr")]
|
[Column("blnr")]
|
||||||
public int BlNr { get; private set; }
|
public int BlNr { get; init; }
|
||||||
|
|
||||||
[Column("type")]
|
[Column("type")]
|
||||||
public string Type { get; private set; } = null!;
|
public required string Type { get; init; }
|
||||||
|
|
||||||
[Column("internal")]
|
[Column("internal")]
|
||||||
public bool IsInternal { get; private set; }
|
public bool IsInternal { get; init; }
|
||||||
|
|
||||||
[Column("addressable")]
|
[Column("addressable")]
|
||||||
public bool IsAddressable { get; private set; }
|
public bool IsAddressable { get; init; }
|
||||||
|
|
||||||
[Column("po_box")]
|
[Column("po_box")]
|
||||||
public bool IsPoBox { get; private set; }
|
public bool IsPoBox { get; init; }
|
||||||
|
|
||||||
[InverseProperty(nameof(AT_PlzDest.AtPlz))]
|
[InverseProperty(nameof(AT_PlzDest.AtPlz))]
|
||||||
public virtual ICollection<AT_PlzDest> Orte { get; private set; } = null!;
|
public virtual ICollection<AT_PlzDest> Orte { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,27 +6,30 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("AT_plz_dest"), PrimaryKey("Id"), Index("Plz", "Okz", IsUnique = true)]
|
[Table("AT_plz_dest"), PrimaryKey("Id"), Index("Plz", "Okz", IsUnique = true)]
|
||||||
public class AT_PlzDest {
|
public class AT_PlzDest {
|
||||||
[Column("plz")]
|
[Column("plz")]
|
||||||
public int Plz { get; private set; }
|
public int Plz { get; init; }
|
||||||
|
|
||||||
[Column("okz")]
|
[Column("okz")]
|
||||||
public int Okz { get; private set; }
|
public int Okz { get; init; }
|
||||||
|
|
||||||
[Column("country")]
|
[Column("country")]
|
||||||
public int CountryNum { get; private set; }
|
public int CountryNum { get; init; }
|
||||||
|
|
||||||
[Column("id")]
|
[Column("id")]
|
||||||
public string Id { get; private set; } = null!;
|
public required string Id { get; init; }
|
||||||
|
|
||||||
[Column("dest")]
|
[Column("dest")]
|
||||||
public string Dest { get; private set; } = null!;
|
public required string Dest { get; init; }
|
||||||
|
|
||||||
|
[NotMapped]
|
||||||
|
public string FullDest => $"{Ort.Name} ({Dest})";
|
||||||
|
|
||||||
[ForeignKey("Plz")]
|
[ForeignKey("Plz")]
|
||||||
public virtual AT_Plz AtPlz { get; private set; } = null!;
|
public virtual AT_Plz AtPlz { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("Okz")]
|
[ForeignKey("Okz")]
|
||||||
public virtual AT_Ort Ort { get; private set; } = null!;
|
public virtual AT_Ort Ort { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("CountryNum")]
|
[ForeignKey("CountryNum")]
|
||||||
public virtual Country Country { get; private set; } = null!;
|
public virtual Country Country { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,15 +65,15 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("FbNr")]
|
[ForeignKey("FbNr")]
|
||||||
public virtual AreaCmtContract Contract { get; private set; } = null!;
|
public virtual AreaCmtContract Contract { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("VtrgId")]
|
[ForeignKey("VtrgId")]
|
||||||
public virtual AreaCmtType AreaCmtType { get; private set; } = null!;
|
public virtual AreaCmtType AreaCmtType { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("CultId")]
|
[ForeignKey("CultId")]
|
||||||
public virtual WineCult? WineCult { get; private set; }
|
public virtual WineCult? WineCult { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -53,13 +53,13 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("KgNr")]
|
[ForeignKey("KgNr")]
|
||||||
public virtual WbKg Kg { get; private set; } = null!;
|
public virtual WbKg Kg { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("KgNr, RdNr")]
|
[ForeignKey("KgNr, RdNr")]
|
||||||
public virtual WbRd? Rd { get; private set; }
|
public virtual WbRd? Rd { get; init; }
|
||||||
|
|
||||||
[InverseProperty(nameof(AreaCmt.Contract))]
|
[InverseProperty(nameof(AreaCmt.Contract))]
|
||||||
public virtual ICollection<AreaCmt> Revisions { get; private set; } = null!;
|
public virtual ICollection<AreaCmt> Revisions { get; init; } = null!;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public AreaCmt? Latest => Revisions.OrderBy(r => r.RevNr).LastOrDefault();
|
public AreaCmt? Latest => Revisions.OrderBy(r => r.RevNr).LastOrDefault();
|
||||||
|
|||||||
@@ -46,10 +46,10 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("SortId")]
|
[ForeignKey("SortId")]
|
||||||
public virtual WineVar WineVar { get; private set; } = null!;
|
public virtual WineVar WineVar { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("AttrId")]
|
[ForeignKey("AttrId")]
|
||||||
public virtual WineAttr? WineAttr { get; private set; }
|
public virtual WineAttr? WineAttr { get; init; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string DisplayName => WineVar.Name + (WineAttr != null ? $" {WineAttr.Name}" : "") + (Discriminator != null ? $" ({Discriminator})" : "");
|
public string DisplayName => WineVar.Name + (WineAttr != null ? $" {WineAttr.Name}" : "") + (Discriminator != null ? $" ({Discriminator})" : "");
|
||||||
|
|||||||
@@ -20,12 +20,12 @@ namespace Elwig.Models.Entities {
|
|||||||
public required string Address { get; set; }
|
public required string Address { get; set; }
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("CountryNum")]
|
[ForeignKey("CountryNum")]
|
||||||
public virtual Country Country { get; private set; } = null!;
|
public virtual Country Country { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("CountryNum, PostalDestId")]
|
[ForeignKey("CountryNum, PostalDestId")]
|
||||||
public virtual PostalDest PostalDest { get; private set; } = null!;
|
public virtual PostalDest PostalDest { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -22,10 +22,10 @@ namespace Elwig.Models.Entities {
|
|||||||
public string? Address { get; set; }
|
public string? Address { get; set; }
|
||||||
|
|
||||||
[ForeignKey("CountryNum")]
|
[ForeignKey("CountryNum")]
|
||||||
public virtual Country? Country { get; private set; }
|
public virtual Country? Country { get; init; }
|
||||||
|
|
||||||
[ForeignKey("CountryNum, PostalDestId")]
|
[ForeignKey("CountryNum, PostalDestId")]
|
||||||
public virtual PostalDest? PostalDest { get; private set; }
|
public virtual PostalDest? PostalDest { get; init; }
|
||||||
|
|
||||||
[Column("phone_nr")]
|
[Column("phone_nr")]
|
||||||
public string? PhoneNr { get; set; }
|
public string? PhoneNr { get; set; }
|
||||||
@@ -37,6 +37,6 @@ namespace Elwig.Models.Entities {
|
|||||||
public string? MobileNr { get; set; }
|
public string? MobileNr { get; set; }
|
||||||
|
|
||||||
[InverseProperty(nameof(Member.Branch))]
|
[InverseProperty(nameof(Member.Branch))]
|
||||||
public virtual ICollection<Member> Members { get; private set; } = null!;
|
public virtual ICollection<Member> Members { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,18 +6,18 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("country"), PrimaryKey("Num"), Index("Alpha2", IsUnique = true), Index("Alpha3", IsUnique = true)]
|
[Table("country"), PrimaryKey("Num"), Index("Alpha2", IsUnique = true), Index("Alpha3", IsUnique = true)]
|
||||||
public class Country {
|
public class Country {
|
||||||
[Column("num")]
|
[Column("num")]
|
||||||
public int Num { get; private set; }
|
public int Num { get; init; }
|
||||||
|
|
||||||
[Column("alpha2")]
|
[Column("alpha2")]
|
||||||
public string Alpha2 { get; private set; } = null!;
|
public required string Alpha2 { get; init; }
|
||||||
|
|
||||||
[Column("alpha3")]
|
[Column("alpha3")]
|
||||||
public string Alpha3 { get; private set; } = null!;
|
public required string Alpha3 { get; init; }
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
[Column("is_visible")]
|
[Column("is_visible")]
|
||||||
public bool IsVisible { get; private set; }
|
public bool IsVisible { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -47,14 +47,14 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Column("vat_amount")]
|
[Column("vat_amount")]
|
||||||
public long VatAmountValue { get; private set; }
|
public long VatAmountValue { get; init; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal VatAmount {
|
public decimal VatAmount {
|
||||||
get => Utils.DecFromDb(VatAmountValue, 2);
|
get => Utils.DecFromDb(VatAmountValue, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
[Column("gross_amount")]
|
[Column("gross_amount")]
|
||||||
public long GrossAmountValue { get; private set; }
|
public long GrossAmountValue { get; init; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal GrossAmount {
|
public decimal GrossAmount {
|
||||||
get => Utils.DecFromDb(GrossAmountValue, 2);
|
get => Utils.DecFromDb(GrossAmountValue, 2);
|
||||||
@@ -77,7 +77,7 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Column("amount")]
|
[Column("amount")]
|
||||||
public long AmountValue { get; private set; }
|
public long AmountValue { get; init; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal Amount {
|
public decimal Amount {
|
||||||
get => Utils.DecFromDb(AmountValue, 2);
|
get => Utils.DecFromDb(AmountValue, 2);
|
||||||
@@ -116,12 +116,12 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("Year, AvNr, MgNr")]
|
[ForeignKey("Year, AvNr, MgNr")]
|
||||||
public virtual PaymentMember Payment { get; private set; } = null!;
|
public virtual PaymentMember Payment { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("Year, AvNr")]
|
[ForeignKey("Year, AvNr")]
|
||||||
public virtual PaymentVar Variant { get; private set; } = null!;
|
public virtual PaymentVar Variant { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,16 +6,16 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("currency"), PrimaryKey("Code")]
|
[Table("currency"), PrimaryKey("Code")]
|
||||||
public class Currency {
|
public class Currency {
|
||||||
[Column("code")]
|
[Column("code")]
|
||||||
public string Code { get; private set; } = null!;
|
public required string Code { get; init; }
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
[Column("symbol")]
|
[Column("symbol")]
|
||||||
public string? Symbol { get; private set; }
|
public string? Symbol { get; init; }
|
||||||
|
|
||||||
[Column("one_euro")]
|
[Column("one_euro")]
|
||||||
public long? OneEuroValue { get; private set; }
|
public long? OneEuroValue { get; init; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal? OneEuro => OneEuroValue != null ? Utils.DecFromDb(OneEuroValue.Value, 6) : null;
|
public decimal? OneEuro => OneEuroValue != null ? Utils.DecFromDb(OneEuroValue.Value, 6) : null;
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ namespace Elwig.Models.Entities {
|
|||||||
public required string ZwstId { get; set; }
|
public required string ZwstId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("ZwstId")]
|
[ForeignKey("ZwstId")]
|
||||||
public virtual Branch Branch { get; private set; } = null!;
|
public virtual Branch Branch { get; init; } = null!;
|
||||||
|
|
||||||
[Column("lnr")]
|
[Column("lnr")]
|
||||||
public int LNr { get; set; }
|
public int LNr { get; set; }
|
||||||
@@ -58,7 +58,7 @@ namespace Elwig.Models.Entities {
|
|||||||
public int MgNr { get; set; }
|
public int MgNr { get; set; }
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
|
|
||||||
[Column("comment")]
|
[Column("comment")]
|
||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
@@ -101,10 +101,10 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("Year")]
|
[ForeignKey("Year")]
|
||||||
public virtual Season Season { get; private set; } = null!;
|
public virtual Season Season { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(DeliveryPart.Delivery))]
|
[InverseProperty(nameof(DeliveryPart.Delivery))]
|
||||||
public virtual ICollection<DeliveryPart> Parts { get; private set; } = null!;
|
public virtual ICollection<DeliveryPart> Parts { get; init; } = null!;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public IEnumerable<DeliveryPart> FilteredParts => PartFilter == null ? Parts : Parts.Where(p => PartFilter(p));
|
public IEnumerable<DeliveryPart> FilteredParts => PartFilter == null ? Parts : Parts.Where(p => PartFilter(p));
|
||||||
|
|
||||||
|
|||||||
@@ -59,13 +59,13 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("Year, DsNr")]
|
[ForeignKey("Year, DsNr")]
|
||||||
public virtual DeliverySchedule Schedule { get; private set; } = null!;
|
public virtual DeliverySchedule Schedule { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("SortId")]
|
[ForeignKey("SortId")]
|
||||||
public virtual WineVar Variety { get; private set; } = null!;
|
public virtual WineVar Variety { get; init; } = null!;
|
||||||
|
|
||||||
public int SearchScore(IEnumerable<string> keywords) {
|
public int SearchScore(IEnumerable<string> keywords) {
|
||||||
return Utils.GetSearchScore([
|
return Utils.GetSearchScore([
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ namespace Elwig.Models.Entities {
|
|||||||
public int DId { get; set; }
|
public int DId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Year, DId")]
|
[ForeignKey("Year, DId")]
|
||||||
public virtual Delivery Delivery { get; private set; } = null!;
|
public virtual Delivery Delivery { get; init; } = null!;
|
||||||
|
|
||||||
[Column("dpnr")]
|
[Column("dpnr")]
|
||||||
public int DPNr { get; set; }
|
public int DPNr { get; set; }
|
||||||
@@ -30,19 +30,19 @@ namespace Elwig.Models.Entities {
|
|||||||
public required string SortId { get; set; }
|
public required string SortId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("SortId")]
|
[ForeignKey("SortId")]
|
||||||
public virtual WineVar Variety { get; private set; } = null!;
|
public virtual WineVar Variety { get; init; } = null!;
|
||||||
|
|
||||||
[Column("attrid")]
|
[Column("attrid")]
|
||||||
public string? AttrId { get; set; }
|
public string? AttrId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("AttrId")]
|
[ForeignKey("AttrId")]
|
||||||
public virtual WineAttr? Attribute { get; private set; }
|
public virtual WineAttr? Attribute { get; init; }
|
||||||
|
|
||||||
[Column("cultid")]
|
[Column("cultid")]
|
||||||
public string? CultId { get; set; }
|
public string? CultId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("CultId")]
|
[ForeignKey("CultId")]
|
||||||
public virtual WineCult? Cultivation { get; private set; }
|
public virtual WineCult? Cultivation { get; init; }
|
||||||
|
|
||||||
[Column("weight")]
|
[Column("weight")]
|
||||||
public int Weight { get; set; }
|
public int Weight { get; set; }
|
||||||
@@ -59,25 +59,25 @@ namespace Elwig.Models.Entities {
|
|||||||
public required string QualId { get; set; }
|
public required string QualId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("QualId")]
|
[ForeignKey("QualId")]
|
||||||
public virtual WineQualLevel Quality { get; private set; } = null!;
|
public virtual WineQualLevel Quality { get; init; } = null!;
|
||||||
|
|
||||||
[Column("hkid")]
|
[Column("hkid")]
|
||||||
public required string HkId { get; set; }
|
public required string HkId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("HkId")]
|
[ForeignKey("HkId")]
|
||||||
public virtual WineOrigin Origin { get; private set; } = null!;
|
public virtual WineOrigin Origin { get; init; } = null!;
|
||||||
|
|
||||||
[Column("kgnr")]
|
[Column("kgnr")]
|
||||||
public int? KgNr { get; set; }
|
public int? KgNr { get; set; }
|
||||||
|
|
||||||
[ForeignKey("KgNr")]
|
[ForeignKey("KgNr")]
|
||||||
public virtual WbKg? Kg { get; private set; }
|
public virtual WbKg? Kg { get; init; }
|
||||||
|
|
||||||
[Column("rdnr")]
|
[Column("rdnr")]
|
||||||
public int? RdNr { get; set; }
|
public int? RdNr { get; set; }
|
||||||
|
|
||||||
[ForeignKey("KgNr, RdNr")]
|
[ForeignKey("KgNr, RdNr")]
|
||||||
public virtual WbRd? Rd { get; private set; }
|
public virtual WbRd? Rd { get; init; }
|
||||||
|
|
||||||
[Column("net_weight")]
|
[Column("net_weight")]
|
||||||
public bool IsNetWeight { get; set; }
|
public bool IsNetWeight { get; set; }
|
||||||
@@ -183,18 +183,18 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[InverseProperty(nameof(DeliveryPartModifier.Part))]
|
[InverseProperty(nameof(DeliveryPartModifier.Part))]
|
||||||
public virtual ICollection<DeliveryPartModifier> PartModifiers { get; private set; } = null!;
|
public virtual ICollection<DeliveryPartModifier> PartModifiers { get; init; } = null!;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public IEnumerable<Modifier> Modifiers => PartModifiers.Select(m => m.Modifier).OrderBy(m => m.Ordering);
|
public IEnumerable<Modifier> Modifiers => PartModifiers.Select(m => m.Modifier).OrderBy(m => m.Ordering);
|
||||||
|
|
||||||
[InverseProperty(nameof(PaymentDeliveryPart.DeliveryPart))]
|
[InverseProperty(nameof(PaymentDeliveryPart.DeliveryPart))]
|
||||||
public virtual PaymentDeliveryPart? Payment { get; private set; }
|
public virtual PaymentDeliveryPart? Payment { get; init; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public string OriginString => Origin.OriginString + "\n" + (Kg?.Gl != null ? $" / {Kg.Gl.Name}" : "") + (Kg != null ? $" / {Kg.AtKg.Gem.Name} / KG {Kg.AtKg.Name}" : "") + (Rd != null ? $" / Ried {Rd.Name}" : "");
|
public string OriginString => Origin.OriginString + "\n" + (Kg?.Gl != null ? $" / {Kg.Gl.Name}" : "") + (Kg != null ? $" / {Kg.AtKg.Gem.Name} / KG {Kg.AtKg.Name}" : "") + (Rd != null ? $" / Ried {Rd.Name}" : "");
|
||||||
|
|
||||||
[InverseProperty(nameof(DeliveryPartBucket.Part))]
|
[InverseProperty(nameof(DeliveryPartBucket.Part))]
|
||||||
public virtual ICollection<DeliveryPartBucket> Buckets { get; private set; } = null!;
|
public virtual ICollection<DeliveryPartBucket> Buckets { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,6 @@ namespace Elwig.Models.Entities {
|
|||||||
public int Value { get; set; }
|
public int Value { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Year, DId, DPNr")]
|
[ForeignKey("Year, DId, DPNr")]
|
||||||
public virtual DeliveryPart Part { get; private set; } = null!;
|
public virtual DeliveryPart Part { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -14,12 +14,12 @@ namespace Elwig.Models.Entities {
|
|||||||
public int DPNr { get; set; }
|
public int DPNr { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Year, DId, DPNr")]
|
[ForeignKey("Year, DId, DPNr")]
|
||||||
public virtual DeliveryPart Part { get; private set; } = null!;
|
public virtual DeliveryPart Part { get; init; } = null!;
|
||||||
|
|
||||||
[Column("modid")]
|
[Column("modid")]
|
||||||
public required string ModId { get; set; }
|
public required string ModId { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Year, ModId")]
|
[ForeignKey("Year, ModId")]
|
||||||
public virtual Modifier Modifier { get; private set; } = null!;
|
public virtual Modifier Modifier { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -72,22 +72,22 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("Year")]
|
[ForeignKey("Year")]
|
||||||
public virtual Season Season { get; private set; } = null!;
|
public virtual Season Season { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("ZwstId")]
|
[ForeignKey("ZwstId")]
|
||||||
public virtual Branch Branch { get; private set; } = null!;
|
public virtual Branch Branch { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("AttrId")]
|
[ForeignKey("AttrId")]
|
||||||
public virtual WineAttr? Attribute { get; private set; }
|
public virtual WineAttr? Attribute { get; init; }
|
||||||
|
|
||||||
[ForeignKey("CultId")]
|
[ForeignKey("CultId")]
|
||||||
public virtual WineCult? Cultivation { get; private set; }
|
public virtual WineCult? Cultivation { get; init; }
|
||||||
|
|
||||||
[InverseProperty(nameof(DeliveryScheduleWineVar.Schedule))]
|
[InverseProperty(nameof(DeliveryScheduleWineVar.Schedule))]
|
||||||
public virtual ICollection<DeliveryScheduleWineVar> Varieties { get; private set; } = null!;
|
public virtual ICollection<DeliveryScheduleWineVar> Varieties { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(DeliveryAncmt.Schedule))]
|
[InverseProperty(nameof(DeliveryAncmt.Schedule))]
|
||||||
public virtual ICollection<DeliveryAncmt> Announcements { get; private set; } = null!;
|
public virtual ICollection<DeliveryAncmt> Announcements { get; init; } = null!;
|
||||||
|
|
||||||
public int SearchScore(IEnumerable<string> keywords) {
|
public int SearchScore(IEnumerable<string> keywords) {
|
||||||
return Utils.GetSearchScore([Description], keywords);
|
return Utils.GetSearchScore([Description], keywords);
|
||||||
|
|||||||
@@ -18,9 +18,9 @@ namespace Elwig.Models.Entities {
|
|||||||
public int Priority { get; set; }
|
public int Priority { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Year, DsNr")]
|
[ForeignKey("Year, DsNr")]
|
||||||
public virtual DeliverySchedule Schedule { get; private set; } = null!;
|
public virtual DeliverySchedule Schedule { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("SortId")]
|
[ForeignKey("SortId")]
|
||||||
public virtual WineVar Variety { get; private set; } = null!;
|
public virtual WineVar Variety { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -133,10 +133,10 @@ namespace Elwig.Models.Entities {
|
|||||||
public int CountryNum { get; set; }
|
public int CountryNum { get; set; }
|
||||||
|
|
||||||
[Column("postal_dest")]
|
[Column("postal_dest")]
|
||||||
public string PostalDestId { get; set; } = null!;
|
public required string PostalDestId { get; set; }
|
||||||
|
|
||||||
[Column("address")]
|
[Column("address")]
|
||||||
public string Address { get; set; } = null!;
|
public required string Address { get; set; }
|
||||||
|
|
||||||
[Column("default_kgnr")]
|
[Column("default_kgnr")]
|
||||||
public int? DefaultKgNr { get; set; }
|
public int? DefaultKgNr { get; set; }
|
||||||
@@ -151,16 +151,16 @@ namespace Elwig.Models.Entities {
|
|||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
[ForeignKey("PredecessorMgNr")]
|
[ForeignKey("PredecessorMgNr")]
|
||||||
public virtual Member? Predecessor { get; private set; }
|
public virtual Member? Predecessor { get; init; }
|
||||||
|
|
||||||
[ForeignKey("CountryNum")]
|
[ForeignKey("CountryNum")]
|
||||||
public virtual Country Country { get; private set; } = null!;
|
public virtual Country Country { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("CountryNum, PostalDestId")]
|
[ForeignKey("CountryNum, PostalDestId")]
|
||||||
public virtual PostalDest PostalDest { get; private set; } = null!;
|
public virtual PostalDest PostalDest { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("DefaultKgNr")]
|
[ForeignKey("DefaultKgNr")]
|
||||||
public virtual WbKg? DefaultWbKg { get; private set; }
|
public virtual WbKg? DefaultWbKg { get; init; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public AT_Kg? DefaultKg => DefaultWbKg?.AtKg;
|
public AT_Kg? DefaultKg => DefaultWbKg?.AtKg;
|
||||||
|
|
||||||
@@ -197,37 +197,37 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("ZwstId")]
|
[ForeignKey("ZwstId")]
|
||||||
public virtual Branch? Branch { get; private set; }
|
public virtual Branch? Branch { get; init; }
|
||||||
|
|
||||||
[InverseProperty(nameof(AreaCmt.Member))]
|
[InverseProperty(nameof(AreaCmt.Member))]
|
||||||
public virtual ICollection<AreaCmt> AreaCommitments { get; private set; } = null!;
|
public virtual ICollection<AreaCmt> AreaCommitments { get; init; } = null!;
|
||||||
|
|
||||||
public IQueryable<AreaCmt> ActiveAreaCommitments(AppDbContext ctx, int? year = null) {
|
public IQueryable<AreaCmt> ActiveAreaCommitments(AppDbContext ctx, int? year = null) {
|
||||||
return ctx.AreaCommitments.Where(c => c.MgNr == MgNr).Where(Utils.ActiveAreaCommitments(year ?? Utils.CurrentYear));
|
return ctx.AreaCommitments.Where(c => c.MgNr == MgNr).Where(Utils.ActiveAreaCommitments(year ?? Utils.CurrentYear));
|
||||||
}
|
}
|
||||||
|
|
||||||
[InverseProperty(nameof(BillingAddr.Member))]
|
[InverseProperty(nameof(BillingAddr.Member))]
|
||||||
public virtual BillingAddr? BillingAddress { get; private set; }
|
public virtual BillingAddr? BillingAddress { get; init; }
|
||||||
|
|
||||||
[InverseProperty(nameof(DeliveryAncmt.Member))]
|
[InverseProperty(nameof(DeliveryAncmt.Member))]
|
||||||
public virtual ICollection<DeliveryAncmt> Announcements { get; private set; } = null!;
|
public virtual ICollection<DeliveryAncmt> Announcements { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(MemberHistory.FromMember))]
|
[InverseProperty(nameof(MemberHistory.FromMember))]
|
||||||
public virtual ICollection<MemberHistory> HistoryFrom { get; private set; } = null!;
|
public virtual ICollection<MemberHistory> HistoryFrom { get; init; } = null!;
|
||||||
[InverseProperty(nameof(MemberHistory.ToMember))]
|
[InverseProperty(nameof(MemberHistory.ToMember))]
|
||||||
public virtual ICollection<MemberHistory> HistoryTo { get; private set; } = null!;
|
public virtual ICollection<MemberHistory> HistoryTo { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Delivery.Member))]
|
[InverseProperty(nameof(Delivery.Member))]
|
||||||
public virtual ICollection<Delivery> Deliveries { get; private set; } = null!;
|
public virtual ICollection<Delivery> Deliveries { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Credit.Member))]
|
[InverseProperty(nameof(Credit.Member))]
|
||||||
public virtual ICollection<Credit> Credits { get; private set; } = null!;
|
public virtual ICollection<Credit> Credits { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(MemberTelNr.Member))]
|
[InverseProperty(nameof(MemberTelNr.Member))]
|
||||||
public virtual ICollection<MemberTelNr> TelephoneNumbers { get; private set; } = null!;
|
public virtual ICollection<MemberTelNr> TelephoneNumbers { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(MemberEmailAddr.Member))]
|
[InverseProperty(nameof(MemberEmailAddr.Member))]
|
||||||
public virtual ICollection<MemberEmailAddr> EmailAddresses { get; private set; } = null!;
|
public virtual ICollection<MemberEmailAddr> EmailAddresses { get; init; } = null!;
|
||||||
|
|
||||||
public string FullAddress => $"{Address}, {PostalDest.AtPlz?.Plz} {PostalDest.AtPlz?.Ort.Name}";
|
public string FullAddress => $"{Address}, {PostalDest.AtPlz?.Plz} {PostalDest.AtPlz?.Ort.Name}";
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,6 @@ namespace Elwig.Models.Entities {
|
|||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,10 +104,10 @@ namespace Elwig.Models.Entities {
|
|||||||
|
|
||||||
public string FormatReasonPhrase(int mgnr) {
|
public string FormatReasonPhrase(int mgnr) {
|
||||||
if (Reason == REASON_TRANSFER) {
|
if (Reason == REASON_TRANSFER) {
|
||||||
if (FromMgNr == mgnr) {
|
if (ToMgNr == mgnr) {
|
||||||
return $"{ReasonPretty} an {ToMember?.FullAdministrativeName ?? "Nachfolger"}" + (Comment != null ? $", {Comment}" : "");
|
|
||||||
} else if (ToMgNr == mgnr) {
|
|
||||||
return $"{ReasonPretty} von {FromMember?.FullAdministrativeName ?? "Vorgänger"}" + (Comment != null ? $", {Comment}" : "");
|
return $"{ReasonPretty} von {FromMember?.FullAdministrativeName ?? "Vorgänger"}" + (Comment != null ? $", {Comment}" : "");
|
||||||
|
} else if (FromMgNr == mgnr) {
|
||||||
|
return $"{ReasonPretty} an {ToMember?.FullAdministrativeName ?? "Nachfolger"}" + (Comment != null ? $", {Comment}" : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return ReasonPretty + (Comment != null ? $", {Comment}" : "");
|
return ReasonPretty + (Comment != null ? $", {Comment}" : "");
|
||||||
@@ -119,12 +119,12 @@ namespace Elwig.Models.Entities {
|
|||||||
public string PoVReasonPhrase => FormatReasonPhrase(PoVMgNr ?? 0);
|
public string PoVReasonPhrase => FormatReasonPhrase(PoVMgNr ?? 0);
|
||||||
|
|
||||||
[ForeignKey("FromMgNr")]
|
[ForeignKey("FromMgNr")]
|
||||||
public virtual Member? FromMember { get; private set; } = null!;
|
public virtual Member? FromMember { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("ToMgNr")]
|
[ForeignKey("ToMgNr")]
|
||||||
public virtual Member? ToMember { get; private set; } = null!;
|
public virtual Member? ToMember { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("CurrencyCode")]
|
[ForeignKey("CurrencyCode")]
|
||||||
public virtual Currency Currency { get; private set; } = null!;
|
public virtual Currency Currency { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -20,6 +20,6 @@ namespace Elwig.Models.Entities {
|
|||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -42,7 +42,7 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("Year")]
|
[ForeignKey("Year")]
|
||||||
public virtual Season Season { get; private set; } = null!;
|
public virtual Season Season { get; init; } = null!;
|
||||||
|
|
||||||
public string ValueStr =>
|
public string ValueStr =>
|
||||||
(Abs != null) ? $"{Utils.GetSign(Abs.Value)}{Math.Abs(Abs.Value).ToString("0." + string.Concat(Enumerable.Repeat('0', Season.Precision)))}\u00a0{Season.Currency.Symbol}/kg" :
|
(Abs != null) ? $"{Utils.GetSign(Abs.Value)}{Math.Abs(Abs.Value).ToString("0." + string.Concat(Enumerable.Repeat('0', Season.Precision)))}\u00a0{Season.Currency.Symbol}/kg" :
|
||||||
|
|||||||
@@ -42,9 +42,9 @@ namespace Elwig.Models.Entities {
|
|||||||
public string? Comment { get; set; }
|
public string? Comment { get; set; }
|
||||||
|
|
||||||
[ForeignKey("Year")]
|
[ForeignKey("Year")]
|
||||||
public virtual Season Season { get; private set; } = null!;
|
public virtual Season Season { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -41,14 +41,14 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Column("amount")]
|
[Column("amount")]
|
||||||
public long AmountValue { get; private set; }
|
public long AmountValue { get; init; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal Amount => Variant.Season.DecFromDb(AmountValue);
|
public decimal Amount => Variant.Season.DecFromDb(AmountValue);
|
||||||
|
|
||||||
[ForeignKey("Year, AvNr")]
|
[ForeignKey("Year, AvNr")]
|
||||||
public virtual PaymentVar Variant { get; private set; } = null!;
|
public virtual PaymentVar Variant { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("Year, DId, DPNr")]
|
[ForeignKey("Year, DId, DPNr")]
|
||||||
public virtual DeliveryPart DeliveryPart { get; private set; } = null!;
|
public virtual DeliveryPart DeliveryPart { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -36,9 +36,9 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("Year, AvNr")]
|
[ForeignKey("Year, AvNr")]
|
||||||
public virtual PaymentVar Variant { get; private set; } = null!;
|
public virtual PaymentVar Variant { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("Year, DId, DPNr")]
|
[ForeignKey("Year, DId, DPNr")]
|
||||||
public virtual DeliveryPart DeliveryPart { get; private set; } = null!;
|
public virtual DeliveryPart DeliveryPart { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -38,17 +38,17 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[Column("amount")]
|
[Column("amount")]
|
||||||
public long AmountValue { get; private set; }
|
public long AmountValue { get; init; }
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public decimal Amount => Variant.Season.DecFromDb(AmountValue);
|
public decimal Amount => Variant.Season.DecFromDb(AmountValue);
|
||||||
|
|
||||||
[ForeignKey("Year, AvNr")]
|
[ForeignKey("Year, AvNr")]
|
||||||
public virtual PaymentVar Variant { get; private set; } = null!;
|
public virtual PaymentVar Variant { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("MgNr")]
|
[ForeignKey("MgNr")]
|
||||||
public virtual Member Member { get; private set; } = null!;
|
public virtual Member Member { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Credit.Payment))]
|
[InverseProperty(nameof(Credit.Payment))]
|
||||||
public virtual Credit? Credit { get; private set; }
|
public virtual Credit? Credit { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -78,15 +78,15 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("Year")]
|
[ForeignKey("Year")]
|
||||||
public virtual Season Season { get; private set; } = null!;
|
public virtual Season Season { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(PaymentMember.Variant))]
|
[InverseProperty(nameof(PaymentMember.Variant))]
|
||||||
public virtual ICollection<PaymentMember> MemberPayments { get; private set; } = null!;
|
public virtual ICollection<PaymentMember> MemberPayments { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(PaymentDeliveryPart.Variant))]
|
[InverseProperty(nameof(PaymentDeliveryPart.Variant))]
|
||||||
public virtual ICollection<PaymentDeliveryPart> DeliveryPartPayments { get; private set; } = null!;
|
public virtual ICollection<PaymentDeliveryPart> DeliveryPartPayments { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Credit.Variant))]
|
[InverseProperty(nameof(Credit.Variant))]
|
||||||
public virtual ICollection<Credit> Credits { get; private set; } = null!;
|
public virtual ICollection<Credit> Credits { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -5,15 +5,15 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("postal_dest"), PrimaryKey("CountryNum", "Id")]
|
[Table("postal_dest"), PrimaryKey("CountryNum", "Id")]
|
||||||
public class PostalDest {
|
public class PostalDest {
|
||||||
[Column("country")]
|
[Column("country")]
|
||||||
public int CountryNum { get; private set; }
|
public int CountryNum { get; init; }
|
||||||
|
|
||||||
[Column("id")]
|
[Column("id")]
|
||||||
public string Id { get; private set; } = null!;
|
public required string Id { get; init; }
|
||||||
|
|
||||||
[ForeignKey("CountryNum")]
|
[ForeignKey("CountryNum")]
|
||||||
public virtual Country Country { get; private set; } = null!;
|
public virtual Country Country { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("Id")]
|
[ForeignKey("Id")]
|
||||||
public virtual AT_PlzDest? AtPlz { get; private set; }
|
public virtual AT_PlzDest? AtPlz { get; init; }
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -123,16 +123,16 @@ namespace Elwig.Models.Entities {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[ForeignKey("CurrencyCode")]
|
[ForeignKey("CurrencyCode")]
|
||||||
public virtual Currency Currency { get; private set; } = null!;
|
public virtual Currency Currency { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Modifier.Season))]
|
[InverseProperty(nameof(Modifier.Season))]
|
||||||
public virtual ICollection<Modifier> Modifiers { get; private set; } = null!;
|
public virtual ICollection<Modifier> Modifiers { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(PaymentVar.Season))]
|
[InverseProperty(nameof(PaymentVar.Season))]
|
||||||
public virtual ICollection<PaymentVar> PaymentVariants { get; private set; } = null!;
|
public virtual ICollection<PaymentVar> PaymentVariants { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Delivery.Season))]
|
[InverseProperty(nameof(Delivery.Season))]
|
||||||
public virtual ICollection<Delivery> Deliveries { get; private set; } = null!;
|
public virtual ICollection<Delivery> Deliveries { get; init; } = null!;
|
||||||
|
|
||||||
public decimal DecFromDb(long value) {
|
public decimal DecFromDb(long value) {
|
||||||
return Utils.DecFromDb(value, Precision);
|
return Utils.DecFromDb(value, Precision);
|
||||||
|
|||||||
@@ -5,15 +5,15 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("wb_gem"), PrimaryKey("Gkz")]
|
[Table("wb_gem"), PrimaryKey("Gkz")]
|
||||||
public class WbGem {
|
public class WbGem {
|
||||||
[Column("gkz")]
|
[Column("gkz")]
|
||||||
public int Gkz { get; private set; }
|
public int Gkz { get; init; }
|
||||||
|
|
||||||
[Column("hkid")]
|
[Column("hkid")]
|
||||||
public string HkId { get; private set; } = null!;
|
public required string HkId { get; init; }
|
||||||
|
|
||||||
[ForeignKey("Gkz")]
|
[ForeignKey("Gkz")]
|
||||||
public virtual AT_Gem AtGem { get; private set; } = null!;
|
public virtual AT_Gem AtGem { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("HkId")]
|
[ForeignKey("HkId")]
|
||||||
public virtual WineOrigin Origin { get; private set; } = null!;
|
public virtual WineOrigin Origin { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -9,9 +9,9 @@ namespace Elwig.Models.Entities {
|
|||||||
public int GlNr { get; set; }
|
public int GlNr { get; set; }
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; set; } = null!;
|
public required string Name { get; set; }
|
||||||
|
|
||||||
[InverseProperty(nameof(WbKg.Gl))]
|
[InverseProperty(nameof(WbKg.Gl))]
|
||||||
public virtual ICollection<WbKg> Kgs { get; private set; } = null!;
|
public virtual ICollection<WbKg> Kgs { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -12,16 +12,16 @@ namespace Elwig.Models.Entities {
|
|||||||
public int? GlNr { get; set; }
|
public int? GlNr { get; set; }
|
||||||
|
|
||||||
[ForeignKey("KgNr")]
|
[ForeignKey("KgNr")]
|
||||||
public virtual AT_Kg AtKg { get; private set; } = null!;
|
public virtual AT_Kg AtKg { get; init; } = null!;
|
||||||
|
|
||||||
[ForeignKey("GlNr")]
|
[ForeignKey("GlNr")]
|
||||||
public virtual WbGl? Gl { get; private set; } = null!;
|
public virtual WbGl? Gl { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(WbRd.Kg))]
|
[InverseProperty(nameof(WbRd.Kg))]
|
||||||
public virtual ICollection<WbRd> Rds { get; private set; } = null!;
|
public virtual ICollection<WbRd> Rds { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Member.DefaultWbKg))]
|
[InverseProperty(nameof(Member.DefaultWbKg))]
|
||||||
public virtual ICollection<Member> Members { get; private set; } = null!;
|
public virtual ICollection<Member> Members { get; init; } = null!;
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public WbGem Gem => AtKg.Gem.WbGem!;
|
public WbGem Gem => AtKg.Gem.WbGem!;
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ namespace Elwig.Models.Entities {
|
|||||||
public required string Name { get; set; }
|
public required string Name { get; set; }
|
||||||
|
|
||||||
[ForeignKey("KgNr")]
|
[ForeignKey("KgNr")]
|
||||||
public virtual WbKg Kg { get; private set; } = null!;
|
public virtual WbKg Kg { get; init; } = null!;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -23,6 +23,16 @@ namespace Elwig.Models.Entities {
|
|||||||
[Column("fill_lower")]
|
[Column("fill_lower")]
|
||||||
public int FillLower { get; set; }
|
public int FillLower { get; set; }
|
||||||
|
|
||||||
|
[Column("min_qualid")]
|
||||||
|
public string? MinQualId { get; set; }
|
||||||
|
[ForeignKey("MinQualId")]
|
||||||
|
public virtual WineQualLevel MinQualityLevel { get; init; } = null!;
|
||||||
|
|
||||||
|
[Column("max_qualid")]
|
||||||
|
public string? MaxQualId { get; set; }
|
||||||
|
[ForeignKey("MaxQualId")]
|
||||||
|
public virtual WineQualLevel MaxQualityLevel { get; init; } = null!;
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,27 +9,27 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("wine_origin"), PrimaryKey("HkId"), Index("Name", IsUnique = true)]
|
[Table("wine_origin"), PrimaryKey("HkId"), Index("Name", IsUnique = true)]
|
||||||
public class WineOrigin {
|
public class WineOrigin {
|
||||||
[Column("hkid")]
|
[Column("hkid")]
|
||||||
public string HkId { get; private set; } = null!;
|
public required string HkId { get; init; }
|
||||||
|
|
||||||
[Column("parent_hkid")]
|
[Column("parent_hkid")]
|
||||||
public string? ParentHkId { get; private set; }
|
public string? ParentHkId { get; init; }
|
||||||
|
|
||||||
[ForeignKey("ParentHkId")]
|
[ForeignKey("ParentHkId")]
|
||||||
public virtual WineOrigin? Parent { get; private set; }
|
public virtual WineOrigin? Parent { get; init; }
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
[Column("blnr")]
|
[Column("blnr")]
|
||||||
public int? BlNr { get; private set; }
|
public int? BlNr { get; init; }
|
||||||
|
|
||||||
[InverseProperty(nameof(WbGem.Origin))]
|
[InverseProperty(nameof(WbGem.Origin))]
|
||||||
public virtual ICollection<WbGem> Gems { get; private set; } = null!;
|
public virtual ICollection<WbGem> Gems { get; init; } = null!;
|
||||||
|
|
||||||
[InverseProperty(nameof(Parent))]
|
[InverseProperty(nameof(Parent))]
|
||||||
public virtual ICollection<WineOrigin> RealChildren { get; private set; } = null!;
|
public virtual ICollection<WineOrigin> RealChildren { get; init; } = null!;
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public List<WineOrigin> Children { get; private set; } = [];
|
public List<WineOrigin> Children { get; init; } = [];
|
||||||
|
|
||||||
public int Level => (Parent?.Level + 1) ?? 0;
|
public int Level => (Parent?.Level + 1) ?? 0;
|
||||||
|
|
||||||
|
|||||||
@@ -7,22 +7,22 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("wine_quality_level"), PrimaryKey("QualId")]
|
[Table("wine_quality_level"), PrimaryKey("QualId")]
|
||||||
public class WineQualLevel : IEquatable<WineQualLevel> {
|
public class WineQualLevel : IEquatable<WineQualLevel> {
|
||||||
[Column("qualid")]
|
[Column("qualid")]
|
||||||
public string QualId { get; private set; } = null!;
|
public required string QualId { get; init; }
|
||||||
|
|
||||||
[Column("origin_level")]
|
[Column("origin_level")]
|
||||||
public int? OriginLevel { get; private set; }
|
public int? OriginLevel { get; init; }
|
||||||
|
|
||||||
[Column("predicate")]
|
[Column("predicate")]
|
||||||
public bool IsPredicate { get; private set; }
|
public bool IsPredicate { get; init; }
|
||||||
|
|
||||||
[Column("min_kmw")]
|
[Column("min_kmw")]
|
||||||
public double? MinKmw { get; private set; }
|
public double? MinKmw { get; init; }
|
||||||
|
|
||||||
[NotMapped]
|
[NotMapped]
|
||||||
public double? MinOe => MinKmw != null ? Utils.KmwToOe((double)MinKmw) : null;
|
public double? MinOe => MinKmw != null ? Utils.KmwToOe((double)MinKmw) : null;
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
public string MinKmwStr => (MinKmw == null) ? "" : $"(mind. {MinKmw:#.0}°)";
|
public string MinKmwStr => (MinKmw == null) ? "" : $"(mind. {MinKmw:#.0}°)";
|
||||||
|
|
||||||
|
|||||||
@@ -6,22 +6,22 @@ namespace Elwig.Models.Entities {
|
|||||||
[Table("wine_variety"), PrimaryKey("SortId")]
|
[Table("wine_variety"), PrimaryKey("SortId")]
|
||||||
public class WineVar {
|
public class WineVar {
|
||||||
[Column("sortid")]
|
[Column("sortid")]
|
||||||
public string SortId { get; private set; } = null!;
|
public required string SortId { get; init; }
|
||||||
|
|
||||||
[Column("type")]
|
[Column("type")]
|
||||||
public string Type { get; private set; } = null!;
|
public required string Type { get; init; }
|
||||||
|
|
||||||
[Column("max_qualid")]
|
[Column("max_qualid")]
|
||||||
public string MaxQualId { get; private set; } = null!;
|
public required string MaxQualId { get; init; }
|
||||||
|
|
||||||
[ForeignKey("MaxQualId")]
|
[ForeignKey("MaxQualId")]
|
||||||
public virtual WineQualLevel MaxQualityLevel { get; private set; } = null!;
|
public virtual WineQualLevel MaxQualityLevel { get; init; } = null!;
|
||||||
|
|
||||||
[Column("name")]
|
[Column("name")]
|
||||||
public string Name { get; private set; } = null!;
|
public required string Name { get; init; }
|
||||||
|
|
||||||
[Column("comment")]
|
[Column("comment")]
|
||||||
public string? Comment { get; private set; }
|
public string? Comment { get; init; }
|
||||||
|
|
||||||
public string SortIdFormat => IsQuw ? SortId : $"({SortId})";
|
public string SortIdFormat => IsQuw ? SortId : $"({SortId})";
|
||||||
public string CommentFormat => (Comment != null) ? $" ({Comment})" : "";
|
public string CommentFormat => (Comment != null) ? $" ({Comment})" : "";
|
||||||
@@ -31,14 +31,6 @@ namespace Elwig.Models.Entities {
|
|||||||
public bool IsQuw => MaxQualId == "QUW";
|
public bool IsQuw => MaxQualId == "QUW";
|
||||||
public Brush? Color => IsWhite ? Brushes.DarkGreen : IsRed ? Brushes.DarkRed : null;
|
public Brush? Color => IsWhite ? Brushes.DarkGreen : IsRed ? Brushes.DarkRed : null;
|
||||||
|
|
||||||
public WineVar() { }
|
|
||||||
|
|
||||||
public WineVar(string sortId, string name) {
|
|
||||||
SortId = sortId;
|
|
||||||
Name = name;
|
|
||||||
MaxQualId = "QUW";
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string ToString() {
|
public override string ToString() {
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -9,7 +9,7 @@ https://go.microsoft.com/fwlink/?LinkID=208121.
|
|||||||
<PublishDir>bin\Publish</PublishDir>
|
<PublishDir>bin\Publish</PublishDir>
|
||||||
<PublishProtocol>FileSystem</PublishProtocol>
|
<PublishProtocol>FileSystem</PublishProtocol>
|
||||||
<_TargetId>Folder</_TargetId>
|
<_TargetId>Folder</_TargetId>
|
||||||
<TargetFramework>net10.0-windows</TargetFramework>
|
<TargetFramework>net11.0-windows</TargetFramework>
|
||||||
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
<RuntimeIdentifier>win-x64</RuntimeIdentifier>
|
||||||
<SelfContained>true</SelfContained>
|
<SelfContained>true</SelfContained>
|
||||||
<PublishSingleFile>false</PublishSingleFile>
|
<PublishSingleFile>false</PublishSingleFile>
|
||||||
|
|||||||
@@ -92,13 +92,13 @@
|
|||||||
{"$ref": "#/definitions/curve_data"}
|
{"$ref": "#/definitions/curve_data"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"geb": {
|
"ctrd": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{"type": "number"},
|
{"type": "number"},
|
||||||
{"$ref": "#/definitions/curve_data"}
|
{"$ref": "#/definitions/curve_data"}
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"contracted": {
|
"geb": {
|
||||||
"anyOf": [
|
"anyOf": [
|
||||||
{"type": "number"},
|
{"type": "number"},
|
||||||
{"$ref": "#/definitions/curve_data"}
|
{"$ref": "#/definitions/curve_data"}
|
||||||
|
|||||||
@@ -52,8 +52,8 @@ UPDATE client_parameter SET param = 'CLIENT_ORGANIC_AUTHORITYCODE' WHERE param =
|
|||||||
UPDATE member_telephone_number SET comment = NULL WHERE comment = '';
|
UPDATE member_telephone_number SET comment = NULL WHERE comment = '';
|
||||||
UPDATE member_email_address SET comment = NULL WHERE comment = '';
|
UPDATE member_email_address SET comment = NULL WHERE comment = '';
|
||||||
|
|
||||||
UPDATE member SET address = 'Untere Weißgerberstraße' WHERE address = 'U. Weißgasse Straße';
|
UPDATE member SET address = CONCAT('Untere Weißgerberstraße ', SUBSTR(address, 21)) WHERE address LIKE 'U. Weißgasse Straße %';
|
||||||
UPDATE member SET address = 'Edgar-Penzig-Franz-Straße' WHERE address = 'Edgar-Penzing-Franz-Straße';
|
UPDATE member SET address = CONCAT('Edgar-Penzig-Franz-Straße ', SUBSTR(address, 28)) WHERE address LIKE 'Edgar-Penzing-Franz-Straße %';
|
||||||
|
|
||||||
UPDATE member
|
UPDATE member
|
||||||
SET address = NORMALIZE_ADDRESS(address, (SELECT o.name FROM AT_plz_dest p JOIN AT_ort o ON o.okz = p.okz WHERE p.id = member.postal_dest))
|
SET address = NORMALIZE_ADDRESS(address, (SELECT o.name FROM AT_plz_dest p JOIN AT_ort o ON o.okz = p.okz WHERE p.id = member.postal_dest))
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
-- schema version 42 to 43
|
||||||
|
|
||||||
|
ALTER TABLE wine_attribute ADD COLUMN min_qualid TEXT DEFAULT NULL;
|
||||||
|
ALTER TABLE wine_attribute ADD COLUMN max_qualid TEXT DEFAULT NULL;
|
||||||
|
|
||||||
|
UPDATE wine_attribute SET min_qualid = 'KAB', max_qualid = 'KAB' WHERE name LIKE '%Kabinett%';
|
||||||
|
UPDATE wine_attribute SET min_qualid = 'QUW' WHERE name LIKE '%DAC%';
|
||||||
|
UPDATE wine_attribute SET max_qualid = 'RSW' WHERE name LIKE '%wei%gepresst%' OR name LIKE '%saft%';
|
||||||
|
|
||||||
|
PRAGMA writable_schema = ON;
|
||||||
|
|
||||||
|
UPDATE sqlite_schema SET sql = REPLACE(sql, '
|
||||||
|
) STRICT', ',
|
||||||
|
CONSTRAINT fk_wine_attribute_wine_quality_level_min FOREIGN KEY (min_qualid) REFERENCES wine_quality_level (qualid)
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
ON DELETE RESTRICT,
|
||||||
|
CONSTRAINT fk_wine_attribute_wine_quality_level_max FOREIGN KEY (max_qualid) REFERENCES wine_quality_level (qualid)
|
||||||
|
ON UPDATE CASCADE
|
||||||
|
ON DELETE RESTRICT
|
||||||
|
) STRICT')
|
||||||
|
WHERE type = 'table' AND name = 'wine_attribute';
|
||||||
|
|
||||||
|
PRAGMA schema_version = 4201;
|
||||||
|
PRAGMA writable_schema = OFF;
|
||||||
@@ -28,7 +28,7 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public static async Task BackupDatabase() {
|
public static async Task BackupDatabase() {
|
||||||
await Database.ExportSql(Path.Combine(App.Config.BackupPath, $"{File.GetLastWriteTime(App.Config.DatabaseFile):yyyy-MM-dd_HH-mm-ss}.sql.zip"), true);
|
await Database.ExportSql(Path.Combine(App.Config.BackupPath, $"{File.GetLastWriteTime(App.Config.DatabaseFile):yyyy-MM-dd_HH-mm-ss}.sql.zip"), true, App.Config.BackupEncryptionKey);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void PruneBackups() {
|
public static void PruneBackups() {
|
||||||
@@ -122,7 +122,7 @@ namespace Elwig.Services {
|
|||||||
if (!InteractionService.AskContinue("Datenbank wiederherstellen", "Soll die Datenbank wirklich unwiederruflich durch die wiederhergestellte Version ersetzt werden?"))
|
if (!InteractionService.AskContinue("Datenbank wiederherstellen", "Soll die Datenbank wirklich unwiederruflich durch die wiederhergestellte Version ersetzt werden?"))
|
||||||
return;
|
return;
|
||||||
Mouse.OverrideCursor = Cursors.Wait;
|
Mouse.OverrideCursor = Cursors.Wait;
|
||||||
await App.ReplaceDatabase(d.FileName);
|
await App.ReplaceDatabase(d.FileName, App.Config.BackupDecryptionKeys);
|
||||||
}
|
}
|
||||||
} catch (Exception exc) {
|
} catch (Exception exc) {
|
||||||
InteractionService.ShowException(exc);
|
InteractionService.ShowException(exc);
|
||||||
|
|||||||
@@ -833,7 +833,7 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
} else if (mode == ExportMode.Upload && App.Config.SyncUrl != null) {
|
} else if (mode == ExportMode.Upload && App.Config.SyncUrl != null) {
|
||||||
await Utils.RunForeground(async () => {
|
await Utils.RunForeground(async () => {
|
||||||
await SyncService.Upload(App.Config.SyncUrl, App.Config.SyncUrl, App.Config.SyncPassword, query, filterNames);
|
await SyncService.Upload(App.Config.SyncUrl, App.Config.SyncUrl, App.Config.SyncPassword, query, filterNames, App.Config.SyncEncryptionKey);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await Utils.RunForeground(async () => {
|
await Utils.RunForeground(async () => {
|
||||||
|
|||||||
@@ -2,19 +2,20 @@ using Microsoft.Data.Sqlite;
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Text.RegularExpressions;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
|
|
||||||
namespace Elwig.Services {
|
namespace Elwig.Services {
|
||||||
public static class InteractionService {
|
public static class InteractionService {
|
||||||
|
|
||||||
public static Func<string, string, string, string?>? Override;
|
public static Func<string, string, string, string?>? Override { get; set; }
|
||||||
public static Action<string, string>? NextInformation;
|
public static Action<string, string>? NextInformation { get; set; }
|
||||||
public static Action<string, string>? NextWarning;
|
public static Action<string, string>? NextWarning { get; set; }
|
||||||
public static Action<string, string>? NextError;
|
public static Action<string, string>? NextError { get; set; }
|
||||||
public static Func<string, string, bool>? NextContinue;
|
public static Func<string, string, bool>? NextContinue { get; set; }
|
||||||
public static Func<string, string, bool>? NextConfirmation;
|
public static Func<string, string, bool>? NextConfirmation { get; set; }
|
||||||
public static Func<string, string, bool>? NextQuestion;
|
public static Func<string, string, bool>? NextQuestion { get; set; }
|
||||||
public static Func<string, string, string?>? NextSave;
|
public static Func<string, string, string?>? NextSave { get; set; }
|
||||||
|
|
||||||
public static readonly Dictionary<string, string> ExtensionFilters = new() {
|
public static readonly Dictionary<string, string> ExtensionFilters = new() {
|
||||||
["pdf"] = "PDF-Datei (*.pdf)|*.pdf",
|
["pdf"] = "PDF-Datei (*.pdf)|*.pdf",
|
||||||
@@ -147,6 +148,10 @@ namespace Elwig.Services {
|
|||||||
text += exc.Message + (showExcType ? $" ({exc.GetType().Name})" : "");
|
text += exc.Message + (showExcType ? $" ({exc.GetType().Name})" : "");
|
||||||
if (exc.InnerException != null) text += "\n\n" + exc.InnerException.Message;
|
if (exc.InnerException != null) text += "\n\n" + exc.InnerException.Message;
|
||||||
}
|
}
|
||||||
|
if (App.Config.Debug && exc.StackTrace != null) {
|
||||||
|
var m = Regex.Match(exc.StackTrace, @"\\([^:\\]*):line ([0-9]+)");
|
||||||
|
if (m != null) text += "\n\n" + m.Groups[1] + ": line " + m.Groups[2];
|
||||||
|
}
|
||||||
if (isError) {
|
if (isError) {
|
||||||
ShowError(title, text);
|
ShowError(title, text);
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -1,5 +1,7 @@
|
|||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
|
using Elwig.Helpers.Export;
|
||||||
using Elwig.Models;
|
using Elwig.Models;
|
||||||
|
using Elwig.Models.Dtos;
|
||||||
using Elwig.Models.Entities;
|
using Elwig.Models.Entities;
|
||||||
using Elwig.ViewModels;
|
using Elwig.ViewModels;
|
||||||
using Microsoft.EntityFrameworkCore;
|
using Microsoft.EntityFrameworkCore;
|
||||||
@@ -10,6 +12,10 @@ using System.Threading.Tasks;
|
|||||||
namespace Elwig.Services {
|
namespace Elwig.Services {
|
||||||
public static class MemberBusinessSharesService {
|
public static class MemberBusinessSharesService {
|
||||||
|
|
||||||
|
public enum ExportSubject {
|
||||||
|
Pending,
|
||||||
|
};
|
||||||
|
|
||||||
public static async Task InitInputs(this MemberBusinessSharesViewModel vm) {
|
public static async Task InitInputs(this MemberBusinessSharesViewModel vm) {
|
||||||
using var ctx = new AppDbContext();
|
using var ctx = new AppDbContext();
|
||||||
vm.DateNoticeString = $"{DateTime.Today:dd.MM.yyyy}";
|
vm.DateNoticeString = $"{DateTime.Today:dd.MM.yyyy}";
|
||||||
@@ -97,5 +103,19 @@ namespace Elwig.Services {
|
|||||||
await tx.CommitAsync();
|
await tx.CommitAsync();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static async Task GenerateMemberMovements(ExportSubject subject, ExportMode mode) {
|
||||||
|
var today = DateTime.Today;
|
||||||
|
var filename = InteractionService.SaveFile($"Ausstehende Mitgl.-Bewegungen {today:dd.MM.yyyy}", $"MitglBewegungen_{today:yyyy-MM-dd}", "ods");
|
||||||
|
if (filename == null)
|
||||||
|
return;
|
||||||
|
await Utils.RunForeground(async () => {
|
||||||
|
using var ctx = new AppDbContext();
|
||||||
|
var hist = await ctx.MemberHistory.Where(h => !h.CompanyHasSigned).ToListAsync();
|
||||||
|
var data = MemberMovementData.FromMemberHistory($"Ausstehend ({today:dd.MM.yyyy})", hist, await ctx.GetMemberHistory());
|
||||||
|
using var ods = new OdsFile(filename);
|
||||||
|
await ods.AddTable(data);
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -172,8 +172,7 @@ namespace Elwig.Services {
|
|||||||
vm.StatusAreaCommitmentToolTip = null;
|
vm.StatusAreaCommitmentToolTip = null;
|
||||||
|
|
||||||
Utils.RunBackground("Mitgliederdaten laden", async () => {
|
Utils.RunBackground("Mitgliederdaten laden", async () => {
|
||||||
if (App.MainDispatcher == null)
|
if (App.Current?.Dispatcher == null) return;
|
||||||
return;
|
|
||||||
using var ctx = new AppDbContext();
|
using var ctx = new AppDbContext();
|
||||||
|
|
||||||
var d1 = ctx.Deliveries.Where(d => d.Year == Utils.CurrentLastSeason - 1 && d.MgNr == m.MgNr);
|
var d1 = ctx.Deliveries.Where(d => d.Year == Utils.CurrentLastSeason - 1 && d.MgNr == m.MgNr);
|
||||||
@@ -197,7 +196,7 @@ namespace Elwig.Services {
|
|||||||
.GroupBy(d => d.Year)
|
.GroupBy(d => d.Year)
|
||||||
.ToDictionaryAsync(g => g.Key, g => g.Any());
|
.ToDictionaryAsync(g => g.Key, g => g.Any());
|
||||||
|
|
||||||
await App.MainDispatcher.BeginInvoke(() => {
|
await App.Current.Dispatcher.BeginInvoke(() => {
|
||||||
if (m.MgNr != vm.MgNr)
|
if (m.MgNr != vm.MgNr)
|
||||||
return;
|
return;
|
||||||
var (d1Grid, _) = DeliveryService.GenerateToolTip(d1GridData, []);
|
var (d1Grid, _) = DeliveryService.GenerateToolTip(d1GridData, []);
|
||||||
@@ -224,9 +223,9 @@ namespace Elwig.Services {
|
|||||||
} else {
|
} else {
|
||||||
vm.OrganicDetails = "...";
|
vm.OrganicDetails = "...";
|
||||||
Utils.RunBackground("Bio-Zertifikatsdaten laden", async () => {
|
Utils.RunBackground("Bio-Zertifikatsdaten laden", async () => {
|
||||||
if (App.MainDispatcher == null) return;
|
if (App.Current?.Dispatcher == null) return;
|
||||||
var certs = await OrganicService.GetTracesCertificates(m);
|
var certs = await OrganicService.GetTracesCertificates(m);
|
||||||
await App.MainDispatcher.BeginInvoke(() => {
|
await App.Current.Dispatcher.BeginInvoke(() => {
|
||||||
if (m.MgNr != vm.MgNr) return;
|
if (m.MgNr != vm.MgNr) return;
|
||||||
vm.FillOrganicInputs(certs.FirstOrDefault(c => c.IsValidForWineProduction));
|
vm.FillOrganicInputs(certs.FirstOrDefault(c => c.IsValidForWineProduction));
|
||||||
});
|
});
|
||||||
@@ -602,7 +601,7 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
} else if (mode == ExportMode.Upload && App.Config.SyncUrl != null) {
|
} else if (mode == ExportMode.Upload && App.Config.SyncUrl != null) {
|
||||||
await Utils.RunForeground(async () => {
|
await Utils.RunForeground(async () => {
|
||||||
await SyncService.Upload(App.Config.SyncUrl, App.Config.SyncUrl, App.Config.SyncPassword, query, filterNames);
|
await SyncService.Upload(App.Config.SyncUrl, App.Config.SyncUrl, App.Config.SyncPassword, query, filterNames, App.Config.SyncEncryptionKey);
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
await Utils.RunForeground(async () => {
|
await Utils.RunForeground(async () => {
|
||||||
|
|||||||
@@ -112,8 +112,6 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private static async Task UpdateSums(this PaymentVariantsViewModel vm, PaymentVar v) {
|
private static async Task UpdateSums(this PaymentVariantsViewModel vm, PaymentVar v) {
|
||||||
if (App.MainDispatcher == null)
|
|
||||||
return;
|
|
||||||
var modText = "-";
|
var modText = "-";
|
||||||
var totalText = "-";
|
var totalText = "-";
|
||||||
var vatText = "-";
|
var vatText = "-";
|
||||||
@@ -133,7 +131,7 @@ namespace Elwig.Services {
|
|||||||
.SumAsync(p => p.AmountValue);
|
.SumAsync(p => p.AmountValue);
|
||||||
totalText = $"{v.Season.DecFromDb(totalSum):N2} {sym}";
|
totalText = $"{v.Season.DecFromDb(totalSum):N2} {sym}";
|
||||||
|
|
||||||
await App.MainDispatcher.BeginInvoke(() => {
|
await App.Current.Dispatcher.BeginInvoke(() => {
|
||||||
if (vm.SelectedPaymentVariant != v)
|
if (vm.SelectedPaymentVariant != v)
|
||||||
return;
|
return;
|
||||||
vm.StatusModifierSum = modText;
|
vm.StatusModifierSum = modText;
|
||||||
@@ -175,7 +173,7 @@ namespace Elwig.Services {
|
|||||||
paymentText = $"{Utils.DecFromDb(await credits.SumAsync(c => c.AmountValue), 2):N2} {sym}";
|
paymentText = $"{Utils.DecFromDb(await credits.SumAsync(c => c.AmountValue), 2):N2} {sym}";
|
||||||
}
|
}
|
||||||
|
|
||||||
await App.MainDispatcher.BeginInvoke(() => {
|
await App.Current.Dispatcher.BeginInvoke(() => {
|
||||||
if (vm.SelectedPaymentVariant != v)
|
if (vm.SelectedPaymentVariant != v)
|
||||||
return;
|
return;
|
||||||
vm.StatusModifierSum = modText;
|
vm.StatusModifierSum = modText;
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ namespace Elwig.Services {
|
|||||||
public static readonly Expression<Func<AreaCmtContract, bool>> ChangedAreaCmtContracts = (c) => ((c.XTime == null && c.MTime > 1751328000) || c.MTime > c.XTime) && (c.ITime == null || c.MTime > c.ITime);
|
public static readonly Expression<Func<AreaCmtContract, bool>> ChangedAreaCmtContracts = (c) => ((c.XTime == null && c.MTime > 1751328000) || c.MTime > c.XTime) && (c.ITime == null || c.MTime > c.ITime);
|
||||||
public static readonly Expression<Func<Delivery, bool>> ChangedDeliveries = (d) => ((d.XTime == null && d.MTime > 1751328000) || d.MTime > d.XTime) && (d.ITime == null || d.MTime > d.ITime);
|
public static readonly Expression<Func<Delivery, bool>> ChangedDeliveries = (d) => ((d.XTime == null && d.MTime > 1751328000) || d.MTime > d.XTime) && (d.ITime == null || d.MTime > d.ITime);
|
||||||
|
|
||||||
public static async Task Upload(string url, string username, string password, IQueryable<Member> query, IEnumerable<string> filterNames) {
|
public static async Task Upload(string url, string username, ReadOnlyMemory<char> password, IQueryable<Member> query, IEnumerable<string> filterNames, ReadOnlyMemory<char> key = default) {
|
||||||
try {
|
try {
|
||||||
var filename = $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip";
|
var filename = $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip";
|
||||||
var path = Path.Combine(App.TempPath, filename);
|
var path = Path.Combine(App.TempPath, filename);
|
||||||
@@ -54,7 +54,7 @@ namespace Elwig.Services {
|
|||||||
InteractionService.ShowError("Mitglieder hochladen", "Es wurden keine Mitglieder zum Hochladen ausgewählt!");
|
InteractionService.ShowError("Mitglieder hochladen", "Es wurden keine Mitglieder zum Hochladen ausgewählt!");
|
||||||
} else {
|
} else {
|
||||||
var exportedAt = DateTime.Now;
|
var exportedAt = DateTime.Now;
|
||||||
await ElwigData.Export(path, members, history, areaCmts, wbKgs, filterNames);
|
await ElwigData.Export(path, members, history, areaCmts, wbKgs, filterNames, key);
|
||||||
await Utils.UploadExportData(path, url, username, password);
|
await Utils.UploadExportData(path, url, username, password);
|
||||||
await UpdateExportedAt(members, areaCmts, [], exportedAt);
|
await UpdateExportedAt(members, areaCmts, [], exportedAt);
|
||||||
InteractionService.ShowInformation("Mitglieder hochgeladen", $"Hochladen von {members.Count:N0} Mitgliedern erfolgreich!");
|
InteractionService.ShowInformation("Mitglieder hochgeladen", $"Hochladen von {members.Count:N0} Mitgliedern erfolgreich!");
|
||||||
@@ -68,7 +68,7 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task Upload(string url, string username, string password, IQueryable<DeliveryPart> query, IEnumerable<string> filterNames) {
|
public static async Task Upload(string url, string username, ReadOnlyMemory<char> password, IQueryable<DeliveryPart> query, IEnumerable<string> filterNames, ReadOnlyMemory<char> key = default) {
|
||||||
try {
|
try {
|
||||||
var filename = $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip";
|
var filename = $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip";
|
||||||
var path = Path.Combine(App.TempPath, filename);
|
var path = Path.Combine(App.TempPath, filename);
|
||||||
@@ -88,7 +88,7 @@ namespace Elwig.Services {
|
|||||||
InteractionService.ShowError("Lieferungen hochladen", "Es wurden keine Lieferungen zum Hochladen ausgewählt!");
|
InteractionService.ShowError("Lieferungen hochladen", "Es wurden keine Lieferungen zum Hochladen ausgewählt!");
|
||||||
} else {
|
} else {
|
||||||
var exportedAt = DateTime.Now;
|
var exportedAt = DateTime.Now;
|
||||||
await ElwigData.Export(path, list, wbKgs, filterNames);
|
await ElwigData.Export(path, list, wbKgs, filterNames, key);
|
||||||
await Utils.UploadExportData(path, url, username, password);
|
await Utils.UploadExportData(path, url, username, password);
|
||||||
await UpdateExportedAt([], [], list, exportedAt);
|
await UpdateExportedAt([], [], list, exportedAt);
|
||||||
InteractionService.ShowInformation("Lieferungen hochgeladen", $"Hochladen von {list.Count:N0} Lieferungen erfolgreich!");
|
InteractionService.ShowInformation("Lieferungen hochgeladen", $"Hochladen von {list.Count:N0} Lieferungen erfolgreich!");
|
||||||
@@ -102,10 +102,11 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task UploadModified(string url, string username, string password) {
|
public static async Task UploadModified(string url, string username, ReadOnlyMemory<char> password, ReadOnlyMemory<char> key = default) {
|
||||||
try {
|
try {
|
||||||
var path = Path.Combine(App.TempPath, $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip");
|
var path = Path.Combine(App.TempPath, $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip");
|
||||||
List<Member> members;
|
List<Member> members;
|
||||||
|
List<MemberHistory> history;
|
||||||
List<AreaCmtContract> areaCmts;
|
List<AreaCmtContract> areaCmts;
|
||||||
List<Delivery> deliveries;
|
List<Delivery> deliveries;
|
||||||
using (var ctx = new AppDbContext()) {
|
using (var ctx = new AppDbContext()) {
|
||||||
@@ -115,6 +116,17 @@ namespace Elwig.Services {
|
|||||||
.Include(m => m.EmailAddresses)
|
.Include(m => m.EmailAddresses)
|
||||||
.OrderBy(m => m.MgNr)
|
.OrderBy(m => m.MgNr)
|
||||||
.ToListAsync();
|
.ToListAsync();
|
||||||
|
var history1 = await ctx.Members.IgnoreAutoIncludes()
|
||||||
|
.Where(ChangedMembers)
|
||||||
|
.SelectMany(m => m.HistoryFrom)
|
||||||
|
.ToListAsync();
|
||||||
|
var history2 = await ctx.Members.IgnoreAutoIncludes()
|
||||||
|
.Where(ChangedMembers)
|
||||||
|
.SelectMany(m => m.HistoryTo)
|
||||||
|
.ToListAsync();
|
||||||
|
history = [.. history1.Union(history2)
|
||||||
|
.DistinctBy(h => h.HistNr)
|
||||||
|
.OrderBy(h => h.DateNotice).ThenBy(h => h.HistNr)];
|
||||||
areaCmts = await ctx.AreaCommitmentContracts
|
areaCmts = await ctx.AreaCommitmentContracts
|
||||||
.Where(ChangedAreaCmtContracts)
|
.Where(ChangedAreaCmtContracts)
|
||||||
.Include(c => c.Revisions)
|
.Include(c => c.Revisions)
|
||||||
@@ -142,10 +154,11 @@ namespace Elwig.Services {
|
|||||||
var exportedAt = DateTime.Now;
|
var exportedAt = DateTime.Now;
|
||||||
await (new ElwigData.ElwigExport {
|
await (new ElwigData.ElwigExport {
|
||||||
Members = (members, ["geändert seit letztem Export"]),
|
Members = (members, ["geändert seit letztem Export"]),
|
||||||
|
History = (history, ["von exportierten Mitgliedern"]),
|
||||||
AreaCmts = (areaCmts, ["geändert seit letztem Export"]),
|
AreaCmts = (areaCmts, ["geändert seit letztem Export"]),
|
||||||
Deliveries = (deliveries, ["geändert seit letzem Export"]),
|
Deliveries = (deliveries, ["geändert seit letzem Export"]),
|
||||||
WbKgs = (wbKgs, ["von exportierten Mitgliedern, Flächenbindungen und Lieferungen"]),
|
WbKgs = (wbKgs, ["von exportierten Mitgliedern, Flächenbindungen und Lieferungen"]),
|
||||||
}).Export(path);
|
}).Export(path, key);
|
||||||
await Utils.UploadExportData(path, url, username, password);
|
await Utils.UploadExportData(path, url, username, password);
|
||||||
await UpdateExportedAt(members, areaCmts, deliveries, exportedAt);
|
await UpdateExportedAt(members, areaCmts, deliveries, exportedAt);
|
||||||
InteractionService.ShowInformation("Mitglieder und Lieferungen hochladen", $"Hochladen von {members.Count:N0} Mitgliedern, {areaCmts.Count:N0} Flächenbindungsverträgen, und {deliveries.Count:N0} Lieferungen erfolgreich!");
|
InteractionService.ShowInformation("Mitglieder und Lieferungen hochladen", $"Hochladen von {members.Count:N0} Mitgliedern, {areaCmts.Count:N0} Flächenbindungsverträgen, und {deliveries.Count:N0} Lieferungen erfolgreich!");
|
||||||
@@ -159,7 +172,7 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task UploadBranchDeliveries(string url, string username, string password, int? year = null) {
|
public static async Task UploadBranchDeliveries(string url, string username, ReadOnlyMemory<char> password, int? year = null, ReadOnlyMemory<char> key = default) {
|
||||||
try {
|
try {
|
||||||
year ??= Utils.CurrentLastSeason;
|
year ??= Utils.CurrentLastSeason;
|
||||||
var path = Path.Combine(App.TempPath, $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip");
|
var path = Path.Combine(App.TempPath, $"{DateTime.Now:yyyy-MM-dd_HH-mm-ss}_{App.ZwstId}.elwig.zip");
|
||||||
@@ -179,7 +192,7 @@ namespace Elwig.Services {
|
|||||||
InteractionService.ShowError("Lieferungen hochladen", "Es gibt keine Lieferungen, die hochgeladen werden können!");
|
InteractionService.ShowError("Lieferungen hochladen", "Es gibt keine Lieferungen, die hochgeladen werden können!");
|
||||||
} else {
|
} else {
|
||||||
var exportedAt = DateTime.Now;
|
var exportedAt = DateTime.Now;
|
||||||
await ElwigData.Export(path, deliveries, wbKgs, [$"{year}", $"Zweigstelle {App.BranchName}"]);
|
await ElwigData.Export(path, deliveries, wbKgs, [$"{year}", $"Zweigstelle {App.BranchName}"], key);
|
||||||
await Utils.UploadExportData(path, url, username, password);
|
await Utils.UploadExportData(path, url, username, password);
|
||||||
await UpdateExportedAt([], [], deliveries, exportedAt);
|
await UpdateExportedAt([], [], deliveries, exportedAt);
|
||||||
InteractionService.ShowInformation("Lieferungen hochladen", $"Hochladen von {deliveries.Count:N0} Lieferungen erfolgreich!");
|
InteractionService.ShowInformation("Lieferungen hochladen", $"Hochladen von {deliveries.Count:N0} Lieferungen erfolgreich!");
|
||||||
@@ -193,7 +206,7 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<List<(string Name, string Url)>> GetFilesToImport(string url, string username, string password) {
|
public static async Task<List<(string Name, string Url)>> GetFilesToImport(string url, string username, ReadOnlyMemory<char> password) {
|
||||||
var data = await Utils.GetExportMetaData(url, username, password);
|
var data = await Utils.GetExportMetaData(url, username, password);
|
||||||
var files = data
|
var files = data
|
||||||
.Select(f => new {
|
.Select(f => new {
|
||||||
@@ -214,7 +227,7 @@ namespace Elwig.Services {
|
|||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task Download(string url, string username, string password, bool confirmImports) {
|
public static async Task Download(string url, string username, ReadOnlyMemory<char> password, bool confirmImports, IEnumerable<ReadOnlyMemory<char>>? keys = null) {
|
||||||
try {
|
try {
|
||||||
var import = await GetFilesToImport(url, username, password);
|
var import = await GetFilesToImport(url, username, password);
|
||||||
var paths = new List<string>();
|
var paths = new List<string>();
|
||||||
@@ -226,7 +239,7 @@ namespace Elwig.Services {
|
|||||||
paths.Add(filename);
|
paths.Add(filename);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
await ElwigData.Import(paths, confirmImports ? ElwigData.ImportMode.Interactively : ElwigData.ImportMode.FromBranches);
|
await ElwigData.Import(paths, confirmImports ? ElwigData.ImportMode.Interactively : ElwigData.ImportMode.FromBranches, keys);
|
||||||
} catch (HttpRequestException exc) {
|
} catch (HttpRequestException exc) {
|
||||||
InteractionService.ShowException("Daten herunterladen", "Eventuell Internetverbindung prüfen!", exc);
|
InteractionService.ShowException("Daten herunterladen", "Eventuell Internetverbindung prüfen!", exc);
|
||||||
} catch (TaskCanceledException exc) {
|
} catch (TaskCanceledException exc) {
|
||||||
@@ -257,7 +270,7 @@ namespace Elwig.Services {
|
|||||||
App.HintContextChange();
|
App.HintContextChange();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> ChangesAvailable(AppDbContext ctx, string url, string username, string password) {
|
public static async Task<bool> ChangesAvailable(AppDbContext ctx, string url, string username, ReadOnlyMemory<char> password) {
|
||||||
try {
|
try {
|
||||||
return await ctx.Members.Where(ChangedMembers).AnyAsync() || await ctx.AreaCommitmentContracts.Where(ChangedAreaCmtContracts).AnyAsync() || await ctx.Deliveries.Where(ChangedDeliveries).AnyAsync() || (Utils.HasInternetConnectivity() && (await GetFilesToImport(url, username, password)).Count > 0);
|
return await ctx.Members.Where(ChangedMembers).AnyAsync() || await ctx.AreaCommitmentContracts.Where(ChangedAreaCmtContracts).AnyAsync() || await ctx.Deliveries.Where(ChangedDeliveries).AnyAsync() || (Utils.HasInternetConnectivity() && (await GetFilesToImport(url, username, password)).Count > 0);
|
||||||
} catch {
|
} catch {
|
||||||
@@ -265,7 +278,7 @@ namespace Elwig.Services {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static async Task<bool> ChangesAvailable(AppDbContext ctx, string url, string username, string password, int? year = null) {
|
public static async Task<bool> ChangesAvailable(AppDbContext ctx, string url, string username, ReadOnlyMemory<char> password, int? year = null) {
|
||||||
try {
|
try {
|
||||||
year ??= Utils.CurrentLastSeason;
|
year ??= Utils.CurrentLastSeason;
|
||||||
return await ctx.Deliveries.Where(d => d.ZwstId == App.ZwstId && d.Year == year).Where(ChangedDeliveries).AnyAsync() || (Utils.HasInternetConnectivity() && (await GetFilesToImport(url, username, password)).Count > 0);
|
return await ctx.Deliveries.Where(d => d.ZwstId == App.ZwstId && d.Year == year).Where(ChangedDeliveries).AnyAsync() || (Utils.HasInternetConnectivity() && (await GetFilesToImport(url, username, password)).Count > 0);
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Elwig.Models.Entities;
|
using Elwig.Models.Entities;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
@@ -15,7 +16,7 @@ namespace Elwig.ViewModels {
|
|||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string? SearchQuery { get; set; } = "";
|
public partial string? SearchQuery { get; set; } = "";
|
||||||
public List<string> TextFilter {
|
public List<string> TextFilter {
|
||||||
get => [.. SearchQuery?.ToLower().Split(' ').ToList().FindAll(e => e.Length > 0) ?? []];
|
get => [.. SearchQuery?.ToLower().Split(' ', StringSplitOptions.RemoveEmptyEntries) ?? []];
|
||||||
set => SearchQuery = string.Join(' ', value.Where(e => e.Length > 0));
|
set => SearchQuery = string.Join(' ', value.Where(e => e.Length > 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using Elwig.Models.Entities;
|
using Elwig.Models.Entities;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -18,7 +19,7 @@ namespace Elwig.ViewModels {
|
|||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string? SearchQuery { get; set; } = "";
|
public partial string? SearchQuery { get; set; } = "";
|
||||||
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ').ToList().FindAll(e => e.Length > 0) ?? []];
|
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ', StringSplitOptions.RemoveEmptyEntries) ?? []];
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string? LastScaleError { get; set; }
|
public partial string? LastScaleError { get; set; }
|
||||||
@@ -117,7 +118,7 @@ namespace Elwig.ViewModels {
|
|||||||
public partial string? WeightString { get; set; }
|
public partial string? WeightString { get; set; }
|
||||||
public int? Weight {
|
public int? Weight {
|
||||||
get => int.TryParse(WeightString?.Replace(Utils.GroupSeparator, ""), out var w) ? w : null;
|
get => int.TryParse(WeightString?.Replace(Utils.GroupSeparator, ""), out var w) ? w : null;
|
||||||
set => WeightString = $"{value:N0}";
|
set => WeightString = value > 0 ? $"{value:N0}" : null;
|
||||||
}
|
}
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string? TareString { get; set; } = "-";
|
public partial string? TareString { get; set; } = "-";
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Elwig.Models.Entities;
|
using Elwig.Models.Entities;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -13,7 +14,7 @@ namespace Elwig.ViewModels {
|
|||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string? SearchQuery { get; set; } = "";
|
public partial string? SearchQuery { get; set; } = "";
|
||||||
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ').ToList().FindAll(e => e.Length > 0) ?? []];
|
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ', StringSplitOptions.RemoveEmptyEntries) ?? []];
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial bool FilterOnlyUpcoming { get; set; }
|
public partial bool FilterOnlyUpcoming { get; set; }
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ namespace Elwig.ViewModels {
|
|||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string? SearchQuery { get; set; } = "";
|
public partial string? SearchQuery { get; set; } = "";
|
||||||
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ').ToList().FindAll(e => e.Length > 0) ?? []];
|
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ', StringSplitOptions.RemoveEmptyEntries) ?? []];
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial bool FilterOnlyUpcoming { get; set; }
|
public partial bool FilterOnlyUpcoming { get; set; }
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using Elwig.Helpers;
|
using Elwig.Helpers;
|
||||||
using Elwig.Models.Entities;
|
using Elwig.Models.Entities;
|
||||||
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Collections.ObjectModel;
|
using System.Collections.ObjectModel;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
@@ -17,11 +18,11 @@ namespace Elwig.ViewModels {
|
|||||||
public int? TransferPredecessorAreaCmts { get; set; } = null;
|
public int? TransferPredecessorAreaCmts { get; set; } = null;
|
||||||
public int? CancelAreaCmts { get; set; } = null;
|
public int? CancelAreaCmts { get; set; } = null;
|
||||||
|
|
||||||
public ObservableCollection<KeyValuePair<string, string>> PhoneNrTypes { get; set; } = new(Utils.PhoneNrTypes);
|
public ObservableCollection<KeyValuePair<string, string>> PhoneNrTypes { get; set; } = [with(Utils.PhoneNrTypes)];
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial string? SearchQuery { get; set; } = "";
|
public partial string? SearchQuery { get; set; } = "";
|
||||||
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ').ToList().FindAll(e => e.Length > 0) ?? []];
|
public List<string> TextFilter => [.. SearchQuery?.ToLower().Split(' ', StringSplitOptions.RemoveEmptyEntries) ?? []];
|
||||||
|
|
||||||
[ObservableProperty]
|
[ObservableProperty]
|
||||||
public partial bool ShowOnlyActiveMembers { get; set; } = true;
|
public partial bool ShowOnlyActiveMembers { get; set; } = true;
|
||||||
|
|||||||
@@ -415,7 +415,7 @@ namespace Elwig.Windows {
|
|||||||
|
|
||||||
private void RevisionList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
private void RevisionList_SelectionChanged(object? sender, SelectionChangedEventArgs? evt) {
|
||||||
RefreshInputs();
|
RefreshInputs();
|
||||||
if (RevisionList.SelectedItem is AreaCmt c) {
|
if (RevisionList.SelectedItem is AreaCmt) {
|
||||||
EditAreaCommitmentButton.IsEnabled = true;
|
EditAreaCommitmentButton.IsEnabled = true;
|
||||||
} else {
|
} else {
|
||||||
EditAreaCommitmentButton.IsEnabled = false;
|
EditAreaCommitmentButton.IsEnabled = false;
|
||||||
|
|||||||
@@ -195,7 +195,7 @@
|
|||||||
<Label Content="PLZ/Ort:" Margin="10,70,0,10"/>
|
<Label Content="PLZ/Ort:" Margin="10,70,0,10"/>
|
||||||
<TextBox x:Name="BranchPlzInput" Margin="0,70,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
|
<TextBox x:Name="BranchPlzInput" Margin="0,70,0,0" Width="42" Grid.Column="1" HorizontalAlignment="Left"
|
||||||
TextChanged="BranchPlzInput_TextChanged" LostFocus="PlzInput_LostFocus" Tag="PLZ"/>
|
TextChanged="BranchPlzInput_TextChanged" LostFocus="PlzInput_LostFocus" Tag="PLZ"/>
|
||||||
<ComboBox x:Name="BranchOrtInput" ItemTemplate="{StaticResource PostalDestTemplate}" TextSearch.TextPath="Ort.Name"
|
<ComboBox x:Name="BranchOrtInput" DisplayMemberPath="FullDest" TextSearch.TextPath="Ort.Name"
|
||||||
Margin="47,70,10,0" Grid.Column="1" Grid.ColumnSpan="3" Width="253" HorizontalAlignment="Left"
|
Margin="47,70,10,0" Grid.Column="1" Grid.ColumnSpan="3" Width="253" HorizontalAlignment="Left"
|
||||||
SelectionChanged="Branch_Changed"/>
|
SelectionChanged="Branch_Changed"/>
|
||||||
|
|
||||||
@@ -247,6 +247,8 @@
|
|||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
<ColumnDefinition Width="100"/>
|
<ColumnDefinition Width="100"/>
|
||||||
<ColumnDefinition Width="*"/>
|
<ColumnDefinition Width="*"/>
|
||||||
|
<ColumnDefinition Width="110"/>
|
||||||
|
<ColumnDefinition Width="150"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
|
|
||||||
<Label Content="Identifikator:" Margin="10,10,0,10"/>
|
<Label Content="Identifikator:" Margin="10,10,0,10"/>
|
||||||
@@ -258,10 +260,28 @@
|
|||||||
TextChanged="WineAttribute_Changed"/>
|
TextChanged="WineAttribute_Changed"/>
|
||||||
|
|
||||||
<CheckBox x:Name="WineAttributeActiveInput" Content="In Übernahme-Fenster anzeigen"
|
<CheckBox x:Name="WineAttributeActiveInput" Content="In Übernahme-Fenster anzeigen"
|
||||||
Grid.Column="1" Margin="0,74,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
|
Grid.Column="1" Grid.ColumnSpan="3" Margin="0,74,10,10" HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
Checked="WineAttribute_Changed" Unchecked="WineAttribute_Changed"/>
|
Checked="WineAttribute_Changed" Unchecked="WineAttribute_Changed"/>
|
||||||
|
|
||||||
<GroupBox Header="Auszahlung" Grid.ColumnSpan="2" Margin="10,100,10,10">
|
<Label Content="Niedrigste Qual.:" Margin="10,10,0,10" Grid.Column="2"/>
|
||||||
|
<ComboBox x:Name="WineAttributeMinQualityLevelInput" Grid.Column="3" Margin="0,10,10,10" HorizontalAlignment="Stretch"
|
||||||
|
TextSearch.TextPath="Name"
|
||||||
|
SelectionChanged="WineAttribute_Changed">
|
||||||
|
<ComboBox.ItemTemplateSelector>
|
||||||
|
<ctrl:WineQualityLevelTemplateSelector/>
|
||||||
|
</ComboBox.ItemTemplateSelector>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<Label Content="Höchste Qual.:" Margin="10,40,0,10" Grid.Column="2"/>
|
||||||
|
<ComboBox x:Name="WineAttributeMaxQualityLevelInput" Grid.Column="3" Margin="0,40,10,10" HorizontalAlignment="Stretch"
|
||||||
|
TextSearch.TextPath="Name"
|
||||||
|
SelectionChanged="WineAttribute_Changed">
|
||||||
|
<ComboBox.ItemTemplateSelector>
|
||||||
|
<ctrl:WineQualityLevelTemplateSelector/>
|
||||||
|
</ComboBox.ItemTemplateSelector>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
|
<GroupBox Header="Auszahlung" Grid.ColumnSpan="4" Margin="10,100,10,10">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Label Content="Max. Ertrag:" Margin="10,10,0,10"/>
|
<Label Content="Max. Ertrag:" Margin="10,10,0,10"/>
|
||||||
<ctrl:UnitTextBox x:Name="WineAttributeMaxKgPerHaInput" Unit="kg/ha" TextChanged="WineAttributeMaxKgPerHaInput_TextChanged"
|
<ctrl:UnitTextBox x:Name="WineAttributeMaxKgPerHaInput" Unit="kg/ha" TextChanged="WineAttributeMaxKgPerHaInput_TextChanged"
|
||||||
@@ -551,21 +571,34 @@
|
|||||||
</TabItem>
|
</TabItem>
|
||||||
<TabItem Header="Parameter">
|
<TabItem Header="Parameter">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
<GroupBox x:Name="ParameterBusinessShare" Header="Geschäftsanteile" Margin="10,10,10,0" VerticalAlignment="Top">
|
<StackPanel Orientation="Horizontal">
|
||||||
<Grid>
|
<GroupBox x:Name="ParameterBusinessShare" Header="Geschäftsanteile" Margin="10,10,10,0" VerticalAlignment="Stretch">
|
||||||
<Label Content="Modus:" Margin="10,10,10,10"/>
|
<Grid>
|
||||||
<ComboBox x:Name="ParameterBusinessShareModeInput" Margin="160,10,10,10" Width="100"
|
<Label Content="Modus:" Margin="10,10,10,10"/>
|
||||||
HorizontalAlignment="Left">
|
<ComboBox x:Name="ParameterBusinessShareModeInput" Margin="160,10,10,10" Width="100"
|
||||||
<ComboBoxItem IsSelected="True">Normal</ComboBoxItem>
|
HorizontalAlignment="Left">
|
||||||
<ComboBoxItem>Rot/weiß</ComboBoxItem>
|
<ComboBoxItem IsSelected="True">Normal</ComboBoxItem>
|
||||||
</ComboBox>
|
<ComboBoxItem>Rot/weiß</ComboBoxItem>
|
||||||
|
</ComboBox>
|
||||||
|
|
||||||
<Label Content="Mitgliederbewegungen:" Margin="10,40,10,10"/>
|
<Label Content="Mitgliederbewegungen:" Margin="10,40,10,10"/>
|
||||||
<CheckBox x:Name="ParameterBusinessShareHistoryInput" Content="Mit Elwig erfassen" Margin="160,45,10,15"
|
<CheckBox x:Name="ParameterBusinessShareHistoryInput" Content="Mit Elwig erfassen" Margin="160,45,10,15"
|
||||||
HorizontalAlignment="Left"
|
HorizontalAlignment="Left"
|
||||||
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
</Grid>
|
</Grid>
|
||||||
</GroupBox>
|
</GroupBox>
|
||||||
|
<GroupBox x:Name="ParameterReceipt" Header="Übernahme" Margin="10,10,10,0" VerticalAlignment="Stretch" HorizontalAlignment="Stretch">
|
||||||
|
<Grid>
|
||||||
|
<Label Content="Höchste Qualitätsstufe:" Margin="10,10,0,10" Grid.Column="2"/>
|
||||||
|
<ComboBox x:Name="ParameterReceiptMaxQualityLevelInput" Grid.Column="3" Margin="150,10,10,10" Width="130"
|
||||||
|
TextSearch.TextPath="Name">
|
||||||
|
<ComboBox.ItemTemplateSelector>
|
||||||
|
<ctrl:WineQualityLevelTemplateSelector/>
|
||||||
|
</ComboBox.ItemTemplateSelector>
|
||||||
|
</ComboBox>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
|
</StackPanel>
|
||||||
<GroupBox x:Name="ParameterAreaCmtGroup" Header="Berechnung Flächenbindungen (aktuelle Saison)" Margin="10,10,10,0" VerticalAlignment="Top">
|
<GroupBox x:Name="ParameterAreaCmtGroup" Header="Berechnung Flächenbindungen (aktuelle Saison)" Margin="10,10,10,0" VerticalAlignment="Top">
|
||||||
<Grid>
|
<Grid>
|
||||||
<CheckBox x:Name="ParameterAllowAttrIntoLowerInput" Content="Erlauben Lieferungen auch auf (konfigurierte) "schlechtere" Flächenbindungen aufzuteilen"
|
<CheckBox x:Name="ParameterAllowAttrIntoLowerInput" Content="Erlauben Lieferungen auch auf (konfigurierte) "schlechtere" Flächenbindungen aufzuteilen"
|
||||||
@@ -611,6 +644,13 @@
|
|||||||
<TabItem Header="Textelemente">
|
<TabItem Header="Textelemente">
|
||||||
<ScrollViewer VerticalScrollBarVisibility="Visible">
|
<ScrollViewer VerticalScrollBarVisibility="Visible">
|
||||||
<StackPanel>
|
<StackPanel>
|
||||||
|
<GroupBox Header="Stammdatenblatt" Margin="10,10,10,10" Height="70">
|
||||||
|
<Grid>
|
||||||
|
<CheckBox x:Name="ModeMemberDataSheetShares" Content="Verlauf der Geschäftsanteile anzeigen" Margin="15,15,10,15"
|
||||||
|
HorizontalAlignment="Left" VerticalAlignment="Top"
|
||||||
|
Checked="CheckBox_Changed" Unchecked="CheckBox_Changed"/>
|
||||||
|
</Grid>
|
||||||
|
</GroupBox>
|
||||||
<GroupBox Header="Lieferschein" Margin="10,10,10,10" Height="180">
|
<GroupBox Header="Lieferschein" Margin="10,10,10,10" Height="180">
|
||||||
<Grid>
|
<Grid>
|
||||||
<Grid.ColumnDefinitions>
|
<Grid.ColumnDefinitions>
|
||||||
|
|||||||
+3
-3
@@ -19,9 +19,9 @@ namespace Elwig.Windows {
|
|||||||
private bool _actUpdate = false;
|
private bool _actUpdate = false;
|
||||||
|
|
||||||
private async Task AreaCommitmentTypesInitEditing(AppDbContext ctx) {
|
private async Task AreaCommitmentTypesInitEditing(AppDbContext ctx) {
|
||||||
_actList = new(await ctx.AreaCommitmentTypes
|
_actList = [with(await ctx.AreaCommitmentTypes
|
||||||
.OrderBy(v => v.VtrgId)
|
.OrderBy(v => v.VtrgId)
|
||||||
.ToListAsync());
|
.ToListAsync())];
|
||||||
_acts = _actList.ToDictionary(v => v.VtrgId, v => (string?)v.VtrgId);
|
_acts = _actList.ToDictionary(v => v.VtrgId, v => (string?)v.VtrgId);
|
||||||
_actIds = _actList.ToDictionary(v => v, v => v.VtrgId);
|
_actIds = _actList.ToDictionary(v => v, v => v.VtrgId);
|
||||||
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, _actList);
|
ControlUtils.RenewItemsSource(AreaCommitmentTypeList, _actList);
|
||||||
@@ -56,7 +56,7 @@ namespace Elwig.Windows {
|
|||||||
.Where(_actIds.ContainsKey)
|
.Where(_actIds.ContainsKey)
|
||||||
.Select(t => {
|
.Select(t => {
|
||||||
t.VtrgId = _actIds[t];
|
t.VtrgId = _actIds[t];
|
||||||
ctx.Entry(t).State = EntityState.Added;
|
ctx.Entry(t).State = EntityState.Modified;
|
||||||
return t;
|
return t;
|
||||||
}));
|
}));
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
@@ -19,7 +19,7 @@ namespace Elwig.Windows {
|
|||||||
private bool _branchUpdate = false;
|
private bool _branchUpdate = false;
|
||||||
|
|
||||||
private async Task BranchesInitEditing(AppDbContext ctx) {
|
private async Task BranchesInitEditing(AppDbContext ctx) {
|
||||||
_branchList = new(await ctx.FetchBranches().ToListAsync());
|
_branchList = [with(await ctx.FetchBranches().ToListAsync())];
|
||||||
_branches = _branchList.ToDictionary(b => b.ZwstId, b => (string?)b.ZwstId);
|
_branches = _branchList.ToDictionary(b => b.ZwstId, b => (string?)b.ZwstId);
|
||||||
_branchIds = _branchList.ToDictionary(b => b, b => b.ZwstId);
|
_branchIds = _branchList.ToDictionary(b => b, b => b.ZwstId);
|
||||||
ControlUtils.RenewItemsSource(BranchList, _branchList);
|
ControlUtils.RenewItemsSource(BranchList, _branchList);
|
||||||
@@ -50,7 +50,7 @@ namespace Elwig.Windows {
|
|||||||
.Where(_branchIds.ContainsKey)
|
.Where(_branchIds.ContainsKey)
|
||||||
.Select(b => {
|
.Select(b => {
|
||||||
b.ZwstId = _branchIds[b];
|
b.ZwstId = _branchIds[b];
|
||||||
ctx.Entry(b).State = EntityState.Added;
|
ctx.Entry(b).State = EntityState.Modified;
|
||||||
return b;
|
return b;
|
||||||
}));
|
}));
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
|
|||||||
@@ -22,7 +22,7 @@ namespace Elwig.Windows {
|
|||||||
private async Task ModifiersInitEditing(AppDbContext ctx) {
|
private async Task ModifiersInitEditing(AppDbContext ctx) {
|
||||||
SeasonList.IsEnabled = false;
|
SeasonList.IsEnabled = false;
|
||||||
var year = (SeasonList.SelectedItem as Season)?.Year;
|
var year = (SeasonList.SelectedItem as Season)?.Year;
|
||||||
_modList = new(await ctx.FetchModifiers(year ?? 0).ToListAsync());
|
_modList = [with(await ctx.FetchModifiers(year ?? 0).ToListAsync())];
|
||||||
_mods = _modList.ToDictionary(m => m.ModId, m => (string?)m.ModId);
|
_mods = _modList.ToDictionary(m => m.ModId, m => (string?)m.ModId);
|
||||||
_modIds = _modList.ToDictionary(m => m, m => m.ModId);
|
_modIds = _modList.ToDictionary(m => m, m => m.ModId);
|
||||||
ControlUtils.RenewItemsSource(SeasonModifierList, _modList);
|
ControlUtils.RenewItemsSource(SeasonModifierList, _modList);
|
||||||
@@ -61,7 +61,7 @@ namespace Elwig.Windows {
|
|||||||
.Where(_modIds.ContainsKey)
|
.Where(_modIds.ContainsKey)
|
||||||
.Select(m => {
|
.Select(m => {
|
||||||
m.ModId = _modIds[m];
|
m.ModId = _modIds[m];
|
||||||
ctx.Entry(m).State = EntityState.Added;
|
ctx.Entry(m).State = EntityState.Modified;
|
||||||
return m;
|
return m;
|
||||||
}));
|
}));
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Elwig.Windows {
|
|||||||
private bool _attrUpdate = false;
|
private bool _attrUpdate = false;
|
||||||
|
|
||||||
private async Task WineAttributesInitEditing(AppDbContext ctx) {
|
private async Task WineAttributesInitEditing(AppDbContext ctx) {
|
||||||
_attrList = new(await ctx.FetchWineAttributes().ToListAsync());
|
_attrList = [with(await ctx.FetchWineAttributes().ToListAsync())];
|
||||||
_attrs = _attrList.ToDictionary(a => a.AttrId, a => (string?)a.AttrId);
|
_attrs = _attrList.ToDictionary(a => a.AttrId, a => (string?)a.AttrId);
|
||||||
_attrIds = _attrList.ToDictionary(a => a, a => a.AttrId);
|
_attrIds = _attrList.ToDictionary(a => a, a => a.AttrId);
|
||||||
ControlUtils.RenewItemsSource(WineAttributeList, _attrList);
|
ControlUtils.RenewItemsSource(WineAttributeList, _attrList);
|
||||||
@@ -50,7 +50,7 @@ namespace Elwig.Windows {
|
|||||||
.Where(_attrIds.ContainsKey)
|
.Where(_attrIds.ContainsKey)
|
||||||
.Select(a => {
|
.Select(a => {
|
||||||
a.AttrId = _attrIds[a];
|
a.AttrId = _attrIds[a];
|
||||||
ctx.Entry(a).State = EntityState.Added;
|
ctx.Entry(a).State = EntityState.Modified;
|
||||||
return a;
|
return a;
|
||||||
}));
|
}));
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
@@ -73,13 +73,18 @@ namespace Elwig.Windows {
|
|||||||
WineAttributeIdInput.Text = "";
|
WineAttributeIdInput.Text = "";
|
||||||
WineAttributeNameInput.Text = "";
|
WineAttributeNameInput.Text = "";
|
||||||
WineAttributeActiveInput.IsChecked = false;
|
WineAttributeActiveInput.IsChecked = false;
|
||||||
|
WineAttributeMinQualityLevelInput.SelectedIndex = 0;
|
||||||
|
WineAttributeMaxQualityLevelInput.SelectedIndex = 0;
|
||||||
WineAttributeMaxKgPerHaInput.Text = "";
|
WineAttributeMaxKgPerHaInput.Text = "";
|
||||||
WineAttributeStrictInput.IsChecked = false;
|
WineAttributeStrictInput.IsChecked = false;
|
||||||
WineAttributeFillLowerInput.SelectedItem = null;
|
WineAttributeFillLowerInput.SelectedItem = null;
|
||||||
} else {
|
} else {
|
||||||
WineAttributeIdInput.Text = attr.AttrId;
|
WineAttributeIdInput.Text = attr.AttrId;
|
||||||
|
|
||||||
WineAttributeNameInput.Text = attr.Name;
|
WineAttributeNameInput.Text = attr.Name;
|
||||||
WineAttributeActiveInput.IsChecked = attr.IsActive;
|
WineAttributeActiveInput.IsChecked = attr.IsActive;
|
||||||
|
ControlUtils.SelectItemWithPk(WineAttributeMinQualityLevelInput, attr.MinQualId);
|
||||||
|
ControlUtils.SelectItemWithPk(WineAttributeMaxQualityLevelInput, attr.MaxQualId);
|
||||||
WineAttributeMaxKgPerHaInput.Text = attr.MaxKgPerHa?.ToString() ?? "";
|
WineAttributeMaxKgPerHaInput.Text = attr.MaxKgPerHa?.ToString() ?? "";
|
||||||
WineAttributeStrictInput.IsChecked = attr.IsStrict;
|
WineAttributeStrictInput.IsChecked = attr.IsStrict;
|
||||||
WineAttributeFillLowerInput.SelectedIndex = attr.FillLower;
|
WineAttributeFillLowerInput.SelectedIndex = attr.FillLower;
|
||||||
@@ -113,6 +118,8 @@ namespace Elwig.Windows {
|
|||||||
WineAttributeIdInput.Text != attr.AttrId ||
|
WineAttributeIdInput.Text != attr.AttrId ||
|
||||||
WineAttributeNameInput.Text != attr.Name ||
|
WineAttributeNameInput.Text != attr.Name ||
|
||||||
WineAttributeActiveInput.IsChecked != attr.IsActive ||
|
WineAttributeActiveInput.IsChecked != attr.IsActive ||
|
||||||
|
WineAttributeMinQualityLevelInput.SelectedItem as WineQualLevel != attr.MinQualityLevel ||
|
||||||
|
WineAttributeMaxQualityLevelInput.SelectedItem as WineQualLevel != attr.MaxQualityLevel ||
|
||||||
WineAttributeMaxKgPerHaInput.Text != attr.MaxKgPerHa?.ToString() ||
|
WineAttributeMaxKgPerHaInput.Text != attr.MaxKgPerHa?.ToString() ||
|
||||||
WineAttributeStrictInput.IsChecked != attr.IsStrict ||
|
WineAttributeStrictInput.IsChecked != attr.IsStrict ||
|
||||||
WineAttributeFillLowerInput.SelectedIndex != attr.FillLower;
|
WineAttributeFillLowerInput.SelectedIndex != attr.FillLower;
|
||||||
@@ -123,6 +130,8 @@ namespace Elwig.Windows {
|
|||||||
attr.AttrId = id;
|
attr.AttrId = id;
|
||||||
attr.Name = WineAttributeNameInput.Text ?? "";
|
attr.Name = WineAttributeNameInput.Text ?? "";
|
||||||
attr.IsActive = WineAttributeActiveInput.IsChecked ?? false;
|
attr.IsActive = WineAttributeActiveInput.IsChecked ?? false;
|
||||||
|
attr.MinQualId = (WineAttributeMinQualityLevelInput.SelectedItem as WineQualLevel)?.QualId;
|
||||||
|
attr.MaxQualId = (WineAttributeMaxQualityLevelInput.SelectedItem as WineQualLevel)?.QualId;
|
||||||
attr.MaxKgPerHa = WineAttributeMaxKgPerHaInput.Text.Length > 0 ? int.Parse(WineAttributeMaxKgPerHaInput.Text) : null;
|
attr.MaxKgPerHa = WineAttributeMaxKgPerHaInput.Text.Length > 0 ? int.Parse(WineAttributeMaxKgPerHaInput.Text) : null;
|
||||||
attr.IsStrict = WineAttributeStrictInput.IsChecked ?? false;
|
attr.IsStrict = WineAttributeStrictInput.IsChecked ?? false;
|
||||||
attr.FillLower = WineAttributeFillLowerInput.SelectedIndex;
|
attr.FillLower = WineAttributeFillLowerInput.SelectedIndex;
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ namespace Elwig.Windows {
|
|||||||
private bool _cultUpdate = false;
|
private bool _cultUpdate = false;
|
||||||
|
|
||||||
private async Task WineCultivationsInitEditing(AppDbContext ctx) {
|
private async Task WineCultivationsInitEditing(AppDbContext ctx) {
|
||||||
_cultList = new(await ctx.FetchWineCultivations().ToListAsync());
|
_cultList = [with(await ctx.FetchWineCultivations().ToListAsync())];
|
||||||
_cults = _cultList.ToDictionary(c => c.CultId, c => (string?)c.CultId);
|
_cults = _cultList.ToDictionary(c => c.CultId, c => (string?)c.CultId);
|
||||||
_cultIds = _cultList.ToDictionary(c => c, c => c.CultId);
|
_cultIds = _cultList.ToDictionary(c => c, c => c.CultId);
|
||||||
ControlUtils.RenewItemsSource(WineCultivationList, _cultList);
|
ControlUtils.RenewItemsSource(WineCultivationList, _cultList);
|
||||||
@@ -50,7 +50,7 @@ namespace Elwig.Windows {
|
|||||||
.Where(_cultIds.ContainsKey)
|
.Where(_cultIds.ContainsKey)
|
||||||
.Select(c => {
|
.Select(c => {
|
||||||
c.CultId = _cultIds[c];
|
c.CultId = _cultIds[c];
|
||||||
ctx.Entry(c).State = EntityState.Added;
|
ctx.Entry(c).State = EntityState.Modified;
|
||||||
return c;
|
return c;
|
||||||
}));
|
}));
|
||||||
await ctx.SaveChangesAsync();
|
await ctx.SaveChangesAsync();
|
||||||
|
|||||||
Loaded 100 of 126 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user