diff --git a/Borepin/Borepin.Android/Borepin.Android.csproj b/Borepin/Borepin.Android/Borepin.Android.csproj index 339d783..b8e91b3 100644 --- a/Borepin/Borepin.Android/Borepin.Android.csproj +++ b/Borepin/Borepin.Android/Borepin.Android.csproj @@ -68,7 +68,7 @@ 8.1.97 - + diff --git a/Borepin/Borepin.GTK/Borepin.GTK.csproj b/Borepin/Borepin.GTK/Borepin.GTK.csproj index 88376b3..1d5964f 100644 --- a/Borepin/Borepin.GTK/Borepin.GTK.csproj +++ b/Borepin/Borepin.GTK/Borepin.GTK.csproj @@ -42,8 +42,8 @@ False ..\..\..\..\..\..\..\Program Files (x86)\GtkSharp\2.12\lib\gtk-sharp-2.0\atk-sharp.dll - - ..\..\packages\DryIoc.dll.5.0.0\lib\net45\DryIoc.dll + + ..\..\packages\DryIoc.dll.5.0.2\lib\net45\DryIoc.dll False diff --git a/Borepin/Borepin.GTK/app.config b/Borepin/Borepin.GTK/app.config index 6d5260f..66373bc 100644 --- a/Borepin/Borepin.GTK/app.config +++ b/Borepin/Borepin.GTK/app.config @@ -12,7 +12,7 @@ - + diff --git a/Borepin/Borepin.GTK/packages.config b/Borepin/Borepin.GTK/packages.config index dc56bb3..fa48c82 100644 --- a/Borepin/Borepin.GTK/packages.config +++ b/Borepin/Borepin.GTK/packages.config @@ -1,6 +1,6 @@  - + diff --git a/Borepin/Borepin.UWP/Borepin.UWP.csproj b/Borepin/Borepin.UWP/Borepin.UWP.csproj index 2f9fcd5..620bb6d 100644 --- a/Borepin/Borepin.UWP/Borepin.UWP.csproj +++ b/Borepin/Borepin.UWP/Borepin.UWP.csproj @@ -182,9 +182,13 @@ - + + + {c587aac3-50a7-4871-a50d-7880b6f24ef6} + Capnp.Net.Runtime + {3251FCE9-FEA3-4662-8BEB-636BE6732D48} FabAccessAPI diff --git a/Borepin/Borepin.iOS/Borepin.iOS.csproj b/Borepin/Borepin.iOS/Borepin.iOS.csproj index 49518ba..5a52689 100644 --- a/Borepin/Borepin.iOS/Borepin.iOS.csproj +++ b/Borepin/Borepin.iOS/Borepin.iOS.csproj @@ -186,7 +186,7 @@ 8.1.97 - + 5.0.0.2401 diff --git a/Borepin/Borepin.macOS/Borepin.macOS.csproj b/Borepin/Borepin.macOS/Borepin.macOS.csproj index ea2c31f..9130cc0 100644 --- a/Borepin/Borepin.macOS/Borepin.macOS.csproj +++ b/Borepin/Borepin.macOS/Borepin.macOS.csproj @@ -59,8 +59,8 @@ - - ..\..\packages\DryIoc.dll.5.0.0\lib\netstandard2.1\DryIoc.dll + + ..\..\packages\DryIoc.dll.5.0.2\lib\netstandard2.1\DryIoc.dll ..\..\packages\Prism.Core.8.1.97\lib\netstandard2.0\Prism.dll diff --git a/Borepin/Borepin.macOS/app.config b/Borepin/Borepin.macOS/app.config index 9218e1a..5cf16ce 100644 --- a/Borepin/Borepin.macOS/app.config +++ b/Borepin/Borepin.macOS/app.config @@ -8,7 +8,7 @@ - + diff --git a/Borepin/Borepin.macOS/packages.config b/Borepin/Borepin.macOS/packages.config index 869649c..fdabcd9 100644 --- a/Borepin/Borepin.macOS/packages.config +++ b/Borepin/Borepin.macOS/packages.config @@ -1,6 +1,6 @@  - + diff --git a/Borepin/Borepin/Base/ConnectionModelBase.cs b/Borepin/Borepin/Base/ConnectionModelBase.cs index 87b67f0..7cc07b3 100644 --- a/Borepin/Borepin/Base/ConnectionModelBase.cs +++ b/Borepin/Borepin/Base/ConnectionModelBase.cs @@ -12,14 +12,12 @@ namespace Borepin.Base public abstract class ConnectionModelBase : PageModelBase { #region Private Fields - protected readonly IPageDialogService _PageDialogService; protected readonly IAPI _API; #endregion #region Constructors - protected ConnectionModelBase(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService) + protected ConnectionModelBase(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService) { - _PageDialogService = pageDialogService; _API = apiService.GetAPI(); _API.ConnectionStatusChanged += OnConnectionStatusChanged; @@ -54,16 +52,6 @@ namespace Borepin.Base { return Task.CompletedTask; } - - public virtual Task LoadInstance(object instance) - { - return Task.CompletedTask; - } - - public virtual Task CreateInstance() - { - return Task.FromResult(null); - } #endregion #region Fields @@ -79,30 +67,13 @@ namespace Borepin.Base #endregion #region INavigationAware - public override void OnNavigatedTo(INavigationParameters parameters) + public override async Task OnNavigatedToVirtual(INavigationParameters parameters) { - if(parameters.ContainsKey("instance")) - { - LoadInstance(parameters.GetValue("instance")); - } - else - { - Log.Trace("No instance"); - LoadInstance(null); - } + await base.OnNavigatedToVirtual(parameters).ConfigureAwait(false); if(_API.IsConnected) { - LoadAPIData(); - } - } - - public override void OnNavigatedFrom(INavigationParameters parameters) - { - object instance = CreateInstance(); - if(instance != null) - { - parameters.Add("instance", instance); + await LoadAPIData().ConfigureAwait(false); } } #endregion diff --git a/Borepin/Borepin/Base/PageModelBase.cs b/Borepin/Borepin/Base/PageModelBase.cs index f4cf05d..9c054d7 100644 --- a/Borepin/Borepin/Base/PageModelBase.cs +++ b/Borepin/Borepin/Base/PageModelBase.cs @@ -1,6 +1,8 @@ using NLog; using Prism.Mvvm; using Prism.Navigation; +using Prism.Services; +using System.Threading.Tasks; namespace Borepin.Base { @@ -15,10 +17,12 @@ namespace Borepin.Base #region Private Fields protected readonly INavigationService _NavigationService; + protected readonly IPageDialogService _PageDialogService; - protected PageModelBase(INavigationService navigationService) + protected PageModelBase(INavigationService navigationService, IPageDialogService pageDialogService) { _NavigationService = navigationService; + _PageDialogService = pageDialogService; } #endregion @@ -34,9 +38,49 @@ namespace Borepin.Base } #endregion + #region Mehtods + public virtual Task LoadInstance(object instance) + { + return Task.CompletedTask; + } + + public virtual Task CreateInstance() + { + return Task.FromResult(null); + } + #endregion + #region INavigationAware - public abstract void OnNavigatedTo(INavigationParameters parameters); - public abstract void OnNavigatedFrom(INavigationParameters parameters); + public async void OnNavigatedTo(INavigationParameters parameters) + { + await OnNavigatedToVirtual(parameters).ConfigureAwait(false); + IsBusy = false; + } + public async void OnNavigatedFrom(INavigationParameters parameters) + { + await OnNavigatedFromVirtual(parameters).ConfigureAwait(false); + } + + public virtual async Task OnNavigatedToVirtual(INavigationParameters parameters) + { + if (parameters.ContainsKey("instance")) + { + await LoadInstance(parameters.GetValue("instance")).ConfigureAwait(false); + } + else + { + Log.Trace("No instance"); + await LoadInstance(null).ConfigureAwait(false); + } + } + public virtual async Task OnNavigatedFromVirtual(INavigationParameters parameters) + { + object instance = await CreateInstance().ConfigureAwait(false); + if (instance != null) + { + parameters.Add("instance", instance); + } + } #endregion } } \ No newline at end of file diff --git a/Borepin/Borepin/Borepin.csproj b/Borepin/Borepin/Borepin.csproj index 33c442f..97ed6e0 100644 --- a/Borepin/Borepin/Borepin.csproj +++ b/Borepin/Borepin/Borepin.csproj @@ -25,13 +25,13 @@ - + all runtime; build; native; contentfiles; analyzers; buildtransitive - + diff --git a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs index e494e2e..3d28024 100644 --- a/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerProcess/AuthPlainPageModel.cs @@ -78,7 +78,7 @@ namespace Borepin.PageModel.AddServerProcess Properties = new Dictionary(StringComparer.Ordinal) { { "username", Username }, - { "password", Password } + { "password", Password }, }, }; diff --git a/Borepin/Borepin/PageModel/AddServerProcess/ChooseAuthTypePageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/ChooseAuthTypePageModel.cs index e5be535..2e3f618 100644 --- a/Borepin/Borepin/PageModel/AddServerProcess/ChooseAuthTypePageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerProcess/ChooseAuthTypePageModel.cs @@ -1,6 +1,8 @@ using Borepin.Base; -using Borepin.Model; +using Borepin.Base.Exceptions; +using FabAccessAPI; using Prism.Navigation; +using Prism.Services; using System.Threading.Tasks; using System.Windows.Input; using Xamarin.Forms; @@ -10,23 +12,34 @@ namespace Borepin.PageModel.AddServerProcess public class ChooseAuthTypePageModel : PageModelBase { #region Private Fields - private Connection _Connection; + private ConnectionData _ConnectionData; #endregion #region Contructors - public ChooseAuthTypePageModel(INavigationService navigationService) : base(navigationService) + public ChooseAuthTypePageModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService) { AuthPlainCommand = new Command(AuthPlainCommandExecute); } #endregion #region LoadData - public override Task LoadData() + public override Task LoadInstance(object instance) { - IsBusy = false; - + if(instance is ConnectionData) + { + _ConnectionData = instance as ConnectionData; + } + else + { + throw new InstanceIncorrectException(); + } return Task.CompletedTask; } + + public override Task CreateInstance() + { + return Task.FromResult(_ConnectionData); + } #endregion #region Commands @@ -38,37 +51,12 @@ namespace Borepin.PageModel.AddServerProcess } public async void AuthPlainCommandExecute() { - _Connection.AuthenticationTyp = AuthenticationTyp.PLAIN; + _ConnectionData.Mechanism = Mechanism.PLAIN; - INavigationParameters parameters = new NavigationParameters() + INavigationResult result = await _NavigationService.NavigateAsync("AddServerProcess_AuthPlainPage").ConfigureAwait(false); + if(result.Exception != null) { - {"instance", _Connection }, - }; - - await _NavigationService.NavigateAsync("AddServerProcess_AuthPlainPage", parameters).ConfigureAwait(false); - } - #endregion - - #region INavigationAware - public override void OnNavigatedTo(INavigationParameters parameters) - { - if (parameters.ContainsKey("instance") && parameters["instance"] is Connection) - { - _Connection = parameters["instance"] as Connection; - } - else - { - _Connection = new Connection(); - } - - LoadData(); - } - - public override void OnNavigatedFrom(INavigationParameters parameters) - { - if (parameters.GetNavigationMode() == NavigationMode.Back) - { - parameters.Add("instance", _Connection); + Log.Fatal(result.Exception, "Navigating failed"); } } #endregion diff --git a/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs b/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs index a8133d6..ba73052 100644 --- a/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs +++ b/Borepin/Borepin/PageModel/AddServerProcess/SelectServerPageModel.cs @@ -12,14 +12,14 @@ using System.Windows.Input; namespace Borepin.PageModel.AddServerProcess { - public class SelectServerPageModel : ConnectionModelBase + public class SelectServerPageModel : PageModelBase { #region Private Fields private ConnectionData _ConnectionData; #endregion #region Constructors - public SelectServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService) : base(navigationService, pageDialogService, apiService) + public SelectServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService) { ConnectToServerCommand = new DelegateCommand(async () => await ConnectToServerExecute().ConfigureAwait(false)); DetectLocalServerCommand = new DelegateCommand(DetectHostCommandExecute); @@ -98,7 +98,8 @@ namespace Borepin.PageModel.AddServerProcess try { - await _API.TestConnection(_ConnectionData).ConfigureAwait(true); + API api = new API(); + await api.TestConnection(_ConnectionData).ConfigureAwait(true); } catch(ConnectingFailedException) { diff --git a/Borepin/Borepin/PageModel/MachineListPageModel.cs b/Borepin/Borepin/PageModel/MachineListPageModel.cs index 50c7dcb..c4663a7 100644 --- a/Borepin/Borepin/PageModel/MachineListPageModel.cs +++ b/Borepin/Borepin/PageModel/MachineListPageModel.cs @@ -31,23 +31,11 @@ namespace Borepin.PageModel #endregion #region Data - public override async Task LoadData() + public override async Task LoadAPIData() { - if (! await CheckConnection().ConfigureAwait(false)) - { - IsConnected = false; + User user_self = await _API.Session.UserSystem.Info.GetUserSelf().ConfigureAwait(false); - IsBusy = false; - return; - } - - IsConnected = true; - - MachineSystem machineSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem; - UserSystem userSystem = (await _BFFHService.GetSession().ConfigureAwait(false)).UserSystem; - User user_self = await userSystem.Info.GetUserSelf().ConfigureAwait(false); - - IReadOnlyList machine_list = await machineSystem.Info.GetMachineList().ConfigureAwait(false); + IReadOnlyList machine_list = await _API.Session.MachineSystem.Info.GetMachineList().ConfigureAwait(false); List viewmodel_list_user_assigned = new List(); List viewmodel_list_not_user_assigned = new List(); @@ -71,8 +59,6 @@ namespace Borepin.PageModel viewmodel_list_sorted.AddRange(viewmodel_list_user_assigned.OrderBy(x => x.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort())); viewmodel_list_sorted.AddRange(viewmodel_list_not_user_assigned.OrderBy(x => x.Name, StringComparison.OrdinalIgnoreCase.WithNaturalSort())); MachineListItemViewModel_List = viewmodel_list_sorted; - - IsBusy = false; } #endregion @@ -101,7 +87,11 @@ namespace Borepin.PageModel } public async Task RefreshCommandExecute() { - await LoadData().ConfigureAwait(true); + if(_API.IsConnected) + { + await LoadAPIData().ConfigureAwait(true); + } + IsRefreshing = false; } @@ -143,16 +133,14 @@ namespace Borepin.PageModel public async void ScanCode_Result(string value) { - if (! _BFFHService.IsConnected) + if (! _API.IsConnected) { IsConnected = false; IsBusy = false; return; } - MachineSystem machineInterface = (await _BFFHService.GetSession().ConfigureAwait(false)).MachineSystem; - - Machine machine = (await machineInterface.Info.GetMachineURN(value).ConfigureAwait(false)).Just; + Machine machine = (await _API.Session.MachineSystem.Info.GetMachineURN(value).ConfigureAwait(false)).Just; if(machine == null) { @@ -186,19 +174,5 @@ namespace Borepin.PageModel } #endregion - - #region INavigationAware - public override void OnNavigatedFrom(INavigationParameters parameters) - { - - } - - public override async void OnNavigatedTo(INavigationParameters parameters) - { - IsBusy = true; - - await LoadData().ConfigureAwait(false); - } - #endregion } } diff --git a/Borepin/Borepin/PageModel/MachinePageModel.cs b/Borepin/Borepin/PageModel/MachinePageModel.cs index 19b6f91..9f2dfe5 100644 --- a/Borepin/Borepin/PageModel/MachinePageModel.cs +++ b/Borepin/Borepin/PageModel/MachinePageModel.cs @@ -30,8 +30,6 @@ namespace Borepin.PageModel #region Data public override Task LoadInstance(object instance) { - IsBusy = true; - if(instance is string) { _ID = instance as string; @@ -41,8 +39,6 @@ namespace Borepin.PageModel throw new InstanceIncorrectException(); } - IsBusy = false; - return Task.CompletedTask; } diff --git a/Borepin/Borepin/PageModel/MainPageModel.cs b/Borepin/Borepin/PageModel/MainPageModel.cs index 36afcd8..218a68e 100644 --- a/Borepin/Borepin/PageModel/MainPageModel.cs +++ b/Borepin/Borepin/PageModel/MainPageModel.cs @@ -1,9 +1,8 @@ -using System; -using System.Threading.Tasks; -using System.Windows.Input; +using System.Windows.Input; using Borepin.Base; using Borepin.Service.Versioning; using Prism.Navigation; +using Prism.Services; using Xamarin.Forms; namespace Borepin.PageModel @@ -15,21 +14,13 @@ namespace Borepin.PageModel #endregion #region Constructors - public MainPageModel(INavigationService navigationService, IVersioningService versioningService) : base(navigationService) + public MainPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IVersioningService versioningService) : base(navigationService, pageDialogService) { _VersioningService = versioningService; - - NavigateCommand = new Command(NavigateCommandExecute); - } - #endregion - - #region LoadData - public override Task LoadData() - { CurrentVersion = _VersioningService.CurrentVersion; CurrentBuild = _VersioningService.CurrentBuild; - return Task.CompletedTask; + NavigateCommand = new Command(NavigateCommandExecute); } #endregion @@ -58,19 +49,11 @@ namespace Borepin.PageModel } public async void NavigateCommandExecute(string view) { - await _NavigationService.NavigateAsync($"NavigationPage/{ view }").ConfigureAwait(false); - } - #endregion - - #region INavigationAware - public override void OnNavigatedFrom(INavigationParameters parameters) - { - - } - - public override async void OnNavigatedTo(INavigationParameters parameters) - { - await LoadData().ConfigureAwait(false); + INavigationResult result = await _NavigationService.NavigateAsync($"NavigationPage/{ view }").ConfigureAwait(false); + if(result.Exception != null) + { + Log.Fatal(result.Exception, "Navigating failed"); + } } #endregion } diff --git a/Borepin/Borepin/PageModel/ScanPageModel.cs b/Borepin/Borepin/PageModel/ScanPageModel.cs index 139da66..b1de8a4 100644 --- a/Borepin/Borepin/PageModel/ScanPageModel.cs +++ b/Borepin/Borepin/PageModel/ScanPageModel.cs @@ -1,6 +1,7 @@ using Borepin.Base; using Prism.Commands; using Prism.Navigation; +using Prism.Services; using System; using System.Threading.Tasks; using System.Windows.Input; @@ -16,7 +17,7 @@ namespace Borepin.PageModel #endregion #region Contructors - public ScanPageModel(INavigationService navigationService) : base(navigationService) + public ScanPageModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService) { AbortCommand = new DelegateCommand(async () => await AbortCommandExecute().ConfigureAwait(true)); ScannedCommand = new DelegateCommand(ScannedCommandExecute); @@ -27,9 +28,15 @@ namespace Borepin.PageModel #endregion #region Data - public override async Task LoadData() + public override Task LoadInstance(object instance) { - await Task.CompletedTask.ConfigureAwait(false); + _Instance = instance; + return Task.CompletedTask; + } + + public override Task CreateInstance() + { + return Task.FromResult(_Instance); } #endregion @@ -73,7 +80,6 @@ namespace Borepin.PageModel { { "result", "scanned" }, { "value", ScanResult.Text }, - { "instance", _Instance }, }; Device.BeginInvokeOnMainThread(async () => @@ -96,22 +102,9 @@ namespace Borepin.PageModel INavigationParameters parameters = new NavigationParameters() { { "result", "abort" }, - { "instance", _Instance }, }; await _NavigationService.GoBackAsync(parameters).ConfigureAwait(false); } #endregion - - #region INavigationService - public override void OnNavigatedFrom(INavigationParameters parameters) - { - - } - - public override void OnNavigatedTo(INavigationParameters parameters) - { - _Instance = parameters.GetValue("instance"); - } - #endregion } } diff --git a/Borepin/Borepin/PageModel/ServerListPageModel.cs b/Borepin/Borepin/PageModel/ServerListPageModel.cs index b030e80..9e6959c 100644 --- a/Borepin/Borepin/PageModel/ServerListPageModel.cs +++ b/Borepin/Borepin/PageModel/ServerListPageModel.cs @@ -9,6 +9,7 @@ using Borepin.Base; using Borepin.Service.Storage; using FabAccessAPI; using Borepin.Service; +using Prism.Services; namespace Borepin.PageModel { @@ -20,7 +21,7 @@ namespace Borepin.PageModel #endregion #region Constructors - public ServerListPageModel(INavigationService navigationService, ILoginStorageService loginStorageService, IAPIService apiService) : base(navigationService) + public ServerListPageModel(INavigationService navigationService, IPageDialogService pageDialogService, ILoginStorageService loginStorageService, IAPIService apiService) : base(navigationService, pageDialogService) { _LoginStorageService = loginStorageService; _API = apiService.GetAPI(); @@ -106,17 +107,5 @@ namespace Borepin.PageModel await _NavigationService.NavigateAsync("AddServerProcess_SelectServerPage").ConfigureAwait(false); } #endregion - - #region INavigationAware - public override void OnNavigatedFrom(INavigationParameters parameters) - { - - } - - public override async void OnNavigatedTo(INavigationParameters parameters) - { - await LoadData().ConfigureAwait(false); - } - #endregion } } diff --git a/Borepin/Borepin/PageModel/ServerPageModel.cs b/Borepin/Borepin/PageModel/ServerPageModel.cs index a268796..4349251 100644 --- a/Borepin/Borepin/PageModel/ServerPageModel.cs +++ b/Borepin/Borepin/PageModel/ServerPageModel.cs @@ -1,5 +1,7 @@ using Borepin.Base; +using Borepin.Base.Exceptions; using Borepin.Service; +using Borepin.Service.Storage; using FabAccessAPI; using FabAccessAPI.Exceptions; using Prism.Commands; @@ -17,12 +19,14 @@ namespace Borepin.PageModel { #region Private Fields private readonly IDialogService _DialogService; + private readonly ILoginStorageService _LoginStorageService; #endregion #region Constructors - public ServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IDialogService dialogService,) : base(navigationService, pageDialogService, apiService) + public ServerPageModel(INavigationService navigationService, IPageDialogService pageDialogService, IAPIService apiService, IDialogService dialogService, ILoginStorageService loginStorageService) : base(navigationService, pageDialogService, apiService) { _DialogService = dialogService; + _LoginStorageService = loginStorageService; ConnectCommand = new DelegateCommand(async () => await ConnectCommandExecute().ConfigureAwait(false)); DisconnectCommand = new DelegateCommand(async () => await DisonnectCommandExecute().ConfigureAwait(false)); @@ -31,20 +35,29 @@ namespace Borepin.PageModel #endregion #region Data - public override Task LoadData() + public override Task LoadInstance(object instance) { - if (_BFFHService.CurrentConnection != null && Connection_Item != null) + if(instance is ConnectionData) { - InstanceIsActiveConnection = Connection_Item.Equals(_BFFHService.CurrentConnection); + Connection_Item = instance as ConnectionData; + } + else + { + throw new InstanceIncorrectException(); + } + + if (_API.ConnectionData != null && Connection_Item != null) + { + InstanceIsActiveConnection = Connection_Item.Equals(_API.ConnectionData); } else { InstanceIsActiveConnection = false; } - if(_Connection_Item != null && _Connection_Item.Address != null) + if(_Connection_Item != null && _Connection_Item.Host != null) { - DisplayAddress = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", _Connection_Item.Address.Host, _Connection_Item.Address.Port); + DisplayAddress = string.Format(CultureInfo.InvariantCulture, "{0}:{1}", _Connection_Item.Host.Host, _Connection_Item.Host.Port); } IsBusy = false; @@ -110,7 +123,11 @@ namespace Borepin.PageModel return; } - await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage").ConfigureAwait(false); + INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/MachineListPage").ConfigureAwait(false); + if(result.Exception != null) + { + Log.Fatal(result.Exception, "Navigating failed"); + } } private ICommand _DisconnectCommand; @@ -123,7 +140,7 @@ namespace Borepin.PageModel { await _API.Disconnect().ConfigureAwait(false); - await LoadData().ConfigureAwait(false); + await LoadInstance(Connection_Item).ConfigureAwait(false); } private ICommand _DeleteCommand; @@ -149,11 +166,15 @@ namespace Borepin.PageModel { if(string.Equals(result.Parameters.GetValue("result"), "confirm", StringComparison.Ordinal)) { - Connection connection = result.Parameters.GetValue("instance"); + ConnectionData connectionData = result.Parameters.GetValue("instance"); - await _BFFHService.RemoveConnection(connection).ConfigureAwait(false); + await _LoginStorageService.Remove(connectionData).ConfigureAwait(false); - await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage").ConfigureAwait(false); + INavigationResult result_nav = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage").ConfigureAwait(false); + if(result_nav.Exception != null) + { + Log.Fatal(result.Exception, "Navigating failed"); + } } } #endregion diff --git a/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs b/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs index ff4e8a4..2f82a3b 100644 --- a/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs +++ b/Borepin/Borepin/PageModel/SetUpProcess/WelcomePageModel.cs @@ -1,7 +1,7 @@ using Borepin.Base; using Prism.Commands; using Prism.Navigation; -using System; +using Prism.Services; using System.Threading.Tasks; using System.Windows.Input; @@ -10,19 +10,12 @@ namespace Borepin.PageModel.SetUpProcess public class WelcomePageModel : PageModelBase { #region Constructors - public WelcomePageModel(INavigationService navigationService) : base(navigationService) + public WelcomePageModel(INavigationService navigationService, IPageDialogService pageDialogService) : base(navigationService, pageDialogService) { NextCommand = new DelegateCommand(NextCommandCommandExecute); } #endregion - #region Data - public override Task LoadData() - { - return Task.CompletedTask; - } - #endregion - #region Commands private ICommand _NextCommand; public ICommand NextCommand @@ -35,17 +28,5 @@ namespace Borepin.PageModel.SetUpProcess await _NavigationService.NavigateAsync("AddServerProcess_SelectServerPage").ConfigureAwait(false); } #endregion - - #region INavigationAware - public override void OnNavigatedFrom(INavigationParameters parameters) - { - - } - - public override void OnNavigatedTo(INavigationParameters parameters) - { - - } - #endregion } } diff --git a/Borepin/Borepin/PageModel/StartPageModel.cs b/Borepin/Borepin/PageModel/StartPageModel.cs index 20f72d5..8c07818 100644 --- a/Borepin/Borepin/PageModel/StartPageModel.cs +++ b/Borepin/Borepin/PageModel/StartPageModel.cs @@ -1,51 +1,45 @@ using Borepin.Base; -using Borepin.Model; -using Borepin.Service.BFFH; +using Borepin.Service.Storage; +using FabAccessAPI; using Prism.AppModel; using Prism.Navigation; +using Prism.Services; using System.Collections.Generic; -using System.Threading.Tasks; namespace Borepin.PageModel { - public class StartPageModel : PageModelBase, IPageLifecycleAware, IInitialize + public class StartPageModel : PageModelBase, IPageLifecycleAware { #region Private Fields - private readonly IBFFHService _BFFHService; + private readonly ILoginStorageService _LoginStorageService; #endregion #region Constructors - public StartPageModel(INavigationService navigationService, IBFFHService bffhService) : base(navigationService) + public StartPageModel(INavigationService navigationService, IPageDialogService pageDialogService, ILoginStorageService loginStorageService) : base(navigationService, pageDialogService) { - _BFFHService = bffhService; - } - #endregion - - #region LoadData - public override Task LoadData() - { - return Task.CompletedTask; - } - #endregion - - #region IInitialize - public void Initialize(INavigationParameters parameters) - { - + _LoginStorageService = loginStorageService; } #endregion #region IPageLifecycleAware public async void OnAppearing() { - IList connection_list = await _BFFHService.GetConnections().ConfigureAwait(false); - if (connection_list.Count == 0) + IList connectionData_List = await _LoginStorageService.GetList().ConfigureAwait(false); + if (connectionData_List.Count == 0) { - await _NavigationService.NavigateAsync("/MainPage/NavigationPage/SetUpProcess_WelcomePage").ConfigureAwait(false); + INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/SetUpProcess_WelcomePage").ConfigureAwait(false); + if (result.Exception != null) + { + Log.Fatal(result.Exception, "Navigating failed"); + } } else { - await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage").ConfigureAwait(false); + INavigationResult result = await _NavigationService.NavigateAsync("/MainPage/NavigationPage/ServerListPage").ConfigureAwait(false); + if (result.Exception != null) + { + Log.Fatal(result.Exception, "Navigating failed"); + } } } @@ -54,17 +48,5 @@ namespace Borepin.PageModel } #endregion - - #region INavigationAware - public override void OnNavigatedFrom(INavigationParameters parameters) - { - - } - - public override void OnNavigatedTo(INavigationParameters parameters) - { - - } - #endregion } } diff --git a/Borepin_Test/Borepin_Test.csproj b/Borepin_Test/Borepin_Test.csproj index 9a58262..91d2aa3 100644 --- a/Borepin_Test/Borepin_Test.csproj +++ b/Borepin_Test/Borepin_Test.csproj @@ -5,7 +5,7 @@ - + diff --git a/FabAccessAPI/FabAccessAPI.csproj b/FabAccessAPI/FabAccessAPI.csproj index ba24ff4..4baf904 100644 --- a/FabAccessAPI/FabAccessAPI.csproj +++ b/FabAccessAPI/FabAccessAPI.csproj @@ -13,7 +13,7 @@ - + diff --git a/FabAccessAPI_Test/API_Test.cs b/FabAccessAPI_Test/API_Test.cs index 2cabfed..fdc0c7d 100644 --- a/FabAccessAPI_Test/API_Test.cs +++ b/FabAccessAPI_Test/API_Test.cs @@ -1,5 +1,4 @@ - -using Capnp.Rpc; +using Capnp.Rpc; using FabAccessAPI; using FabAccessAPI.Exceptions; using NUnit.Framework; @@ -24,10 +23,7 @@ namespace FabAccessAPI_Test Username = "UnkownUser", Properties = new Dictionary() { - { "Username", "UnkownUser" } - }, - SecretProperties = new Dictionary() - { + { "Username", "UnkownUser" }, { "Password", TestEnv.PASSWORD } } }; diff --git a/FabAccessAPI_Test/FabAccessAPI_Test.csproj b/FabAccessAPI_Test/FabAccessAPI_Test.csproj index d867fe2..87292d1 100644 --- a/FabAccessAPI_Test/FabAccessAPI_Test.csproj +++ b/FabAccessAPI_Test/FabAccessAPI_Test.csproj @@ -1,4 +1,4 @@ - + netcoreapp3.1 @@ -10,7 +10,7 @@ - + diff --git a/FabAccessAPI_Test/TestEnv.cs b/FabAccessAPI_Test/TestEnv.cs index 538b8fc..d331553 100644 --- a/FabAccessAPI_Test/TestEnv.cs +++ b/FabAccessAPI_Test/TestEnv.cs @@ -20,12 +20,9 @@ namespace FabAccessAPI_Test Username = username, Properties = new Dictionary() { - { "Username", username } + { "Username", username }, + { "Password", TestEnv.PASSWORD }, }, - SecretProperties = new Dictionary() - { - { "Password", TestEnv.PASSWORD } - } }; return connectionData;