From 91f71083fab5335f27e55964175550b908fa11d1 Mon Sep 17 00:00:00 2001 From: TheJoKlLa Date: Mon, 23 May 2022 13:51:32 +0200 Subject: [PATCH] Added: New API Struktur --- .../Borepin.Android/Borepin.Android.csproj | 1 + .../Borepin.Android/Services/APIService.cs | 13 +++------ .../Services/APIService_New.cs | 28 +++++++++++++++++++ .../Borepin/PageModel/MachineListPageModel.cs | 20 ------------- Borepin/Borepin/PageModel/ScanURNPageModel.cs | 2 +- Borepin/Borepin/PageModel/ServerPageModel.cs | 4 +-- 6 files changed, 36 insertions(+), 32 deletions(-) create mode 100644 Borepin/Borepin.Android/Services/APIService_New.cs diff --git a/Borepin/Borepin.Android/Borepin.Android.csproj b/Borepin/Borepin.Android/Borepin.Android.csproj index b8e91b3..6f628be 100644 --- a/Borepin/Borepin.Android/Borepin.Android.csproj +++ b/Borepin/Borepin.Android/Borepin.Android.csproj @@ -79,6 +79,7 @@ + diff --git a/Borepin/Borepin.Android/Services/APIService.cs b/Borepin/Borepin.Android/Services/APIService.cs index 815d895..cee9bb1 100644 --- a/Borepin/Borepin.Android/Services/APIService.cs +++ b/Borepin/Borepin.Android/Services/APIService.cs @@ -1,6 +1,4 @@ -using Android.App; -using Android.Content; -using Borepin.Service; +using Borepin.Service; using FabAccessAPI; namespace Borepin.Droid.Services @@ -8,21 +6,18 @@ namespace Borepin.Droid.Services public class APIService : IAPIService { #region Private Members - private readonly APIServiceConnection _APIServiceConnection; + private readonly IAPI _API; #endregion #region Constructors public APIService() { - Context context = Application.Context; - Intent service = new Intent(context, typeof(APIBindedService)); - context.BindService(service, _APIServiceConnection, Bind.AutoCreate); + _API = new API(); } #endregion - public IAPI GetAPI() { - return _APIServiceConnection?.Binder?.Service?.GetAPI(); + return _API; } } } \ No newline at end of file diff --git a/Borepin/Borepin.Android/Services/APIService_New.cs b/Borepin/Borepin.Android/Services/APIService_New.cs new file mode 100644 index 0000000..1defae9 --- /dev/null +++ b/Borepin/Borepin.Android/Services/APIService_New.cs @@ -0,0 +1,28 @@ +using Android.App; +using Android.Content; +using Borepin.Service; +using FabAccessAPI; + +namespace Borepin.Droid.Services +{ + public class APIService_New : IAPIService + { + #region Private Members + private readonly APIServiceConnection _APIServiceConnection; + #endregion + + #region Constructors + public APIService_New() + { + Context context = Application.Context; + Intent service = new Intent(context, typeof(APIBindedService)); + context.BindService(service, _APIServiceConnection, Bind.AutoCreate); + } + #endregion + + public IAPI GetAPI() + { + return _APIServiceConnection?.Binder?.Service?.GetAPI(); + } + } +} \ No newline at end of file diff --git a/Borepin/Borepin/PageModel/MachineListPageModel.cs b/Borepin/Borepin/PageModel/MachineListPageModel.cs index 023938f..d7a69a0 100644 --- a/Borepin/Borepin/PageModel/MachineListPageModel.cs +++ b/Borepin/Borepin/PageModel/MachineListPageModel.cs @@ -110,26 +110,6 @@ namespace Borepin.PageModel await _NavigationService.NavigateAsync("ScanPage", parameters).ConfigureAwait(false); } - - public async void ScanCode_Result(string value) - { - if (! _API.IsConnected) - { - IsConnected = false; - IsBusy = false; - return; - } - - Machine machine = (await _API.Session.MachineSystem.Info.GetMachineURN(value).ConfigureAwait(false)).Just; - - if(machine == null) - { - IsBusy = false; - return; - } - - IsBusy = false; - } #endregion } } diff --git a/Borepin/Borepin/PageModel/ScanURNPageModel.cs b/Borepin/Borepin/PageModel/ScanURNPageModel.cs index 18d547f..2c01d49 100644 --- a/Borepin/Borepin/PageModel/ScanURNPageModel.cs +++ b/Borepin/Borepin/PageModel/ScanURNPageModel.cs @@ -97,7 +97,7 @@ namespace Borepin.PageModel { NavigationParameters parameters = new NavigationParameters { - { "id", id }, + { "instance", id }, }; Device.BeginInvokeOnMainThread(async () => diff --git a/Borepin/Borepin/PageModel/ServerPageModel.cs b/Borepin/Borepin/PageModel/ServerPageModel.cs index 3d209c4..3ef20a6 100644 --- a/Borepin/Borepin/PageModel/ServerPageModel.cs +++ b/Borepin/Borepin/PageModel/ServerPageModel.cs @@ -177,9 +177,9 @@ namespace Borepin.PageModel } public async Task DisonnectCommandExecute() { - await _API.Disconnect().ConfigureAwait(false); _API.UnbindAllEvents(); - + await _API.Disconnect().ConfigureAwait(false); + await LoadInstance(Connection_Item).ConfigureAwait(false); }