[feat:] added unprocessed-item-to-new-set-Option to address-combining
This commit is contained in:
@@ -150,52 +150,70 @@
|
|||||||
<Image Source="assets/calc_man.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
<Image Source="assets/calc_man.png" VerticalAlignment="Center" HorizontalAlignment="Center" />
|
||||||
</Grid>
|
</Grid>
|
||||||
<Grid Grid.Row="2" Margin="20" IsVisible="False" x:Name="GrdCombineTypes">
|
<Grid Grid.Row="2" Margin="20" IsVisible="False" x:Name="GrdCombineTypes">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10"
|
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Spacing="10"
|
||||||
Margin="5,0,0,0">
|
Margin="5,0,0,0">
|
||||||
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
||||||
HorizontalContentAlignment="Center" x:Name="BtnCombineUnion"
|
HorizontalContentAlignment="Center" x:Name="BtnCombineUnion"
|
||||||
Click="BtnCombineUnion_OnClick"
|
Click="BtnCombineUnion_OnClick"
|
||||||
Margin="0,0,0,10">
|
Margin="0,0,0,10">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="SquaresUnite" Width="36" Height="36" />
|
<LucideIcon Kind="SquaresUnite" Width="36" Height="36" />
|
||||||
<Label Content="Vereinigung" VerticalContentAlignment="Center" FontSize="15"
|
<Label Content="Vereinigung" VerticalContentAlignment="Center" FontSize="15"
|
||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Label FontSize="9" Content="Fügt Elemente beider Mengen in eine Menge zusammen"></Label>
|
||||||
|
</StackPanel>
|
||||||
</Button>
|
</Button>
|
||||||
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
||||||
HorizontalContentAlignment="Center" x:Name="BtnCombineIntersect"
|
HorizontalContentAlignment="Center" x:Name="BtnCombineIntersect"
|
||||||
Click="BtnCombineIntersection_OnClick"
|
Click="BtnCombineIntersection_OnClick"
|
||||||
Margin="0,0,0,10">
|
Margin="0,0,0,10">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="SquaresIntersect" Width="36" Height="36" />
|
<LucideIcon Kind="SquaresIntersect" Width="36" Height="36" />
|
||||||
<Label Content="Schnittmenge" VerticalContentAlignment="Center"
|
<Label Content="Schnittmenge" VerticalContentAlignment="Center"
|
||||||
FontSize="15"
|
FontSize="15"
|
||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Label FontSize="9" Content="Überträgt nur doppelte Elemente in die neue Menge"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
||||||
HorizontalContentAlignment="Center" x:Name="BtnCombineDifference"
|
HorizontalContentAlignment="Center" x:Name="BtnCombineDifference"
|
||||||
Click="BtnCombineDifference_OnClick"
|
Click="BtnCombineDifference_OnClick"
|
||||||
Margin="0,0,0,10">
|
Margin="0,0,0,10">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="SquaresSubtract" Width="36" Height="36" />
|
<LucideIcon Kind="SquaresSubtract" Width="36" Height="36" />
|
||||||
<Label Content="Differenz" VerticalContentAlignment="Center"
|
<Label Content="Differenz" VerticalContentAlignment="Center"
|
||||||
FontSize="15"
|
FontSize="15"
|
||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Label FontSize="9" Content="Elemente der ersten Menge ohne Elemente der zweiten Menge"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</Button>
|
</Button>
|
||||||
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
<Button HorizontalAlignment="Stretch" MinWidth="240"
|
||||||
HorizontalContentAlignment="Center" x:Name="BtnCombineSymmetric"
|
HorizontalContentAlignment="Center" x:Name="BtnCombineSymmetric"
|
||||||
Click="BtnCombineSymmetricDifference_OnClick"
|
Click="BtnCombineSymmetricDifference_OnClick"
|
||||||
Margin="0,0,0,10">
|
Margin="0,0,0,10">
|
||||||
|
<StackPanel Orientation="Vertical">
|
||||||
<StackPanel Orientation="Horizontal">
|
<StackPanel Orientation="Horizontal">
|
||||||
<LucideIcon Kind="SquaresExclude" Width="36" Height="36" />
|
<LucideIcon Kind="SquaresExclude" Width="36" Height="36" />
|
||||||
<Label Content="Symmetrische Differenz" VerticalContentAlignment="Center"
|
<Label Content="Symmetrische Differenz" VerticalContentAlignment="Center"
|
||||||
FontSize="15"
|
FontSize="15"
|
||||||
FontWeight="Bold" />
|
FontWeight="Bold" />
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<Label FontSize="9" Content="Nur Elemente, die NICHT doppelt sind"></Label>
|
||||||
|
</StackPanel>
|
||||||
|
|
||||||
</Button>
|
</Button>
|
||||||
</StackPanel>
|
</StackPanel>
|
||||||
|
<CheckBox HorizontalAlignment="Center" x:Name="CbMergeExportUnmerged" IsChecked="False">Speichere Unverarbeitete in neuem Verteiler</CheckBox>
|
||||||
|
</StackPanel>
|
||||||
</Grid>
|
</Grid>
|
||||||
</Grid>
|
</Grid>
|
||||||
</TabItem>
|
</TabItem>
|
||||||
|
|||||||
@@ -247,10 +247,16 @@ public partial class MainWindow : Window
|
|||||||
progressWindow.Show(_instance);
|
progressWindow.Show(_instance);
|
||||||
|
|
||||||
var processor = new CombineAddresses(progressWindow);
|
var processor = new CombineAddresses(progressWindow);
|
||||||
var result = await processor.Perform(address_lists, type);
|
var result = await processor.Perform(address_lists, type, CbMergeExportUnmerged.IsChecked);
|
||||||
|
|
||||||
result.owner_id = owner_id;
|
if(result.Item1 != null)
|
||||||
Settings._instance.addressSets.addresses.Add(result);
|
result.Item1.owner_id = owner_id;
|
||||||
|
if(result.Item2 != null)
|
||||||
|
result.Item2.owner_id = owner_id;
|
||||||
|
if(result.Item1 != null)
|
||||||
|
Settings._instance.addressSets.addresses.Add(result.Item1);
|
||||||
|
if(result.Item2 != null)
|
||||||
|
Settings._instance.addressSets.addresses.Add(result.Item2);
|
||||||
Settings.Save();
|
Settings.Save();
|
||||||
progressWindow.Close();
|
progressWindow.Close();
|
||||||
|
|
||||||
|
|||||||
@@ -16,14 +16,14 @@ public class CombineAddresses
|
|||||||
_progress = progressWindow;
|
_progress = progressWindow;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<KasAddressList> Perform(List<KasAddressList> address_lists, string type)
|
public async Task<(KasAddressList,KasAddressList)> Perform(List<KasAddressList> address_lists, string type, bool? exportUnused)
|
||||||
{
|
{
|
||||||
var res = await Task.Run(async () =>
|
var res = await Task.Run(async () =>
|
||||||
{
|
{
|
||||||
if (type == "difference") return Difference(address_lists);
|
if (type == "difference") return Difference(address_lists, exportUnused);
|
||||||
if (type == "union") return Union(address_lists);
|
if (type == "union") return Union(address_lists, exportUnused);
|
||||||
if (type == "intersection") return Intersection(address_lists);
|
if (type == "intersection") return Intersection(address_lists, exportUnused);
|
||||||
if (type == "symdiff") return SymmetricDifference(address_lists);
|
if (type == "symdiff") return SymmetricDifference(address_lists, exportUnused);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
@@ -48,7 +48,7 @@ public class CombineAddresses
|
|||||||
// }
|
// }
|
||||||
// });
|
// });
|
||||||
// return result;
|
// return result;
|
||||||
return null;
|
return (null,null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -91,11 +91,11 @@ public class CombineAddresses
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<KasAddressList> Difference(List<KasAddressList> address_lists,
|
public async Task<(KasAddressList,KasAddressList)> Difference(List<KasAddressList> address_lists, bool? return_unused,
|
||||||
Progress? progress = null)
|
Progress? progress = null)
|
||||||
{
|
{
|
||||||
if (address_lists == null || address_lists.Count == 0)
|
if (address_lists == null || address_lists.Count == 0)
|
||||||
return new KasAddressList("difference");
|
return (new KasAddressList("difference"),null);
|
||||||
|
|
||||||
progress ??= new Progress
|
progress ??= new Progress
|
||||||
{
|
{
|
||||||
@@ -107,14 +107,17 @@ public class CombineAddresses
|
|||||||
var restUnion = new List<KasPerson>();
|
var restUnion = new List<KasPerson>();
|
||||||
for (var i = 1; i < address_lists.Count; i++)
|
for (var i = 1; i < address_lists.Count; i++)
|
||||||
restUnion.AddRange(address_lists[i].KasPersons);
|
restUnion.AddRange(address_lists[i].KasPersons);
|
||||||
|
|
||||||
var result = new KasAddressList("difference");
|
var result = new KasAddressList("difference");
|
||||||
|
var second_result = new KasAddressList("difference_rest");
|
||||||
|
|
||||||
foreach (var person in address_lists[0].KasPersons)
|
foreach (var person in address_lists[0].KasPersons)
|
||||||
{
|
{
|
||||||
var isDouble = restUnion.Any(p => CompareAddresses(person, p));
|
var isDouble = restUnion.Any(p => CompareAddresses(person, p));
|
||||||
if (!isDouble)
|
if (!isDouble)
|
||||||
result.KasPersons.Add(person);
|
result.KasPersons.Add(person);
|
||||||
|
else
|
||||||
|
second_result.KasPersons.Add(person);
|
||||||
|
|
||||||
|
|
||||||
progress.Increment();
|
progress.Increment();
|
||||||
if (progress.LogAction == null) continue;
|
if (progress.LogAction == null) continue;
|
||||||
@@ -122,17 +125,18 @@ public class CombineAddresses
|
|||||||
$"Person mit refsid {person.refsid} verglichen mit {restUnion.Count} Personen des Restes.";
|
$"Person mit refsid {person.refsid} verglichen mit {restUnion.Count} Personen des Restes.";
|
||||||
await Dispatcher.UIThread.InvokeAsync(() => progress.LogAction?.Invoke(logMessage));
|
await Dispatcher.UIThread.InvokeAsync(() => progress.LogAction?.Invoke(logMessage));
|
||||||
}
|
}
|
||||||
|
if(return_unused == true) return (result,second_result);
|
||||||
return result;
|
else return (result, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<KasAddressList> Union(List<KasAddressList> address_lists, Progress progress = null)
|
public async Task<(KasAddressList,KasAddressList)> Union(List<KasAddressList> address_lists, bool? return_unused, Progress progress = null)
|
||||||
{
|
{
|
||||||
var result = new KasAddressList("union");
|
var result = new KasAddressList("union");
|
||||||
|
var second_result = new KasAddressList("union_rest");
|
||||||
|
|
||||||
if (address_lists == null || address_lists.Count == 0)
|
if (address_lists == null || address_lists.Count == 0)
|
||||||
return result;
|
return (result,null);
|
||||||
|
|
||||||
var total = address_lists.Sum(l => l.KasPersons.Count);
|
var total = address_lists.Sum(l => l.KasPersons.Count);
|
||||||
var processed = 0;
|
var processed = 0;
|
||||||
@@ -142,6 +146,8 @@ public class CombineAddresses
|
|||||||
{
|
{
|
||||||
if (!result.KasPersons.Any(existing => CompareAddresses(existing, person)))
|
if (!result.KasPersons.Any(existing => CompareAddresses(existing, person)))
|
||||||
result.KasPersons.Add(person);
|
result.KasPersons.Add(person);
|
||||||
|
else
|
||||||
|
second_result.KasPersons.Add(person);
|
||||||
|
|
||||||
processed++;
|
processed++;
|
||||||
var percent = processed / (double)total * 100;
|
var percent = processed / (double)total * 100;
|
||||||
@@ -155,7 +161,8 @@ public class CombineAddresses
|
|||||||
Dispatcher.UIThread.Post(() => progress.LogAction?.Invoke(logMessage));
|
Dispatcher.UIThread.Post(() => progress.LogAction?.Invoke(logMessage));
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
if(return_unused == true) return (result,second_result);
|
||||||
|
else return (result, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -164,12 +171,13 @@ public class CombineAddresses
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public async Task<KasAddressList> Intersection(List<KasAddressList> address_lists, Progress progress = null)
|
public async Task<(KasAddressList,KasAddressList)> Intersection(List<KasAddressList> address_lists, bool? return_unused, Progress progress = null)
|
||||||
{
|
{
|
||||||
var result = new KasAddressList("intersection");
|
var result = new KasAddressList("intersection");
|
||||||
|
var second_result = new KasAddressList("intersection_rest");
|
||||||
|
|
||||||
if (address_lists == null || address_lists.Count == 0)
|
if (address_lists == null || address_lists.Count == 0)
|
||||||
return result;
|
return (result,null);
|
||||||
|
|
||||||
// Nur die erste Liste als Ausgangspunkt verwenden
|
// Nur die erste Liste als Ausgangspunkt verwenden
|
||||||
var baseList = address_lists[0];
|
var baseList = address_lists[0];
|
||||||
@@ -186,6 +194,8 @@ public class CombineAddresses
|
|||||||
|
|
||||||
if (isInAll)
|
if (isInAll)
|
||||||
result.KasPersons.Add(person);
|
result.KasPersons.Add(person);
|
||||||
|
else
|
||||||
|
second_result.KasPersons.Add(person);
|
||||||
|
|
||||||
processed++;
|
processed++;
|
||||||
var percent = processed / (double)total * 100;
|
var percent = processed / (double)total * 100;
|
||||||
@@ -202,16 +212,18 @@ public class CombineAddresses
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return result;
|
if(return_unused == true) return (result,second_result);
|
||||||
|
else return (result, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public async Task<KasAddressList> SymmetricDifference(List<KasAddressList> address_lists, Progress progress = null)
|
public async Task<(KasAddressList,KasAddressList)> SymmetricDifference(List<KasAddressList> address_lists, bool? return_unused, Progress progress = null)
|
||||||
{
|
{
|
||||||
var result = new KasAddressList("symmetric_difference");
|
var result = new KasAddressList("symmetric_difference");
|
||||||
|
var second_result = new KasAddressList("symmetric_rest");
|
||||||
|
|
||||||
if (address_lists == null || address_lists.Count == 0)
|
if (address_lists == null || address_lists.Count == 0)
|
||||||
return result;
|
return (result, null);
|
||||||
|
|
||||||
var total = address_lists.Sum(l => l.KasPersons.Count);
|
var total = address_lists.Sum(l => l.KasPersons.Count);
|
||||||
var processed = 0;
|
var processed = 0;
|
||||||
@@ -254,8 +266,11 @@ public class CombineAddresses
|
|||||||
foreach (var (person, count) in allPersons)
|
foreach (var (person, count) in allPersons)
|
||||||
if (count == 1)
|
if (count == 1)
|
||||||
result.KasPersons.Add(person);
|
result.KasPersons.Add(person);
|
||||||
|
else
|
||||||
|
second_result.KasPersons.Add(person);
|
||||||
|
|
||||||
return result;
|
if(return_unused == true) return (result,second_result);
|
||||||
|
else return (result, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user