[struc:] moved KasPersonError-Instance from addressset to KasPerson-Instance
This commit is contained in:
@@ -5,7 +5,7 @@ namespace Logof_Client;
|
|||||||
|
|
||||||
public class KasAddressList //Address-Set
|
public class KasAddressList //Address-Set
|
||||||
{
|
{
|
||||||
public List<KasPersonError> errors = new();
|
//public List<KasPersonError> errors = new();
|
||||||
public List<KasPerson> KasPersons;
|
public List<KasPerson> KasPersons;
|
||||||
|
|
||||||
public KasAddressList(string name)
|
public KasAddressList(string name)
|
||||||
@@ -13,12 +13,9 @@ public class KasAddressList //Address-Set
|
|||||||
KasPersons = new List<KasPerson>();
|
KasPersons = new List<KasPerson>();
|
||||||
Name = name;
|
Name = name;
|
||||||
foreach (var set in Settings._instance.addressSets.addresses)
|
foreach (var set in Settings._instance.addressSets.addresses)
|
||||||
{
|
|
||||||
if (Name == set.Name)
|
if (Name == set.Name)
|
||||||
{
|
|
||||||
Name = name + "-new";
|
Name = name + "-new";
|
||||||
}
|
|
||||||
}
|
|
||||||
var highest = 0;
|
var highest = 0;
|
||||||
foreach (var k in Settings._instance.addressSets.addresses)
|
foreach (var k in Settings._instance.addressSets.addresses)
|
||||||
if (highest <= k.ID)
|
if (highest <= k.ID)
|
||||||
@@ -37,17 +34,20 @@ public class KasAddressList //Address-Set
|
|||||||
|
|
||||||
public static string GenerateName(string basic_type, bool? is_rest = false)
|
public static string GenerateName(string basic_type, bool? is_rest = false)
|
||||||
{
|
{
|
||||||
if(is_rest == true)
|
if (is_rest == true)
|
||||||
return basic_type + " - " + DateTime.Now.ToShortDateString() + " - Rest";
|
return basic_type + " - " + DateTime.Now.ToShortDateString() + " - Rest";
|
||||||
else
|
|
||||||
return basic_type + " - " + DateTime.Now.ToShortDateString();
|
return basic_type + " - " + DateTime.Now.ToShortDateString();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateErrorList(List<(int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>)> errorList)
|
// public void UpdateErrorList(List<KasPersonError> errorList)
|
||||||
{
|
// {
|
||||||
errors.Clear();
|
// //errors.Clear();
|
||||||
foreach (var error in errorList) errors.Add(new KasPersonError(error));
|
// // foreach (KasPersonError err in errorList)
|
||||||
}
|
// // {
|
||||||
|
// //
|
||||||
|
// // }
|
||||||
|
// //foreach (var error in errorList) errors.Add(new KasPersonError(error));
|
||||||
|
// }
|
||||||
|
|
||||||
public static int GetIDByAddressSetListItem(string listItemName)
|
public static int GetIDByAddressSetListItem(string listItemName)
|
||||||
{
|
{
|
||||||
@@ -58,6 +58,8 @@ public class KasAddressList //Address-Set
|
|||||||
|
|
||||||
public class KasPerson
|
public class KasPerson
|
||||||
{
|
{
|
||||||
|
public KasPersonError PersonError = null;
|
||||||
|
|
||||||
public KasPerson()
|
public KasPerson()
|
||||||
{
|
{
|
||||||
refsid = 0;
|
refsid = 0;
|
||||||
@@ -165,37 +167,14 @@ public class KasPerson
|
|||||||
|
|
||||||
public class KasPersonError
|
public class KasPersonError
|
||||||
{
|
{
|
||||||
public KasPersonError((int, List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>) single_result)
|
public KasPersonError((List<AddressCheck.ErrorTypes>, List<AddressCheck.WarningTypes>) single_result)
|
||||||
{
|
{
|
||||||
refsid = single_result.Item1;
|
//refsid = single_result.Item1;
|
||||||
errors = single_result.Item2;
|
errors = single_result.Item1;
|
||||||
warnings = single_result.Item3;
|
warnings = single_result.Item2;
|
||||||
// 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 int refsid { get; set; }
|
||||||
public List<AddressCheck.ErrorTypes> errors { get; set; } = new();
|
public List<AddressCheck.ErrorTypes> errors { get; set; } = new();
|
||||||
public List<AddressCheck.WarningTypes> warnings { get; set; } = new();
|
public List<AddressCheck.WarningTypes> warnings { get; set; } = new();
|
||||||
}
|
}
|
||||||
@@ -1,5 +1,6 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using Avalonia;
|
using Avalonia;
|
||||||
using Avalonia.Controls;
|
using Avalonia.Controls;
|
||||||
using Avalonia.Interactivity;
|
using Avalonia.Interactivity;
|
||||||
@@ -11,10 +12,10 @@ public partial class ResultWindow : Window
|
|||||||
{
|
{
|
||||||
public List<CheckBox> errortypecheckboxes = new();
|
public List<CheckBox> errortypecheckboxes = new();
|
||||||
public KasAddressList ur_addresses = new("Ergebnis_" + DateTime.Now.ToString("ddMMyy_HHmmss"));
|
public KasAddressList ur_addresses = new("Ergebnis_" + DateTime.Now.ToString("ddMMyy_HHmmss"));
|
||||||
public List<KasPersonError> ur_result;
|
public List<KasPerson> ur_result;
|
||||||
public List<CheckBox> warningtypecheckboxes = new();
|
public List<CheckBox> warningtypecheckboxes = new();
|
||||||
|
|
||||||
public ResultWindow(List<KasPersonError> result,
|
public ResultWindow(List<KasPerson> result,
|
||||||
int addressSetID)
|
int addressSetID)
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -24,12 +25,12 @@ public partial class ResultWindow : Window
|
|||||||
//ViewSingle(200552426);
|
//ViewSingle(200552426);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void GenerateView(List<KasPersonError> result)
|
private void GenerateView(List<KasPerson> result)
|
||||||
{
|
{
|
||||||
// var errors = new List<KasPersonError>();
|
// Filter to only show persons with errors
|
||||||
//foreach (var single_result in result) errors.Add(single_result);
|
var result_with_errors = result.Where(p => p.PersonError != null).ToList();
|
||||||
LblResultCount.Content = $"{result.Count}/{ur_result.Count} Ergebnisse";
|
LblResultCount.Content = $"{result_with_errors.Count}/{ur_result.Count} Ergebnisse";
|
||||||
DgResult.ItemsSource = result;
|
DgResult.ItemsSource = result_with_errors;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void ViewSingle(int refsid)
|
private void ViewSingle(int refsid)
|
||||||
@@ -62,18 +63,20 @@ public partial class ResultWindow : Window
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void Load(List<KasPersonError> result)
|
private void Load(List<KasPerson> result)
|
||||||
{
|
{
|
||||||
var knownErrors = new List<AddressCheck.ErrorTypes>();
|
var knownErrors = new List<AddressCheck.ErrorTypes>();
|
||||||
var knownWarnings = new List<AddressCheck.WarningTypes>();
|
var knownWarnings = new List<AddressCheck.WarningTypes>();
|
||||||
|
|
||||||
foreach (var single_result in result)
|
foreach (var person in result)
|
||||||
{
|
{
|
||||||
foreach (var errtyp in single_result.errors)
|
if (person.PersonError == null) continue;
|
||||||
|
|
||||||
|
foreach (var errtyp in person.PersonError.errors)
|
||||||
if (!knownErrors.Contains(errtyp))
|
if (!knownErrors.Contains(errtyp))
|
||||||
knownErrors.Add(errtyp);
|
knownErrors.Add(errtyp);
|
||||||
|
|
||||||
foreach (var wartyp in single_result.warnings)
|
foreach (var wartyp in person.PersonError.warnings)
|
||||||
if (!knownWarnings.Contains(wartyp))
|
if (!knownWarnings.Contains(wartyp))
|
||||||
knownWarnings.Add(wartyp);
|
knownWarnings.Add(wartyp);
|
||||||
}
|
}
|
||||||
@@ -108,7 +111,7 @@ public partial class ResultWindow : Window
|
|||||||
|
|
||||||
private void UpdateFilter()
|
private void UpdateFilter()
|
||||||
{
|
{
|
||||||
var temp_result = new List<KasPersonError>();
|
var temp_result = new List<KasPerson>();
|
||||||
var checked_types = new List<AddressCheck.ErrorTypes>();
|
var checked_types = new List<AddressCheck.ErrorTypes>();
|
||||||
var checked_types_war = new List<AddressCheck.WarningTypes>();
|
var checked_types_war = new List<AddressCheck.WarningTypes>();
|
||||||
foreach (var cb in errortypecheckboxes)
|
foreach (var cb in errortypecheckboxes)
|
||||||
@@ -121,21 +124,19 @@ public partial class ResultWindow : Window
|
|||||||
checked_types_war.Add(
|
checked_types_war.Add(
|
||||||
(AddressCheck.WarningTypes)Enum.Parse(typeof(AddressCheck.WarningTypes), cb.Content.ToString()));
|
(AddressCheck.WarningTypes)Enum.Parse(typeof(AddressCheck.WarningTypes), cb.Content.ToString()));
|
||||||
|
|
||||||
foreach (var sres in ur_result)
|
foreach (var person in ur_result)
|
||||||
{
|
{
|
||||||
foreach (var err in sres.errors)
|
if (person.PersonError == null) continue;
|
||||||
if (checked_types.Contains(err) && !temp_result.Contains(sres))
|
|
||||||
temp_result.Add(sres);
|
|
||||||
|
|
||||||
foreach (var war in sres.warnings)
|
foreach (var err in person.PersonError.errors)
|
||||||
if (checked_types_war.Contains(war) && !temp_result.Contains(sres))
|
if (checked_types.Contains(err) && !temp_result.Contains(person))
|
||||||
temp_result.Add(sres);
|
temp_result.Add(person);
|
||||||
|
|
||||||
|
foreach (var war in person.PersonError.warnings)
|
||||||
|
if (checked_types_war.Contains(war) && !temp_result.Contains(person))
|
||||||
|
temp_result.Add(person);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
//var errors = new List<KasPersonError>();
|
|
||||||
//foreach (var single_result in temp_result) errors.Add(new KasPersonError(single_result));
|
|
||||||
|
|
||||||
LblResultCount.Content = $"{temp_result.Count}/{ur_result.Count} Ergebnisse";
|
LblResultCount.Content = $"{temp_result.Count}/{ur_result.Count} Ergebnisse";
|
||||||
DgResult.ItemsSource = temp_result;
|
DgResult.ItemsSource = temp_result;
|
||||||
}
|
}
|
||||||
@@ -145,7 +146,7 @@ public partial class ResultWindow : Window
|
|||||||
foreach (var selected in DgResult.SelectedItems)
|
foreach (var selected in DgResult.SelectedItems)
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
var _asKas = (KasPersonError)selected;
|
var _asKas = (KasPerson)selected;
|
||||||
ViewSingle(_asKas.refsid);
|
ViewSingle(_asKas.refsid);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
using System.Threading;
|
using System.Threading;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using Avalonia.Threading;
|
using Avalonia.Threading;
|
||||||
@@ -35,12 +36,20 @@ public class AddressCheck
|
|||||||
_progress = progressWindow;
|
_progress = progressWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<List<KasPersonError>> Perform(int id)
|
public async Task<List<KasPerson>> Perform(int id)
|
||||||
{
|
{
|
||||||
foreach (var adset in Settings._instance.addressSets.addresses)
|
// Find the index of the address set with the given id
|
||||||
if (adset.ID == id)
|
var adset_index = -1;
|
||||||
|
for (var i = 0; i < Settings._instance.addressSets.addresses.Count; i++)
|
||||||
|
if (Settings._instance.addressSets.addresses[i].ID == id)
|
||||||
{
|
{
|
||||||
var failed_refsids = new List<KasPersonError>();
|
adset_index = i;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (adset_index == -1) return new List<KasPerson>();
|
||||||
|
|
||||||
|
var adset = Settings._instance.addressSets.addresses[adset_index];
|
||||||
var total = adset.KasPersons.Count;
|
var total = adset.KasPersons.Count;
|
||||||
var current = 0;
|
var current = 0;
|
||||||
|
|
||||||
@@ -92,7 +101,6 @@ public class AddressCheck
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
|
||||||
if (!AddressCreator.CheckPLZ(person.pplz, person.land))
|
if (!AddressCreator.CheckPLZ(person.pplz, person.land))
|
||||||
{
|
{
|
||||||
hasFaults = true;
|
hasFaults = true;
|
||||||
@@ -224,9 +232,13 @@ public class AddressCheck
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (hasFaults)
|
if (hasFaults)
|
||||||
lock (failed_refsids)
|
lock (Settings._instance.addressSets.addresses)
|
||||||
{
|
{
|
||||||
failed_refsids.Add(new KasPersonError((person.refsid, errors, warnings)));
|
// Directly set PersonError in the address set
|
||||||
|
var person_index = adset.KasPersons.IndexOf(person);
|
||||||
|
if (person_index >= 0)
|
||||||
|
Settings._instance.addressSets.addresses[adset_index].KasPersons[person_index].PersonError =
|
||||||
|
new KasPersonError((errors, warnings));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Fortschritt aktualisieren
|
// Fortschritt aktualisieren
|
||||||
@@ -241,11 +253,12 @@ public class AddressCheck
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
adset.errors = failed_refsids;
|
|
||||||
Settings.Save();
|
|
||||||
return failed_refsids;
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
Settings.Save();
|
||||||
|
|
||||||
|
// Return only the persons with errors from the address set
|
||||||
|
return Settings._instance.addressSets.addresses[adset_index].KasPersons
|
||||||
|
.Where(p => p.PersonError != null)
|
||||||
|
.ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user