[feat:] print out removed address
This commit is contained in:
@@ -3,16 +3,26 @@ using System.Collections.Generic;
|
|||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Threading.Tasks.Dataflow;
|
using System.Threading.Tasks.Dataflow;
|
||||||
|
using System.Threading;
|
||||||
|
using Avalonia.Threading;
|
||||||
|
|
||||||
namespace Logof_Client;
|
namespace Logof_Client;
|
||||||
|
|
||||||
public class AddressShortener(ProgressWindow progressWindow)
|
public class AddressShortener
|
||||||
{
|
{
|
||||||
|
private readonly ProgressWindow _progress;
|
||||||
|
|
||||||
|
public AddressShortener(ProgressWindow progressWindow)
|
||||||
|
{
|
||||||
|
_progress = progressWindow;
|
||||||
|
}
|
||||||
public async Task Perform(KasAddressList list)
|
public async Task Perform(KasAddressList list)
|
||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
List<int> doubled_ids = new List<int>();
|
List<int> doubled_ids = new List<int>();
|
||||||
|
int[] percentages = [25,25,25,25];
|
||||||
|
|
||||||
for (int i = 0; i < list.KasPersons.Count; i++)
|
for (int i = 0; i < list.KasPersons.Count; i++)
|
||||||
{
|
{
|
||||||
var address = list.KasPersons[i];
|
var address = list.KasPersons[i];
|
||||||
@@ -26,8 +36,19 @@ public class AddressShortener(ProgressWindow progressWindow)
|
|||||||
doubled_ids.Add(address.refsid);
|
doubled_ids.Add(address.refsid);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// var cd = Interlocked.Increment(ref current);
|
||||||
|
|
||||||
|
// if (cd % 10 == 0)
|
||||||
|
// {
|
||||||
|
// var percent = cd / (double)total * 100;
|
||||||
|
|
||||||
|
// await Dispatcher.UIThread.InvokeAsync(() =>
|
||||||
|
// _progress.ChangePercentage(percent));
|
||||||
|
// }
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
// delete doubled addresses by refsid
|
// delete doubled addresses by refsid
|
||||||
foreach (int id in doubled_ids)
|
foreach (int id in doubled_ids)
|
||||||
{
|
{
|
||||||
@@ -65,12 +86,19 @@ public class AddressShortener(ProgressWindow progressWindow)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
string faileds = "Folgende Adressen wurden entfernt:\n(refsid - Name, Vorname)\n\n";
|
||||||
// delete doubled addresses by refsid
|
// delete doubled addresses by refsid
|
||||||
foreach (int id in toRemove)
|
foreach (int id in toRemove)
|
||||||
{
|
{
|
||||||
// does this remove both of the doubled addresses?
|
// does this remove both of the doubled addresses?
|
||||||
list.KasPersons.Remove(list.KasPersons.Find(x => x.id == id));
|
var pers = list.KasPersons.Find(x => x.id == id);
|
||||||
|
faileds += pers.refsid + " - " + pers.name + ", " + pers.vorname + "\n";
|
||||||
|
list.KasPersons.Remove(pers);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
await Dispatcher.UIThread.InvokeAsync(() => _progress.Hide());
|
||||||
|
if (toRemove.Count > 0) await Dispatcher.UIThread.InvokeAsync(() => MessageBox.Show(null,faileds,"Fehlerhafte Adressen"));
|
||||||
|
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user