Compare commits
2 Commits
c5aabc2a02
..
v0.8.1
| Author | SHA1 | Date | |
|---|---|---|---|
| 488830cdad | |||
| 52fbefb803 |
@@ -223,6 +223,10 @@
|
||||
|
||||
</Button>
|
||||
</StackPanel>
|
||||
<StackPanel Orientation="Vertical" HorizontalAlignment="Center">
|
||||
<RadioButton Content="Vergleiche nach refsid" IsChecked="True" x:Name="RbComprefsid"></RadioButton>
|
||||
<RadioButton Content="Vergleiche nach finaler Adresse" IsChecked="False" x:Name="RbCompfinAd"></RadioButton>
|
||||
</StackPanel>
|
||||
<CheckBox HorizontalAlignment="Center" x:Name="CbMergeExportUnmerged" IsChecked="False">Speichere Unverarbeitete in neuem Verteiler</CheckBox>
|
||||
</StackPanel>
|
||||
</Grid>
|
||||
|
||||
+43
-8
@@ -125,12 +125,34 @@ public partial class MainWindow : Window
|
||||
|
||||
private void MnuAbout_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "https://mypapercloud.de/logof/",
|
||||
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void MnuHelp_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
try
|
||||
{
|
||||
Process.Start(new ProcessStartInfo
|
||||
{
|
||||
FileName = "https://mypapercloud.de/logof/wiki/",
|
||||
UseShellExecute = true // Wichtig für Plattformübergreifendes Öffnen
|
||||
});
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine($"Fehler beim Öffnen des Links: {ex.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
private void MnuGit_OnClick(object? sender, RoutedEventArgs e)
|
||||
@@ -449,14 +471,14 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
private async void StartCombine(List<KasAddressList> address_lists, int owner_id, string type)
|
||||
private async void StartCombine(List<KasAddressList> address_lists, int owner_id, string type, CombineAddresses.CombineType comb_type)
|
||||
{
|
||||
var progressWindow = new ProgressWindow();
|
||||
|
||||
progressWindow.Show(_instance);
|
||||
|
||||
var processor = new CombineAddresses(progressWindow);
|
||||
var result = await processor.Perform(address_lists, type, CbMergeExportUnmerged.IsChecked);
|
||||
var result = await processor.Perform(address_lists, type, comb_type, CbMergeExportUnmerged.IsChecked);
|
||||
|
||||
if (result.Item1 != null)
|
||||
result.Item1.owner_id = owner_id;
|
||||
@@ -747,7 +769,7 @@ public partial class MainWindow : Window
|
||||
Convert.ToInt32(item.ToString().Split(" - ")[0])));
|
||||
try
|
||||
{
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "difference");
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "difference", GetCombiningTyp());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -763,7 +785,7 @@ public partial class MainWindow : Window
|
||||
Convert.ToInt32(item.ToString().Split(" - ")[0])));
|
||||
try
|
||||
{
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "union");
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "union", GetCombiningTyp());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -780,7 +802,7 @@ public partial class MainWindow : Window
|
||||
Convert.ToInt32(item.ToString().Split(" - ")[0])));
|
||||
try
|
||||
{
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "intersection");
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "intersection", GetCombiningTyp());
|
||||
}
|
||||
catch
|
||||
{
|
||||
@@ -788,6 +810,19 @@ public partial class MainWindow : Window
|
||||
}
|
||||
}
|
||||
|
||||
public CombineAddresses.CombineType GetCombiningTyp()
|
||||
{
|
||||
if (RbComprefsid.IsChecked == true)
|
||||
{
|
||||
return CombineAddresses.CombineType.refsid;
|
||||
} else if (RbCompfinAd.IsChecked == true)
|
||||
{
|
||||
return CombineAddresses.CombineType.final_adress;
|
||||
}
|
||||
|
||||
return CombineAddresses.CombineType.none;
|
||||
}
|
||||
|
||||
private void BtnCombineSymmetricDifference_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var list = new List<KasAddressList>();
|
||||
@@ -795,7 +830,7 @@ public partial class MainWindow : Window
|
||||
list.Add(Settings._instance.addressSets.GetAddressSetByID(
|
||||
Convert.ToInt32(item.ToString().Split(" - ")[0])));
|
||||
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "symdiff");
|
||||
StartCombine(list, Convert.ToInt32(LstCustomers.SelectedItem.ToString().Split(" - ")[0]), "symdiff", GetCombiningTyp());
|
||||
}
|
||||
|
||||
private async void BtnGenerateLabels_OnClick(object? sender, RoutedEventArgs e)
|
||||
|
||||
+24
-16
@@ -16,13 +16,20 @@ public class CombineAddresses
|
||||
_progress = progressWindow;
|
||||
}
|
||||
|
||||
public async Task<(KasAddressList, KasAddressList)> Perform(List<KasAddressList> address_lists, string type,
|
||||
public enum CombineType
|
||||
{
|
||||
refsid,
|
||||
final_adress,
|
||||
none
|
||||
}
|
||||
|
||||
public async Task<(KasAddressList, KasAddressList)> Perform(List<KasAddressList> address_lists, string type, CombineType comb_type,
|
||||
bool? exportUnused)
|
||||
{
|
||||
if (type == "difference") return await Difference(address_lists, exportUnused);
|
||||
if (type == "union") return await Union(address_lists, exportUnused);
|
||||
if (type == "intersection") return await Intersection(address_lists, exportUnused);
|
||||
if (type == "symdiff") return await SymmetricDifference(address_lists, exportUnused);
|
||||
if (type == "difference") return await Difference(address_lists, comb_type, exportUnused);
|
||||
if (type == "union") return await Union(address_lists, comb_type, exportUnused);
|
||||
if (type == "intersection") return await Intersection(address_lists, comb_type, exportUnused);
|
||||
if (type == "symdiff") return await SymmetricDifference(address_lists, comb_type, exportUnused);
|
||||
|
||||
return (null, null);
|
||||
}
|
||||
@@ -35,11 +42,12 @@ public class CombineAddresses
|
||||
/// <param name="second">Second address to compare</param>
|
||||
/// <param name="only_refsid">If true, only a refsid-check will be done</param>
|
||||
/// <returns></returns>
|
||||
public bool CompareAddresses(KasPerson first, KasPerson second, bool only_refsid = false)
|
||||
public bool CompareAddresses(KasPerson first, KasPerson second, CombineType comb_type)
|
||||
{
|
||||
// A refsid of 0 means "missing", so it must not collapse unrelated entries.
|
||||
if (first.refsid != 0 && second.refsid != 0 && first.refsid == second.refsid) return true;
|
||||
if (!only_refsid)
|
||||
if(comb_type == CombineType.refsid)
|
||||
if (first.refsid != 0 && second.refsid != 0 && first.refsid == second.refsid) return true;
|
||||
if (comb_type == CombineType.final_adress)
|
||||
if (first.name == second.name &&
|
||||
first.anrede == second.anrede &&
|
||||
first.anredzus == second.anredzus &&
|
||||
@@ -68,7 +76,7 @@ public class CombineAddresses
|
||||
return false;
|
||||
}
|
||||
|
||||
public async Task<(KasAddressList, KasAddressList)> Difference(List<KasAddressList> address_lists,
|
||||
public async Task<(KasAddressList, KasAddressList)> Difference(List<KasAddressList> address_lists, CombineType comb_type,
|
||||
bool? return_unused,
|
||||
Progress? progress = null)
|
||||
{
|
||||
@@ -92,7 +100,7 @@ public class CombineAddresses
|
||||
|
||||
foreach (var person in address_lists[0].KasPersons)
|
||||
{
|
||||
var isDouble = restUnion.Any(p => CompareAddresses(person, p));
|
||||
var isDouble = restUnion.Any(p => CompareAddresses(person, p, comb_type));
|
||||
if (!isDouble)
|
||||
result.KasPersons.Add(person);
|
||||
else
|
||||
@@ -111,7 +119,7 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
|
||||
public async Task<(KasAddressList, KasAddressList)> Union(List<KasAddressList> address_lists, bool? return_unused,
|
||||
public async Task<(KasAddressList, KasAddressList)> Union(List<KasAddressList> address_lists, CombineType comb_type, bool? return_unused,
|
||||
Progress progress = null)
|
||||
{
|
||||
var result = new KasAddressList(await KasAddressList.GenerateName("union"));
|
||||
@@ -128,7 +136,7 @@ public class CombineAddresses
|
||||
foreach (var list in address_lists)
|
||||
foreach (var person in list.KasPersons)
|
||||
{
|
||||
if (!result.KasPersons.Any(existing => CompareAddresses(existing, person)))
|
||||
if (!result.KasPersons.Any(existing => CompareAddresses(existing, person, comb_type)))
|
||||
result.KasPersons.Add(person);
|
||||
else
|
||||
second_result.KasPersons.Add(person);
|
||||
@@ -155,7 +163,7 @@ public class CombineAddresses
|
||||
return null;
|
||||
}
|
||||
|
||||
public async Task<(KasAddressList, KasAddressList)> Intersection(List<KasAddressList> address_lists,
|
||||
public async Task<(KasAddressList, KasAddressList)> Intersection(List<KasAddressList> address_lists, CombineType comb_type,
|
||||
bool? return_unused, Progress progress = null)
|
||||
{
|
||||
var result = new KasAddressList(await KasAddressList.GenerateName("intersection"));
|
||||
@@ -176,7 +184,7 @@ public class CombineAddresses
|
||||
{
|
||||
// Prüfen, ob Person in *allen* anderen Listen vorkommt
|
||||
var isInAll = otherLists.All(list =>
|
||||
list.KasPersons.Any(existing => CompareAddresses(existing, person)));
|
||||
list.KasPersons.Any(existing => CompareAddresses(existing, person, comb_type)));
|
||||
|
||||
if (isInAll)
|
||||
result.KasPersons.Add(person);
|
||||
@@ -203,7 +211,7 @@ public class CombineAddresses
|
||||
}
|
||||
|
||||
|
||||
public async Task<(KasAddressList, KasAddressList)> SymmetricDifference(List<KasAddressList> address_lists,
|
||||
public async Task<(KasAddressList, KasAddressList)> SymmetricDifference(List<KasAddressList> address_lists, CombineType comb_type,
|
||||
bool? return_unused, Progress progress = null)
|
||||
{
|
||||
var result = new KasAddressList(await KasAddressList.GenerateName("symmetric_difference"));
|
||||
@@ -223,7 +231,7 @@ public class CombineAddresses
|
||||
foreach (var person in list.KasPersons)
|
||||
{
|
||||
// Prüfen, ob schon vorhanden
|
||||
var existing = allPersons.FirstOrDefault(p => CompareAddresses(p.person, person));
|
||||
var existing = allPersons.FirstOrDefault(p => CompareAddresses(p.person, person, comb_type));
|
||||
if (existing.person != null)
|
||||
{
|
||||
// Falls schon drin → Vorkommen erhöhen
|
||||
|
||||
Reference in New Issue
Block a user