Compare commits
4 Commits
2c5f2ed48b
...
a46539c3cc
| Author | SHA1 | Date | |
|---|---|---|---|
| a46539c3cc | |||
| 72a5630db1 | |||
| 7697edac5e | |||
| 028b9793db |
+1
-1
@@ -121,7 +121,7 @@
|
||||
FontWeight="Bold" />
|
||||
</StackPanel>
|
||||
</Button>
|
||||
<Button Width="250" IsEnabled="False"
|
||||
<Button Width="250" IsEnabled="False" Click="BtnShorten_OnClick"
|
||||
HorizontalContentAlignment="Center" x:Name="BtnShorten"
|
||||
Margin="0,0,0,10">
|
||||
<StackPanel Orientation="Horizontal">
|
||||
|
||||
+35
-1
@@ -96,7 +96,28 @@ public partial class MainWindow : Window
|
||||
|
||||
new ResultWindow(result, addresSetID).Show();
|
||||
|
||||
Settings.Save();
|
||||
|
||||
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
|
||||
}
|
||||
|
||||
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();
|
||||
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
|
||||
}
|
||||
|
||||
@@ -543,7 +564,7 @@ public partial class MainWindow : Window
|
||||
var selected_path = paths[0].Path;
|
||||
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == ((Customer)LstSettingsCustomers.SelectedItems[0]).ID)
|
||||
if (customer == ((Customer)LstCustomers.SelectedItems[0]))
|
||||
{
|
||||
if (customer.patch == null)
|
||||
{
|
||||
@@ -617,6 +638,7 @@ public partial class MainWindow : Window
|
||||
BtnCheck.IsEnabled = true;
|
||||
BtnCombine.IsEnabled = true;
|
||||
BtnGenerateLabels.IsEnabled = true;
|
||||
BtnShorten.IsEnabled = true;
|
||||
|
||||
// BtnRepair.IsEnabled = true;
|
||||
// BtnShorten.IsEnabled = true;
|
||||
@@ -1086,4 +1108,16 @@ public partial class MainWindow : Window
|
||||
}
|
||||
RefreshCustomerItems();
|
||||
}
|
||||
|
||||
private void BtnShorten_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;
|
||||
}
|
||||
|
||||
StartAddressShortener((KasAddressList)LstCustomerAdressSets.SelectedItem);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,79 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Tasks.Dataflow;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
public class AddressShortener(ProgressWindow progressWindow)
|
||||
{
|
||||
private readonly ProgressWindow _progress = progressWindow;
|
||||
|
||||
public async Task Perform(KasAddressList list)
|
||||
{
|
||||
// find doubled addresses by refsid
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// 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))
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// 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));
|
||||
}
|
||||
|
||||
//return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user