From 3d1bd6a9d999668e7e71662ccf5a7653fff7fe1d Mon Sep 17 00:00:00 2001 From: Stefan Grushko Date: Sun, 14 Apr 2024 14:45:13 +0200 Subject: [PATCH 1/5] fix: missing AutoFill tab and invalid Tracking number code Resolves #77 --- .../AutoComplete/AutoKeyboardInputHelper.cs | 19 ++++----------- Mapp.UI/Mapp.UI.csproj | 1 + Mapp.UI/Settings/AppSettings.Designer.cs | 2 +- Mapp.UI/Startup/Bootstrapper.cs | 2 +- Mapp.UI/ViewModels/AutoFillViewModel.cs | 23 ++++++++----------- Mapp.UI/ViewModels/MainViewModel.cs | 2 ++ Mapp.UI/Views/AutoFillView.xaml | 7 +++--- 7 files changed, 24 insertions(+), 32 deletions(-) diff --git a/Mapp.BusinessLogic.Invoices/AutoComplete/AutoKeyboardInputHelper.cs b/Mapp.BusinessLogic.Invoices/AutoComplete/AutoKeyboardInputHelper.cs index c963100..5111100 100644 --- a/Mapp.BusinessLogic.Invoices/AutoComplete/AutoKeyboardInputHelper.cs +++ b/Mapp.BusinessLogic.Invoices/AutoComplete/AutoKeyboardInputHelper.cs @@ -1,6 +1,7 @@ using System; using System.Threading.Tasks; using Mapp.Application.Interfaces; +using Mapp.Common; using WindowsInput.Native; namespace Mapp.BusinessLogic.AutoComplete; @@ -13,14 +14,14 @@ public interface IAutoKeyboardInputHelper : IDisposable public class AutoKeyboardInputHelper : IAutoKeyboardInputHelper { - private readonly IAutocompleteConfiguration _autocompleteConfiguration; + private readonly ISettingsWrapper _settingsWrapper; private IInputSimulator _inputSim; private IKeyboardHook _keyboardHook; private bool _isCommandPressed; - public AutoKeyboardInputHelper(IAutocompleteConfiguration autocompleteConfiguration, IKeyboardHook keyboardHook, IInputSimulator inputSimulator) + public AutoKeyboardInputHelper(ISettingsWrapper settingsWrapper, IKeyboardHook keyboardHook, IInputSimulator inputSimulator) { - _autocompleteConfiguration = autocompleteConfiguration; + _settingsWrapper = settingsWrapper; _inputSim = inputSimulator; _keyboardHook = keyboardHook; // TODO replace by https://www.nuget.org/packages/MouseKeyHook/ _keyboardHook.KeyDown += keyboardHook_KeyDown; @@ -48,7 +49,7 @@ private void keyboardHook_KeyDown(object sender, VKeys key) if (key == VKeys.F4 && _isCommandPressed) /*&& elapsedTime.Seconds > 2*/ { //_lastAutoinputTime = DateTime.Now; - _inputSim.TextEntry($"RR{_autocompleteConfiguration.TrackingCode}CZ"); + _inputSim.TextEntry($"RR{_settingsWrapper.TrackingCode}CZ"); _inputSim.KeyPress(VirtualKeyCode.TAB); Task.Delay(TimeSpan.FromMilliseconds(50)); _inputSim.TextEntry(DateTime.Now.ToString("dd.MM.yyyy")); @@ -70,13 +71,3 @@ private void keyboardHook_KeyUp(object sender, VKeys key) } } } - -public interface IAutocompleteConfiguration -{ - public string TrackingCode { get; set; } -} - -public class AutocompleteConfiguration : IAutocompleteConfiguration -{ - public string TrackingCode { get; set; } -} \ No newline at end of file diff --git a/Mapp.UI/Mapp.UI.csproj b/Mapp.UI/Mapp.UI.csproj index 1e87761..8d18865 100644 --- a/Mapp.UI/Mapp.UI.csproj +++ b/Mapp.UI/Mapp.UI.csproj @@ -69,6 +69,7 @@ + diff --git a/Mapp.UI/Settings/AppSettings.Designer.cs b/Mapp.UI/Settings/AppSettings.Designer.cs index a7145e3..38134cd 100644 --- a/Mapp.UI/Settings/AppSettings.Designer.cs +++ b/Mapp.UI/Settings/AppSettings.Designer.cs @@ -12,7 +12,7 @@ namespace Mapp.UI.Settings { [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] - [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.3.0.0")] + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("Microsoft.VisualStudio.Editors.SettingsDesigner.SettingsSingleFileGenerator", "17.8.0.0")] public sealed partial class AppSettings : global::System.Configuration.ApplicationSettingsBase { private static AppSettings defaultInstance = ((AppSettings)(global::System.Configuration.ApplicationSettingsBase.Synchronized(new AppSettings()))); diff --git a/Mapp.UI/Startup/Bootstrapper.cs b/Mapp.UI/Startup/Bootstrapper.cs index fc2bd4c..11a7e81 100644 --- a/Mapp.UI/Startup/Bootstrapper.cs +++ b/Mapp.UI/Startup/Bootstrapper.cs @@ -42,7 +42,6 @@ public IContainer ConfigureContainer() builder.RegisterAsInterfaceSingleton(); builder.RegisterAsInterfaceSingleton(); builder.RegisterAsInterfaceSingleton(); - builder.RegisterAsInterfaceSingleton(); builder.RegisterAsInterfaceSingleton(); builder.RegisterAsInterfaceSingleton(); builder.RegisterAsInterfaceSingleton(); @@ -56,6 +55,7 @@ public IContainer ConfigureContainer() builder.RegisterAsInterface(); builder.RegisterInstance(new SettingsWrapper(Settings.AppSettings.Default, true)).As(); + builder.RegisterType(); builder.RegisterType(); return builder.Build(); diff --git a/Mapp.UI/ViewModels/AutoFillViewModel.cs b/Mapp.UI/ViewModels/AutoFillViewModel.cs index b3a5314..5357d09 100644 --- a/Mapp.UI/ViewModels/AutoFillViewModel.cs +++ b/Mapp.UI/ViewModels/AutoFillViewModel.cs @@ -9,24 +9,21 @@ namespace Mapp.UI.ViewModels; public class AutoFillViewModel: TabViewModelBase { private readonly ISettingsWrapper _settingsWrapper; - private readonly ITransactionsReader _transactionsReader; - private readonly IGpcGenerator _gpcGenerator; - private readonly IFileOperationService _fileOperationService; - private readonly IDialogService _dialogService; public RelayCommand ConvertTransactionsCommand { get; } + public string TrackingCode + { + get => _settingsWrapper.TrackingCode; + set + { + _settingsWrapper.TrackingCode = value; + } + } + public override string Title => LocalizationStrings.AutoFillTabTitle.GetLocalized(); - public AutoFillViewModel(ISettingsWrapper settingsWrapper, - ITransactionsReader transactionsReader, - IGpcGenerator gpcGenerator, - IFileOperationService fileOperationService, - IDialogService dialogService) + public AutoFillViewModel(ISettingsWrapper settingsWrapper) { _settingsWrapper = settingsWrapper; - _transactionsReader = transactionsReader; - _gpcGenerator = gpcGenerator; - _fileOperationService = fileOperationService; - _dialogService = dialogService; } } \ No newline at end of file diff --git a/Mapp.UI/ViewModels/MainViewModel.cs b/Mapp.UI/ViewModels/MainViewModel.cs index 973b8c3..9284346 100644 --- a/Mapp.UI/ViewModels/MainViewModel.cs +++ b/Mapp.UI/ViewModels/MainViewModel.cs @@ -47,6 +47,7 @@ public MainViewModel() public MainViewModel( ISettingsWrapper settingsWrapper, IInvoiceConverterViewModel invoiceConverterVM, + AutoFillViewModel autofillVm, IWarehouseQuantityUpdaterViewModel warehouseQuantityUpdaterVM, ITransactionsConverterViewModel transactionsConverterVM) { @@ -56,6 +57,7 @@ public MainViewModel( _tabs.Add(invoiceConverterVM as TabViewModelBase); _tabs.Add(warehouseQuantityUpdaterVM as TabViewModelBase); + _tabs.Add(autofillVm); _tabs.Add(transactionsConverterVM as TabViewModelBase); Tabs = CollectionViewSource.GetDefaultView(_tabs); diff --git a/Mapp.UI/Views/AutoFillView.xaml b/Mapp.UI/Views/AutoFillView.xaml index e9a6223..a306bda 100644 --- a/Mapp.UI/Views/AutoFillView.xaml +++ b/Mapp.UI/Views/AutoFillView.xaml @@ -3,9 +3,10 @@ xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" - xmlns:local="clr-namespace:Mapp.UI.Views.Converters" - mc:Ignorable="d" - d:DesignHeight="450" d:DesignWidth="800"> + xmlns:local="clr-namespace:Mapp.UI.Views.Converters" xmlns:viewmodels="clr-namespace:Mapp.UI.ViewModels" + mc:Ignorable="d" + d:DesignHeight="450" d:DesignWidth="800" + d:DataContext="{d:DesignInstance Type=viewmodels:AutoFillViewModel, IsDesignTimeCreatable=True}"> From cd7a362d2607f996b7e841d4cf981b6361cd2ef6 Mon Sep 17 00:00:00 2001 From: Stefan Grushko Date: Sun, 14 Apr 2024 15:05:20 +0200 Subject: [PATCH 2/5] fix: start invoice conversion button is enabled when everything is fixed Resolves #79 --- Mapp.DataAccess/AutocompleteDataLoader.cs | 14 +- Mapp.UI/App.xaml | 2 + Mapp.UI/Extensions/RelayCommandExtensions.cs | 237 +++++++++++++++++++ Mapp.UI/Mapp.UI.csproj | 2 +- Mapp.UI/Views/InvoiceConverterView.xaml | 7 +- 5 files changed, 252 insertions(+), 10 deletions(-) create mode 100644 Mapp.UI/Extensions/RelayCommandExtensions.cs diff --git a/Mapp.DataAccess/AutocompleteDataLoader.cs b/Mapp.DataAccess/AutocompleteDataLoader.cs index 2ecc81c..60bd6d7 100644 --- a/Mapp.DataAccess/AutocompleteDataLoader.cs +++ b/Mapp.DataAccess/AutocompleteDataLoader.cs @@ -1,6 +1,7 @@ using System.Collections.Generic; using System.IO; using System.Reflection; +using System.Threading; using Mapp.Common; namespace Mapp.DataAccess @@ -24,18 +25,17 @@ public interface IAutocompleteData public class AutocompleteData : IAutocompleteData { - public Dictionary ProdWarehouseSectionBySku { get; set; } // TODO fix names + public Dictionary ProdWarehouseSectionBySku { get; set; } = new(); // TODO fix names - public Dictionary PohodaProdCodeBySku { get; set; } // TODO decide - SKU or AmazonProdCode + public Dictionary PohodaProdCodeBySku { get; set; } = new();// TODO decide - SKU or AmazonProdCode - public Dictionary ShippingNameBySku { get; set; } + public Dictionary ShippingNameBySku { get; set; } = new(); - public Dictionary PackQuantitySku { get; set; } + public Dictionary PackQuantitySku { get; set; } = new(); - public Dictionary CustomsDeclarationBySku { get; set; } - - public Dictionary DefaultShippingByPartnerCountry { get; set; } + public Dictionary CustomsDeclarationBySku { get; set; } = new(); + public Dictionary DefaultShippingByPartnerCountry { get; set; } = new(); public void UpdateAutocompleteData(T newParamValue, IDictionary autocompleteData, string productKey) { diff --git a/Mapp.UI/App.xaml b/Mapp.UI/App.xaml index 67244ee..c0c9407 100644 --- a/Mapp.UI/App.xaml +++ b/Mapp.UI/App.xaml @@ -4,6 +4,7 @@ xmlns:system="clr-namespace:System;assembly=System.Runtime" xmlns:views="clr-namespace:Mapp.UI.Views" xmlns:viewModels="clr-namespace:Mapp.UI.ViewModels" + xmlns:extensions="clr-namespace:Mapp.UI.Extensions" xmlns:converters="clr-namespace:Mapp.UI.Views.Converters" Startup="Application_Startup" Exit="Application_OnExit"> @@ -15,6 +16,7 @@ +