/// <summary> /// Build a test summary and save it to the specified URL /// </summary> /// <param name="fileName">Save location for test summary</param> /// <param name="testHeader">Test summary header information</param> /// <param name="testData">Test summary data information</param> /// <returns>passed indicator</returns> public bool WriteTestSummary(string fileName, TestSummary_TestInfo_Type TestInfo, ONVIF_TestCases.TestCases_Class.TestGroup_Type Tests) { bool passed = false; Document myDocument = new Document(PageSize.A4); //ChapterCount = 1; // make sure the date has been set if (TestInfo.TestDateAndTime == "") { TestInfo.TestDateAndTime = String.Format("{0} @ {1}\n", System.DateTime.Now.ToShortDateString(), System.DateTime.Now.ToLongTimeString()); } if (fileName.Contains("verbose")) { verboseOutput = true; } else { verboseOutput = false; } try { // create a new instance of the results file PdfWriter.GetInstance(myDocument, new FileStream(fileName, FileMode.Create)); myDocument.Open(); // build the footer with the ONVIF required information HeaderFooter footer = new HeaderFooter(new Phrase("Device - " + TestInfo.Device_Model + " " + TestInfo.TestDateAndTime + " ONVIF Test Report Page: "), true); footer.Border = Rectangle.NO_BORDER; footer.Alignment = Element.ALIGN_CENTER; myDocument.Footer = footer; BuildCoverPage(myDocument, TestInfo); // add summary BuildSummary(myDocument, Tests); // add index if (CreateIndex) { BuildIndex(myDocument, Tests); } // add test data AddTestGroupInfo(myDocument, Tests); } catch (DocumentException de) { Console.Error.WriteLine(de.Message); passed = false; } catch (IOException ioe) { Console.Error.WriteLine(ioe.Message); passed = false; } // don't forget to close the file myDocument.Close(); return(passed); }
/// <summary> /// Build Cover page /// </summary> /// <param name="myDocument">Document</param> /// <param name="TestInfo">Tests</param> private void BuildCoverPage(Document myDocument, TestSummary_TestInfo_Type TestInfo) { Stream logoStream = GetLogo(); // if the logo was found add it to the file if (logoStream != null) { Image logo = Image.GetInstance(logoStream); logo.Alignment = Element.ALIGN_CENTER; myDocument.Add(logo); } myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine)); myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine)); myDocument.Add(new iTextSharp.text.Paragraph(Environment.NewLine)); Paragraph p0 = new Paragraph(new Chunk("\n", FontFactory.GetFont(FontFactory.TIMES, 12))); p0.Add(new Chunk("ONVIF Conformance Test", FontFactory.GetFont(FontFactory.TIMES_BOLD, 20))); p0.Add("\n\n"); p0.Add(new Chunk("Performed by", FontFactory.GetFont(FontFactory.TIMES, 16))); p0.Add("\n\n"); p0.Add(String.Format("Operator - {0}\n", TestInfo.Operator)); p0.Add(String.Format("Organization - {0}\n", TestInfo.OrganizationName)); p0.Add(String.Format("Address - {0}\n", TestInfo.OrganizationAddress)); p0.Add(Environment.NewLine); p0.Add(Environment.NewLine); p0.Add(new Chunk("Device Under Test", FontFactory.GetFont(FontFactory.TIMES, 16))); p0.Add("\n\n"); p0.Add(String.Format("Brand - {0}\n", TestInfo.Device_Brand)); p0.Add(String.Format("Model - {0}\n", TestInfo.Device_Model)); p0.Add(String.Format("Serial Number - {0}\n", TestInfo.Device_SerialNumber)); p0.Add(String.Format("Firmware Version - {0}\n", TestInfo.Device_FWversion)); p0.Add(String.Format("Other - {0}\n", TestInfo.Device_Other)); p0.Add(Environment.NewLine); p0.Add(Environment.NewLine); p0.Add(Environment.NewLine); // add the ONVIF information //p0.Add("ONVIF Test Tool Version\n"); p0.Add(String.Format("{0}", TestInfo.ToolVersion)); p0.Add(Environment.NewLine); //p0.Add("ONVIF Test Specification Version\n"); p0.Add(String.Format("{0}", TestInfo.TestVersion)); p0.Add(Environment.NewLine); //p0.Add("ONVIF Core Specification Version\n"); p0.Add(String.Format("{0}", TestInfo.CoreVersion)); p0.Alignment = Element.ALIGN_CENTER; p0.Add(Environment.NewLine); p0.Add(Environment.NewLine); p0.Add(Environment.NewLine); p0.Add("Test Date and Time - " + TestInfo.TestDateAndTime); myDocument.Add(p0); }