[chore:] added address patch
This commit is contained in:
@@ -18,23 +18,26 @@ public partial class MainWindow : Window
|
||||
InitializeComponent();
|
||||
_instance = this;
|
||||
WindowState = WindowState.Maximized;
|
||||
Global.Load();
|
||||
Settings.Load();
|
||||
}
|
||||
|
||||
private async void StartAddressCheck(Uri path)
|
||||
private async void StartAddressCheck(KasAddressList addresses)
|
||||
{
|
||||
var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
|
||||
//var addresses = DataImport.ImportKasAddressList(path); // Ihr Code hier
|
||||
|
||||
var progressWindow = new ProgressWindow();
|
||||
|
||||
progressWindow.Show(_instance);
|
||||
|
||||
var processor = new AddressCheck(progressWindow);
|
||||
var result = await processor.Perform(addresses.Item2);
|
||||
var result = await processor.Perform(addresses);
|
||||
|
||||
|
||||
progressWindow.Close();
|
||||
|
||||
|
||||
new ResultWindow(result, addresses.Item2).Show();
|
||||
new ResultWindow(result, addresses).Show();
|
||||
//await MessageBox.Show(_instance, $"{result.Count} Einträge fehlerhaft.", "Fertig");
|
||||
}
|
||||
|
||||
@@ -105,13 +108,18 @@ public partial class MainWindow : Window
|
||||
|
||||
private void BtnCheck_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (filePath == null)
|
||||
if (LstCustomerAdressSets.SelectedIndex == -1)
|
||||
{
|
||||
MessageBox.Show(null, "Bitte zunächst eine Datei auswählen", "Datei fehlt");
|
||||
MessageBox.Show(null, "Bitte zunächst ein Adress-Set auswählen", "Kein Adress-Set ausgewählt");
|
||||
return;
|
||||
}
|
||||
|
||||
StartAddressCheck(filePath);
|
||||
var set = new KasAddressList("");
|
||||
foreach (var adset in Settings._instance.addressSets.addresses)
|
||||
if (adset.Name == LstCustomerAdressSets.SelectedItem.ToString())
|
||||
set = adset;
|
||||
|
||||
StartAddressCheck(set);
|
||||
// var result = DataImport.ImportKasAddressList(filePath);
|
||||
// if (result.Item1)
|
||||
// {
|
||||
@@ -209,4 +217,185 @@ public partial class MainWindow : Window
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private void BtnSettingsAddCustomer_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Settings._instance.customers.customers.Add(new Customer());
|
||||
TbSettingsCustomerDescription.Text = "";
|
||||
TbSettingsCustomerName.Text = "";
|
||||
TbSettingsCustomerPatchInfo.Text = "";
|
||||
//Settings.Save();
|
||||
//RefreshCustomerItems();
|
||||
}
|
||||
|
||||
private void TbSettingsCustomerName_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == Settings._instance.customers.current)
|
||||
customer.name = TbSettingsCustomerName.Text;
|
||||
//Settings.Save();
|
||||
//RefreshCustomerItems();
|
||||
}
|
||||
|
||||
private void LstSettingsCustomers_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (LstSettingsCustomers.SelectedIndex < 0) return;
|
||||
Settings._instance.customers.current =
|
||||
Customer.GetIDByCustomerListItem(LstSettingsCustomers.SelectedItems[0].ToString());
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == Settings._instance.customers.current)
|
||||
{
|
||||
TbSettingsCustomerDescription.Text = customer.description;
|
||||
TbSettingsCustomerName.Text = customer.name;
|
||||
if (customer.patch != null)
|
||||
TbSettingsCustomerPatchInfo.Text = customer.patch.ToString();
|
||||
else
|
||||
TbSettingsCustomerPatchInfo.Text = "";
|
||||
}
|
||||
}
|
||||
|
||||
public void RefreshCustomerItems()
|
||||
{
|
||||
if (LstCustomers.Items.Count > 0)
|
||||
LstCustomers.SelectedIndex = -1;
|
||||
else
|
||||
LstCustomers.SelectedItem = null;
|
||||
|
||||
LstCustomers.Items.Clear();
|
||||
if (LstSettingsCustomers.Items.Count > 0)
|
||||
LstSettingsCustomers.SelectedIndex = -1;
|
||||
else
|
||||
LstSettingsCustomers.SelectedItem = null;
|
||||
|
||||
LstSettingsCustomers.Items.Clear();
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
{
|
||||
LstCustomers.Items.Add(customer.ID + " - " + customer.name);
|
||||
LstSettingsCustomers.Items.Add(customer.ID + " - " + customer.name);
|
||||
}
|
||||
}
|
||||
|
||||
private void TbSettingsCustomerDescription_OnTextChanged(object? sender, TextChangedEventArgs e)
|
||||
{
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == Settings._instance.customers.current)
|
||||
customer.description = TbSettingsCustomerDescription.Text;
|
||||
//Settings.Save();
|
||||
}
|
||||
|
||||
private void BtnSettingsSaveCustomerData_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
Settings.Save();
|
||||
RefreshCustomerItems();
|
||||
}
|
||||
|
||||
private void LstCustomers_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (LstCustomers.SelectedItems == null || LstCustomers.SelectedIndex == -1) return;
|
||||
var customer_id = int.Parse(LstCustomers.SelectedItem.ToString().Split(" - ")[0]);
|
||||
RefreshAddressSetListItems(customer_id);
|
||||
}
|
||||
|
||||
private async void BtnCustomerAddressSetImport_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
var opts = new FilePickerOpenOptions();
|
||||
opts.Title = "Address-Set importieren...";
|
||||
opts.AllowMultiple = false;
|
||||
|
||||
var type = new FilePickerFileType("CSV-Dateien (*.csv)");
|
||||
type.Patterns = new[] { "*.csv" };
|
||||
opts.FileTypeFilter = new[] { type };
|
||||
|
||||
var paths = await StorageProvider.OpenFilePickerAsync(opts);
|
||||
|
||||
if (paths?.Count <= 0) return;
|
||||
|
||||
if (LstCustomers.SelectedIndex < 0) return;
|
||||
|
||||
|
||||
var selected_path = paths[0].Path;
|
||||
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == Customer.GetIDByCustomerListItem(LstCustomers.SelectedItems[0].ToString()))
|
||||
if (customer.patch == null)
|
||||
{
|
||||
var got = DataImport.ImportKasAddressList(selected_path, customer.patch);
|
||||
if (!got.Item1)
|
||||
{
|
||||
Console.WriteLine("Error while importing. Please try another file.");
|
||||
}
|
||||
else
|
||||
{
|
||||
got.Item2.SetOwner(customer.ID);
|
||||
Settings._instance.addressSets.addresses.Add(got.Item2);
|
||||
}
|
||||
|
||||
var customer_id = int.Parse(LstCustomers.SelectedItem.ToString().Split(" - ")[0]);
|
||||
RefreshAddressSetListItems(customer_id);
|
||||
}
|
||||
|
||||
Settings.Save();
|
||||
}
|
||||
|
||||
public void RefreshAddressSetListItems(int customer_id)
|
||||
{
|
||||
if (LstCustomers.SelectedIndex < 0) return;
|
||||
LstCustomerAdressSets.SelectedItems = null;
|
||||
LstCustomerAdressSets.Items.Clear();
|
||||
foreach (var k in Settings._instance.addressSets.addresses)
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == k.owner_id && customer.ID == customer_id)
|
||||
LstCustomerAdressSets.Items.Add(k.Name);
|
||||
}
|
||||
|
||||
private void LstCustomerAdressSets_OnSelectionChanged(object? sender, SelectionChangedEventArgs e)
|
||||
{
|
||||
if (LstCustomerAdressSets.SelectedItems == null || LstCustomerAdressSets.SelectedIndex == -1)
|
||||
{
|
||||
BtnCheck.IsEnabled = false;
|
||||
BtnCombine.IsEnabled = false;
|
||||
|
||||
BtnGenerateLabels.IsEnabled = false;
|
||||
BtnRepair.IsEnabled = false;
|
||||
BtnShorten.IsEnabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
BtnCheck.IsEnabled = true;
|
||||
BtnCombine.IsEnabled = true;
|
||||
|
||||
// BtnGenerateLabels.IsEnabled = true;
|
||||
// BtnRepair.IsEnabled = true;
|
||||
// BtnShorten.IsEnabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
private async void BtnSettingsImportCustomerAddressPatch_OnClick(object? sender, RoutedEventArgs e)
|
||||
{
|
||||
if (LstSettingsCustomers.SelectedIndex == null || LstSettingsCustomers.SelectedIndex == -1) return;
|
||||
|
||||
var opts = new FilePickerOpenOptions();
|
||||
opts.Title = "Address-Patch für " + LstSettingsCustomers.SelectedItems[0] + "importieren...";
|
||||
opts.AllowMultiple = false;
|
||||
|
||||
var type = new FilePickerFileType("ADPAC-Dateien (*.adpac)");
|
||||
type.Patterns = new[] { "*.adpac" };
|
||||
opts.FileTypeFilter = new[] { type };
|
||||
|
||||
var paths = await StorageProvider.OpenFilePickerAsync(opts);
|
||||
|
||||
if (paths?.Count <= 0) return;
|
||||
|
||||
if (LstSettingsCustomers.SelectedIndex < 0) return;
|
||||
|
||||
|
||||
var selected_path = paths[0].Path;
|
||||
|
||||
foreach (var customer in Settings._instance.customers.customers)
|
||||
if (customer.ID == Customer.GetIDByCustomerListItem(LstSettingsCustomers.SelectedItems[0].ToString()))
|
||||
customer.patch = AddressPatch.Import(selected_path);
|
||||
|
||||
|
||||
Settings.Save();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user