From cb1b51c238c64f570d73b7dca6a2eee205b2da01 Mon Sep 17 00:00:00 2001 From: Roy Ben Shabat Date: Sat, 11 Apr 2020 00:54:54 +0300 Subject: Implemented FSE bug reporting !!! --- .../ViewModels/FileSystemViewVM.cs | 20 +- .../Tango.FSE.PPCConsole/ViewModels/LogsViewVM.cs | 1 + .../ViewModels/MonitoringViewVM.cs | 2 +- .../ViewModels/UpdatesViewVM.cs | 5 +- .../Tango.FSE.PPCConsole/Views/ConsoleView.xaml | 2 +- .../Tango.FSE.PPCConsole/Views/LogsView.xaml | 2 +- .../Views/RemoteDesktopView.xaml | 4 +- .../Tango.FSE.PPCConsole/Views/UpdatesView.xaml | 210 +++++++------- .../CacheEntities/CachedBugInfoResponse.cs | 17 ++ .../FSE/Tango.FSE.BL/FSEServiceBase.cs | 6 + .../FSE/Tango.FSE.BL/FSEServicesContainer.cs | 6 + .../FSE/Tango.FSE.BL/IAuthenticationService.cs | 6 + .../Tango.FSE.BL/Services/BugReportingService.cs | 66 +++++ .../FSE/Tango.FSE.BL/Tango.FSE.BL.csproj | 2 + .../FSE/Tango.FSE.BL/Web/FSEWebClientBase.cs | 9 + .../FSE/Tango.FSE.Common/BugReporting/Bug.cs | 44 +++ .../FSE/Tango.FSE.Common/BugReporting/BugType.cs | 14 + .../Tango.FSE.Common/BugReporting/IBugReporter.cs | 34 +++ .../FSE/Tango.FSE.Common/FSEViewModel.cs | 7 + .../Notifications/INotificationProvider.cs | 17 ++ .../Tango.FSE.Common/Notifications/MessageType.cs | 3 +- .../Tango.FSE.Common/Notifications/SnackbarItem.cs | 75 ++++- .../FSE/Tango.FSE.Common/Resources/Styles.xaml | 37 +++ .../FSE/Tango.FSE.Common/Tango.FSE.Common.csproj | 3 + .../Visual_Studio/FSE/Tango.FSE.UI/App.xaml.cs | 17 +- .../DefaultAuthenticationProvider.cs | 7 + .../BugReporting/DefaultBugReporter.cs | 318 +++++++++++++++++++++ .../BugReporting/SystemInformationModel.cs | 23 ++ .../BugReporting/SystemInformationTemplate.cshtml | 82 ++++++ .../Tango.FSE.UI/Console/DefaultConsoleProvider.cs | 5 + .../FSE/Tango.FSE.UI/Dialogs/BugReportView.xaml | 48 ++++ .../FSE/Tango.FSE.UI/Dialogs/BugReportView.xaml.cs | 28 ++ .../FSE/Tango.FSE.UI/Dialogs/BugReportViewVM.cs | 52 ++++ .../FileSystem/DefaultFileSystemProvider.cs | 6 + .../Notifications/DefaultNotificationProvider.cs | 49 +++- .../Performance/DefaultPerformanceProvider.cs | 6 + .../FSE/Tango.FSE.UI/Tango.FSE.UI.csproj | 78 +++++ .../FSE/Tango.FSE.UI/ViewModelLocator.cs | 5 + .../FSE/Tango.FSE.UI/ViewModels/LayoutViewVM.cs | 12 + .../FSE/Tango.FSE.UI/ViewModels/LoadingViewVM.cs | 2 +- .../FSE/Tango.FSE.UI/Views/LayoutView.xaml | 5 +- .../FSE/Tango.FSE.UI/Views/MainView.xaml | 17 +- .../Messages/BugReportingInfoRequest.cs | 14 + .../Messages/BugReportingInfoResponse.cs | 16 ++ .../FSE/Tango.FSE.Web/Tango.FSE.Web.csproj | 2 + .../Tango.Transport/Web/WebTransportClient.cs | 47 +-- .../Controllers/FSEController.cs | 13 + .../Tango.MachineService/MachineServiceConfig.cs | 4 + .../Web/Tango.MachineService/Web.config | 4 + 49 files changed, 1290 insertions(+), 162 deletions(-) create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedBugInfoResponse.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.BL/Services/BugReportingService.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/Bug.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/BugType.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/IBugReporter.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/BugReporting/DefaultBugReporter.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/BugReporting/SystemInformationModel.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/BugReporting/SystemInformationTemplate.cshtml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/BugReportView.xaml create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/BugReportView.xaml.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.UI/Dialogs/BugReportViewVM.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoRequest.cs create mode 100644 Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoResponse.cs (limited to 'Software/Visual_Studio') diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs index 6fb46320b..6dea5c146 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/FileSystemViewVM.cs @@ -211,7 +211,14 @@ namespace Tango.FSE.PPCConsole.ViewModels { if (e.DifferentFromPrevious) { - await Navigate(null); + try + { + await Navigate(null, null, true); + } + catch (Exception ex) + { + NotificationProvider.PushErrorReportingSnackbar(ex, "PPC Module Error", "Could not initialize the remote file system provider."); + } } } } @@ -406,7 +413,7 @@ namespace Tango.FSE.PPCConsole.ViewModels await Navigate(null, specialFolder); } - private async Task Navigate(String path, Environment.SpecialFolder? specialFolder = null) + private async Task Navigate(String path, Environment.SpecialFolder? specialFolder = null, bool throwError = false) { try { @@ -439,7 +446,14 @@ namespace Tango.FSE.PPCConsole.ViewModels { IsFree = true; Mouse.OverrideCursor = null; - await NotificationProvider.ShowError($"Error navigating to the specified path.\n{ex.FlattenMessage()}"); + if (!throwError) + { + await NotificationProvider.ShowError($"Error navigating to the specified path.\n{ex.FlattenMessage()}"); + } + else + { + throw ex; + } } finally { diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/LogsViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/LogsViewVM.cs index 52955e18a..a78e52ebe 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/LogsViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/LogsViewVM.cs @@ -174,6 +174,7 @@ namespace Tango.FSE.PPCConsole.ViewModels catch (Exception ex) { LogManager.Log(ex, "Error loading log files."); + NotificationProvider.PushErrorReportingSnackbar(ex, "PPC Module Error", "Could not initialize the remote PPC logs history."); } finally { diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs index 4b37e6b31..6c0c3f05f 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/MonitoringViewVM.cs @@ -265,7 +265,7 @@ namespace Tango.FSE.PPCConsole.ViewModels { FetchingSystemInfo = false; LogManager.Log(ex, "Error retrieving system information from remote machine."); - await NotificationProvider.ShowWarning("Error retrieving the remote machine PPC system information."); + NotificationProvider.PushErrorReportingSnackbar(ex, "PPC Module Error", "Error retrieving the remote machine PPC system information."); } finally { diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs index d97824fe9..81307ffd1 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/ViewModels/UpdatesViewVM.cs @@ -47,7 +47,7 @@ namespace Tango.FSE.PPCConsole.ViewModels get { return _packages; } set { _packages = value; RaisePropertyChangedAuto(); } } - + private String _filter; /// /// Gets or sets the search filter. @@ -141,7 +141,7 @@ namespace Tango.FSE.PPCConsole.ViewModels private async void LoadMachineUpdates() { - if (!MachineProvider.ConnectionType.IsRemote()) return; + if (!MachineProvider.IsConnected || !MachineProvider.ConnectionType.IsRemote()) return; if (!_loaded) { @@ -167,6 +167,7 @@ namespace Tango.FSE.PPCConsole.ViewModels catch (Exception ex) { LogManager.Log(ex, "Error retrieving machine updates."); + NotificationProvider.PushErrorReportingSnackbar(ex, "PPC Module Error", "Error occurred while trying to retrieve the machine software updates history."); } finally { diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml index 1aad6fa58..63fa5f5cd 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/ConsoleView.xaml @@ -10,7 +10,7 @@ xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:ConsoleViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.ConsoleViewVM}"> - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/LogsView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/LogsView.xaml index 81258e971..dde14d6c7 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/LogsView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/LogsView.xaml @@ -42,7 +42,7 @@ - + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml index 919bbb14e..9aa8cab3c 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/RemoteDesktopView.xaml @@ -12,8 +12,8 @@ xmlns:material="http://materialdesigninxaml.net/winfx/xaml/themes" mc:Ignorable="d" d:DesignHeight="720" d:DesignWidth="1280" d:DataContext="{d:DesignInstance Type=vm:RemoteDesktopViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.RemoteDesktopViewVM}" Foreground="{StaticResource FSE_PrimaryForegroundBrush}" Focusable="False"> - - + + diff --git a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml index 8a8e6546e..29d370507 100644 --- a/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml +++ b/Software/Visual_Studio/FSE/Modules/Tango.FSE.PPCConsole/Views/UpdatesView.xaml @@ -12,112 +12,114 @@ xmlns:dragablz="http://dragablz.net/winfx/xaml/dragablz" mc:Ignorable="d" d:DesignHeight="450" d:DesignWidth="800" d:DataContext="{d:DesignInstance Type=vm:UpdatesViewVM, IsDesignTimeCreatable=False}" DataContext="{x:Static global:ViewModelLocator.UpdatesViewVM}"> - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - Loading machine updates... + + + + + + + + + Loading machine updates... + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedBugInfoResponse.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedBugInfoResponse.cs new file mode 100644 index 000000000..73e142d78 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/CacheEntities/CachedBugInfoResponse.cs @@ -0,0 +1,17 @@ +using LiteDB; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.Web.Messages; + +namespace Tango.FSE.BL.CacheEntities +{ + public class CachedBugInfoResponse + { + [BsonId] + public String EnvironmentID { get; set; } + public BugReportingInfoResponse Response { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServiceBase.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServiceBase.cs index 9aeefd4d0..f2eb0dbe1 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServiceBase.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServiceBase.cs @@ -23,6 +23,8 @@ namespace Tango.FSE.BL [TangoInject] protected FSEWebClient WebClient { get; set; } + protected FSEServicesContainer Services { get; set; } + protected User CurrentUser { get { return Authentication.CurrentUser; } @@ -34,6 +36,10 @@ namespace Tango.FSE.BL { TangoIOC.Default.Inject(this); DiskCache = CacheManager.Default; + TangoIOC.Default.GetInstanceWhenAvailable((x) => + { + Services = x; + }); } public void Dispose() diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs index ef50bf036..2fa6cae53 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/FSEServicesContainer.cs @@ -32,6 +32,11 @@ namespace Tango.FSE.BL /// public AuthenticationService AuthenticationService { get; set; } + /// + /// Gets or sets the bug reporting service. + /// + public BugReportingService BugReportingService { get; set; } + /// /// Initializes a new instance of the class. /// @@ -42,6 +47,7 @@ namespace Tango.FSE.BL UsersService = new UsersService(); GatewayService = new GatewayService(); AuthenticationService = new AuthenticationService(); + BugReportingService = new BugReportingService(); } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/IAuthenticationService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/IAuthenticationService.cs index 0169c38b9..200831337 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/IAuthenticationService.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/IAuthenticationService.cs @@ -4,6 +4,7 @@ using System.Linq; using System.Text; using System.Threading.Tasks; using Tango.BL.Entities; +using Tango.MachineService.Gateway; namespace Tango.FSE.BL { @@ -12,6 +13,11 @@ namespace Tango.FSE.BL /// public interface IAuthenticationService { + /// + /// Gets the current environment configuration. + /// + EnvironmentConfiguration CurrentEnvironment { get; } + /// /// Gets the global current user. /// diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/BugReportingService.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/BugReportingService.cs new file mode 100644 index 000000000..5650aeab8 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Services/BugReportingService.cs @@ -0,0 +1,66 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.FSE.BL.CacheEntities; +using Tango.FSE.Web.Messages; + +namespace Tango.FSE.BL.Services +{ + public class BugReportingService : FSEServiceBase + { + private const string BUG_INFO_RESPONSES_COLLECTION = "BugInfoResponses"; + + /// + /// Gets the necessary information required in order to initialize a TFS API client. + /// + /// + public Task GetBugReportingInfo() + { + LogManager.Log($"Retrieving bug reporting information for environment '{Authentication.CurrentEnvironment.Name}'..."); + + return DataResolver.Builder.New() + .ConfigureCascade(DataResolverNode.Online, DataResolverNode.DiskCache) + .Online((context) => + { + var response = WebClient.GetBugReportInfo(new BugReportingInfoRequest()).Result; + + LogManager.Log("Bug reporting information retrieved successfully. Caching bug reporting information on disk..."); + + try + { + using (var cache = DiskCache.CreateContext()) + { + cache.GetCollection(BUG_INFO_RESPONSES_COLLECTION).Upsert(new CachedBugInfoResponse() + { + Response = response, + EnvironmentID = Authentication.CurrentEnvironment.ID + }); + } + } + catch (Exception ex) + { + LogManager.Log(ex, "Error caching online bug reporting information response."); + } + + return response; + }) + .DiskCache((context) => + { + using (var cache = DiskCache.CreateContext()) + { + var cachedResponse = cache.GetCollection(BUG_INFO_RESPONSES_COLLECTION).FindOne(x => x.EnvironmentID == Authentication.CurrentEnvironment.ID); + + if (cachedResponse == null) + { + throw new KeyNotFoundException($"Could not locate cached bug reporting information for the current environment {Authentication.CurrentEnvironment.Name}."); + } + + return cachedResponse.Response; + } + }) + .BuildExecuteAsync(); + } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj index 6e9863095..0eae2baa3 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Tango.FSE.BL.csproj @@ -71,6 +71,7 @@ + @@ -87,6 +88,7 @@ + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.BL/Web/FSEWebClientBase.cs b/Software/Visual_Studio/FSE/Tango.FSE.BL/Web/FSEWebClientBase.cs index e13ef73de..fbfd1e647 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.BL/Web/FSEWebClientBase.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.BL/Web/FSEWebClientBase.cs @@ -39,5 +39,14 @@ namespace Tango.FSE.BL.Web } + /// + /// Executes the GetBugReportInfo action and returns Tango.FSE.Web.Messages.BugReportingInfoResponse. + /// + /// + public Task GetBugReportInfo(Tango.FSE.Web.Messages.BugReportingInfoRequest request) + { + return Post("GetBugReportInfo", request); + } + } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/Bug.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/Bug.cs new file mode 100644 index 000000000..a1f5f3f86 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/Bug.cs @@ -0,0 +1,44 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.Common.BugReporting +{ + /// + /// Represents a bug report. + /// + public class Bug + { + /// + /// Gets or sets the bug type. + /// + public BugType Type { get; set; } + + /// + /// Gets or sets the title. + /// + public String Title { get; set; } + + /// + /// Gets or sets the description. + /// + public String Description { get; set; } + + /// + /// Gets or sets optional comments. + /// + public String Comments { get; set; } + + /// + /// Gets or sets optional exception. + /// + public Exception Exception { get; set; } + + /// + /// Gets or sets optional steps to reproduce. + /// + public String StepsToReproduce { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/BugType.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/BugType.cs new file mode 100644 index 000000000..fc03c1fd4 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/BugType.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.Common.BugReporting +{ + public enum BugType + { + FSE, + PPC + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/IBugReporter.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/IBugReporter.cs new file mode 100644 index 000000000..e0bafdb54 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/BugReporting/IBugReporter.cs @@ -0,0 +1,34 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Tango.FSE.Common.BugReporting +{ + /// + /// Represents a bug reporting service. + /// + public interface IBugReporter + { + /// + /// Submits the specified bug. + /// + /// The bug. + /// + Task SubmitBug(Bug bug); + + /// + /// Displays a bug submission dialog. When confirmed, will submit the specified bug. + /// + /// The bug. + /// + Task ShowBugReportDialog(Bug bug); + + /// + /// Displays a bug submission dialog. When confirmed, will submit the new created bug. + /// + /// + Task ShowBugReportDialog(); + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs index b3d867349..01b27c8ea 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/FSEViewModel.cs @@ -32,6 +32,7 @@ using Tango.Settings; using Tango.SharedUI; using static Tango.SharedUI.Controls.NavigationControl; using Tango.FSE.BL.Connectivity; +using Tango.FSE.Common.BugReporting; namespace Tango.FSE.Common { @@ -139,6 +140,12 @@ namespace Tango.FSE.Common [TangoInject] public IConnectivityProvider ConnectivityProvider { get; set; } + /// + /// Gets or sets the bug reporter. + /// + [TangoInject] + public IBugReporter BugReporter { get; set; } + /// /// Gets or sets the FSE service. /// diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs index 49402bd41..4bb844e5a 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/INotificationProvider.cs @@ -281,6 +281,23 @@ namespace Tango.FSE.Common.Notifications /// SnackbarItem PushSnackbarItem(MessageType type, String title, bool canClose, String message = null, TimeSpan? timeout = null, Action closeAction = null, Action pressAction = null); + /// + /// Display a new error SnackBar. Pressing the snack bar will display the issue reporting dialog. + /// + /// The exception. + /// The title. + /// The message. + /// + SnackbarItem PushErrorReportingSnackbar(Exception exception, String title, String message); + + /// + /// Displays a indeterminate progress Snackbar. Should use and . + /// + /// The title. + /// The message. + /// + SnackbarItem PushProgressSnackbar(String title, String message); + /// /// Pops the snack bar item. /// diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/MessageType.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/MessageType.cs index c4090865e..43c0d83d0 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/MessageType.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/MessageType.cs @@ -12,6 +12,7 @@ namespace Tango.FSE.Common.Notifications Question, Warning, Error, - Success + Success, + Busy, } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/SnackbarItem.cs b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/SnackbarItem.cs index 6246d0ce1..46f4484b0 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/SnackbarItem.cs +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Notifications/SnackbarItem.cs @@ -15,15 +15,37 @@ namespace Tango.FSE.Common.Notifications private Action _pressAction; private bool _isClosed; - public MessageType Type { get; set; } + private MessageType _type; + public MessageType Type + { + get { return _type; } + set { _type = value; RaisePropertyChangedAuto(); } + } public String Title { get; set; } - public String Message { get; set; } + private String _message; + public String Message + { + get { return _message; } + set { _message = value; RaisePropertyChangedAuto(); } + } + + private bool _isProgress; + public bool IsProgress + { + get { return _isProgress; } + set { _isProgress = value; RaisePropertyChangedAuto(); } + } public TimeSpan? Timeout { get; set; } - public bool CanClose { get; set; } + private bool _canClose; + public bool CanClose + { + get { return _canClose; } + set { _canClose = value; RaisePropertyChangedAuto(); } + } public RelayCommand CloseCommand { get; private set; } @@ -46,6 +68,8 @@ namespace Tango.FSE.Common.Notifications _pressAction = () => { + if (IsProgress) return; + if (pressAction != null) { Close(); @@ -69,9 +93,41 @@ namespace Tango.FSE.Common.Notifications PressCommand = new RelayCommand(() => { _pressAction?.Invoke(); }); CloseCommand = new RelayCommand(() => { _closeAction?.Invoke(); }); - if (Timeout != null) + StartCloseTimeout(Timeout); + } + + public void Close() + { + if (!_isClosed) { - Task.Delay(Timeout.Value).ContinueWith((x) => + _isClosed = true; + TangoIOC.Default.GetInstance().PopSnackbarItem(this); + } + } + + public void ProgressCompleted(String message, TimeSpan? timeout = null) + { + IsProgress = false; + CanClose = true; + Message = message; + Type = MessageType.Success; + StartCloseTimeout(timeout); + } + + public void ProgressFailed(String message, TimeSpan? timeout = null) + { + IsProgress = false; + CanClose = true; + Message = message; + Type = MessageType.Error; + StartCloseTimeout(timeout); + } + + private void StartCloseTimeout(TimeSpan? timeout) + { + if (timeout != null) + { + Task.Delay(timeout.Value).ContinueWith((x) => { if (!_isClosed) { @@ -84,14 +140,5 @@ namespace Tango.FSE.Common.Notifications }); } } - - public void Close() - { - if (!_isClosed) - { - _isClosed = true; - TangoIOC.Default.GetInstance().PopSnackbarItem(this); - } - } } } diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml index 462e2a976..bb3d6ebe8 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml +++ b/Software/Visual_Studio/FSE/Tango.FSE.Common/Resources/Styles.xaml @@ -495,6 +495,7 @@ + @@ -524,6 +525,42 @@ + + + @@ -98,17 +99,25 @@ + + + + - - - + + + + + + + diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoRequest.cs b/Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoRequest.cs new file mode 100644 index 000000000..ee52e3368 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoRequest.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.FSE.Web.Messages +{ + public class BugReportingInfoRequest : WebRequestMessage + { + + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoResponse.cs b/Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoResponse.cs new file mode 100644 index 000000000..f5f326bb8 --- /dev/null +++ b/Software/Visual_Studio/FSE/Tango.FSE.Web/Messages/BugReportingInfoResponse.cs @@ -0,0 +1,16 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Transport.Web; + +namespace Tango.FSE.Web.Messages +{ + public class BugReportingInfoResponse : WebResponseMessage + { + public String CollectionUrl { get; set; } + public String PersonalToken { get; set; } + public String UserEmail { get; set; } + } +} diff --git a/Software/Visual_Studio/FSE/Tango.FSE.Web/Tango.FSE.Web.csproj b/Software/Visual_Studio/FSE/Tango.FSE.Web/Tango.FSE.Web.csproj index 166162caf..299240d60 100644 --- a/Software/Visual_Studio/FSE/Tango.FSE.Web/Tango.FSE.Web.csproj +++ b/Software/Visual_Studio/FSE/Tango.FSE.Web/Tango.FSE.Web.csproj @@ -41,6 +41,8 @@ + + diff --git a/Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs b/Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs index fde08b968..14b9a7562 100644 --- a/Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs +++ b/Software/Visual_Studio/Tango.Transport/Web/WebTransportClient.cs @@ -103,36 +103,43 @@ namespace Tango.Transport.Web } catch (HttpRequestException ex) { - String message = JObject.Parse(data).GetValue("Message").ToString(); - Exception exception = null; - try { - String exceptionMessage = JObject.Parse(data).GetValue("ExceptionMessage").ToString(); - String exceptionType = JObject.Parse(data).GetValue("ExceptionType").ToString(); - String stackTrace = JObject.Parse(data).GetValue("StackTrace").ToString(); - Type type = GetType(exceptionType); - if (type != null) + String message = JObject.Parse(data).GetValue("Message").ToString(); + Exception exception = null; + + try { - exception = Activator.CreateInstance(type, new object[] { exceptionMessage + "\n" + stackTrace }) as Exception; - + String exceptionMessage = JObject.Parse(data).GetValue("ExceptionMessage").ToString(); + String exceptionType = JObject.Parse(data).GetValue("ExceptionType").ToString(); + String stackTrace = JObject.Parse(data).GetValue("StackTrace").ToString(); + Type type = GetType(exceptionType); + if (type != null) + { + exception = Activator.CreateInstance(type, new object[] { exceptionMessage + "\n" + stackTrace }) as Exception; + + } + else + { + exception = new HttpException(exceptionMessage + "\n" + stackTrace); + } } - else + catch { - exception = new HttpException(exceptionMessage + "\n" + stackTrace); + if (message == null) + { + Logging.LogManager.Default.Log($"Error parsing response message!\n{data}"); + } + + throw new HttpRequestException(ex.Message + " " + message); } + + throw exception; } catch { - if (message == null) - { - Logging.LogManager.Default.Log($"Error parsing response message!\n{data}"); - } - - throw new HttpRequestException(ex.Message + " " + message); + throw ex; } - - throw exception; } return JsonConvert.DeserializeObject(data); diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs index 95a26d78e..dccf2d24c 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/Controllers/FSEController.cs @@ -10,6 +10,7 @@ using Tango.BL.Entities; using Tango.Core; using Tango.Core.Cryptography; using Tango.FSE.Web.Messages; +using Tango.MachineService.Filters; using Tango.Web.Controllers; using Tango.Web.Helpers; using Tango.Web.Security; @@ -104,5 +105,17 @@ namespace Tango.MachineService.Controllers PasswordChangeRequired = user.PasswordChangeRequired }; } + + [HttpPost] + [JwtTokenFilter] + public BugReportingInfoResponse GetBugReportInfo(BugReportingInfoRequest request) + { + return new BugReportingInfoResponse() + { + CollectionUrl = MachineServiceConfig.FSE_TFS_COLLECTION_URL, + PersonalToken = MachineServiceConfig.FSE_TFS_PERSONAL_TOKEN, + UserEmail = MachineServiceConfig.FSE_TFS_USER_EMAIL + }; + } } } diff --git a/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs b/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs index 014ef68ba..f781dbb89 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs +++ b/Software/Visual_Studio/Web/Tango.MachineService/MachineServiceConfig.cs @@ -17,5 +17,9 @@ namespace Tango.MachineService public static String REFRESH_TOKENS_TABLE_PARTITION => ConfigurationManager.AppSettings[nameof(REFRESH_TOKENS_TABLE_PARTITION)].ToString(); public static bool USE_DB_ACCESS_TOKENS => bool.Parse(ConfigurationManager.AppSettings[nameof(USE_DB_ACCESS_TOKENS)].ToString()); public static String CDN_ENDPOINT => ConfigurationManager.AppSettings[nameof(CDN_ENDPOINT)].ToString(); + + public static String FSE_TFS_COLLECTION_URL => ConfigurationManager.AppSettings[nameof(FSE_TFS_COLLECTION_URL)].ToString(); + public static String FSE_TFS_PERSONAL_TOKEN => ConfigurationManager.AppSettings[nameof(FSE_TFS_PERSONAL_TOKEN)].ToString(); + public static String FSE_TFS_USER_EMAIL => ConfigurationManager.AppSettings[nameof(FSE_TFS_USER_EMAIL)].ToString(); } } \ No newline at end of file diff --git a/Software/Visual_Studio/Web/Tango.MachineService/Web.config b/Software/Visual_Studio/Web/Tango.MachineService/Web.config index 1da22f45b..2c6408e50 100644 --- a/Software/Visual_Studio/Web/Tango.MachineService/Web.config +++ b/Software/Visual_Studio/Web/Tango.MachineService/Web.config @@ -31,6 +31,10 @@ + + + +