From 97e45f70267d961168b77b149022b94022e0e199 Mon Sep 17 00:00:00 2001 From: Roy Ben-Shabat Date: Tue, 24 Apr 2018 19:05:53 +0300 Subject: Working on reporting... --- .../ViewModels/LoadingViewVM.cs | 14 ++++++- .../ViewModels/MainViewVM.cs | 28 +++++++++++++- .../ViewModels/ReportIssueViewVM.cs | 43 ++++++++++++++++++++++ 3 files changed, 83 insertions(+), 2 deletions(-) create mode 100644 Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs (limited to 'Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels') diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs index 512341f7e..2b2b442f7 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/LoadingViewVM.cs @@ -15,6 +15,7 @@ using Tango.SharedUI; using Tango.BL; using Tango.MachineStudio.Common.EventLogging; using Tango.BL.Enumerations; +using Tango.MachineStudio.UI.TFS; namespace Tango.MachineStudio.UI.ViewModels { @@ -25,6 +26,7 @@ namespace Tango.MachineStudio.UI.ViewModels public class LoadingViewVM : ViewModel { private INotificationProvider _notificationProvider; + private TeamFoundationServiceExtendedClient _tfs; private INavigationManager _navigationManager; private IStudioModuleLoader _studioModuleLoader; private IEventLogger _eventLogger; @@ -45,8 +47,9 @@ namespace Tango.MachineStudio.UI.ViewModels /// The navigation manager. /// The studio module loader. /// The notification provider. - public LoadingViewVM(IStudioApplicationManager applicationManager, INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider, IEventLogger eventLogger) + public LoadingViewVM(IStudioApplicationManager applicationManager, INavigationManager navigationManager, IStudioModuleLoader studioModuleLoader, INotificationProvider notificationProvider, IEventLogger eventLogger, TeamFoundationServiceExtendedClient teamFoundationClient) { + _tfs = teamFoundationClient; _eventLogger = eventLogger; ApplicationManager = applicationManager; _navigationManager = navigationManager; @@ -66,6 +69,15 @@ namespace Tango.MachineStudio.UI.ViewModels { try { + try + { + _tfs.Initialize(); + } + catch (Exception ex) + { + LogManager.Log(ex, "Could not initialize Team Foundation Service client."); + } + ObservablesEntitiesAdapter.Instance.Initialize(); _eventLogger.Log(EventTypes.ApplicationStarted, "Application Started!"); 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 2144983de..0882267e8 100644 --- a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/MainViewVM.cs @@ -29,6 +29,7 @@ using Tango.MachineStudio.Common.StudioApplication; using Tango.MachineStudio.Common.Update; using Tango.MachineStudio.UI.StudioApplication; using Tango.MachineStudio.UI.SupervisingController; +using Tango.MachineStudio.UI.TFS; using Tango.MachineStudio.UI.Views; using Tango.MachineStudio.UI.Windows; using Tango.PMR.Stubs; @@ -142,6 +143,11 @@ namespace Tango.MachineStudio.UI.ViewModels /// public RelayCommand ResolveMachineEventCommand { get; set; } + /// + /// Gets or sets the report issue command. + /// + public RelayCommand ReportIssueCommand { get; set; } + private IAuthenticationProvider _authenticationProvider; /// /// Gets or sets the authentication provider. @@ -182,6 +188,11 @@ namespace Tango.MachineStudio.UI.ViewModels set { _applicationManager = value; RaisePropertyChangedAuto(); } } + /// + /// Gets or sets the TFS client. + /// + public TeamFoundationServiceExtendedClient TFSClient { get; set; } + /// /// Gets or sets the speech provider. /// @@ -247,8 +258,9 @@ namespace Tango.MachineStudio.UI.ViewModels IEventLogger eventLogger, IDiagnosticsFrameProvider frameProvider, ISpeechProvider speechProvider, - IHtmlPresenter htmlPresenter) : base() + IHtmlPresenter htmlPresenter, TeamFoundationServiceExtendedClient tfs) : base() { + TFSClient = tfs; _eventLogger = eventLogger; _navigation = navigationManager; AuthenticationProvider = authenticationProvider; @@ -288,6 +300,8 @@ namespace Tango.MachineStudio.UI.ViewModels ToggleSpeechCommand = new RelayCommand(() => { SpeechProvider.Mute = !SpeechProvider.Mute; }); ResolveMachineEventCommand = new RelayCommand(ResolveMachineEvent); + + ReportIssueCommand = new RelayCommand(ReportIssue); } private void MachineEventsStateProvider_EventsResolved(object sender, IEnumerable e) @@ -628,5 +642,17 @@ namespace Tango.MachineStudio.UI.ViewModels _notificationProvider.ShowWarning("Could not locate guidance content for the specified event."); } } + + private void ReportIssue() + { + _notificationProvider.ShowModalDialog(new ReportIssueViewVM(TFSClient.Project, TFSClient.CreateBug()), async (vm) => + { + using (_notificationProvider.PushTaskItem("Uploading bug report...")) + { + await TFSClient.UploadWorkItem(vm.WorkItem); + } + + }, null); + } } } diff --git a/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs new file mode 100644 index 000000000..9660db8a5 --- /dev/null +++ b/Software/Visual_Studio/MachineStudio/Tango.MachineStudio.UI/ViewModels/ReportIssueViewVM.cs @@ -0,0 +1,43 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; +using Tango.MachineStudio.Common.Notifications; +using Tango.MachineStudio.UI.TFS; +using Tango.SharedUI.Components; +using Tango.TFS; + +namespace Tango.MachineStudio.UI.ViewModels +{ + public class ReportIssueViewVM : DialogViewVM + { + public SelectedObjectCollection SelectedTags { get; set; } + + public Project Project { get; set; } + + [WorkItemValidation] + public WorkItem WorkItem { get; set; } + + public ReportIssueViewVM() : base() + { + + } + + public ReportIssueViewVM(Project project, WorkItem workItem) : this() + { + Project = project; + WorkItem = workItem; + SelectedTags = new SelectedObjectCollection(Project.Tags.ToObservableCollection(), new System.Collections.ObjectModel.ObservableCollection()); + } + + protected override void Accept() + { + if (Validate()) + { + WorkItem.Tags = SelectedTags.SynchedSource.ToList(); + base.Accept(); + } + } + } +} -- cgit v1.3.1