Compare commits
11
Commits
v0.9.1
..
c966604b07
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
c966604b07 | ||
|
|
c0d7053847 | ||
|
|
612a55a070 | ||
|
|
b3e7b64baf | ||
|
|
81ee99ef27 | ||
|
|
59e7d96131 | ||
|
|
7b49ed8b47 | ||
|
|
e725cac742 | ||
|
|
15d1a26251 | ||
|
|
05caa559b4 | ||
|
|
22130bcb41 |
@@ -208,7 +208,6 @@ public class KasPerson
|
||||
|
||||
public static int GenerateNewID(int base_id)
|
||||
{
|
||||
//var newid = 100000 + base_id;
|
||||
int highest = 0;
|
||||
foreach (var set in Settings._instance.addressSets.addresses)
|
||||
{
|
||||
@@ -217,8 +216,6 @@ public class KasPerson
|
||||
if(add.id >= highest) highest = add.id+1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return highest + base_id + 1;
|
||||
}
|
||||
|
||||
@@ -228,10 +225,8 @@ public class KasPerson
|
||||
{
|
||||
return refsid + " - " + name;
|
||||
}
|
||||
else
|
||||
{
|
||||
return id + " - " + name;
|
||||
}
|
||||
|
||||
return id + " - " + name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -239,12 +234,10 @@ public class KasPersonError
|
||||
{
|
||||
public KasPersonError((List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>) single_result)
|
||||
{
|
||||
//refsid = single_result.Item1;
|
||||
errors = single_result.Item1;
|
||||
warnings = single_result.Item2;
|
||||
}
|
||||
|
||||
//public int refsid { get; set; }
|
||||
public List<AddressCheck.ErrorTypes> errors { get; set; } = new();
|
||||
public List<AddressCheck.WarningTypes> warnings { get; set; } = new();
|
||||
|
||||
|
||||
@@ -0,0 +1,181 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
/// <summary>
|
||||
/// Handles schema versioning and migrations for JSON data structures.
|
||||
/// This system allows tracking schema changes and automatically migrating
|
||||
/// old data to new formats when the schema version changes.
|
||||
/// </summary>
|
||||
public static class SchemaMigration
|
||||
{
|
||||
// Current schema version - increment when you make breaking changes
|
||||
public const int CURRENT_SCHEMA_VERSION = 3;
|
||||
|
||||
// Dictionary of migration functions, keyed by the version they migrate TO
|
||||
private static readonly Dictionary<int, Func<JObject, JObject>> Migrations = new()
|
||||
{
|
||||
// Example: Migration from v1 to v2
|
||||
// When loading v1 data, this will be called to upgrade to v2
|
||||
// { 2, MigrateV1ToV2 },
|
||||
|
||||
// Example: Migration from v2 to v3
|
||||
// { 3, MigrateV2ToV3 },
|
||||
};
|
||||
|
||||
/// <summary>
|
||||
/// Checks the schema version of loaded JSON and applies migrations if needed.
|
||||
/// </summary>
|
||||
public static JObject MigrateIfNeeded(JObject jsonObject, int? loadedVersion)
|
||||
{
|
||||
// If no version found, assume it's version 1 (legacy data)
|
||||
int sourceVersion = loadedVersion ?? 1;
|
||||
|
||||
// If versions match, no migration needed
|
||||
if (sourceVersion == CURRENT_SCHEMA_VERSION)
|
||||
return jsonObject;
|
||||
|
||||
// If loaded version is newer than current, warn and return as-is
|
||||
if (sourceVersion > CURRENT_SCHEMA_VERSION)
|
||||
{
|
||||
Logger.Log($"Warning: Data schema version {sourceVersion} is newer than application schema version {CURRENT_SCHEMA_VERSION}. " +
|
||||
"This might indicate data was created with a newer version of the application.",
|
||||
Logger.LogType.Warning);
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
// Apply migrations sequentially from source version to current version
|
||||
Logger.Log($"Migrating data from schema version {sourceVersion} to {CURRENT_SCHEMA_VERSION}", Logger.LogType.Info);
|
||||
|
||||
for (int targetVersion = sourceVersion + 1; targetVersion <= CURRENT_SCHEMA_VERSION; targetVersion++)
|
||||
{
|
||||
if (Migrations.TryGetValue(targetVersion, out var migration))
|
||||
{
|
||||
try
|
||||
{
|
||||
jsonObject = migration(jsonObject);
|
||||
Logger.Log($"Successfully migrated to schema version {targetVersion}", Logger.LogType.Info);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error during migration to version {targetVersion}: {ex.Message}", Logger.LogType.Error);
|
||||
throw;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Logger.Log($"No migration defined from version {targetVersion - 1} to {targetVersion}", Logger.LogType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
return jsonObject;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Example migration function: from v1 to v2.
|
||||
/// Rename 'old_field_name' to 'new_field_name'
|
||||
/// </summary>
|
||||
private static JObject MigrateV1ToV2(JObject obj)
|
||||
{
|
||||
// Example: Rename a field
|
||||
if (obj.TryGetValue("old_field_name", out var value))
|
||||
{
|
||||
obj["new_field_name"] = value;
|
||||
obj.Remove("old_field_name");
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Example migration function: from v2 to v3.
|
||||
/// Add a new required field with a default value.
|
||||
/// </summary>
|
||||
private static JObject MigrateV2ToV3(JObject obj)
|
||||
{
|
||||
// Example: Add a new field that didn't exist before
|
||||
if (!obj.ContainsKey("new_required_field"))
|
||||
{
|
||||
obj["new_required_field"] = "default_value";
|
||||
}
|
||||
|
||||
return obj;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Registers a new migration function that will be called when upgrading to a specific version.
|
||||
/// Call this during application startup to register your custom migrations.
|
||||
/// </summary>
|
||||
/// <param name="targetVersion">The schema version this migration upgrades TO</param>
|
||||
/// <param name="migration">The migration function that transforms the JObject</param>
|
||||
public static void RegisterMigration(int targetVersion, Func<JObject, JObject> migration)
|
||||
{
|
||||
if (targetVersion <= 1)
|
||||
throw new ArgumentException("Target version must be greater than 1");
|
||||
|
||||
if (Migrations.ContainsKey(targetVersion))
|
||||
Logger.Log($"Warning: Overwriting existing migration for version {targetVersion}", Logger.LogType.Warning);
|
||||
|
||||
Migrations[targetVersion] = migration;
|
||||
Logger.Log($"Registered migration to schema version {targetVersion}", Logger.LogType.Info);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method: Add a new property to an object if it doesn't exist
|
||||
/// </summary>
|
||||
public static void AddPropertyIfMissing(JObject obj, string propertyName, object defaultValue)
|
||||
{
|
||||
if (!obj.ContainsKey(propertyName))
|
||||
{
|
||||
obj[propertyName] = JToken.FromObject(defaultValue);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method: Rename a property in a JSON object
|
||||
/// </summary>
|
||||
public static void RenameProperty(JObject obj, string oldName, string newName)
|
||||
{
|
||||
if (obj.TryGetValue(oldName, out var value))
|
||||
{
|
||||
obj[newName] = value;
|
||||
obj.Remove(oldName);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method: Move a nested property to the root level
|
||||
/// </summary>
|
||||
public static void FlattenProperty(JObject obj, string sourcePath, string targetPropertyName)
|
||||
{
|
||||
var value = obj.SelectToken(sourcePath);
|
||||
if (value != null)
|
||||
{
|
||||
obj[targetPropertyName] = value;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method: Merge a root property into a nested object
|
||||
/// </summary>
|
||||
public static void NestProperty(JObject obj, string propertyName, string nestedPath)
|
||||
{
|
||||
if (obj.TryGetValue(propertyName, out var value))
|
||||
{
|
||||
var parts = nestedPath.Split('.');
|
||||
JObject current = obj;
|
||||
|
||||
for (int i = 0; i < parts.Length - 1; i++)
|
||||
{
|
||||
if (!current.ContainsKey(parts[i]))
|
||||
current[parts[i]] = new JObject();
|
||||
current = (JObject)current[parts[i]];
|
||||
}
|
||||
|
||||
current[parts[^1]] = value;
|
||||
obj.Remove(propertyName);
|
||||
}
|
||||
}
|
||||
}
|
||||
+54
-22
@@ -2,19 +2,23 @@ using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
public class Settings
|
||||
{
|
||||
public static Settings _instance = new();
|
||||
|
||||
/// <summary>
|
||||
/// Schema version - increment this when you make breaking changes to the Settings structure
|
||||
/// </summary>
|
||||
public int schemaVersion { get; set; } = SchemaMigration.CURRENT_SCHEMA_VERSION;
|
||||
|
||||
public AddressSets addressSets = new();
|
||||
public Customers customers = new();
|
||||
public PdfExportSettings pdfExport { get; set; } = new();
|
||||
|
||||
// public string settingsPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
// "logofclient", "config.json");
|
||||
|
||||
public Settings()
|
||||
{
|
||||
_instance = this;
|
||||
@@ -25,20 +29,36 @@ public class Settings
|
||||
{
|
||||
if (!Directory.Exists(Global._instance.config_path) && !File.Exists((Global._instance.config_path)))
|
||||
Directory.CreateDirectory(Global._instance.config_path);
|
||||
// if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||
|
||||
var json = JsonConvert.SerializeObject(_instance);
|
||||
// Always save with current schema version
|
||||
_instance.schemaVersion = SchemaMigration.CURRENT_SCHEMA_VERSION;
|
||||
var json = JsonConvert.SerializeObject(_instance, Formatting.Indented);
|
||||
File.WriteAllText(Path.Combine(Global._instance.config_path,"config.json"), json);
|
||||
}
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
//if (!string.IsNullOrEmpty(Global._instance.config_path)) _instance.settingsPath = Global._instance.config_path;
|
||||
|
||||
try
|
||||
{
|
||||
var contents = File.ReadAllText(Path.Combine(Global._instance.config_path, "config.json"));
|
||||
_instance = JsonConvert.DeserializeObject<Settings>(contents);
|
||||
|
||||
// First, parse as JObject to check schema version
|
||||
var jsonObject = JObject.Parse(contents);
|
||||
int? loadedVersion = jsonObject["schemaVersion"]?.Value<int>();
|
||||
|
||||
// Apply migrations if needed
|
||||
jsonObject = SchemaMigration.MigrateIfNeeded(jsonObject, loadedVersion);
|
||||
|
||||
// Now deserialize the migrated JSON
|
||||
_instance = jsonObject.ToObject<Settings>();
|
||||
|
||||
// Save after migration to persist the upgraded schema
|
||||
if (loadedVersion != SchemaMigration.CURRENT_SCHEMA_VERSION)
|
||||
{
|
||||
Logger.Log("Settings file was migrated to new schema version and saved.", Logger.LogType.Info);
|
||||
Save();
|
||||
}
|
||||
|
||||
MainWindow._instance.RefreshCustomerItems();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -88,6 +108,11 @@ public class Global
|
||||
{
|
||||
public static Global _instance;
|
||||
|
||||
/// <summary>
|
||||
/// Schema version - increment this when you make breaking changes to the Global structure
|
||||
/// </summary>
|
||||
public int schemaVersion { get; set; } = SchemaMigration.CURRENT_SCHEMA_VERSION;
|
||||
|
||||
public Global()
|
||||
{
|
||||
_instance = this;
|
||||
@@ -116,6 +141,9 @@ public class Global
|
||||
"logofclient")))
|
||||
Directory.CreateDirectory(Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
|
||||
"logofclient"));
|
||||
|
||||
// Always save with current schema version
|
||||
_instance.schemaVersion = SchemaMigration.CURRENT_SCHEMA_VERSION;
|
||||
var json = JsonConvert.SerializeObject(_instance, Formatting.Indented);
|
||||
File.WriteAllText(
|
||||
Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "logofclient",
|
||||
@@ -124,18 +152,29 @@ public class Global
|
||||
|
||||
public static void Load()
|
||||
{
|
||||
// if (!File.Exists(Path.Combine(
|
||||
// Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "logofclient",
|
||||
// "global.config")))
|
||||
// File.Create(Path.Combine(
|
||||
// Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "logofclient",
|
||||
// "global.config"));
|
||||
try
|
||||
{
|
||||
var contents = File.ReadAllText(Path.Combine(
|
||||
Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), "logofclient",
|
||||
"global.config"));
|
||||
_instance = JsonConvert.DeserializeObject<Global>(contents) ?? new Global();
|
||||
|
||||
// First, parse as JObject to check schema version
|
||||
var jsonObject = JObject.Parse(contents);
|
||||
int? loadedVersion = jsonObject["schemaVersion"]?.Value<int>();
|
||||
|
||||
// Apply migrations if needed
|
||||
jsonObject = SchemaMigration.MigrateIfNeeded(jsonObject, loadedVersion);
|
||||
|
||||
// Now deserialize the migrated JSON
|
||||
_instance = jsonObject.ToObject<Global>() ?? new Global();
|
||||
|
||||
// Save after migration to persist the upgraded schema
|
||||
if (loadedVersion != SchemaMigration.CURRENT_SCHEMA_VERSION)
|
||||
{
|
||||
Logger.Log("Global settings file was migrated to new schema version and saved.", Logger.LogType.Info);
|
||||
Save();
|
||||
}
|
||||
|
||||
_instance.NormalizePaths();
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -196,13 +235,6 @@ public class Customer
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// public static int GetIDByCustomerListItem(string item_content)
|
||||
// {
|
||||
// var id = item_content.Split(" - ")[0];
|
||||
// return int.Parse(id);
|
||||
// }
|
||||
}
|
||||
|
||||
public class AddressSets
|
||||
|
||||
@@ -28,7 +28,6 @@ public static class Logger
|
||||
{
|
||||
Console.WriteLine(ex);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public enum LogType
|
||||
|
||||
+19
-2
@@ -154,7 +154,7 @@
|
||||
<TextBlock TextWrapping="Wrap" FontSize="9" Text="Generiert Versandetiketten und Bundleitzettel" HorizontalAlignment="Stretch" TextAlignment="Left"></TextBlock>
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Width="250" IsEnabled="False"
|
||||
<Button Width="250" IsEnabled="False" Click="BtnRepair_OnClick"
|
||||
HorizontalContentAlignment="Center" x:Name="BtnRepair" VerticalAlignment="Stretch"
|
||||
Margin="0,0,0,10">
|
||||
<StackPanel Orientation="Vertical">
|
||||
@@ -220,7 +220,6 @@
|
||||
<Label FontSize="9"
|
||||
Content="Elemente der ersten Menge ohne Elemente der zweiten Menge" />
|
||||
</StackPanel>
|
||||
|
||||
</Button>
|
||||
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
||||
HorizontalContentAlignment="Center" x:Name="BtnCombineSymmetric"
|
||||
@@ -248,6 +247,24 @@
|
||||
<CheckBox HorizontalAlignment="Left" x:Name="CbMergeDeleteOld" IsChecked="False">Lösche ursprüngliche Sets</CheckBox>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
<Label HorizontalAlignment="Center" Content="Reihenfolge:"></Label>
|
||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10">
|
||||
<ListBox x:Name="LstCombineAddressSetSort" SelectionMode="Single" SelectionChanged="LstCombineAddressSetSort_OnSelectionChanged"></ListBox>
|
||||
<StackPanel Orientation="Vertical">
|
||||
<Button HorizontalAlignment="Stretch" MinWidth="40"
|
||||
HorizontalContentAlignment="Center" x:Name="BtnCombineAddressSetSortUp"
|
||||
Click="BtnCombineAddressSetSortUp_OnClick"
|
||||
Margin="0,0,0,10">
|
||||
<LucideIcon Kind="ArrowBigUp" Width="36" Height="36" />
|
||||
</Button>
|
||||
<Button HorizontalAlignment="Stretch" MinWidth="40"
|
||||
HorizontalContentAlignment="Center" x:Name="BtnCombineAddressSetSortDown"
|
||||
Click="BtnCombineAddressSetSortDown_OnClick"
|
||||
Margin="0,0,0,10">
|
||||
<LucideIcon Kind="ArrowBigDown" Width="36" Height="36" />
|
||||
</Button>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
<Grid Grid.Row="2" Margin="20" ColumnDefinitions="*,5*,*" IsVisible="False" x:Name="GrdExportMarginOptions">
|
||||
|
||||
+116
-85
@@ -31,7 +31,7 @@ public partial class MainWindow : Window
|
||||
SetSettingsCustomerEnabledState(false);
|
||||
//Hide();
|
||||
|
||||
var s = new StartupWindow();
|
||||
//var s = new StartupWindow();
|
||||
//s.Show();
|
||||
|
||||
_instance = this;
|
||||
@@ -85,54 +85,49 @@ public partial class MainWindow : Window
|
||||
{
|
||||
Logger.Log($"Error while doing wiki stuff: {ex.Message}", Logger.LogType.Error);
|
||||
}
|
||||
|
||||
//Thread.Sleep(3000);
|
||||
//Show();
|
||||
}
|
||||
|
||||
private async void StartAddressCheck(int addresSetID)
|
||||
{
|
||||
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
|
||||
|
||||
var progressWindow = new ProgressWindow();
|
||||
|
||||
progressWindow.Show(_instance);
|
||||
|
||||
var processor = new AddressCheck(progressWindow);
|
||||
var result = await processor.Perform(addresSetID);
|
||||
|
||||
// foreach (var item in result)
|
||||
// {
|
||||
// }
|
||||
|
||||
progressWindow.Close();
|
||||
|
||||
|
||||
new ResultWindow(result, addresSetID).Show();
|
||||
|
||||
Settings.Save();
|
||||
|
||||
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
|
||||
RefreshAddressSetListItems((LstCustomers.SelectedItem as Customer).ID);
|
||||
}
|
||||
|
||||
private async void StartAddressShortener(KasAddressList set)
|
||||
{
|
||||
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
|
||||
|
||||
var progressWindow = new ProgressWindow();
|
||||
|
||||
progressWindow.Show(_instance);
|
||||
|
||||
var processor = new AddressShortener(progressWindow);
|
||||
await processor.Perform(set);
|
||||
|
||||
// foreach (var item in result)
|
||||
// {
|
||||
// }
|
||||
progressWindow.Close();
|
||||
Settings.Save();
|
||||
|
||||
RefreshAddressSetListItems((LstCustomers.SelectedItem as Customer).ID);
|
||||
}
|
||||
|
||||
private async void StartAddressRepairer(KasAddressList set)
|
||||
{
|
||||
var progressWindow = new ProgressWindow();
|
||||
progressWindow.Show(_instance);
|
||||
|
||||
var processor = new AddressRepair(progressWindow);
|
||||
await processor.Perform(set);
|
||||
|
||||
progressWindow.Close();
|
||||
Settings.Save();
|
||||
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
|
||||
|
||||
RefreshAddressSetListItems((LstCustomers.SelectedItem as Customer).ID);
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +145,7 @@ public partial class MainWindow : Window
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "https://mypapercloud.de/logof/",
|
||||
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -166,7 +161,7 @@ public partial class MainWindow : Window
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "https://mypapercloud.de/logof/wiki/",
|
||||
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -182,7 +177,7 @@ public partial class MainWindow : Window
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "https://git.mypapercloud.de/fierke/logofclient",
|
||||
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
|
||||
UseShellExecute = true
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -231,19 +226,6 @@ public partial class MainWindow : Window
|
||||
_selectedWikiFilePath = item.Path;
|
||||
var text = await _wikiService.LoadFileContentAsync(item.Path);
|
||||
MsvWikiView.Markdown = text;
|
||||
// try
|
||||
// {
|
||||
// PreviewPanel.Children.Clear();
|
||||
// var rendered = MarkdownRenderer.Render(text ?? string.Empty);
|
||||
// PreviewPanel.Children.Add(rendered);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Logger.Log($"Error while rendering markdown: {ex.Message}", Logger.LogType.Error);
|
||||
// PreviewPanel.Children.Clear();
|
||||
// PreviewPanel.Children.Add(new TextBlock { Text = text ?? string.Empty });
|
||||
// }
|
||||
|
||||
EditButton.IsEnabled = true;
|
||||
}
|
||||
else
|
||||
@@ -387,8 +369,7 @@ public partial class MainWindow : Window
|
||||
TbWikiPath.Text = chosen;
|
||||
Global._instance.wiki_storage_path = chosen;
|
||||
Global.Save();
|
||||
|
||||
// reinit wiki service and reload tree
|
||||
|
||||
_wikiService = new WikiService();
|
||||
PopulateNavTree();
|
||||
}
|
||||
@@ -404,7 +385,6 @@ public partial class MainWindow : Window
|
||||
|
||||
if (folder == null || folder.Count == 0) return;
|
||||
var chosen = PathUtilities.NormalizeFileSystemPath(folder[0].Path);
|
||||
//TbFontPath.Text = chosen;
|
||||
Global._instance.font_path = chosen;
|
||||
Global.Save();
|
||||
}
|
||||
@@ -448,9 +428,6 @@ public partial class MainWindow : Window
|
||||
Settings._instance.addressSets.addresses.Add(result.Item2);
|
||||
Settings.Save();
|
||||
progressWindow.Close();
|
||||
|
||||
|
||||
//new ResultWindow(result, addresSetID).Show();
|
||||
}
|
||||
|
||||
|
||||
@@ -480,8 +457,6 @@ public partial class MainWindow : Window
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == Settings._instance.customers.current.ID)
|
||||
customer.name = TbSettingsCustomerName.Text;
|
||||
//Settings.Save();
|
||||
//RefreshCustomerItems();
|
||||
}
|
||||
|
||||
private void LstSettingsCustomers_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
@@ -490,9 +465,6 @@ public partial class MainWindow : Window
|
||||
if (LstSettingsCustomers.SelectedIndex < 0) return;
|
||||
Settings._instance.customers.current =
|
||||
((Customer)LstSettingsCustomers.SelectedItems[0]);
|
||||
//foreach (var customer in Settings._instance.customers.customers)
|
||||
//if (customer.ID == Settings._instance.customers.current.ID)
|
||||
//{
|
||||
TbSettingsCustomerDescription.Text = Settings._instance.customers.current.description;
|
||||
TbSettingsCustomerName.Text = Settings._instance.customers.current.name;
|
||||
TbSettingsCustomerSenderAddress.Text = Settings._instance.customers.current.sender_address;
|
||||
@@ -502,12 +474,19 @@ public partial class MainWindow : Window
|
||||
else
|
||||
TbSettingsCustomerPatchInfo.Text = "";
|
||||
SetSettingsCustomerEnabledState();
|
||||
//}
|
||||
}
|
||||
|
||||
private void SetSettingsCustomerEnabledState(bool enable = true)
|
||||
{
|
||||
List<Object> nboom = new() { BtnSettingsImportCustomerAddressPatch, GrdCSVDividerButtonsAndTb, TbSettingsCustomerDescription, TbSettingsCustomerName, BtnDeleteCustomer, TbSettingsCustomerSenderAddress};
|
||||
List<Object> nboom = new()
|
||||
{
|
||||
BtnSettingsImportCustomerAddressPatch,
|
||||
GrdCSVDividerButtonsAndTb,
|
||||
TbSettingsCustomerDescription,
|
||||
TbSettingsCustomerName,
|
||||
BtnDeleteCustomer,
|
||||
TbSettingsCustomerSenderAddress
|
||||
};
|
||||
foreach (var obj in nboom)
|
||||
{
|
||||
(obj as Control).IsEnabled = enable;
|
||||
@@ -530,8 +509,6 @@ public partial class MainWindow : Window
|
||||
PopulateNavTree(editedWikiFilePath, editedWikiFilePath);
|
||||
};
|
||||
ew.Show();
|
||||
|
||||
//await MessageBox.Show(this, "Edit feature is currently disabled.", "Edit Disabled");
|
||||
}
|
||||
|
||||
public void RefreshCustomerItems(int index = 0)
|
||||
@@ -598,7 +575,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
try
|
||||
{
|
||||
MakeCalcManVisible();
|
||||
MakeCalcManVisible();
|
||||
var opts = new FilePickerOpenOptions();
|
||||
opts.Title = "Address-Set importieren...";
|
||||
opts.AllowMultiple = false;
|
||||
@@ -608,14 +585,11 @@ public partial class MainWindow : Window
|
||||
opts.FileTypeFilter = new[] { type };
|
||||
|
||||
var paths = await StorageProvider.OpenFilePickerAsync(opts);
|
||||
|
||||
if (paths?.Count <= 0) return;
|
||||
|
||||
if (LstCustomers.SelectedIndex < 0) return;
|
||||
|
||||
|
||||
var selected_path = paths[0].Path;
|
||||
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer == ((Customer)LstCustomers.SelectedItems[0]))
|
||||
{
|
||||
@@ -631,8 +605,6 @@ public partial class MainWindow : Window
|
||||
got.Item2.SetOwner(customer.ID);
|
||||
Settings._instance.addressSets.addresses.Add(got.Item2);
|
||||
}
|
||||
|
||||
//var customer_id = int.Parse(LstCustomers.SelectedItem.ToString().Split(" - ")[0]);
|
||||
RefreshAddressSetListItems(customer.ID);
|
||||
}
|
||||
else
|
||||
@@ -647,8 +619,6 @@ public partial class MainWindow : Window
|
||||
got.Item2.SetOwner(customer.ID);
|
||||
Settings._instance.addressSets.addresses.Add(got.Item2);
|
||||
}
|
||||
|
||||
//var customer_id = int.Parse(LstCustomers.SelectedItem.ToString().Split(" - ")[0]);
|
||||
RefreshAddressSetListItems(customer.ID);
|
||||
}
|
||||
}
|
||||
@@ -704,7 +674,7 @@ public partial class MainWindow : Window
|
||||
if (pers.PersonError != null)
|
||||
{
|
||||
BtnShorten.IsEnabled = true;
|
||||
// BtnRepair.IsEnabled = true;
|
||||
BtnRepair.IsEnabled = true;
|
||||
break;
|
||||
}
|
||||
else
|
||||
@@ -712,9 +682,15 @@ public partial class MainWindow : Window
|
||||
BtnShorten.IsEnabled = false;
|
||||
BtnRepair.IsEnabled = false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
||||
LstCombineAddressSetSort.Items.Clear();
|
||||
foreach (var selected in LstCustomerAdressSets.SelectedItems)
|
||||
{
|
||||
try
|
||||
{
|
||||
LstCombineAddressSetSort.Items.Add(selected as KasAddressList);
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -733,19 +709,13 @@ public partial class MainWindow : Window
|
||||
opts.FileTypeFilter = new[] { type };
|
||||
|
||||
var paths = await StorageProvider.OpenFilePickerAsync(opts);
|
||||
|
||||
if (paths?.Count <= 0) return;
|
||||
|
||||
//if (LstSettingsCustomers.SelectedIndex < 0) return;
|
||||
|
||||
|
||||
var selected_path = paths[0].Path;
|
||||
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == ((Customer)LstSettingsCustomers.SelectedItems[0]).ID)
|
||||
customer.patch = AddressPatch.Import(selected_path);
|
||||
|
||||
|
||||
|
||||
Settings.Save();
|
||||
} catch (Exception ex)
|
||||
{
|
||||
@@ -776,13 +746,12 @@ public partial class MainWindow : Window
|
||||
MessageBox.Show(this, "Unknown Error: " + ex.Message, "Error");
|
||||
Logger.Log($"Error while converting: {ex.Message}", Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void BtnCombineDifference_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var list = new List<KasAddressList>();
|
||||
foreach (var item in LstCustomerAdressSets.SelectedItems)
|
||||
foreach (var item in LstCombineAddressSetSort.Items)
|
||||
list.Add((KasAddressList)item);
|
||||
try
|
||||
{
|
||||
@@ -797,7 +766,7 @@ public partial class MainWindow : Window
|
||||
private void BtnCombineUnion_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var list = new List<KasAddressList>();
|
||||
foreach (var item in LstCustomerAdressSets.SelectedItems)
|
||||
foreach (var item in LstCombineAddressSetSort.Items)
|
||||
list.Add((KasAddressList)item);
|
||||
try
|
||||
{
|
||||
@@ -813,7 +782,7 @@ public partial class MainWindow : Window
|
||||
private void BtnCombineIntersection_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var list = new List<KasAddressList>();
|
||||
foreach (var item in LstCustomerAdressSets.SelectedItems)
|
||||
foreach (var item in LstCombineAddressSetSort.Items)
|
||||
list.Add((KasAddressList)item);
|
||||
try
|
||||
{
|
||||
@@ -830,7 +799,8 @@ public partial class MainWindow : Window
|
||||
if (RbComprefsid.IsChecked == true)
|
||||
{
|
||||
return CombineAddresses.CombineType.refsid;
|
||||
} else if (RbCompfinAd.IsChecked == true)
|
||||
}
|
||||
if (RbCompfinAd.IsChecked == true)
|
||||
{
|
||||
return CombineAddresses.CombineType.final_adress;
|
||||
}
|
||||
@@ -841,7 +811,7 @@ public partial class MainWindow : Window
|
||||
private void BtnCombineSymmetricDifference_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var list = new List<KasAddressList>();
|
||||
foreach (var item in LstCustomerAdressSets.SelectedItems)
|
||||
foreach (var item in LstCombineAddressSetSort.Items)
|
||||
list.Add((KasAddressList)item);
|
||||
|
||||
StartCombine(list, Convert.ToInt32((LstCustomers.SelectedItem as Customer).ID), "symdiff", GetCombiningTyp());
|
||||
@@ -892,8 +862,10 @@ public partial class MainWindow : Window
|
||||
filePath
|
||||
);
|
||||
|
||||
Logger.Log("PDF OK");
|
||||
Logger.Log("PDF seems OK");
|
||||
}
|
||||
|
||||
RefreshAddressSetListItems((LstCustomers.SelectedItem as Customer).ID);
|
||||
}
|
||||
|
||||
catch (Exception ex)
|
||||
@@ -1089,9 +1061,7 @@ public partial class MainWindow : Window
|
||||
}
|
||||
|
||||
if (_selectedCountry == null) return;
|
||||
//Console.WriteLine("Refreshing alternatives...");
|
||||
foreach (var a in _selectedCountry.alternatives) LbSettingsAlternatives.Items.Add(a);
|
||||
//Console.WriteLine(a);
|
||||
TbSettingsCountryName.Text = _selectedCountry.name;
|
||||
TbSettingsCountryTranslation.Text = _selectedCountry.translation;
|
||||
|
||||
@@ -1246,7 +1216,6 @@ public partial class MainWindow : Window
|
||||
if (set.ID == id)
|
||||
{
|
||||
curr_set = set;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -1309,7 +1278,6 @@ public partial class MainWindow : Window
|
||||
{
|
||||
Logger.Log($"Error while changing CSV divider: {ex.Message}", Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private async void MnIAdSetDelete_OnClick(object? sender, RoutedEventArgs e)
|
||||
@@ -1327,14 +1295,14 @@ public partial class MainWindow : Window
|
||||
Settings.Save();
|
||||
RefreshAddressSetListItems(cus_id);
|
||||
break;
|
||||
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
MessageBox.Show(this, ex.StackTrace, "Fehler");
|
||||
Logger.Log($"Error while deleting address set: {ex.Message}", Logger.LogType.Error);
|
||||
}}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void Tb_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
@@ -1346,4 +1314,67 @@ public partial class MainWindow : Window
|
||||
{
|
||||
PopulateNavTree();
|
||||
}
|
||||
|
||||
private void BtnRepair_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
MakeCalcManVisible();
|
||||
if (LstCustomerAdressSets.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show(null, "Bitte zunächst ein Adress-Set auswählen", "Kein Adress-Set ausgewählt");
|
||||
return;
|
||||
}
|
||||
|
||||
StartAddressRepairer((KasAddressList)LstCustomerAdressSets.SelectedItem);
|
||||
}
|
||||
|
||||
private void BtnCombineAddressSetSortUp_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var selected = (LstCombineAddressSetSort.SelectedItem as KasAddressList);
|
||||
int index = LstCombineAddressSetSort.SelectedIndex;
|
||||
if (LstCombineAddressSetSort.SelectedIndex != null && LstCombineAddressSetSort.SelectedIndex != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
LstCombineAddressSetSort.Items.RemoveAt(index);
|
||||
LstCombineAddressSetSort.Items.Insert(index-1, selected);
|
||||
LstCombineAddressSetSort.SelectedIndex = index - 1;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnCombineAddressSetSortDown_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var selected = (LstCombineAddressSetSort.SelectedItem as KasAddressList);
|
||||
int index = LstCombineAddressSetSort.SelectedIndex;
|
||||
if (LstCombineAddressSetSort.SelectedIndex != null && LstCombineAddressSetSort.SelectedIndex != -1)
|
||||
{
|
||||
try
|
||||
{
|
||||
LstCombineAddressSetSort.Items.RemoveAt(index);
|
||||
LstCombineAddressSetSort.Items.Insert(index+1, selected);
|
||||
LstCombineAddressSetSort.SelectedIndex = index + 1;
|
||||
} catch {}
|
||||
}
|
||||
}
|
||||
|
||||
private void LstCombineAddressSetSort_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (LstCombineAddressSetSort.SelectedIndex == 0)
|
||||
{
|
||||
BtnCombineAddressSetSortDown.IsEnabled = true;
|
||||
BtnCombineAddressSetSortUp.IsEnabled = false;
|
||||
} else if (LstCombineAddressSetSort.SelectedIndex == LstCombineAddressSetSort.Items.Count - 1)
|
||||
{
|
||||
BtnCombineAddressSetSortUp.IsEnabled = true;
|
||||
BtnCombineAddressSetSortDown.IsEnabled = false;
|
||||
} else if (LstCombineAddressSetSort.SelectedIndex == LstCombineAddressSetSort.Items.Count - 1 && LstCombineAddressSetSort.SelectedIndex == 0)
|
||||
{
|
||||
BtnCombineAddressSetSortUp.IsEnabled = false;
|
||||
BtnCombineAddressSetSortDown.IsEnabled = false;
|
||||
} else
|
||||
{
|
||||
BtnCombineAddressSetSortDown.IsEnabled = true;
|
||||
BtnCombineAddressSetSortUp.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,7 +40,6 @@ public partial class NamingWindow : Window
|
||||
|
||||
AddButton("Ok");
|
||||
|
||||
|
||||
var tcs = new TaskCompletionSource<string>();
|
||||
wind.Closed += delegate { tcs.TrySetResult(res); };
|
||||
if (parent != null)
|
||||
|
||||
@@ -19,6 +19,5 @@ public partial class ProgressWindow : Window
|
||||
public void AddToLog(string message, string percent)
|
||||
{
|
||||
TbLog.Text = message + $"\n{percent}%";
|
||||
//ScvLog.ScrollToEnd();
|
||||
}
|
||||
}
|
||||
@@ -7,4 +7,4 @@ See [mypapercloud.de](https://mypapercloud.de/logof) for more.
|
||||
Please report any bugs you find to fierke@mypapertown.de, thank you!
|
||||
|
||||
## Contributing
|
||||
Feel free to contribute to this project using your MyPaperCloud-Account (request it via fierke@mypapertown.de) or a local git.mypapercloud.de-Account you are able to create.
|
||||
See [CODE OF CONDUCT](https://git.mypapercloud.de/fierke/logofclient/src/branch/main/CODE_OF_CONDUCT.md)
|
||||
+61
-2
@@ -3,8 +3,9 @@
|
||||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
|
||||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
|
||||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" Icon="assets/icon.ico"
|
||||
xmlns:local="using:Logof_Client"
|
||||
x:Class="Logof_Client.ResultWindow"
|
||||
Title="Ergebnis">
|
||||
Title="Ergebnis" x:DataType="local:ResultWindow">
|
||||
<Grid Grid.ColumnDefinitions="200,*">
|
||||
<Grid>
|
||||
<Label Content="Filter" Margin="10,10,10,0" HorizontalAlignment="Stretch" VerticalAlignment="Top" />
|
||||
@@ -21,7 +22,65 @@
|
||||
</Grid>
|
||||
<ScrollViewer Grid.Column="1" HorizontalScrollBarVisibility="Auto" VerticalScrollBarVisibility="Auto">
|
||||
<!-- <TextBlock x:Name="TbResults"></TextBlock> -->
|
||||
<ListBox x:Name="LbResults"></ListBox>
|
||||
<!-- <ListBox x:Name="LbResults"></ListBox> -->
|
||||
<!-- <DataGrid ItemsSource="{Binding Results}" IsReadOnly="True" -->
|
||||
<!-- AutoGenerateColumns="False"> -->
|
||||
<!-- -->
|
||||
<!-- -->
|
||||
<!-- <DataGrid.Columns> -->
|
||||
<!-- <DataGridTextColumn Header="ID" -->
|
||||
<!-- Binding="{Binding PersonId}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Name" -->
|
||||
<!-- Binding="{Binding Name}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Errors" -->
|
||||
<!-- Binding="{Binding Errors}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Warnings" -->
|
||||
<!-- Binding="{Binding Warnings}" /> -->
|
||||
<!-- -->
|
||||
<!-- <DataGridTextColumn Header="Refsid" -->
|
||||
<!-- Binding="{Binding Refsid}" /> -->
|
||||
<!-- </DataGrid.Columns> -->
|
||||
<!-- -->
|
||||
<!-- </DataGrid> -->
|
||||
<ListBox ItemsSource="{Binding Results}" SelectedItems="{Binding SelectedResults}">
|
||||
<ListBox.ItemsPanel>
|
||||
<ItemsPanelTemplate>
|
||||
<VirtualizingStackPanel />
|
||||
</ItemsPanelTemplate>
|
||||
</ListBox.ItemsPanel>
|
||||
|
||||
<ListBox.ItemTemplate>
|
||||
<DataTemplate>
|
||||
<Grid Margin="2">
|
||||
<Grid.ColumnDefinitions>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="*"/>
|
||||
<ColumnDefinition Width="2*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
<ColumnDefinition Width="3*"/>
|
||||
</Grid.ColumnDefinitions>
|
||||
|
||||
<TextBlock Grid.Column="0"
|
||||
Text="{Binding PersonId}" />
|
||||
|
||||
<TextBlock Grid.Column="1"
|
||||
Text="{Binding Refsid}" />
|
||||
|
||||
<TextBlock Grid.Column="2"
|
||||
Text="{Binding Name}" />
|
||||
|
||||
<TextBlock Grid.Column="3"
|
||||
Text="{Binding Errors}" />
|
||||
|
||||
<TextBlock Grid.Column="4"
|
||||
Text="{Binding Warnings}" />
|
||||
</Grid>
|
||||
</DataTemplate>
|
||||
</ListBox.ItemTemplate>
|
||||
</ListBox>
|
||||
<!-- <StackPanel x:Name="StkResults" Orientation="Vertical" Margin="10" /> -->
|
||||
</ScrollViewer>
|
||||
|
||||
|
||||
+71
-75
@@ -1,6 +1,9 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.ObjectModel;
|
||||
using System.ComponentModel;
|
||||
using System.Linq;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Avalonia;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Interactivity;
|
||||
@@ -8,79 +11,72 @@ using Avalonia.Layout;
|
||||
using Avalonia.Media;
|
||||
|
||||
namespace Logof_Client;
|
||||
using System.ComponentModel;
|
||||
using System.Runtime.CompilerServices;
|
||||
|
||||
public partial class ResultWindow : Window
|
||||
public partial class ResultWindow : Window, INotifyPropertyChanged
|
||||
{
|
||||
public event PropertyChangedEventHandler? PropertyChanged;
|
||||
|
||||
private List<ResultItem> _results = new();
|
||||
|
||||
public List<ResultItem> Results
|
||||
{
|
||||
get => _results;
|
||||
private set
|
||||
{
|
||||
_results = value;
|
||||
PropertyChanged?.Invoke(
|
||||
this,
|
||||
new PropertyChangedEventArgs(nameof(Results))
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
public List<CheckBox> errortypecheckboxes = new();
|
||||
public KasAddressList ur_addresses = new("Ergebnis_" + DateTime.Now.ToString("ddMMyy_HHmmss"));
|
||||
public List<KasPerson> ur_result;
|
||||
public List<CheckBox> warningtypecheckboxes = new();
|
||||
public List<ResultItem>? SelectedResults { get; set; }
|
||||
|
||||
public ResultWindow(List<KasPerson> result,
|
||||
int addressSetID)
|
||||
public ResultWindow(List<KasPerson> result, int addressSetID)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
DataContext = this;
|
||||
|
||||
ur_result = result;
|
||||
ur_addresses = ur_addresses;
|
||||
|
||||
Load(result);
|
||||
//ViewSingle(200552426);
|
||||
}
|
||||
|
||||
private void GenerateView(List<KasPerson> result)
|
||||
{
|
||||
//public List<ResultItem> Results { get; private set; } = new();
|
||||
private void GenerateView(List<KasPerson> result) {
|
||||
try
|
||||
{
|
||||
|
||||
|
||||
// Filter to only show persons with errors
|
||||
var result_with_errors = result.Where(p => p.PersonError != null).ToList();
|
||||
LblResultCount.Content = $"{result_with_errors.Count}/{ur_result.Count} Ergebnisse";
|
||||
|
||||
// TbResults.Text = "";
|
||||
// foreach (var person in result_with_errors) TbResults.Text += person.PersonError.GetString()+"\n";
|
||||
LbResults.Items.Clear();
|
||||
foreach (var person in result_with_errors) LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
// StkResults.Children.Clear();
|
||||
// foreach (var person in result_with_errors) StkResults.Children.Add(CreatePersonGrid(person));
|
||||
//LbResults.Items.Clear();
|
||||
// foreach (var person in result_with_errors)
|
||||
// LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
Results = result_with_errors
|
||||
.Select(person => new ResultItem
|
||||
{
|
||||
Person = person,
|
||||
PersonId = person.id,
|
||||
Name = $"{person.vorname} {person.name}".Trim(),
|
||||
Errors = string.Join(", ", person.PersonError.errors),
|
||||
Warnings = string.Join(", ", person.PersonError.warnings),
|
||||
Refsid = person.refsid.ToString() ?? ""
|
||||
})
|
||||
.ToList();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log("Error while generating result view: " + ex.Message, Logger.LogType.Warning);
|
||||
}
|
||||
}
|
||||
|
||||
private Grid CreatePersonGrid(KasPerson person)
|
||||
{
|
||||
var grid = new Grid
|
||||
{
|
||||
ColumnDefinitions = ColumnDefinitions.Parse("100,*,100,*,100,*"),
|
||||
RowDefinitions = RowDefinitions.Parse("Auto"),
|
||||
Margin = new Thickness(0, 5, 0, 5),
|
||||
Background = new SolidColorBrush(Color.Parse("#F0F0F0"))
|
||||
};
|
||||
|
||||
// ID
|
||||
grid.Children.Add(new TextBlock
|
||||
{
|
||||
Text = "id: ",
|
||||
FontWeight = FontWeight.Bold, Margin = new Thickness(5)
|
||||
});
|
||||
grid.Children.Add(new TextBlock { Text = person.id.ToString(), Margin = new Thickness(5) });
|
||||
Grid.SetColumn(grid.Children[1], 1);
|
||||
|
||||
// PLZ
|
||||
grid.Children.Add(new TextBlock { Text = "plz:", FontWeight = FontWeight.Bold, Margin = new Thickness(5) });
|
||||
Grid.SetColumn(grid.Children[2], 2);
|
||||
grid.Children.Add(new TextBlock { Text = person.plz, Margin = new Thickness(5) });
|
||||
Grid.SetColumn(grid.Children[3], 3);
|
||||
|
||||
// PPLZ
|
||||
grid.Children.Add(new TextBlock { Text = "errors:", FontWeight = FontWeight.Bold, Margin = new Thickness(5) });
|
||||
Grid.SetColumn(grid.Children[4], 4);
|
||||
grid.Children.Add(new TextBlock { Text = person.PersonError.GetString(), Margin = new Thickness(5) });
|
||||
Grid.SetColumn(grid.Children[5], 5);
|
||||
|
||||
return grid;
|
||||
Logger.Log("Error while generating result view: " + ex.Message, Logger.LogType.Warning);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
private void ViewSingle(int id)
|
||||
@@ -139,7 +135,7 @@ public partial class ResultWindow : Window
|
||||
var cb = new CheckBox();
|
||||
cb.IsChecked = true;
|
||||
cb.Content = errtype.ToString();
|
||||
//cb.Click += (sender, e) => UpdateFilter();
|
||||
|
||||
errortypecheckboxes.Add(cb);
|
||||
StpFilterOptions.Children.Add(cb);
|
||||
}
|
||||
@@ -149,7 +145,7 @@ public partial class ResultWindow : Window
|
||||
var cb = new CheckBox();
|
||||
cb.IsChecked = true;
|
||||
cb.Content = wartype.ToString();
|
||||
//cb.Click += (sender, e) => UpdateFilter();
|
||||
|
||||
warningtypecheckboxes.Add(cb);
|
||||
StpFilterOptions.Children.Add(cb);
|
||||
}
|
||||
@@ -163,10 +159,6 @@ public partial class ResultWindow : Window
|
||||
|
||||
}
|
||||
|
||||
private void BtnUpdateFilter_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
}
|
||||
|
||||
private void UpdateFilter()
|
||||
{
|
||||
try
|
||||
@@ -224,12 +216,10 @@ public partial class ResultWindow : Window
|
||||
|
||||
LblResultCount.Content = $"{temp_result.Count}/{ur_result.Count} Ergebnisse";
|
||||
|
||||
LbResults.Items.Clear();
|
||||
foreach (var person in temp_result) LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
// TbResults.Text = "";
|
||||
// foreach (var person in temp_result) TbResults.Text += person.PersonError.GetString() +"\n";
|
||||
// StkResults.Children.Clear();
|
||||
// foreach (var person in temp_result) StkResults.Children.Add(CreatePersonGrid(person));
|
||||
//LbResults.Items.Clear();
|
||||
GenerateView(temp_result);
|
||||
//foreach (var person in temp_result) LbResults.Items.Add(person.PersonError.ToString(person));
|
||||
|
||||
} catch (Exception ex)
|
||||
{
|
||||
Logger.Log("Error while updating filter: " + ex.Message, Logger.LogType.Warning);
|
||||
@@ -240,16 +230,7 @@ public partial class ResultWindow : Window
|
||||
|
||||
private void BtnShowSelected_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
// foreach (var selected in DgResult.SelectedItems)
|
||||
// try
|
||||
// {
|
||||
// var _asKas = (KasPerson)selected;
|
||||
// ViewSingle(_asKas.id);
|
||||
// }
|
||||
// catch (Exception ex)
|
||||
// {
|
||||
// Console.WriteLine(ex.Message);
|
||||
// }
|
||||
// once upon a time, there was a feature like this
|
||||
}
|
||||
|
||||
private void BtnExecuteFilter_OnClick(object? sender, RoutedEventArgs e)
|
||||
@@ -257,4 +238,19 @@ public partial class ResultWindow : Window
|
||||
Console.WriteLine("Updating filter...");
|
||||
UpdateFilter();
|
||||
}
|
||||
}
|
||||
//public ObservableCollection<ResultItem> Results { get; } = new();
|
||||
}
|
||||
public class ResultItem
|
||||
{
|
||||
public int PersonId { get; init; }
|
||||
|
||||
public string Name { get; init; } = "";
|
||||
|
||||
public string Errors { get; init; } = "";
|
||||
|
||||
public string Warnings { get; init; } = "";
|
||||
|
||||
public string Refsid { get; init; } = "";
|
||||
|
||||
public KasPerson Person { get; init; } = null!;
|
||||
}
|
||||
|
||||
@@ -8,6 +8,4 @@ public partial class StartupWindow : Window
|
||||
{
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
+73
-79
@@ -58,6 +58,33 @@ public class AddressCheck
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
|
||||
// Refsids, die mehrfach vorkommen
|
||||
var doubledRefsids = adset.KasPersons
|
||||
.Where(p => p.refsid > 0)
|
||||
.GroupBy(p => p.refsid)
|
||||
.Where(g => g.Count() > 1)
|
||||
.ToDictionary(g => g.Key, g => true);
|
||||
|
||||
// Adressen, die mehrfach vorkommen
|
||||
var doubledAddresses = adset.KasPersons
|
||||
.GroupBy(p => (
|
||||
p.name,
|
||||
p.strasse,
|
||||
p.vorname,
|
||||
p.ort,
|
||||
p.funktion,
|
||||
p.funktion2,
|
||||
p.funktionad,
|
||||
p.abteilung,
|
||||
p.name1,
|
||||
p.name2,
|
||||
p.name3,
|
||||
p.name4,
|
||||
p.name5))
|
||||
.Where(g => g.Count() > 1)
|
||||
.ToDictionary(g => g.Key, g => true);
|
||||
|
||||
foreach (var person in adset.KasPersons)
|
||||
{
|
||||
var errors = new List<ErrorTypes>();
|
||||
@@ -79,20 +106,6 @@ public class AddressCheck
|
||||
hasFaults = true;
|
||||
errors.Add(ErrorTypes.PlzNotUsable);
|
||||
}
|
||||
// if ((person.plz < 10000 && string.IsNullOrWhiteSpace(person.land)) ||
|
||||
// (person.plz < 10000 && person.land == "GER") ||
|
||||
// (person.plz < 10000 && person.land == "DE"))
|
||||
// {
|
||||
// hasFaults = true;
|
||||
// errors.Add(ErrorTypes.PlzTooShort);
|
||||
// }
|
||||
// else if ((person.plz > 99999 && string.IsNullOrWhiteSpace(person.land)) ||
|
||||
// (person.plz > 99999 && person.land == "GER") ||
|
||||
// (person.plz > 99999 && person.land == "DE"))
|
||||
// {
|
||||
// hasFaults = true;
|
||||
// errors.Add(ErrorTypes.PlzTooLong);
|
||||
// }
|
||||
}
|
||||
|
||||
|
||||
@@ -109,21 +122,6 @@ public class AddressCheck
|
||||
hasFaults = true;
|
||||
errors.Add(ErrorTypes.PPlzNotUsable);
|
||||
}
|
||||
|
||||
// if ((person.pplz < 10000 && string.IsNullOrWhiteSpace(person.land)) ||
|
||||
// (person.pplz < 10000 && person.land == "GER") ||
|
||||
// (person.pplz < 10000 && person.land == "DE"))
|
||||
// {
|
||||
// hasFaults = true;
|
||||
// errors.Add(ErrorTypes.PPlzTooShort);
|
||||
// }
|
||||
// else if ((person.pplz > 99999 && string.IsNullOrWhiteSpace(person.land)) ||
|
||||
// (person.pplz > 99999 && person.land == "GER") ||
|
||||
// (person.pplz > 99999 && person.land == "DE"))
|
||||
// {
|
||||
// hasFaults = true;
|
||||
// errors.Add(ErrorTypes.PPlzTooLong);
|
||||
// }
|
||||
}
|
||||
|
||||
if (warnings.Contains(WarningTypes.NoPLZ) && warnings.Contains(WarningTypes.NoPPLZ))
|
||||
@@ -184,47 +182,34 @@ public class AddressCheck
|
||||
}
|
||||
|
||||
// Address-Component-Count
|
||||
if (!string.IsNullOrWhiteSpace(person.strasse2)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.land)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.name1)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.name2)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.name3)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.name4)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.name5)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.funktion)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.funktion2)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.funktionad)) address_component_count++;
|
||||
if (!string.IsNullOrWhiteSpace(person.abteilung)) address_component_count++;
|
||||
|
||||
// Double-Refsid or DoubleAddresses
|
||||
foreach (var person2 in adset.KasPersons)
|
||||
// Double-Refsid
|
||||
if (person.refsid > 0 &&
|
||||
doubledRefsids.ContainsKey(person.refsid))
|
||||
{
|
||||
if (adset.KasPersons.IndexOf(person) == adset.KasPersons.IndexOf(person2)) continue;
|
||||
|
||||
if (person.refsid == person2.refsid) // trifft auf Patch-Addressen nicht zu
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.DoubledRefsid);
|
||||
}
|
||||
|
||||
if (person.name == person2.name &&
|
||||
person.strasse == person2.strasse &&
|
||||
person.vorname == person2.vorname &&
|
||||
person.ort == person2.ort &&
|
||||
person.funktion == person2.funktion &&
|
||||
person.funktion2 == person2.funktion2 &&
|
||||
person.funktionad == person2.funktionad &&
|
||||
person.abteilung == person2.abteilung &&
|
||||
person.name1 == person2.name1 &&
|
||||
person.name2 == person2.name2 &&
|
||||
person.name3 == person2.name3 &&
|
||||
person.name4 == person2.name4 &&
|
||||
person.name5 == person2.name5) //
|
||||
|
||||
{
|
||||
hasFaults = true;
|
||||
errors.Add(ErrorTypes.MayBeSameAddress);
|
||||
}
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.DoubledRefsid);
|
||||
}
|
||||
|
||||
// Double-Address
|
||||
var addressKey = (
|
||||
person.name,
|
||||
person.strasse,
|
||||
person.vorname,
|
||||
person.ort,
|
||||
person.funktion,
|
||||
person.funktion2,
|
||||
person.funktionad,
|
||||
person.abteilung,
|
||||
person.name1,
|
||||
person.name2,
|
||||
person.name3,
|
||||
person.name4,
|
||||
person.name5);
|
||||
|
||||
if (doubledAddresses.ContainsKey(addressKey))
|
||||
{
|
||||
hasFaults = true;
|
||||
errors.Add(ErrorTypes.MayBeSameAddress);
|
||||
}
|
||||
|
||||
// Adressen-Länge
|
||||
@@ -246,16 +231,26 @@ public class AddressCheck
|
||||
}
|
||||
|
||||
// Fortschritt aktualisieren
|
||||
Interlocked.Increment(ref current);
|
||||
var percent = current / (double)total * 100;
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
if (hasFaults)
|
||||
_progress.AddToLog($"Person mit id {person.id} ist fehlerhaft",
|
||||
Convert.ToInt32(percent).ToString());
|
||||
// Interlocked.Increment(ref current);
|
||||
// var percent = current / (double)total * 100;
|
||||
// await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
// {
|
||||
// if (hasFaults)
|
||||
// _progress.AddToLog($"Person mit id {person.id} ist fehlerhaft",
|
||||
// Convert.ToInt32(percent).ToString());
|
||||
//
|
||||
// _progress.ChangePercentage(percent);
|
||||
// });
|
||||
|
||||
var cd = Interlocked.Increment(ref current);
|
||||
|
||||
_progress.ChangePercentage(percent);
|
||||
});
|
||||
if (cd % 10 == 0)
|
||||
{
|
||||
var percent = cd / (double)total * 100;
|
||||
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
_progress.ChangePercentage(percent));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
@@ -265,7 +260,6 @@ public class AddressCheck
|
||||
return Settings._instance.addressSets.addresses[adset_index].KasPersons
|
||||
.Where(p => p.PersonError != null)
|
||||
.ToList();
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
@@ -5,36 +5,6 @@ namespace Logof_Client;
|
||||
|
||||
public static class AddressCreator
|
||||
{
|
||||
//+++ Aufbau +++
|
||||
//
|
||||
// Von unten anfangen, max. 7 Zeilen
|
||||
//
|
||||
// + Wenn Land nicht Deutschland Abbildung von Land (Fettgedruckt)
|
||||
//
|
||||
// Alternative A (wenn PPLZ + Ort ausgefüllt):
|
||||
// + Abbildung PPLZ + Ort - Ort ggf. Abschneiden, wenn länger als eine Zeile … das längste was ich finden konnte: „Giugliano in Campania-Lago Patra“ (passt exakt auf eine Zeile)
|
||||
// + Abbildung Postfach – wenn leer, dann Straße
|
||||
// + Abbildung Wenn Anredezusatz nicht leer, Anredezusatz, sonst Anrede + Titel + Vorname + Adel + Name + Namenszusatz in Klammern
|
||||
// + Abbildung Name 1 + Name 2 + Name 3 + Name 4 + Name 5 + Abteilung (insgesamt max. 7 Zeilen)
|
||||
//
|
||||
// ansonsten
|
||||
//
|
||||
// + Abbildung PLZ + Ort - Ort ggf. Abschneiden, wenn länger als eine Zeile … das längste was ich finden konnte: „Giugliano in Campania-Lago Patra“ (passt exakt auf eine Zeile)
|
||||
// + Abbildung Straße – wenn Straße leer, dann Postfach
|
||||
// + Abbildung Wenn Anredezusatz nicht leer, Anredezusatz, sonst Anrede + Titel + Vorname + Adel + Name + Namenszusatz in Klammern
|
||||
// + Abbildung Name 1 + Name 2 + Name 3 + Name 4 + Name 5 + Abteilung (insgesamt max. 7 Zeilen)
|
||||
//
|
||||
// Auswurf Fehler-Datei
|
||||
//
|
||||
// + wenn keine PLZ und/oder kein Ort -> Fehler
|
||||
// + wenn kein Name 1-5 und/oder Name -> Fehler
|
||||
//
|
||||
// Auswurf CSV-Datei (Komma/TAB, UTF-8, ISO…)
|
||||
//
|
||||
// Auswurf PDF mit normalen Absender
|
||||
//
|
||||
// Auswurf PDF mit PvSt.
|
||||
|
||||
/// <summary>
|
||||
/// Creates max-seven-lines-long Markdown address-string. Analyzes the KasPerson-Instance to find the best result.
|
||||
/// </summary>
|
||||
@@ -93,7 +63,7 @@ public static class AddressCreator
|
||||
}
|
||||
|
||||
CountryFound:
|
||||
string_address = "**" + countryToShow + "**"; // Needs to be bold
|
||||
string_address = "**" + countryToShow + "**"; // bold
|
||||
address_line_count++;
|
||||
}
|
||||
|
||||
@@ -125,8 +95,7 @@ public static class AddressCreator
|
||||
string_address = nameline + "\n" + string_address;
|
||||
address_line_count++;
|
||||
}
|
||||
|
||||
// REIHENFOLGE
|
||||
|
||||
var nameattribs = new[]
|
||||
{ address.name1, address.name2, address.name3, address.name4, address.name5, address.abteilung };
|
||||
|
||||
@@ -152,7 +121,6 @@ public static class AddressCreator
|
||||
{
|
||||
string plz = address.plz;
|
||||
if (address.IsGermany()) plz = NormalizeGermanPLZ(address.plz);
|
||||
|
||||
|
||||
KasPerson.SetUsedPLZ(id, plz);
|
||||
string_address = plz + " " + address.ort + "\n" + string_address;
|
||||
@@ -214,8 +182,7 @@ public static class AddressCreator
|
||||
.Where(s => !string.IsNullOrWhiteSpace(s))
|
||||
)
|
||||
+ (string.IsNullOrWhiteSpace(namezus) ? "" : $" ({namezus.Trim()})");
|
||||
|
||||
// else
|
||||
|
||||
return string.Join(" ",
|
||||
new[] { anrede, titel, vorname, adel, name }
|
||||
.Where(s => !string.IsNullOrWhiteSpace(s))
|
||||
@@ -271,7 +238,6 @@ public static class AddressCreator
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public static string NormalizeGermanPLZ(string plz)
|
||||
|
||||
+31
-34
@@ -63,37 +63,37 @@ public class AddressPatch
|
||||
{
|
||||
var patch = new AddressPatch();
|
||||
|
||||
// Alle Zeilen aus der Datei laden
|
||||
var lines = File.ReadAllLines(filename.LocalPath);
|
||||
|
||||
// Alle Properties der Klasse (Strings und bools)
|
||||
var properties = typeof(AddressPatch).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
// Nur die Properties, die mit _is enden (also die String-Werte)
|
||||
var stringProps = properties.Where(p => p.PropertyType == typeof(string) && p.Name.EndsWith("_is"));
|
||||
|
||||
foreach (var prop in stringProps)
|
||||
{
|
||||
// Beispiel: prop.Name = "name_is"
|
||||
var baseName = prop.Name.Substring(0, prop.Name.Length - 3); // "name"
|
||||
|
||||
// In der Datei wird nach "name:" gesucht (ohne _is)
|
||||
var line = lines.FirstOrDefault(l => l.StartsWith(baseName + ":"));
|
||||
if (line != null)
|
||||
{
|
||||
// Wert extrahieren (alles nach dem Doppelpunkt)
|
||||
var value = line.Substring(line.IndexOf(':') + 1).Trim();
|
||||
|
||||
// Wert im Patch-Objekt setzen
|
||||
prop.SetValue(patch, value);
|
||||
|
||||
// Passendes has_ Feld aktivieren, z.B. "has_name"
|
||||
var hasProp = properties.FirstOrDefault(p => p.Name == "has_" + baseName);
|
||||
if (hasProp != null && hasProp.PropertyType == typeof(bool)) hasProp.SetValue(patch, true);
|
||||
}
|
||||
}
|
||||
|
||||
return patch;
|
||||
// Alle Zeilen aus der Datei laden
|
||||
var lines = File.ReadAllLines(filename.LocalPath);
|
||||
|
||||
// Alle Properties der Klasse (Strings und bools)
|
||||
var properties = typeof(AddressPatch).GetProperties(BindingFlags.Public | BindingFlags.Instance);
|
||||
|
||||
// Nur die Properties, die mit _is enden (also die String-Werte)
|
||||
var stringProps = properties.Where(p => p.PropertyType == typeof(string) && p.Name.EndsWith("_is"));
|
||||
|
||||
foreach (var prop in stringProps)
|
||||
{
|
||||
// Beispiel: prop.Name = "name_is"
|
||||
var baseName = prop.Name.Substring(0, prop.Name.Length - 3); // "name"
|
||||
|
||||
// In der Datei wird nach "name:" gesucht (ohne _is)
|
||||
var line = lines.FirstOrDefault(l => l.StartsWith(baseName + ":"));
|
||||
if (line != null)
|
||||
{
|
||||
// Wert extrahieren (alles nach dem Doppelpunkt)
|
||||
var value = line.Substring(line.IndexOf(':') + 1).Trim();
|
||||
|
||||
// Wert im Patch-Objekt setzen
|
||||
prop.SetValue(patch, value);
|
||||
|
||||
// Passendes has_ Feld aktivieren, z.B. "has_name"
|
||||
var hasProp = properties.FirstOrDefault(p => p.Name == "has_" + baseName);
|
||||
if (hasProp != null && hasProp.PropertyType == typeof(bool)) hasProp.SetValue(patch, true);
|
||||
}
|
||||
}
|
||||
|
||||
return patch;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -101,8 +101,6 @@ public class AddressPatch
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -135,6 +133,5 @@ public class AddressPatch
|
||||
}
|
||||
|
||||
return "Error while parsing";
|
||||
|
||||
}
|
||||
}
|
||||
+14
-8
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
@@ -7,20 +8,25 @@ public class AddressRepair(ProgressWindow progressWindow)
|
||||
{
|
||||
private readonly ProgressWindow _progress = progressWindow;
|
||||
|
||||
public KasAddressList Perform(KasAddressList all_addresses,
|
||||
List<(int, List<AddressCheck.ErrorTypes>)> failed_addresses)
|
||||
public async Task Perform(KasAddressList list)
|
||||
{
|
||||
try
|
||||
{
|
||||
|
||||
foreach (var person in list.KasPersons)
|
||||
{
|
||||
// German PLZ too short (e.g. Dresden)
|
||||
if (person.IsGermany() && person.plz.Length <= 4)
|
||||
{
|
||||
while (person.plz.Length <= 4)
|
||||
{
|
||||
person.plz = "0" + person.plz;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error while performing address repair: {ex.Message}", Logger.LogType.Error);
|
||||
Logger.Log($"Error while performing address shortener: {ex.Message}", Logger.LogType.Error);
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
+50
-53
@@ -8,72 +8,69 @@ namespace Logof_Client;
|
||||
|
||||
public class AddressShortener(ProgressWindow progressWindow)
|
||||
{
|
||||
private readonly ProgressWindow _progress = progressWindow;
|
||||
|
||||
public async Task Perform(KasAddressList list)
|
||||
{
|
||||
try
|
||||
{
|
||||
List<int> doubled_ids = new List<int>();
|
||||
for (int i = 0; i < list.KasPersons.Count; i++)
|
||||
{
|
||||
var address = list.KasPersons[i];
|
||||
for (int j = 0; j < list.KasPersons.Count; j++)
|
||||
{
|
||||
if (i == j) continue;
|
||||
var sec_address = list.KasPersons[j];
|
||||
|
||||
if (address.refsid == sec_address.refsid && !doubled_ids.Contains(address.refsid) && address.refsid != 0)
|
||||
{
|
||||
doubled_ids.Add(address.refsid);
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int i = 0; i < list.KasPersons.Count; i++)
|
||||
{
|
||||
var address = list.KasPersons[i];
|
||||
for (int j = 0; j < list.KasPersons.Count; j++)
|
||||
{
|
||||
if (i == j) continue;
|
||||
var sec_address = list.KasPersons[j];
|
||||
|
||||
|
||||
// delete doubled addresses by refsid
|
||||
foreach (int id in doubled_ids)
|
||||
if (address.refsid == sec_address.refsid && !doubled_ids.Contains(address.refsid) && address.refsid != 0)
|
||||
{
|
||||
// does this remove both of the doubled addresses?
|
||||
list.KasPersons.Remove(list.KasPersons.FirstOrDefault(x => x.refsid == id));
|
||||
doubled_ids.Add(address.refsid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
List<int> toRemove = new List<int>();
|
||||
foreach (var address in list.KasPersons)
|
||||
// delete doubled addresses by refsid
|
||||
foreach (int id in doubled_ids)
|
||||
{
|
||||
// does this remove both of the doubled addresses?
|
||||
list.KasPersons.Remove(list.KasPersons.FirstOrDefault(x => x.refsid == id));
|
||||
}
|
||||
|
||||
List<int> toRemove = new List<int>();
|
||||
foreach (var address in list.KasPersons)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.NoPLZorPPLZ))
|
||||
{
|
||||
try
|
||||
{
|
||||
if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.NoPLZorPPLZ))
|
||||
{
|
||||
toRemove.Add(address.id);
|
||||
}
|
||||
else if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PlzNotUsable) &&
|
||||
address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PPlzNotUsable))
|
||||
{
|
||||
toRemove.Add(address.id);
|
||||
} else if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PlzNotUsable) &&
|
||||
address.PersonError.warnings.Contains(AddressCheck.WarningTypes.NoPPLZ))
|
||||
{
|
||||
toRemove.Add(address.id);
|
||||
}
|
||||
else if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PPlzNotUsable) &&
|
||||
address.PersonError.warnings.Contains(AddressCheck.WarningTypes.NoPLZ))
|
||||
{
|
||||
toRemove.Add(address.id);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("PersonError not accessible: " + address.id);
|
||||
}
|
||||
toRemove.Add(address.id);
|
||||
}
|
||||
|
||||
// delete doubled addresses by refsid
|
||||
foreach (int id in toRemove)
|
||||
else if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PlzNotUsable) &&
|
||||
address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PPlzNotUsable))
|
||||
{
|
||||
// does this remove both of the doubled addresses?
|
||||
list.KasPersons.Remove(list.KasPersons.Find(x => x.id == id));
|
||||
toRemove.Add(address.id);
|
||||
} else if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PlzNotUsable) &&
|
||||
address.PersonError.warnings.Contains(AddressCheck.WarningTypes.NoPPLZ))
|
||||
{
|
||||
toRemove.Add(address.id);
|
||||
}
|
||||
else if (address.PersonError.errors.Contains(AddressCheck.ErrorTypes.PPlzNotUsable) &&
|
||||
address.PersonError.warnings.Contains(AddressCheck.WarningTypes.NoPLZ))
|
||||
{
|
||||
toRemove.Add(address.id);
|
||||
}
|
||||
}
|
||||
catch
|
||||
{
|
||||
Console.WriteLine("PersonError not accessible: " + address.id);
|
||||
}
|
||||
}
|
||||
|
||||
// delete doubled addresses by refsid
|
||||
foreach (int id in toRemove)
|
||||
{
|
||||
// does this remove both of the doubled addresses?
|
||||
list.KasPersons.Remove(list.KasPersons.Find(x => x.id == id));
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
+10
-19
@@ -30,15 +30,15 @@ public class CombineAddresses
|
||||
{
|
||||
var result = await Execute(address_lists,type,comb_type,exportUnused);
|
||||
|
||||
if (deleteOld == true)
|
||||
{
|
||||
foreach (var list in address_lists)
|
||||
{
|
||||
Settings._instance.addressSets.addresses.Remove(list);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
if (deleteOld == true)
|
||||
{
|
||||
foreach (var list in address_lists)
|
||||
{
|
||||
Settings._instance.addressSets.addresses.Remove(list);
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -46,8 +46,6 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
return (null,null);
|
||||
|
||||
|
||||
}
|
||||
|
||||
private async Task<(KasAddressList, KasAddressList)> Execute(List<KasAddressList> address_lists, string type, CombineType comb_type,
|
||||
@@ -67,7 +65,6 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
return (null,null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -144,8 +141,7 @@ public class CombineAddresses
|
||||
result.KasPersons.Add(person);
|
||||
else
|
||||
second_result.KasPersons.Add(person);
|
||||
|
||||
|
||||
|
||||
progress.Increment();
|
||||
if (progress.LogAction == null) continue;
|
||||
var logMessage =
|
||||
@@ -162,7 +158,6 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
return (null,null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -211,7 +206,6 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
return (null,null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -274,7 +268,6 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
return (null,null);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -343,9 +336,7 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
return (null,null);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Progress
|
||||
|
||||
+1
-3
@@ -59,8 +59,7 @@ public class CsvBuilder
|
||||
EscapeCsvField(l.abteilung),
|
||||
EscapeCsvField(l.funktionad)
|
||||
}));
|
||||
|
||||
// weitere Cases
|
||||
|
||||
return result.ToString();
|
||||
}
|
||||
|
||||
@@ -81,6 +80,5 @@ public class CsvBuilder
|
||||
}
|
||||
|
||||
return "";
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
+2
-19
@@ -130,9 +130,7 @@ public class DataImport
|
||||
var hasProperties = patchType.GetProperties(binding)
|
||||
.Where(p => p.PropertyType == typeof(bool) && p.Name.StartsWith("has_", StringComparison.OrdinalIgnoreCase))
|
||||
.ToArray();
|
||||
|
||||
//var last_refsid = 1000000;
|
||||
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
var line = reader.ReadLine();
|
||||
@@ -143,8 +141,6 @@ public class DataImport
|
||||
|
||||
var fieldValues = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
//var refsid_existing = false;
|
||||
|
||||
foreach (var hasProp in hasProperties)
|
||||
{
|
||||
var fieldName = hasProp.Name.Substring(4);
|
||||
@@ -240,23 +236,10 @@ public class DataImport
|
||||
{
|
||||
Logger.Log($"Error while importing kas address list with patch: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
|
||||
// int GenerateNewRefsid()
|
||||
// {
|
||||
// var biggest = last_refsid;
|
||||
// foreach (var set in Settings._instance.addressSets.addresses)
|
||||
// foreach (var address in set.KasPersons)
|
||||
// if (biggest < address.id)
|
||||
// biggest = address.id + 1;
|
||||
//
|
||||
// last_refsid = biggest + 1;
|
||||
// return last_refsid;
|
||||
// }
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private static int ParseInt(string input)
|
||||
{
|
||||
return int.TryParse(input, out var result) ? result : 0;
|
||||
|
||||
+18
-74
@@ -48,8 +48,6 @@ public class PdfBuilder
|
||||
{
|
||||
Logger.Log($"Error while font resolving: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private static void EnsureFontResolverRegistered()
|
||||
@@ -57,14 +55,12 @@ public class PdfBuilder
|
||||
try
|
||||
{
|
||||
if (GlobalFontSettings.FontResolver != null) return;
|
||||
//var fontsDir = Path.Combine(AppContext.BaseDirectory, "fonts");
|
||||
GlobalFontSettings.FontResolver = new StableFontResolver(Global._instance.font_path);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error while ensuring font resolver register state: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private static string StripStyleSuffix(string name)
|
||||
@@ -84,7 +80,6 @@ public class PdfBuilder
|
||||
}
|
||||
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -101,11 +96,6 @@ public class PdfBuilder
|
||||
{
|
||||
// Find the AddressSet by ID
|
||||
var addressSet = Settings._instance.addressSets.GetAddressSetByID(addressSetId);
|
||||
// foreach (var pers in addressSet.KasPersons)
|
||||
// {
|
||||
// AddressCreator.CreateFinalMarkdownString(pers.id);
|
||||
// }
|
||||
// addressSet.KasPersons = addressSet.KasPersons.OrderBy(x => x.IsGermany()).ThenBy(y => y.used_plz).ToList();
|
||||
|
||||
if (addressSet == null)
|
||||
throw new ArgumentException($"AddressSet with ID {addressSetId} not found");
|
||||
@@ -114,7 +104,6 @@ public class PdfBuilder
|
||||
throw new ArgumentException($"AddressSet with ID {addressSetId} contains no addresses");
|
||||
|
||||
// Generate markdown addresses from all KasPersons in the set
|
||||
//var addresses = new string?[addressSet.KasPersons.Count];
|
||||
var addresses_german = new List<string>();
|
||||
var addresses_inter = new List<string>();
|
||||
|
||||
@@ -170,8 +159,6 @@ public class PdfBuilder
|
||||
else
|
||||
addresses_inter.Add(addr);
|
||||
}
|
||||
|
||||
|
||||
|
||||
if (addresses_german.Count == 0 && addresses_inter.Count == 0)
|
||||
{
|
||||
@@ -188,17 +175,11 @@ public class PdfBuilder
|
||||
{
|
||||
ExportRunningSheets(addressSetId, outputPath);
|
||||
}
|
||||
//CreateAddressLabelPdfWithPlaceholder(addresses_german, placeholderText, outputPath);
|
||||
//CreateAddressLabelPdfWithPlaceholder(addresses_inter, placeholderText, output_inter);
|
||||
|
||||
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error while creating address label pdf from address set with placeholder: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -211,32 +192,31 @@ public class PdfBuilder
|
||||
{
|
||||
try
|
||||
{
|
||||
if (addresses == null || addresses.Count == 0)
|
||||
throw new ArgumentException("Addresses array cannot be null or empty");
|
||||
if (addresses == null || addresses.Count == 0)
|
||||
throw new ArgumentException("Addresses array cannot be null or empty");
|
||||
|
||||
var document = new PdfDocument();
|
||||
var document = new PdfDocument();
|
||||
|
||||
var addressIndex = 0;
|
||||
var isFirstCell = true;
|
||||
var addressIndex = 0;
|
||||
var isFirstCell = true;
|
||||
|
||||
while (addressIndex < addresses.Count || isFirstCell)
|
||||
while (addressIndex < addresses.Count || isFirstCell)
|
||||
{
|
||||
var page = document.AddPage();
|
||||
page.Size = PageSize.A4;
|
||||
|
||||
using (var gfx = XGraphics.FromPdfPage(page))
|
||||
{
|
||||
var page = document.AddPage();
|
||||
page.Size = PageSize.A4;
|
||||
|
||||
using (var gfx = XGraphics.FromPdfPage(page))
|
||||
{
|
||||
DrawPageWithPlaceholder(gfx, addresses, ref addressIndex, ref isFirstCell, placeholderText, pvst);
|
||||
}
|
||||
DrawPageWithPlaceholder(gfx, addresses, ref addressIndex, ref isFirstCell, placeholderText, pvst);
|
||||
}
|
||||
}
|
||||
|
||||
document.Save(outputPath);
|
||||
document.Save(outputPath);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Logger.Log($"Error while creating address label pdf with placeholder: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -272,7 +252,6 @@ public class PdfBuilder
|
||||
{
|
||||
Logger.Log($"Error while drawing page with placholder: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void DrawCell(XGraphics gfx, double x, double y, bool pvst, string? address, bool isPlaceholer = false)
|
||||
@@ -298,7 +277,6 @@ public class PdfBuilder
|
||||
{
|
||||
Logger.Log($"Error while drawing cell: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void InsertDPPressepostImage(XGraphics gfx, XRect cell)
|
||||
@@ -307,7 +285,6 @@ public class PdfBuilder
|
||||
{
|
||||
const double imageSizeX = 47.3; // pt
|
||||
const double imageSizeY = 14.8; // pt
|
||||
//const double margin = 20.0; // pt
|
||||
|
||||
var imagePath = Path.Combine("assets", "DP_VerkVermerk_PresseP_NAT.jpg");
|
||||
|
||||
@@ -344,7 +321,6 @@ public class PdfBuilder
|
||||
{
|
||||
Logger.Log($"Error while drawing empty cell: {ex.Message}",Logger.LogType.Error);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private enum TextStyle
|
||||
@@ -673,7 +649,6 @@ public class PdfBuilder
|
||||
return availableHeightMm / _settings.rowsPerPage;
|
||||
}
|
||||
|
||||
|
||||
public void ExportRunningSheets(int setID, string path)
|
||||
{
|
||||
string international_path = path;
|
||||
@@ -692,7 +667,6 @@ public class PdfBuilder
|
||||
|
||||
CreateGermanyRunningSheets(setID, path);
|
||||
CreateInternationalRunningSheets(setID, international_path);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -792,21 +766,8 @@ public class PdfBuilder
|
||||
document.Save(path);
|
||||
}
|
||||
|
||||
private void DrawGermanyRunningSheet(
|
||||
XGraphics gfx,
|
||||
double x,
|
||||
double y,
|
||||
double w,
|
||||
double h,
|
||||
KasAddressList list,
|
||||
dynamic result,
|
||||
List<(int,string,string,string,int)> grouped_nums,
|
||||
XFont fontLabel,
|
||||
XFont fontText,
|
||||
XFont fontBig,
|
||||
int pal_nr,
|
||||
int bundleOnPallet,
|
||||
int totalBundleNumber){
|
||||
private void DrawGermanyRunningSheet(XGraphics gfx, double x, double y, double w, double h, KasAddressList list, dynamic result, List<(int,string,string,string,int)> grouped_nums, XFont fontLabel, XFont fontText, XFont fontBig, int pal_nr, int bundleOnPallet, int totalBundleNumber)
|
||||
{
|
||||
double line = 1.0;
|
||||
|
||||
string sender = Customer.GetCustomerByID(list.owner_id)?.sender_address ?? "[Absender]";
|
||||
@@ -916,7 +877,6 @@ public class PdfBuilder
|
||||
new XRect(midSplit + 5, y + r1 + r2 + 4, w - (midSplit - x) - 10, 14),
|
||||
XStringFormats.TopLeft);
|
||||
|
||||
// Bottom left labels
|
||||
// Bottom left labels
|
||||
gfx.DrawString("Einlieferungsdatum:", fontLabel, XBrushes.Black,
|
||||
new XRect(x + 5, y + r1 + r2 + r3 + 4, leftBottomW - 10, 14),
|
||||
@@ -989,7 +949,7 @@ public class PdfBuilder
|
||||
KasAddressList list = Settings._instance.addressSets.GetAddressSetByID(setID);
|
||||
|
||||
var document = new PdfDocument();
|
||||
document.Info.Title = $"Laufzettel für {list.Name}";
|
||||
document.Info.Title = $"Leitzettel für {list.Name}";
|
||||
document.Info.Subject = "powered by logofclient";
|
||||
document.Info.Author = "logofclient";
|
||||
|
||||
@@ -1082,22 +1042,7 @@ public class PdfBuilder
|
||||
|
||||
document.Save(path);
|
||||
}
|
||||
private void DrawInternationalRunningSheet(
|
||||
XGraphics gfx,
|
||||
double x,
|
||||
double y,
|
||||
double w,
|
||||
double h,
|
||||
KasAddressList list,
|
||||
dynamic result,
|
||||
List<(int,string,string,string,int)> grouped_nums,
|
||||
XFont fontLabel,
|
||||
XFont fontText,
|
||||
XFont fontBig,
|
||||
int pal_nr,
|
||||
int bundleOnPallet,
|
||||
int totalBundleNumber,
|
||||
string category = "ECONOMY Non-EU")
|
||||
private void DrawInternationalRunningSheet(XGraphics gfx, double x, double y, double w, double h, KasAddressList list, dynamic result, List<(int,string,string,string,int)> grouped_nums, XFont fontLabel, XFont fontText, XFont fontBig, int pal_nr, int bundleOnPallet, int totalBundleNumber, string category = "ECONOMY Non-EU")
|
||||
{
|
||||
double line = 1.0;
|
||||
|
||||
@@ -1208,7 +1153,6 @@ public class PdfBuilder
|
||||
new XRect(midSplit + 5, y + r1 + r2 + 4, w - (midSplit - x) - 10, 14),
|
||||
XStringFormats.TopLeft);
|
||||
|
||||
// Bottom left labels
|
||||
// Bottom left labels
|
||||
gfx.DrawString("Einlieferungsdatum:", fontLabel, XBrushes.Black,
|
||||
new XRect(x + 5, y + r1 + r2 + r3 + 4, leftBottomW - 10, 14),
|
||||
|
||||
@@ -1,140 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Media;
|
||||
using Markdig;
|
||||
using Markdig.Syntax;
|
||||
using Markdig.Syntax.Inlines;
|
||||
using System.Text;
|
||||
|
||||
namespace Logof_Client.Wiki;
|
||||
|
||||
public static class MarkdownRenderer
|
||||
{
|
||||
// public static Control Render(string markdown)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// var panel = new StackPanel { Spacing = 6 };
|
||||
// if (string.IsNullOrWhiteSpace(markdown)) return panel;
|
||||
//
|
||||
// var doc = Markdown.Parse(markdown);
|
||||
//
|
||||
// foreach (var block in doc)
|
||||
// {
|
||||
// switch (block)
|
||||
// {
|
||||
// case HeadingBlock hb:
|
||||
// {
|
||||
// var text = GetInlineText(hb.Inline);
|
||||
// var tb = new TextBlock
|
||||
// {
|
||||
// Text = text,
|
||||
// FontWeight = FontWeight.Bold,
|
||||
// Margin = new Avalonia.Thickness(0, hb.Level == 1 ? 6 : 2, 0, 2)
|
||||
// };
|
||||
// tb.FontSize = hb.Level switch { 1 => 22, 2 => 18, 3 => 16, _ => 14 };
|
||||
// panel.Children.Add(tb);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case ParagraphBlock pb:
|
||||
// {
|
||||
// var text = GetInlineText(pb.Inline);
|
||||
// var tb = new TextBlock { Text = text, TextWrapping = Avalonia.Media.TextWrapping.Wrap };
|
||||
// panel.Children.Add(tb);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case FencedCodeBlock cb:
|
||||
// {
|
||||
// var sb = new StringBuilder();
|
||||
// foreach (var line in cb.Lines.Lines)
|
||||
// {
|
||||
// sb.Append(line.ToString());
|
||||
// }
|
||||
// var codeBox = new TextBox
|
||||
// {
|
||||
// Text = sb.ToString(),
|
||||
// FontFamily = "Consolas, monospace",
|
||||
// IsReadOnly = true,
|
||||
// AcceptsReturn = true
|
||||
// };
|
||||
// panel.Children.Add(codeBox);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// case ListBlock lb:
|
||||
// {
|
||||
// var sp = new StackPanel { Spacing = 2 };
|
||||
// var number = 1;
|
||||
// foreach (var item in lb)
|
||||
// {
|
||||
// if (item is ListItemBlock lib)
|
||||
// {
|
||||
// var itemText = new StringBuilder();
|
||||
// foreach (var sub in lib)
|
||||
// {
|
||||
// if (sub is ParagraphBlock pp)
|
||||
// itemText.Append(GetInlineText(pp.Inline));
|
||||
// }
|
||||
// var tb = new TextBlock { Text = (lb.IsOrdered ? (number++ + ". ") : "• ") + itemText.ToString() };
|
||||
// sp.Children.Add(tb);
|
||||
// }
|
||||
// }
|
||||
// panel.Children.Add(sp);
|
||||
// break;
|
||||
// }
|
||||
//
|
||||
// default:
|
||||
// {
|
||||
// // fallback: raw text
|
||||
// panel.Children.Add(new TextBlock { Text = block.ToString() });
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return panel;
|
||||
// } catch (Exception ex) { Logger.Log($"Error while : {ex.Message}",Logger.LogType.Error);}
|
||||
//
|
||||
// return new Panel();
|
||||
// }
|
||||
//
|
||||
// private static string GetInlineText(ContainerInline? container)
|
||||
// {
|
||||
// try
|
||||
// {
|
||||
// if (container == null) return string.Empty;
|
||||
// var sb = new StringBuilder();
|
||||
// foreach (var inline in container)
|
||||
// {
|
||||
// switch (inline)
|
||||
// {
|
||||
// case LiteralInline li:
|
||||
// sb.Append(li.Content.ToString());
|
||||
// break;
|
||||
// case EmphasisInline ei:
|
||||
// sb.Append(GetInlineText(ei));
|
||||
// break;
|
||||
// case CodeInline ci:
|
||||
// sb.Append(ci.Content);
|
||||
// break;
|
||||
// case LinkInline li:
|
||||
// sb.Append(GetInlineText(li));
|
||||
// break;
|
||||
// case LineBreakInline:
|
||||
// sb.Append("\n");
|
||||
// break;
|
||||
// default:
|
||||
// sb.Append(inline.ToString());
|
||||
// break;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return sb.ToString();
|
||||
// } catch (Exception ex) { Logger.Log($"Error while : {ex.Message}",Logger.LogType.Error);}
|
||||
//
|
||||
// return null;
|
||||
// }
|
||||
}
|
||||
Reference in New Issue
Block a user