private List<ReleaseNoteWorkItem> GenerateReleaseNoteWorkItems(CommandLineOptions options) { if (!string.IsNullOrWhiteSpace(options.WarningsFile)) { _warningsFile = File.Create(options.WarningsFile); Log(string.Format(CultureInfo.InvariantCulture, "Writing out warnings to {0}...", options.WarningsFile)); } Log(string.Format(CultureInfo.InvariantCulture, "Querying Tfs using {0}...", _tfsQueryItem.ToString())); var releaseNotes = new List<ReleaseNoteWorkItem>(); var queryDefinition = _workItemStore.GetQueryDefinition(_tfsQueryItem.Id); var variables = new Dictionary<string, string> { { "project", _tfsQueryItem.Project.Name } }; var workItemCollection = _workItemStore.Query(queryDefinition.QueryText, variables); Log(string.Format(CultureInfo.InvariantCulture, "Found {0} Work Items", workItemCollection.Count)); foreach (WorkItem workItem in workItemCollection) { Log(string.Format(CultureInfo.InvariantCulture, "WI: {0}, Title: {1}", workItem.Id, workItem.Title)); bool isBug = workItem.Type.Name == "Bug"; if (!releaseNotes.Any(r => r.WorkItemId == workItem.Id)) { string[] areas = workItem.AreaPath.Split(new[] { @"\" }, StringSplitOptions.RemoveEmptyEntries); string area = string.Empty; for (int i = 1; i < areas.Length; i++) { area += areas[i] + " : "; } var note = new ReleaseNoteWorkItem { Area = area.TrimEnd(' ', ':'), BuildNumber = isBug ? (string)workItem["Integration Build"] : "N/A", Classification = (string)workItem["Classification"], ClientRef = isBug ? (string)workItem["Source reference"] : string.Empty, Feedback = isBug ? (string)workItem["Release Note Html"] : "N/A", ResolutionType = isBug ? (string)workItem["Resolution Type"] : "N/A", Severity = isBug ? (string)workItem["Severity"] : string.Empty, WorkItemId = workItem.Id, WorkItemTitle = workItem.Title, WorkItemAnchor = _linkService.GetWorkItemEditorUrl(workItem.Id).ToString(), }; VerifyNote(options, workItem, note); releaseNotes.Add(note); } } if (_warningsFile != null) { _warningsFile.Close(); Log(string.Format(CultureInfo.InvariantCulture, "Warnings written to {0}", options.WarningsFile)); } Log("Done Querying Tfs"); return releaseNotes; }
private void VerifyNote(CommandLineOptions options, WorkItem workItem, ReleaseNoteWorkItem note) { string warningText = string.Empty; if (string.IsNullOrWhiteSpace(note.Area)) { warningText = string.Format(CultureInfo.InvariantCulture, "WI: {0}, No Area Path specified! Url to fix {1}{2}", workItem.Id, note.WorkItemAnchor, Environment.NewLine); } if (string.IsNullOrWhiteSpace(note.Feedback) || note.Feedback == options.IncompleteFeedbackTag) { warningText += string.Format(CultureInfo.InvariantCulture, "WI: {0}, No Feedback specified! Url to fix {1}{2}", workItem.Id, note.WorkItemAnchor, Environment.NewLine); } if (!string.IsNullOrWhiteSpace(warningText)) { if (_warningsFile != null) { byte[] info = new UTF8Encoding(true).GetBytes(warningText); _warningsFile.Write(info, 0, info.Length); } Console.ForegroundColor = ConsoleColor.Yellow; Log(string.Format(CultureInfo.InvariantCulture, "Warn: {0}", warningText)); Console.ResetColor(); } }
private PdfPCell WriteFeedback(ReleaseNoteWorkItem workItem) { var sb = new StringBuilder(); foreach (var element in HTMLWorker.ParseToList(new StringReader(workItem.Feedback), null)) { if (element.IsContent()) { foreach (var chunk in element.Chunks) { sb.AppendLine(chunk.Content); } } } return new PdfPCell(new Phrase(sb.ToString(), _cellFont)) { BorderWidth = BorderWidth, BorderColor = _headerColor, PaddingTop = CellPadding, PaddingBottom = CellPadding }; }
private void WriteTableRow(ReleaseNoteWorkItem workItem) { _table.AddCell(CreateCell(workItem.Area, _cellFont, BaseColor.WHITE)); _table.AddCell(CreateCell(workItem.WorkItemTitle, _cellFont, BaseColor.WHITE)); _table.AddCell(WriteFeedback(workItem)); _table.AddCell(WriteClientRef(workItem)); }
private PdfPCell WriteClientRef(ReleaseNoteWorkItem workItem) { var cell = new PdfPCell { BorderWidth = BorderWidth, BorderColor = _headerColor, PaddingTop = CellPadding, PaddingBottom = CellPadding }; cell.AddElement(new Phrase(workItem.ClientRef.Trim(), _cellFont)); if (Settings.LinkWorkItems) { var idText = new Chunk(string.Format(CultureInfo.InvariantCulture, "TFS{0}", workItem.WorkItemId.ToString(CultureInfo.InvariantCulture)), _urlFont); idText.SetAnchor(workItem.WorkItemAnchor); cell.AddElement(idText); } return cell; }