From 47fad304ebc8f056f1c5ffcde037c66029fc80c9 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 1 May 2018 14:44:53 +0300 Subject: Added device information for ConnectResponse. Fixed issue with razor parser. Added report issue option to application crash. Added DeviceInformation to MachineOperator. Added LastHardwareConfiguration to machine operator. --- .../Tango.MachineStudio.UI/App.xaml.cs | 51 +++++++++- .../Console/ConsoleManager.cs | 14 +++ .../Console/ConsoleWindow.xaml | 113 +++++++++++++++++++++ .../Console/ConsoleWindow.xaml.cs | 28 +++++ .../Console/ConsoleWindowVM.cs | 88 ++++++++++++++++ .../DefaultStudioApplicationManager.cs | 5 + .../TFS/SystemInformationModel.cs | 2 +- .../TFS/SystemInformationTemplate.cshtml | 13 ++- .../TFS/TeamFoundationServiceExtendedClient.cs | 9 +- .../Tango.MachineStudio.UI.csproj | 9 ++ .../Tango.MachineStudio.UI/ViewModelLocator.cs | 10 ++ .../ViewModels/MainViewVM.cs | 14 +++ .../Tango.MachineStudio.UI/Views/MainView.xaml | 7 ++ .../Windows/ExceptionResolutions.cs | 3 +- .../Windows/ExceptionWindow.xaml | 12 ++- .../Windows/ExceptionWindow.xaml.cs | 7 +- 16 files changed, 374 insertions(+), 11 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleManager.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs index d9c64b9e3..f124ebb54 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/App.xaml.cs @@ -15,6 +15,11 @@ using Tango.Settings; using Tango.MachineStudio.Common.EventLogging; using Tango.BL.Enumerations; using Tango.Core.DI; +using Tango.MachineStudio.UI.TFS; +using Tango.TFS; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.ViewModels; +using Tango.MachineStudio.UI.Views; namespace Tango.MachineStudio.UI { @@ -82,7 +87,26 @@ namespace Tango.MachineStudio.UI Application.Current.Dispatcher.Invoke(() => { - ExceptionWindow exWin = new ExceptionWindow(e.Exception); + WorkItem bug = null; + TeamFoundationServiceExtendedClient tfsClient = null; + INotificationProvider notification = null; + + try + { + tfsClient = TangoIOC.Default.GetInstance(); + notification = TangoIOC.Default.GetInstance(); + + if (tfsClient != null && tfsClient.IsInitialized) + { + bug = tfsClient.CreateBug(); + } + } + catch (Exception ex) + { + Debug.WriteLine(ex.ToString()); + } + + ExceptionWindow exWin = new ExceptionWindow(e.Exception, bug != null); exWin.ShowDialog(); switch (exWin.Resolution) @@ -100,6 +124,31 @@ namespace Tango.MachineStudio.UI e.TryRecover = false; LogManager.Log("User selection was to shutdown the application. Restarting..."); Environment.Exit(0); + break; + case ExceptionResolutions.Report: + e.TryRecover = true; + LogManager.Log("User selection was to report the issue."); + + if (bug != null) + { + notification.ShowModalDialog(new ReportIssueViewVM(tfsClient.Project, bug), async (vm) => + { + using (notification.PushTaskItem("Uploading bug report...")) + { + try + { + tfsClient.FinalizeBug(vm.WorkItem); + await tfsClient.UploadWorkItem(vm.WorkItem); + } + catch (Exception ex) + { + notification.ShowError("An error occurred while trying to create the issue." + Environment.NewLine + ex.Message); + } + } + + }, null); + } + break; } }); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleManager.cs new file mode 100644 index 000000000..0a737c526 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleManager.cs @@ -0,0 +1,14 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.Core.DI; + +namespace Tango.MachineStudio.UI.Console +{ + public class ConsoleManager + { + public TangoIOC TangoIOC { get; set; } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml new file mode 100644 index 000000000..90c07b1af --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml @@ -0,0 +1,113 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs new file mode 100644 index 000000000..459c3d119 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindow.xaml.cs @@ -0,0 +1,28 @@ +using MahApps.Metro.Controls; +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Data; +using System.Windows.Documents; +using System.Windows.Input; +using System.Windows.Media; +using System.Windows.Media.Imaging; +using System.Windows.Shapes; + +namespace Tango.MachineStudio.UI.Console +{ + /// + /// Interaction logic for ConsoleWindow.xaml + /// + public partial class ConsoleWindow : MetroWindow + { + public ConsoleWindow() + { + InitializeComponent(); + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs new file mode 100644 index 000000000..c88976948 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Console/ConsoleWindowVM.cs @@ -0,0 +1,88 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Linq; +using System.Text; +using System.Threading; +using System.Threading.Tasks; +using System.Windows.Threading; +using Tango.Core.Commands; +using Tango.MachineStudio.Common.Modules; +using Tango.SharedUI; + +namespace Tango.MachineStudio.UI.Console +{ + public class ConsoleWindowVM : ViewModel + { + + /// + /// Gets or sets the additional highlight C# types. + /// + public ObservableCollection> HighlightTypes { get; set; } + + /// + /// Gets or sets the intellisense types. + /// + public ObservableCollection> IntellisenseTypes { get; set; } + + /// + /// Gets or sets the run command. + /// + public RelayCommand RunCommand { get; set; } + + /// + /// Gets or sets the stop command. + /// + public RelayCommand StopCommand { get; set; } + + /// + /// Gets or sets the clear command. + /// + public RelayCommand ClearCommand { get; set; } + + public ConsoleWindowVM(IStudioModuleLoader moduleLoader) + { + RunCommand = new RelayCommand(Run); + StopCommand = new RelayCommand(Stop); + + HighlightTypes = new ObservableCollection>(); + IntellisenseTypes = new ObservableCollection>(); + + IntellisenseTypes.Add(new KeyValuePair("consoleManager", typeof(ConsoleManager))); + + foreach (var moduleType in moduleLoader.UserModules.SelectMany(x => x.MainViewType.Assembly.GetTypes())) + { + if (!moduleType.FullName.Contains("<") && !moduleType.FullName.Contains(">")) + { + HighlightTypes.Add(new KeyValuePair(moduleType.FullName, moduleType)); + } + } + + HighlightTypes.Add(new KeyValuePair("Thread", typeof(Thread))); + HighlightTypes.Add(new KeyValuePair("DateTime", typeof(DateTime))); + HighlightTypes.Add(new KeyValuePair("TimeSpan", typeof(TimeSpan))); + HighlightTypes.Add(new KeyValuePair("Dispatcher", typeof(Dispatcher))); + HighlightTypes.Add(new KeyValuePair("Task", typeof(Task))); + HighlightTypes.Add(new KeyValuePair("List", typeof(IList))); + HighlightTypes.Add(new KeyValuePair("int", typeof(Int32))); + HighlightTypes.Add(new KeyValuePair("double", typeof(Double))); + HighlightTypes.Add(new KeyValuePair("String", typeof(String))); + HighlightTypes.Add(new KeyValuePair("string", typeof(String))); + + foreach (var item in HighlightTypes) + { + IntellisenseTypes.Add(item); + } + } + + private void Stop() + { + + } + + private void Run() + { + + } + } +} diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs index 0bbcfd313..a5aa6261d 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/StudioApplication/DefaultStudioApplicationManager.cs @@ -229,6 +229,11 @@ namespace Tango.MachineStudio.UI.StudioApplication } } + /// + /// Notify the application manager about an external opened window. + /// When application exists. All registered windows will be closed. + /// + /// The window. public void RegisterOpenedWindow(Window window) { _openedWindows.Add(window); diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs index e5e8b2d67..5dde73744 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationModel.cs @@ -15,7 +15,7 @@ namespace Tango.MachineStudio.UI.TFS public String HostName { get; set; } public Machine Machine { get; set; } public String ConfigurationString { get; set; } - public String HardwareString { get; set; } + public String LoadedHardwareConfigurationString { get; set; } public String LoadedProcessParametersString { get; set; } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml index 698932d46..54db28e32 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/SystemInformationTemplate.cshtml @@ -60,11 +60,18 @@ -
Configuration
+
Machine Configuration
@vm.ConfigurationString
-
Hardware Version
-
@vm.HardwareString
+
Hardware Configuration
+ if (vm.LoadedHardwareConfigurationString != null) + { +
@vm.LoadedHardwareConfigurationString
+ } + else + { +
NOT SET
+ }
Process Parameters
diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs index 0a8cbd60d..4ca296523 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/TFS/TeamFoundationServiceExtendedClient.cs @@ -181,7 +181,7 @@ namespace Tango.MachineStudio.UI.TFS SystemInformationModel sysModel = new SystemInformationModel(); sysModel.ApplicationVersion = app.Version; - sysModel.EmbeddedVersion = "Fake Version"; + sysModel.EmbeddedVersion = "N/A"; sysModel.HostName = Environment.MachineName; sysModel.UserName = auth.CurrentUser.Contact.FullName; @@ -190,6 +190,7 @@ namespace Tango.MachineStudio.UI.TFS Machine machine = app.ConnectedMachine.Machine; sysModel.Machine = machine; + sysModel.EmbeddedVersion = app.ConnectedMachine.DeviceInformation.Version; MachineDesigner.Views.MainView machineView = new MachineDesigner.Views.MainView(); machineView.Width = 1280; @@ -210,12 +211,16 @@ namespace Tango.MachineStudio.UI.TFS }); sysModel.ConfigurationString = machine.Configuration.CloneConfiguration().ToJsonString(nameof(Configuration.MachinesConfigurations), nameof(Configuration.MachineVersions)); - sysModel.HardwareString = machine.Configuration.HardwareVersion.ToJsonString(nameof(HardwareVersion.Configurations)); if (app.ConnectedMachine.CurrentProcessParameters != null) { sysModel.LoadedProcessParametersString = app.ConnectedMachine.CurrentProcessParameters.ToJsonString(nameof(ProcessParametersTable.ProcessParametersTablesGroup)); } + + if (app.ConnectedMachine.CurrentHardwareConfiguration != null) + { + sysModel.LoadedHardwareConfigurationString = app.ConnectedMachine.CurrentHardwareConfiguration.ToJsonString(); + } } String html = String.Empty; diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj index c6afdca4b..3fd1e23fe 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Tango.MachineStudio.UI.csproj @@ -131,6 +131,11 @@ MSBuild:Compile Designer + + + ConsoleWindow.xaml + + HtmlWindow.xaml @@ -207,6 +212,10 @@ ModuleWindow.xaml + + Designer + MSBuild:Compile + MSBuild:Compile Designer diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs index 8d3a2c6bf..6e337c0e9 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModelLocator.cs @@ -13,6 +13,7 @@ using Tango.MachineStudio.Common.Speech; using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Common.Video; using Tango.MachineStudio.UI.Authentication; +using Tango.MachineStudio.UI.Console; using Tango.MachineStudio.UI.Html; using Tango.MachineStudio.UI.Modules; using Tango.MachineStudio.UI.Navigation; @@ -85,6 +86,7 @@ namespace Tango.MachineStudio.UI TangoIOC.Default.Register(); TangoIOC.Default.Register(); TangoIOC.Default.Register(); + TangoIOC.Default.Register(); //Register View (Supervising Controller Pattern). //if (!ViewModelBase.IsInDesignModeStatic) @@ -157,5 +159,13 @@ namespace Tango.MachineStudio.UI return TangoIOC.Default.GetInstance(); } } + + public ConsoleWindowVM ConsoleWindowVM + { + get + { + return TangoIOC.Default.GetInstance(); + } + } } } \ No newline at end of file diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs index 5beeeca54..04b973f23 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -153,6 +153,11 @@ namespace Tango.MachineStudio.UI.ViewModels /// public RelayCommand OpenResolvedBugsCommand { get; set; } + /// + /// Gets or sets the open developer console command. + /// + public RelayCommand OpenDeveloperConsoleCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; /// /// Gets or sets the authentication provider. @@ -308,6 +313,7 @@ namespace Tango.MachineStudio.UI.ViewModels ReportIssueCommand = new RelayCommand(ReportIssue); OpenResolvedBugsCommand = new RelayCommand(OpenResolvedBugs); + OpenDeveloperConsoleCommand = new RelayCommand(OpenDeveloperConsole); } private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable e) @@ -720,5 +726,13 @@ namespace Tango.MachineStudio.UI.ViewModels _notificationProvider.ShowModalDialog(vm, (_) => { }, null); } + + private void OpenDeveloperConsole() + { + Console.ConsoleWindow console = new Console.ConsoleWindow(); + ApplicationManager.RegisterOpenedWindow(console); + console.Owner = MainWindow.Instance; + console.Show(); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml index bb46814b5..29bd70451 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Views/MainView.xaml @@ -190,6 +190,13 @@ + + + + + + diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs index 0f74fee17..0a6f2de39 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/Windows/ExceptionWindow.xaml.cs @@ -33,10 +33,15 @@ namespace Tango.MachineStudio.UI.Windows DataContext = this; } - public ExceptionWindow(Exception ex) : this() + public ExceptionWindow(Exception ex, bool canReport) : this() { Exception = ex.FlattenException(); ResolveCommand = new RelayCommand(Resolve); + + if (!canReport) + { + btnReport.Visibility = Visibility.Collapsed; + } } private void Resolve(ExceptionResolutions resolution) -- cgit v1.3.1