[chore:] added ID to addres-sets (yes, there was no -_-)
This commit is contained in:
@@ -1,25 +1,43 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
public class KasAddressList
|
||||
public class KasAddressList //Address-Set
|
||||
{
|
||||
public List<KasPersonError> errors = new();
|
||||
public List<KasPerson> KasPersons;
|
||||
|
||||
public KasAddressList(string name)
|
||||
{
|
||||
KasPersons = new List<KasPerson>();
|
||||
Name = name;
|
||||
var highest = 0;
|
||||
foreach (var k in Settings._instance.addressSets.addresses)
|
||||
if (highest <= k.ID)
|
||||
highest = k.ID + 1;
|
||||
ID = highest;
|
||||
}
|
||||
|
||||
public string Name { get; set; } = "Neues Address-Set";
|
||||
public int owner_id { get; set; }
|
||||
public int ID { get; }
|
||||
|
||||
public void SetOwner(int owner_id)
|
||||
{
|
||||
this.owner_id = owner_id;
|
||||
}
|
||||
|
||||
public void UpdateErrorList(List<(int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>)> errorList)
|
||||
{
|
||||
errors.Clear();
|
||||
foreach (var error in errorList) errors.Add(new KasPersonError(error));
|
||||
}
|
||||
|
||||
public static int GetIDByAddressSetListItem(string listItemName)
|
||||
{
|
||||
var id = listItemName.Split(" - ")[0];
|
||||
return int.Parse(id);
|
||||
}
|
||||
}
|
||||
|
||||
public class KasPerson
|
||||
@@ -134,32 +152,34 @@ public class KasPersonError
|
||||
public KasPersonError((int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>) single_result)
|
||||
{
|
||||
refsid = single_result.Item1;
|
||||
try
|
||||
{
|
||||
foreach (var err in single_result.Item2) errors += err + ", ";
|
||||
errors = errors.Trim();
|
||||
errors = errors.TrimEnd(',');
|
||||
}
|
||||
catch
|
||||
{
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (single_result.Item3 != null)
|
||||
{
|
||||
foreach (var err in single_result.Item3) warnings += err + ", ";
|
||||
warnings = warnings.Trim();
|
||||
warnings = warnings.TrimEnd(',');
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Console.WriteLine(e.Message);
|
||||
}
|
||||
errors = single_result.Item2;
|
||||
warnings = single_result.Item3;
|
||||
// try
|
||||
// {
|
||||
// foreach (var err in single_result.Item2) errors += err + ", ";
|
||||
// errors = errors.Trim();
|
||||
// errors = errors.TrimEnd(',');
|
||||
// }
|
||||
// catch
|
||||
// {
|
||||
// }
|
||||
//
|
||||
// try
|
||||
// {
|
||||
// if (single_result.Item3 != null)
|
||||
// {
|
||||
// foreach (var err in single_result.Item3) warnings += err + ", ";
|
||||
// warnings = warnings.Trim();
|
||||
// warnings = warnings.TrimEnd(',');
|
||||
// }
|
||||
// }
|
||||
// catch (Exception e)
|
||||
// {
|
||||
// Console.WriteLine(e.Message);
|
||||
// }
|
||||
}
|
||||
|
||||
public int refsid { get; set; }
|
||||
public string errors { get; set; } = "";
|
||||
public string warnings { get; set; } = "";
|
||||
public List<AddressCheck.ErrorTypes> errors { get; set; } = new();
|
||||
public List<AddressCheck.WarningTypes> warnings { get; set; } = new();
|
||||
}
|
||||
@@ -22,7 +22,7 @@ public partial class MainWindow : Window
|
||||
Settings.Load();
|
||||
}
|
||||
|
||||
private async void StartAddressCheck(KasAddressList addresses)
|
||||
private async void StartAddressCheck(int addresSetID)
|
||||
{
|
||||
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
|
||||
|
||||
@@ -31,13 +31,18 @@ public partial class MainWindow : Window
|
||||
progressWindow.Show(_instance);
|
||||
|
||||
var processor = new AddressCheck(progressWindow);
|
||||
var result = await processor.Perform(addresses);
|
||||
var result = await processor.Perform(addresSetID);
|
||||
|
||||
// foreach (var item in result)
|
||||
// {
|
||||
// }
|
||||
|
||||
progressWindow.Close();
|
||||
|
||||
|
||||
new ResultWindow(result, addresses).Show();
|
||||
new ResultWindow(result, addresSetID).Show();
|
||||
|
||||
|
||||
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
|
||||
}
|
||||
|
||||
@@ -115,12 +120,12 @@ public partial class MainWindow : Window
|
||||
return;
|
||||
}
|
||||
|
||||
var set = new KasAddressList("");
|
||||
foreach (var adset in Settings._instance.addressSets.addresses)
|
||||
if (adset.Name == LstCustomerAdressSets.SelectedItem.ToString())
|
||||
set = adset;
|
||||
//var set = new KasAddressList("");
|
||||
//foreach (var adset in Settings._instance.addressSets.addresses)
|
||||
//if (adset.ID == KasAddressList.GetIDByAddressSetListItem(LstCustomerAdressSets.SelectedItem.ToString()))
|
||||
StartAddressCheck(KasAddressList.GetIDByAddressSetListItem(LstCustomerAdressSets.SelectedItem.ToString()));
|
||||
|
||||
|
||||
StartAddressCheck(set);
|
||||
// var result = DataImport.ImportKasAddressList(filePath);
|
||||
// if (result.Item1)
|
||||
// {
|
||||
@@ -379,7 +384,7 @@ public partial class MainWindow : Window
|
||||
foreach (var k in Settings._instance.addressSets.addresses)
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == k.owner_id && customer.ID == customer_id)
|
||||
LstCustomerAdressSets.Items.Add(k.Name);
|
||||
LstCustomerAdressSets.Items.Add(k.ID + " - " + k.Name);
|
||||
}
|
||||
|
||||
private void LstCustomerAdressSets_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
|
||||
@@ -11,25 +11,25 @@ public partial class ResultWindow : Window
|
||||
{
|
||||
public List<CheckBox> errortypecheckboxes = new();
|
||||
public KasAddressList ur_addresses = new("Ergebnis_" + DateTime.Now.ToString("ddMMyy_HHmmss"));
|
||||
public List<(int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>)> ur_result;
|
||||
public List<KasPersonError> ur_result;
|
||||
public List<CheckBox> warningtypecheckboxes = new();
|
||||
|
||||
public ResultWindow(List<(int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>)> result,
|
||||
KasAddressList ur_addresses)
|
||||
public ResultWindow(List<KasPersonError> result,
|
||||
int addressSetID)
|
||||
{
|
||||
InitializeComponent();
|
||||
ur_result = result;
|
||||
this.ur_addresses = ur_addresses;
|
||||
ur_addresses = ur_addresses;
|
||||
Load(result);
|
||||
//ViewSingle(200552426);
|
||||
}
|
||||
|
||||
private void GenerateView(List<(int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>)> result)
|
||||
private void GenerateView(List<KasPersonError> result)
|
||||
{
|
||||
var errors = new List<KasPersonError>();
|
||||
foreach (var single_result in result) errors.Add(new KasPersonError(single_result));
|
||||
LblResultCount.Content = $"{errors.Count}/{ur_result.Count} Ergebnisse";
|
||||
DgResult.ItemsSource = errors;
|
||||
// var errors = new List<KasPersonError>();
|
||||
//foreach (var single_result in result) errors.Add(single_result);
|
||||
LblResultCount.Content = $"{result.Count}/{ur_result.Count} Ergebnisse";
|
||||
DgResult.ItemsSource = result;
|
||||
}
|
||||
|
||||
private void ViewSingle(int refsid)
|
||||
@@ -62,18 +62,18 @@ public partial class ResultWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
private void Load(List<(int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>)> result)
|
||||
private void Load(List<KasPersonError> result)
|
||||
{
|
||||
var knownErrors = new List<AddressCheck.ErrorTypes>();
|
||||
var knownWarnings = new List<AddressCheck.WarningTypes>();
|
||||
|
||||
foreach (var single_result in result)
|
||||
{
|
||||
foreach (var errtyp in single_result.Item2)
|
||||
foreach (var errtyp in single_result.errors)
|
||||
if (!knownErrors.Contains(errtyp))
|
||||
knownErrors.Add(errtyp);
|
||||
|
||||
foreach (var wartyp in single_result.Item3)
|
||||
foreach (var wartyp in single_result.warnings)
|
||||
if (!knownWarnings.Contains(wartyp))
|
||||
knownWarnings.Add(wartyp);
|
||||
}
|
||||
@@ -108,7 +108,7 @@ public partial class ResultWindow : Window
|
||||
|
||||
private void UpdateFilter()
|
||||
{
|
||||
var temp_result = new List<(int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>)>();
|
||||
var temp_result = new List<KasPersonError>();
|
||||
var checked_types = new List<AddressCheck.ErrorTypes>();
|
||||
var checked_types_war = new List<AddressCheck.WarningTypes>();
|
||||
foreach (var cb in errortypecheckboxes)
|
||||
@@ -123,21 +123,21 @@ public partial class ResultWindow : Window
|
||||
|
||||
foreach (var sres in ur_result)
|
||||
{
|
||||
foreach (var err in sres.Item2)
|
||||
foreach (var err in sres.errors)
|
||||
if (checked_types.Contains(err) && !temp_result.Contains(sres))
|
||||
temp_result.Add(sres);
|
||||
|
||||
foreach (var war in sres.Item3)
|
||||
foreach (var war in sres.warnings)
|
||||
if (checked_types_war.Contains(war) && !temp_result.Contains(sres))
|
||||
temp_result.Add(sres);
|
||||
}
|
||||
|
||||
|
||||
var errors = new List<KasPersonError>();
|
||||
foreach (var single_result in temp_result) errors.Add(new KasPersonError(single_result));
|
||||
//var errors = new List<KasPersonError>();
|
||||
//foreach (var single_result in temp_result) errors.Add(new KasPersonError(single_result));
|
||||
|
||||
LblResultCount.Content = $"{errors.Count}/{ur_result.Count} Ergebnisse";
|
||||
DgResult.ItemsSource = errors;
|
||||
LblResultCount.Content = $"{temp_result.Count}/{ur_result.Count} Ergebnisse";
|
||||
DgResult.ItemsSource = temp_result;
|
||||
}
|
||||
|
||||
private void BtnShowSelected_OnClick(object? sender, RoutedEventArgs e)
|
||||
|
||||
@@ -37,197 +37,205 @@ public class AddressCheck
|
||||
_progress = progressWindow;
|
||||
}
|
||||
|
||||
public async Task<List<(int, List<ErrorTypes>, List<WarningTypes>)>> Perform(KasAddressList addresses)
|
||||
public async Task<List<KasPersonError>> Perform(int id)
|
||||
{
|
||||
var failed_refsids = new List<(int, List<ErrorTypes>, List<WarningTypes>)>();
|
||||
var total = addresses.KasPersons.Count;
|
||||
var current = 0;
|
||||
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
foreach (var person in addresses.KasPersons)
|
||||
foreach (var adset in Settings._instance.addressSets.addresses)
|
||||
if (adset.ID == id)
|
||||
{
|
||||
var errors = new List<ErrorTypes>();
|
||||
var warnings = new List<WarningTypes>();
|
||||
var hasFaults = false;
|
||||
var failed_refsids = new List<KasPersonError>();
|
||||
var total = adset.KasPersons.Count;
|
||||
var current = 0;
|
||||
|
||||
var address_component_count = 2; // cause anrede and name are first
|
||||
|
||||
// PLZ-Prüfung
|
||||
if (person.plz == 0 || person.plz == null)
|
||||
await Task.Run(async () =>
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoPLZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
if ((person.plz < 10000 && string.IsNullOrWhiteSpace(person.land)) ||
|
||||
(person.plz < 10000 && person.land == "GER") ||
|
||||
(person.plz < 10000 && person.land == "DE"))
|
||||
foreach (var person in adset.KasPersons)
|
||||
{
|
||||
hasFaults = true;
|
||||
errors.Add(ErrorTypes.PlzTooShort);
|
||||
var errors = new List<ErrorTypes>();
|
||||
var warnings = new List<WarningTypes>();
|
||||
var hasFaults = false;
|
||||
|
||||
var address_component_count = 2; // cause anrede and name are first
|
||||
|
||||
// PLZ-Prüfung
|
||||
if (person.plz == 0 || person.plz == null)
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoPLZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PPLZ-Prüfung
|
||||
if (person.pplz == 0 || person.pplz == null)
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoPPLZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
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))
|
||||
{
|
||||
hasFaults = true;
|
||||
errors.Add(ErrorTypes.NoPLZorPPLZ);
|
||||
}
|
||||
|
||||
// Ort-Prüfung
|
||||
if (string.IsNullOrWhiteSpace(person.ort))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoCity);
|
||||
}
|
||||
else
|
||||
{
|
||||
address_component_count++;
|
||||
}
|
||||
|
||||
// Street-Number
|
||||
var street = person.strasse.ToCharArray();
|
||||
var intcount = 0;
|
||||
foreach (var c in street)
|
||||
{
|
||||
int maybe;
|
||||
if (int.TryParse(c.ToString(), out maybe)) intcount++;
|
||||
}
|
||||
|
||||
if (intcount == 0)
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoStreetNumber);
|
||||
}
|
||||
|
||||
// Last-Name
|
||||
if (string.IsNullOrWhiteSpace(person.name))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoLastName);
|
||||
}
|
||||
|
||||
// First-Name
|
||||
if (string.IsNullOrWhiteSpace(person.vorname))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoFirstName);
|
||||
}
|
||||
|
||||
// Street-Check
|
||||
if (string.IsNullOrWhiteSpace(person.strasse))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoStreet);
|
||||
}
|
||||
else
|
||||
{
|
||||
address_component_count++;
|
||||
}
|
||||
|
||||
// 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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
// Adressen-Länge
|
||||
if (address_component_count > 10)
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.FullAddressTooLong);
|
||||
}
|
||||
|
||||
if (hasFaults)
|
||||
lock (failed_refsids)
|
||||
{
|
||||
failed_refsids.Add(new KasPersonError((person.refsid, errors, warnings)));
|
||||
}
|
||||
|
||||
// Fortschritt aktualisieren
|
||||
Interlocked.Increment(ref current);
|
||||
var percent = current / (double)total * 100;
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
if (hasFaults)
|
||||
_progress.AddToLog($"Person mit refsid {person.refsid} ist fehlerhaft");
|
||||
|
||||
_progress.ChangePercentage(percent);
|
||||
});
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// PPLZ-Prüfung
|
||||
if (person.pplz == 0 || person.pplz == null)
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoPPLZ);
|
||||
}
|
||||
else
|
||||
{
|
||||
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))
|
||||
{
|
||||
hasFaults = true;
|
||||
errors.Add(ErrorTypes.NoPLZorPPLZ);
|
||||
}
|
||||
|
||||
// Ort-Prüfung
|
||||
if (string.IsNullOrWhiteSpace(person.ort))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoCity);
|
||||
}
|
||||
else
|
||||
{
|
||||
address_component_count++;
|
||||
}
|
||||
|
||||
// Street-Number
|
||||
var street = person.strasse.ToCharArray();
|
||||
var intcount = 0;
|
||||
foreach (var c in street)
|
||||
{
|
||||
int maybe;
|
||||
if (int.TryParse(c.ToString(), out maybe)) intcount++;
|
||||
}
|
||||
|
||||
if (intcount == 0)
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoStreetNumber);
|
||||
}
|
||||
|
||||
// Last-Name
|
||||
if (string.IsNullOrWhiteSpace(person.name))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoLastName);
|
||||
}
|
||||
|
||||
// First-Name
|
||||
if (string.IsNullOrWhiteSpace(person.vorname))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoFirstName);
|
||||
}
|
||||
|
||||
// Street-Check
|
||||
if (string.IsNullOrWhiteSpace(person.strasse))
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.NoStreet);
|
||||
}
|
||||
else
|
||||
{
|
||||
address_component_count++;
|
||||
}
|
||||
|
||||
// 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 addresses.KasPersons)
|
||||
{
|
||||
if (addresses.KasPersons.IndexOf(person) == addresses.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);
|
||||
}
|
||||
}
|
||||
|
||||
// Adressen-Länge
|
||||
if (address_component_count > 10)
|
||||
{
|
||||
hasFaults = true;
|
||||
warnings.Add(WarningTypes.FullAddressTooLong);
|
||||
}
|
||||
|
||||
if (hasFaults)
|
||||
lock (failed_refsids)
|
||||
{
|
||||
failed_refsids.Add((person.refsid, errors, warnings));
|
||||
}
|
||||
|
||||
// Fortschritt aktualisieren
|
||||
Interlocked.Increment(ref current);
|
||||
var percent = current / (double)total * 100;
|
||||
await Dispatcher.UIThread.InvokeAsync(() =>
|
||||
{
|
||||
if (hasFaults)
|
||||
_progress.AddToLog($"Person mit refsid {person.refsid} ist fehlerhaft");
|
||||
|
||||
_progress.ChangePercentage(percent);
|
||||
});
|
||||
adset.errors = failed_refsids;
|
||||
Settings.Save();
|
||||
return failed_refsids;
|
||||
}
|
||||
});
|
||||
return failed_refsids;
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user