public void FileBug(HierarchyNodeViewModel vm = null) { vm = vm ?? this.treeviewHierarchy.SelectedItem as HierarchyNodeViewModel; if (vm == null) { MessageDialog.Show(Properties.Resources.HierarchyControl_FileBug_Could_not_find_the_selected_item__the_bug_filing_is_canceled); return; } if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { System.Diagnostics.Process.Start(vm.IssueLink.OriginalString); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } #pragma warning restore CA1031 // Do not catch general exception types } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(FileBugRequestSource.Hierarchy); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = this.SelectedElement.GetIssueInformation(IssueType.NoFailure); FileIssueAction.AttachIssueData(issueInformation, this.ElementContext.Id, this.SelectedElement.BoundingRectangle, this.SelectedElement.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } File.Delete(issueInformation.TestFileName); } else { bool?accepted = MessageDialog.Show(Properties.Resources.HierarchyControl_FileIssue_Configure); if (accepted.HasValue && accepted.Value) { this.HierarchyActions.SwitchToServerLogin(); } } } }
/// <summary> /// Handles click on file bug button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFileBug_Click(object sender, RoutedEventArgs e) { var vm = ((Button)sender).Tag as RuleResultViewModel; if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { Process.Start(vm.IssueLink.OriginalString); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } #pragma warning restore CA1031 // Do not catch general exception types } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(FileBugRequestSource.AutomatedChecks); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = vm.GetIssueInformation(); FileIssueAction.AttachIssueData(issueInformation, this.ElementContext.Id, vm.Element.BoundingRectangle, vm.Element.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } File.Delete(issueInformation.TestFileName); } else { bool?accepted = MessageDialog.Show(Properties.Resources.AutomatedChecksControl_btnFileBug_Click_File_Issue_Configure); if (accepted.HasValue && accepted.Value) { SwitchToServerLogin(); } } } }
/// <summary> /// Handles control-related issue filing /// </summary> internal static void FileIssueFromControl(FileIssueWrapperInput input) { IIssueFilingSource vm = input.VM; if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { System.Diagnostics.Process.Start(vm.IssueLink.OriginalString); } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } #pragma warning restore CA1031 // Do not catch general exception types } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(input.RequestSource); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = null; try { issueInformation = input.IssueInformationProvider(); FileIssueAction.AttachIssueData(issueInformation, input.EcId, vm.Element.BoundingRectangle, vm.Element.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } } #pragma warning disable CA1031 // Do not catch general exception types catch (Exception ex) { ex.ReportException(); } #pragma warning restore CA1031 // Do not catch general exception types finally { if (issueInformation != null && File.Exists(issueInformation.TestFileName)) { File.Delete(issueInformation.TestFileName); } } } else { bool?accepted = MessageDialog.Show(Properties.Resources.FileIssuesChooseLocation); if (accepted.HasValue && accepted.Value) { input.SwitchToServerLogin(); } } } }
/// <summary> /// Handles click on file bug button /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnFileBug_Click(object sender, RoutedEventArgs e) { var vm = ((Button)sender).Tag as ScanListViewItemViewModel; if (vm.IssueLink != null) { // Bug already filed, open it in a new window try { System.Diagnostics.Process.Start(vm.IssueLink.OriginalString); } catch (Exception ex) { ex.ReportException(); // Happens when bug is deleted, message describes that work item doesn't exist / possible permission issue MessageDialog.Show(ex.InnerException?.Message); vm.IssueDisplayText = null; } } else { // File a new bug var telemetryEvent = TelemetryEventFactory.ForIssueFilingRequest(FileBugRequestSource.HowtoFix); Logger.PublishTelemetryEvent(telemetryEvent); if (IssueReporter.IsConnected) { IssueInformation issueInformation = null; try { issueInformation = vm.GetIssueInformation(); FileIssueAction.AttachIssueData(issueInformation, this.EcId, vm.Element.BoundingRectangle, vm.Element.UniqueId); IIssueResult issueResult = FileIssueAction.FileIssueAsync(issueInformation); if (issueResult != null) { vm.IssueDisplayText = issueResult.DisplayText; vm.IssueLink = issueResult.IssueLink; } } catch (Exception ex) { ex.ReportException(); } finally { if (issueInformation != null && File.Exists(issueInformation.TestFileName)) { File.Delete(issueInformation.TestFileName); } } } else { bool?accepted = MessageDialog.Show(Properties.Resources.ScannerResultControl_btnFileBug_Click_File_Issue_Configure); if (accepted.HasValue && accepted.Value) { SwitchToServerLogin(); } } } }