private static void MergeBuildNotesAndCreateFinalOutput(List <byte[]> otherDocs) { // Test final report i.e. created by merging documents generation DirectoryInfo di = new DirectoryInfo(System.Reflection.Assembly.GetExecutingAssembly().Location); byte[] primaryDoc = File.ReadAllBytes(Path.Combine(di.Parent.FullName, @"Templates\BuildTemplateCover.docx")); // Final report generation OpenXmlHelper openXmlHelper = new OpenXmlHelper(DocumentGenerationInfo.NamespaceUri); byte[] result = openXmlHelper.AppendDocumentsToPrimaryDocument(primaryDoc, otherDocs); // Final Protected report generation using (MemoryStream msfinalDocument = new MemoryStream()) { msfinalDocument.Write(result, 0, result.Length); using (WordprocessingDocument finalDocument = WordprocessingDocument.Open(msfinalDocument, true)) { OpenXmlHelper.ProtectDocument(finalDocument); } msfinalDocument.Position = 0; result = new byte[msfinalDocument.Length]; msfinalDocument.Read(result, 0, result.Length); msfinalDocument.Close(); } WriteOutputToFile("BuildNotes.docx", result); }
private void MergeBuildNotesAndCreateFinalOutput(IList <byte[]> otherDocs) { // Test final report i.e. created by merging documents generation var di = new DirectoryInfo(Assembly.GetExecutingAssembly().Location); byte[] primaryDoc = File.ReadAllBytes(Path.Combine(di.Parent.FullName, @"Templates\BuildTemplateCover.docx")); // Final report generation var openXmlHelper = new OpenXmlHelper(DocumentGenerationInfo.NamespaceUri); var result = openXmlHelper.AppendDocumentsToPrimaryDocument(primaryDoc, otherDocs); // Final Protected report generation using (var msfinalDocument = new MemoryStream()) { msfinalDocument.Write(result, 0, result.Length); using (var finalDocument = WordprocessingDocument.Open(msfinalDocument, true)) { OpenXmlHelper.ProtectDocument(finalDocument); } msfinalDocument.Position = 0; result = new byte[msfinalDocument.Length]; msfinalDocument.Read(result, 0, result.Length); msfinalDocument.Close(); } this.EvaluateIfBuildNotesNeedCheckInAndDisplayResults(result); }
/// <summary> /// Generates the final report by appending documents. /// </summary> private static void GenerateFinalReportByAppendingDocuments() { // Test final report i.e. created by merging documents generation byte[] primaryDoc = File.ReadAllBytes(@"Sample Templates\Test_Template - Final.docx"); List <byte[]> otherDocs = new List <byte[]>(); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template1_Out.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template1_BeforeRefresh_Out.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template1_AfterRefresh_Out.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template2_Out.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template2_AfterRefresh_Out.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template2_Databinding_Table_Out.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template1_Databinding_Out_BeforeRefresh.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template1_Databinding_Out_AfterRefresh.docx")); otherDocs.Add(File.ReadAllBytes(@"Sample Templates\Test_Template3_Out.docx")); // Final report generation OpenXmlHelper openXmlHelper = new OpenXmlHelper(DocumentGenerationInfo.NamespaceUri); byte[] result = openXmlHelper.AppendDocumentsToPrimaryDocument(primaryDoc, otherDocs); WriteOutputToFile("FinalReport.docx", "Test_Template - Final.docx", result); // Final Protected report generation using (MemoryStream msfinalDocument = new MemoryStream()) { msfinalDocument.Write(result, 0, result.Length); using (WordprocessingDocument finalDocument = WordprocessingDocument.Open(msfinalDocument, true)) { openXmlHelper.ProtectDocument(finalDocument); } msfinalDocument.Position = 0; result = new byte[msfinalDocument.Length]; msfinalDocument.Read(result, 0, result.Length); msfinalDocument.Close(); } WriteOutputToFile("FinalReport_Protected.docx", "Test_Template - Final.docx", result); }