[fix:] naming window showed nothing
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
@@ -32,11 +33,16 @@ public class KasAddressList //Address-Set
|
||||
this.owner_id = owner_id;
|
||||
}
|
||||
|
||||
public static string GenerateName(string basic_type, bool? is_rest = false)
|
||||
public static async Task<string> GenerateName(string basic_type, bool? is_rest = false)
|
||||
{
|
||||
string pre = "";
|
||||
|
||||
if (is_rest == true)
|
||||
return basic_type + " - " + DateTime.Now.ToShortDateString() + " - Rest";
|
||||
return basic_type + " - " + DateTime.Now.ToShortDateString();
|
||||
pre = basic_type + " - " + DateTime.Now.ToShortDateString();
|
||||
|
||||
var result = await NamingWindow.Show(MainWindow._instance, pre);
|
||||
return string.IsNullOrWhiteSpace(result) ? pre : result;
|
||||
}
|
||||
|
||||
// public void UpdateErrorList(List<KasPersonError> errorList)
|
||||
|
||||
+4
-4
@@ -194,7 +194,7 @@ public partial class MainWindow : Window
|
||||
private async void StartCombine(Uri path)
|
||||
{
|
||||
MakeCalcManVisible();
|
||||
var addresses = DataImport.ImportKasAddressList(path);
|
||||
var addresses = await DataImport.ImportKasAddressList(path);
|
||||
var progressWindow = new ProgressWindow();
|
||||
var address_list = new List<KasAddressList> { addresses.Item2 };
|
||||
|
||||
@@ -216,7 +216,7 @@ public partial class MainWindow : Window
|
||||
if (file == null) return;
|
||||
|
||||
//filePath = file[0].Path;
|
||||
foreach (var f in file) address_list.Add(DataImport.ImportKasAddressList(f.Path).Item2);
|
||||
foreach (var f in file) address_list.Add((await DataImport.ImportKasAddressList(f.Path)).Item2);
|
||||
|
||||
progressWindow.Show(_instance);
|
||||
|
||||
@@ -542,7 +542,7 @@ public partial class MainWindow : Window
|
||||
{
|
||||
if (customer.patch == null)
|
||||
{
|
||||
var got = DataImport.ImportKasAddressList(selected_path, null, customer.separator);
|
||||
var got = await DataImport.ImportKasAddressList(selected_path, null, customer.separator);
|
||||
if (!got.Item1)
|
||||
{
|
||||
Console.WriteLine("Error while importing. Please try another file.");
|
||||
@@ -558,7 +558,7 @@ public partial class MainWindow : Window
|
||||
}
|
||||
else
|
||||
{
|
||||
var got = DataImport.ImportKasAddressList(selected_path, customer.patch, customer.separator);
|
||||
var got = await DataImport.ImportKasAddressList(selected_path, customer.patch, customer.separator);
|
||||
if (!got.Item1)
|
||||
{
|
||||
Console.WriteLine("Error while importing. Please try another file.");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using Avalonia.Controls;
|
||||
using Avalonia.Markup.Xaml;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
@@ -9,9 +8,7 @@ public partial class NamingWindow : Window
|
||||
{
|
||||
public NamingWindow()
|
||||
{
|
||||
AvaloniaXamlLoader.Load(this);
|
||||
|
||||
//InitializeComponent();
|
||||
InitializeComponent();
|
||||
}
|
||||
|
||||
public static Task<string> Show(Window parent, string input = "", string info = "Bitte geben Sie einen Namen ein:")
|
||||
@@ -54,7 +51,7 @@ public partial class NamingWindow : Window
|
||||
catch (Exception ex)
|
||||
{
|
||||
Console.WriteLine("Error while showing naming window: " + ex.Message);
|
||||
return null;
|
||||
return Task.FromResult<string>(null!);
|
||||
}
|
||||
}
|
||||
}
|
||||
+13
-38
@@ -19,36 +19,11 @@ public class CombineAddresses
|
||||
public async Task<(KasAddressList, KasAddressList)> Perform(List<KasAddressList> address_lists, string type,
|
||||
bool? exportUnused)
|
||||
{
|
||||
var res = await Task.Run(async () =>
|
||||
{
|
||||
if (type == "difference") return Difference(address_lists, exportUnused);
|
||||
if (type == "union") return Union(address_lists, exportUnused);
|
||||
if (type == "intersection") return Intersection(address_lists, exportUnused);
|
||||
if (type == "symdiff") return SymmetricDifference(address_lists, 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);
|
||||
|
||||
return null;
|
||||
});
|
||||
|
||||
|
||||
return res.Result;
|
||||
|
||||
|
||||
// KasAddressList result = new("Ergebnis_" + DateTime.Now.ToString("ddMMyy_HHmmss"));
|
||||
// await Task.Run(async () =>
|
||||
// {
|
||||
// for (var i = 0; i < address_lists.Count; i++)
|
||||
// if (i == 0)
|
||||
// lock (result)
|
||||
// {
|
||||
// result = address_lists[i];
|
||||
// }
|
||||
// else
|
||||
// lock (result)
|
||||
// {
|
||||
// result = Merge(result, address_lists[i], i + 1, address_lists.Count).Result;
|
||||
// }
|
||||
// });
|
||||
// return result;
|
||||
return (null, null);
|
||||
}
|
||||
|
||||
@@ -97,7 +72,7 @@ public class CombineAddresses
|
||||
Progress? progress = null)
|
||||
{
|
||||
if (address_lists == null || address_lists.Count == 0)
|
||||
return (new KasAddressList(KasAddressList.GenerateName("difference")), null);
|
||||
return (new KasAddressList(await KasAddressList.GenerateName("difference")), null);
|
||||
|
||||
progress ??= new Progress
|
||||
{
|
||||
@@ -109,8 +84,8 @@ public class CombineAddresses
|
||||
var restUnion = new List<KasPerson>();
|
||||
for (var i = 1; i < address_lists.Count; i++)
|
||||
restUnion.AddRange(address_lists[i].KasPersons);
|
||||
var result = new KasAddressList(KasAddressList.GenerateName("difference"));
|
||||
var second_result = new KasAddressList(KasAddressList.GenerateName("difference_rest"));
|
||||
var result = new KasAddressList(await KasAddressList.GenerateName("difference"));
|
||||
var second_result = new KasAddressList(await KasAddressList.GenerateName("difference_rest", false));
|
||||
|
||||
foreach (var person in address_lists[0].KasPersons)
|
||||
{
|
||||
@@ -136,8 +111,8 @@ public class CombineAddresses
|
||||
public async Task<(KasAddressList, KasAddressList)> Union(List<KasAddressList> address_lists, bool? return_unused,
|
||||
Progress progress = null)
|
||||
{
|
||||
var result = new KasAddressList(KasAddressList.GenerateName("union"));
|
||||
var second_result = new KasAddressList(KasAddressList.GenerateName("union_rest"));
|
||||
var result = new KasAddressList(await KasAddressList.GenerateName("union"));
|
||||
var second_result = new KasAddressList(await KasAddressList.GenerateName("union_rest", false));
|
||||
|
||||
if (address_lists == null || address_lists.Count == 0)
|
||||
return (result, null);
|
||||
@@ -178,8 +153,8 @@ public class CombineAddresses
|
||||
public async Task<(KasAddressList, KasAddressList)> Intersection(List<KasAddressList> address_lists,
|
||||
bool? return_unused, Progress progress = null)
|
||||
{
|
||||
var result = new KasAddressList(KasAddressList.GenerateName("intersection"));
|
||||
var second_result = new KasAddressList(KasAddressList.GenerateName("intersection_rest"));
|
||||
var result = new KasAddressList(await KasAddressList.GenerateName("intersection"));
|
||||
var second_result = new KasAddressList(await KasAddressList.GenerateName("intersection_rest", false));
|
||||
|
||||
if (address_lists == null || address_lists.Count == 0)
|
||||
return (result, null);
|
||||
@@ -225,8 +200,8 @@ public class CombineAddresses
|
||||
public async Task<(KasAddressList, KasAddressList)> SymmetricDifference(List<KasAddressList> address_lists,
|
||||
bool? return_unused, Progress progress = null)
|
||||
{
|
||||
var result = new KasAddressList(KasAddressList.GenerateName("symmetric_difference"));
|
||||
var second_result = new KasAddressList(KasAddressList.GenerateName("symmetric_rest"));
|
||||
var result = new KasAddressList(await KasAddressList.GenerateName("symmetric_difference"));
|
||||
var second_result = new KasAddressList(await KasAddressList.GenerateName("symmetric_rest", false));
|
||||
|
||||
if (address_lists == null || address_lists.Count == 0)
|
||||
return (result, null);
|
||||
|
||||
+10
-9
@@ -4,20 +4,21 @@ using System.IO;
|
||||
using System.Linq;
|
||||
using System.Reflection;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Logof_Client;
|
||||
|
||||
public class DataImport
|
||||
{
|
||||
public static (bool, KasAddressList) ImportKasAddressList(Uri pathToCsv, AddressPatch patch = null,
|
||||
public static async Task<(bool, KasAddressList)> ImportKasAddressList(Uri pathToCsv, AddressPatch patch = null,
|
||||
char separator = ',')
|
||||
{
|
||||
if (patch == null)
|
||||
return ImportKasAddressListWithoutPatch(pathToCsv, separator);
|
||||
return ImportKasAddressListWithPatch(pathToCsv, patch, separator);
|
||||
return await ImportKasAddressListWithoutPatch(pathToCsv, separator);
|
||||
return await ImportKasAddressListWithPatch(pathToCsv, patch, separator);
|
||||
}
|
||||
|
||||
private static (bool, KasAddressList) ImportKasAddressListWithoutPatch(Uri pathToCsv, char separator)
|
||||
private static async Task<(bool, KasAddressList)> ImportKasAddressListWithoutPatch(Uri pathToCsv, char separator)
|
||||
{
|
||||
if (!File.Exists(pathToCsv.LocalPath))
|
||||
{
|
||||
@@ -33,8 +34,8 @@ public class DataImport
|
||||
return (false, null);
|
||||
}
|
||||
|
||||
var imported =
|
||||
new KasAddressList(KasAddressList.GenerateName(Path.GetFileNameWithoutExtension(pathToCsv.LocalPath)));
|
||||
var imported = new KasAddressList(
|
||||
await KasAddressList.GenerateName(Path.GetFileNameWithoutExtension(pathToCsv.LocalPath)));
|
||||
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
@@ -91,7 +92,7 @@ public class DataImport
|
||||
return (true, imported);
|
||||
}
|
||||
|
||||
private static (bool, KasAddressList) ImportKasAddressListWithPatch(Uri pathToCsv, AddressPatch patch,
|
||||
private static async Task<(bool, KasAddressList)> ImportKasAddressListWithPatch(Uri pathToCsv, AddressPatch patch,
|
||||
char separator)
|
||||
{
|
||||
if (!File.Exists(pathToCsv.LocalPath))
|
||||
@@ -110,8 +111,8 @@ public class DataImport
|
||||
|
||||
var headers = ParseCsvLine(headerLine, separator);
|
||||
|
||||
var imported =
|
||||
new KasAddressList(KasAddressList.GenerateName(Path.GetFileNameWithoutExtension(pathToCsv.LocalPath)));
|
||||
var imported = new KasAddressList(
|
||||
await KasAddressList.GenerateName(Path.GetFileNameWithoutExtension(pathToCsv.LocalPath)));
|
||||
var patchType = typeof(AddressPatch);
|
||||
var binding = BindingFlags.Public | BindingFlags.Instance | BindingFlags.IgnoreCase;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user