2 Commits
3 changed files with 51 additions and 10 deletions
+1 -1
View File
@@ -154,7 +154,7 @@
<TextBlock TextWrapping="Wrap" FontSize="9" Text="Generiert Versandetiketten und Bundleitzettel" HorizontalAlignment="Stretch" TextAlignment="Left"></TextBlock> <TextBlock TextWrapping="Wrap" FontSize="9" Text="Generiert Versandetiketten und Bundleitzettel" HorizontalAlignment="Stretch" TextAlignment="Left"></TextBlock>
</StackPanel> </StackPanel>
</Button> </Button>
<Button Width="250" IsEnabled="False" <Button Width="250" IsEnabled="False" Click="BtnRepair_OnClick"
HorizontalContentAlignment="Center" x:Name="BtnRepair" VerticalAlignment="Stretch" HorizontalContentAlignment="Center" x:Name="BtnRepair" VerticalAlignment="Stretch"
Margin="0,0,0,10"> Margin="0,0,0,10">
<StackPanel Orientation="Vertical"> <StackPanel Orientation="Vertical">
+33 -1
View File
@@ -135,6 +135,26 @@ public partial class MainWindow : Window
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig"); //await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
} }
private async void StartAddressRepairer(KasAddressList set)
{
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
var progressWindow = new ProgressWindow();
progressWindow.Show(_instance);
var processor = new AddressRepair(progressWindow);
await processor.Perform(set);
// foreach (var item in result)
// {
// }
progressWindow.Close();
Settings.Save();
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
}
private void MnuExit_OnClick(object? sender, RoutedEventArgs e) private void MnuExit_OnClick(object? sender, RoutedEventArgs e)
{ {
@@ -704,7 +724,7 @@ public partial class MainWindow : Window
if (pers.PersonError != null) if (pers.PersonError != null)
{ {
BtnShorten.IsEnabled = true; BtnShorten.IsEnabled = true;
// BtnRepair.IsEnabled = true; BtnRepair.IsEnabled = true;
break; break;
} }
else else
@@ -1346,4 +1366,16 @@ public partial class MainWindow : Window
{ {
PopulateNavTree(); 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);
}
} }
+15 -6
View File
@@ -1,5 +1,6 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Threading.Tasks;
namespace Logof_Client; namespace Logof_Client;
@@ -7,20 +8,28 @@ public class AddressRepair(ProgressWindow progressWindow)
{ {
private readonly ProgressWindow _progress = progressWindow; private readonly ProgressWindow _progress = progressWindow;
public KasAddressList Perform(KasAddressList all_addresses, public async Task Perform(KasAddressList list)
List<(int, List<AddressCheck.ErrorTypes>)> failed_addresses)
{ {
try 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) 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;
} }
} }