Loading INAF.Apps.Uwp.SLabDataManager/Assets/xml/remoteoperations.xml +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ <operation type="IsAnySpectrumTypeSavedOnCloud">AppSpectraFilesActions/IsAnySpectrumTypeSavedOnCloud</operation> <operation type="IsSpectrumTypeSavedOnCloud">AppSpectraFilesActions/IsSpectrumTypeSavedOnCloud</operation> <operation type="GetSampleDataValues">AppSpectraFilesActions/GetSampleDataValues</operation> <operation type="GetChildrenSpectraTypes">AppSpectraFilesActions/GetChildrenSpectraTypes</operation> <!-- USERS --> <operation type="GetUserPermissions">Users/GetUserPermissions</operation> </operationUrls> Loading INAF.Apps.Uwp.SLabDataManager/Converters/Converters.cs +27 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,33 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters } } public sealed class SmoothedSpectrumCreatedConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { bool isEnableButtonRequested = System.Convert.ToBoolean(value); SpectrumType destSpectrumType = ((string)parameter).ToSpectrumType(); SpectraContainer spectraContainer = Ioc.Default.GetService<SpectraContainer>(); return isEnableButtonRequested && spectraContainer.isAnySpectrumOfType(destSpectrumType); } catch (Exception) { return Visibility.Collapsed; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class SmoothingButtonVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) Loading INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsManager.cs +32 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,38 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations return result; } private async Task<T> getAsync<T>(RemoteOperationType remoteOperationType, string args) { T result = default; try { using (var httpClient = new HttpClient()) { JwtTokenModel tokenModel = settingsHelper.get<JwtTokenModel>(Constants.Constants.AUTHENTICATION_TOKEN); httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", tokenModel.Token); var url = remoteOperationsRepository.getUrl(remoteOperationType, args); using (var response = await httpClient.GetAsync(new Uri(url))) { if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsStringAsync(); //System.Diagnostics.Debug.WriteLine($"responseContent: {responseContent}"); result = JsonConvert.DeserializeObject<T>(responseContent); } } } } catch (Exception ex) { logger.Write<RemoteOperationsManager>($"{nameof(postAsync)} - ex: {ex.Message}", Serilog.Events.LogEventLevel.Error); } return result; } private async Task<T> postAsync<T>(object model, RemoteOperationType remoteOperationType) { T result = default; Loading INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsManagerSpectraFileActions.cs +5 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations { public partial class RemoteOperationsManager { public async Task<int> getChildrenSpectraTypes(SpectrumType spectrumType) { return await getAsync<int>(RemoteOperationType.GetChildrenSpectraTypes, string.Join("=", string.Join(string.Empty, nameof(SpectrumType), "Id"), ((int)spectrumType).ToString())); } public async Task<GenericIdResponseModel> isAnySpectrumTypeSavedOnCloudAsync(IsAnySpectrumTypeSavedOnCloudRequestModel model) { return await postAsync<GenericIdResponseModel>(model, RemoteOperationType.IsAnySpectrumTypeSavedOnCloud); Loading INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsRepository.cs +6 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations return string.Join("/", BaseUrl, RemoteOperations.FirstOrDefault(x => x.Type == type).Url); } public string getUrl(RemoteOperationType type, string args) { string baseUrl = string.Join("/", BaseUrl, RemoteOperations.FirstOrDefault(x => x.Type == type).Url); return string.Join("?", baseUrl, args); } public void setBaseUrl(string baseUrl) { BaseUrl = baseUrl; Loading Loading
INAF.Apps.Uwp.SLabDataManager/Assets/xml/remoteoperations.xml +1 −0 Original line number Diff line number Diff line Loading @@ -18,6 +18,7 @@ <operation type="IsAnySpectrumTypeSavedOnCloud">AppSpectraFilesActions/IsAnySpectrumTypeSavedOnCloud</operation> <operation type="IsSpectrumTypeSavedOnCloud">AppSpectraFilesActions/IsSpectrumTypeSavedOnCloud</operation> <operation type="GetSampleDataValues">AppSpectraFilesActions/GetSampleDataValues</operation> <operation type="GetChildrenSpectraTypes">AppSpectraFilesActions/GetChildrenSpectraTypes</operation> <!-- USERS --> <operation type="GetUserPermissions">Users/GetUserPermissions</operation> </operationUrls> Loading
INAF.Apps.Uwp.SLabDataManager/Converters/Converters.cs +27 −0 Original line number Diff line number Diff line Loading @@ -232,6 +232,33 @@ namespace INAF.Apps.Uwp.SLabDataManager.Converters } } public sealed class SmoothedSpectrumCreatedConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) { try { bool isEnableButtonRequested = System.Convert.ToBoolean(value); SpectrumType destSpectrumType = ((string)parameter).ToSpectrumType(); SpectraContainer spectraContainer = Ioc.Default.GetService<SpectraContainer>(); return isEnableButtonRequested && spectraContainer.isAnySpectrumOfType(destSpectrumType); } catch (Exception) { return Visibility.Collapsed; } } public object ConvertBack(object value, Type targetType, object parameter, string language) { throw new NotImplementedException(); } } public sealed class SmoothingButtonVisibilityConverter : IValueConverter { public object Convert(object value, Type targetType, object parameter, string language) Loading
INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsManager.cs +32 −0 Original line number Diff line number Diff line Loading @@ -113,6 +113,38 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations return result; } private async Task<T> getAsync<T>(RemoteOperationType remoteOperationType, string args) { T result = default; try { using (var httpClient = new HttpClient()) { JwtTokenModel tokenModel = settingsHelper.get<JwtTokenModel>(Constants.Constants.AUTHENTICATION_TOKEN); httpClient.DefaultRequestHeaders.Authorization = new HttpCredentialsHeaderValue("Bearer", tokenModel.Token); var url = remoteOperationsRepository.getUrl(remoteOperationType, args); using (var response = await httpClient.GetAsync(new Uri(url))) { if (response.IsSuccessStatusCode) { var responseContent = await response.Content.ReadAsStringAsync(); //System.Diagnostics.Debug.WriteLine($"responseContent: {responseContent}"); result = JsonConvert.DeserializeObject<T>(responseContent); } } } } catch (Exception ex) { logger.Write<RemoteOperationsManager>($"{nameof(postAsync)} - ex: {ex.Message}", Serilog.Events.LogEventLevel.Error); } return result; } private async Task<T> postAsync<T>(object model, RemoteOperationType remoteOperationType) { T result = default; Loading
INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsManagerSpectraFileActions.cs +5 −0 Original line number Diff line number Diff line Loading @@ -9,6 +9,11 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations { public partial class RemoteOperationsManager { public async Task<int> getChildrenSpectraTypes(SpectrumType spectrumType) { return await getAsync<int>(RemoteOperationType.GetChildrenSpectraTypes, string.Join("=", string.Join(string.Empty, nameof(SpectrumType), "Id"), ((int)spectrumType).ToString())); } public async Task<GenericIdResponseModel> isAnySpectrumTypeSavedOnCloudAsync(IsAnySpectrumTypeSavedOnCloudRequestModel model) { return await postAsync<GenericIdResponseModel>(model, RemoteOperationType.IsAnySpectrumTypeSavedOnCloud); Loading
INAF.Apps.Uwp.SLabDataManager/Helpers/RemoteOperations/RemoteOperationsRepository.cs +6 −0 Original line number Diff line number Diff line Loading @@ -31,6 +31,12 @@ namespace INAF.Apps.Uwp.SLabDataManager.Helpers.RemoteOperations return string.Join("/", BaseUrl, RemoteOperations.FirstOrDefault(x => x.Type == type).Url); } public string getUrl(RemoteOperationType type, string args) { string baseUrl = string.Join("/", BaseUrl, RemoteOperations.FirstOrDefault(x => x.Type == type).Url); return string.Join("?", baseUrl, args); } public void setBaseUrl(string baseUrl) { BaseUrl = baseUrl; Loading