private void txtOutput_MouseDoubleClick(object sender, MouseEventArgs e) { if (this.txtOutput.SelectedItems == null || this.txtOutput.SelectedItems.Count == 0) { return; } FilingResult fr = this.txtOutput.SelectedItems[0].Tag as FilingResult; if (fr == null) { return; } if (this.splitContainer1.Panel2Collapsed) { int tmp = this.splitContainer1.Panel1.Width; this.splitContainer1.Panel2Collapsed = false; if (tmp != this.splitContainer1.Panel1.Width) { this.splitContainer1.SplitterDistance = tmp; } } string path = Path.Combine(Data.AutoTester.logPath, fr.Name); if (Directory.Exists(path)) { this.webBrowser1.Navigate(path); } else if (Directory.Exists(Data.AutoTester.logPath)) { this.webBrowser1.Navigate(path); } }
private void RunTest(string threadPath, object o) { this.throttler.WaitOne(); try { // Discontinue loop if cancelled if (!this.workerTester.CancellationPending) { FilingResult result = new FilingResult(); StringBuilder testErrors = new StringBuilder(); Data.AutoTester.RunTest(result, testErrors, threadPath); lock (this.errorFileInfo) { using (StreamWriter writer = new StreamWriter(this.errorFileInfo.FullName, true)) { writer.Write(testErrors.ToString()); } } //.NET 2.0 equivalent of "Action" delegate ThreadStart actUpdateProgress = new ThreadStart(() => this.UpdateProgress(result)); //execute on the UI thread this.testingProgress.Invoke(actUpdateProgress); } } catch (Exception ex) { if (this.workerTester.CancellationPending) { //suppress exceptions caused by cancelation } else { //otherwise, throw the exception throw ex; } } // Release thread in any case finally { this.threadCounter.CompletionState++; this.throttler.Release(); } }
private void UpdateProgress(FilingResult result) { this.testingProgress.pgbOverall.Value++; Label lbl = this.testingProgress.Controls["lblStatus"] as Label; lbl.Text = string.Format("Status: {0}/{1}", this.threadCounter.CompletionState, this.threadCounter.CompletionTarget); ListViewItem item = new ListViewItem(result.Name); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, result.Success.ToString())); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, result.Errors.ToString())); item.SubItems.Add(new ListViewItem.ListViewSubItem(item, result.Reason)); item.Tag = result; this.txtOutput.Items.Add(item); this.txtOutput.AutoResizeColumns(ColumnHeaderAutoResizeStyle.ColumnContent); if (result.Success == false || result.Errors > 0) { this.lblDifferencesCount.Text = (int.Parse(this.lblDifferencesCount.Text) + 1).ToString(); } }
private void LogMetricsForProcessedModel(SarifLog sarifLog, SarifWorkItemModel sarifWorkItemModel, FilingResult filingResult, Dictionary <string, object> additionalCustomDimensions = null) { additionalCustomDimensions ??= new Dictionary <string, object>(); this.FilingResult = filingResult; string logGuid = sarifLog.GetProperty <Guid>("guid").ToString(); string tags = string.Join(",", sarifWorkItemModel.LabelsOrTags); string uris = sarifWorkItemModel.LocationUris?.Count > 0 ? string.Join(",", sarifWorkItemModel.LocationUris) : ""; var workItemMetrics = new Dictionary <string, object> { { "LogGuid", logGuid }, { "WorkItemModelGuid", sarifWorkItemModel.Guid }, { nameof(sarifWorkItemModel.Area), sarifWorkItemModel.Area }, { nameof(sarifWorkItemModel.BodyOrDescription), sarifWorkItemModel.BodyOrDescription }, { "FilingResult", filingResult.ToString() }, { nameof(sarifWorkItemModel.CommentOrDiscussion), sarifWorkItemModel.CommentOrDiscussion }, { nameof(sarifWorkItemModel.HtmlUri), sarifWorkItemModel.HtmlUri }, { nameof(sarifWorkItemModel.Iteration), sarifWorkItemModel.Iteration }, { "LabelsOrTags", tags }, { "LocationUri", uris }, { nameof(sarifWorkItemModel.Milestone), sarifWorkItemModel.Milestone }, { nameof(sarifWorkItemModel.OwnerOrAccount), sarifWorkItemModel.OwnerOrAccount }, { nameof(sarifWorkItemModel.RepositoryOrProject), sarifWorkItemModel.RepositoryOrProject }, { nameof(sarifWorkItemModel.Title), sarifWorkItemModel.Title }, { nameof(sarifWorkItemModel.Uri), sarifWorkItemModel.Uri }, }; foreach (string key in additionalCustomDimensions.Keys) { workItemMetrics.Add(key, additionalCustomDimensions[key]); } EventId coreEventId; switch (filingResult) { case FilingResult.Canceled: coreEventId = EventIds.WorkItemCanceledCoreMetrics; break; case FilingResult.ExceptionRaised: coreEventId = EventIds.WorkItemExceptionCoreMetrics; break; default: coreEventId = EventIds.WorkItemFiledCoreMetrics; break; } this.Logger.LogMetrics(coreEventId, workItemMetrics); Dictionary <string, RuleMetrics> ruleIdToMetricsMap = CreateRuleMetricsMap(sarifLog); foreach (string tool in ruleIdToMetricsMap.Keys) { RuleMetrics ruleMetrics = ruleIdToMetricsMap[tool]; var workItemDetailMetrics = new Dictionary <string, object> { { "LogGuid", logGuid }, { "WorkItemModelGuid", sarifWorkItemModel.Guid }, { nameof(ruleMetrics.Tool), ruleMetrics.Tool }, { nameof(ruleMetrics.RuleId), ruleMetrics.RuleId }, { nameof(ruleMetrics.ErrorCount), ruleMetrics.ErrorCount }, { nameof(ruleMetrics.WarningCount), ruleMetrics.WarningCount }, { nameof(ruleMetrics.NoteCount), ruleMetrics.NoteCount }, { nameof(ruleMetrics.OpenCount), ruleMetrics.OpenCount }, { nameof(ruleMetrics.ReviewCount), ruleMetrics.ReviewCount }, { nameof(ruleMetrics.SuppressedByTransformerCount), ruleMetrics.SuppressedByTransformerCount } }; this.Logger.LogMetrics(EventIds.WorkItemFiledDetailMetrics, workItemDetailMetrics); } }