Last active
December 15, 2015 17:09
-
-
Save cjlotz/5294738 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
... | |
public List<Bookmark> Bookmarks { get; private set; } | |
public ReleaseNotesWriterSettings Settings { get; private set; } | |
public IReadOnlyList<ReleaseNoteWorkItem> WorkItems { get; private set; } | |
public void Publish(string outputFile) | |
{ | |
var stream = new MemoryStream(); | |
try | |
{ | |
_document = new Document(PageSize.A4, 36, 36, 90, 72); | |
// Initialize pdf writer | |
_writer = PdfWriter.GetInstance(_document, stream); | |
_writer.PageEvent = new ReleaseNotesPdfPageEvents(Settings); | |
// Open document to write | |
_document.Open(); | |
_document.AddTitle("Your Title"); | |
_document.AddSubject("Release Notes"); | |
_document.AddAuthor("Your Name"); | |
_document.AddKeywords("Release Notes"); | |
_document.AddCreationDate(); | |
_document.AddCreator("ReleaseNotesGenerator"); | |
// Add manual release notes for current release | |
int chapterNumber = 1; | |
if (!string.IsNullOrEmpty(Settings.NewReleaseNotesFile) && File.Exists(Settings.NewReleaseNotesFile)) | |
{ | |
Bookmarks.AddRange(Merge(Settings.NewReleaseNotesFile, 1)); | |
if (Bookmarks.Count > 0) | |
chapterNumber = Bookmarks.Count; | |
} | |
// Add automatic releases notes for current release | |
WriteWorkItems("How do I?", ref chapterNumber, WorkItems.Where(x => x.ResolutionType == "How do I" || x.ResolutionType == "As Designed")); | |
WriteWorkItems("Bug Fixes", ref chapterNumber, WorkItems.Where(x => x.ResolutionType == "Bug Fix")); | |
WriteWorkItems("Known Issues", ref chapterNumber, WorkItems.Where(x => x.ResolutionType == "Known Issue")); | |
WriteWorkItems("User Manual", ref chapterNumber, WorkItems.Where(x => x.ResolutionType == "User Manual")); | |
CreateBookmarks(); | |
} | |
catch (Exception exception) | |
{ | |
throw new Exception("There has an unexpected exception occured whilst creating the release notes: " + exception.Message, exception); | |
} | |
finally | |
{ | |
_document.Close(); | |
} | |
File.WriteAllBytes(outputFile, stream.GetBuffer()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment