[chore:] logging for AddressShortener.cs
This commit is contained in:
+64
-59
@@ -12,68 +12,73 @@ public class AddressShortener(ProgressWindow progressWindow)
|
|||||||
|
|
||||||
public async Task Perform(KasAddressList list)
|
public async Task Perform(KasAddressList list)
|
||||||
{
|
{
|
||||||
// find doubled addresses by refsid
|
try
|
||||||
List<int> doubled_ids = new List<int>();
|
|
||||||
for (int i = 0; i < list.KasPersons.Count; i++)
|
|
||||||
{
|
{
|
||||||
var address = list.KasPersons[i];
|
List<int> doubled_ids = new List<int>();
|
||||||
for (int j = 0; j < list.KasPersons.Count; j++)
|
for (int i = 0; i < list.KasPersons.Count; i++)
|
||||||
{
|
{
|
||||||
if (i == j) continue;
|
var address = list.KasPersons[i];
|
||||||
var sec_address = list.KasPersons[j];
|
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)
|
if (address.refsid == sec_address.refsid && !doubled_ids.Contains(address.refsid) && address.refsid != 0)
|
||||||
{
|
{
|
||||||
doubled_ids.Add(address.refsid);
|
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));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception ex)
|
||||||
|
{
|
||||||
|
Logger.Log($"Error while performing address shortener: {ex.Message}", Logger.LogType.Error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// 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