protected override void GenerateReportHeader() { byte[] logoByte = Common.GlobalProfile.Logo; string contactInfo = Common.GlobalProfile.ContactInfo; if (logoByte != null || !string.IsNullOrWhiteSpace(contactInfo)) { PdfPTable headerTable = PdfElementGenerator.createTable(new float[] { 0.57f, 0.05f, 0.38f }); PdfPCell[] headRowCells = headerTable.Rows[0].GetCells(); if (logoByte != null) { headRowCells[0].Image = this.getImage(logoByte); } if (!string.IsNullOrWhiteSpace(contactInfo)) { headRowCells[2].Phrase = PdfElementGenerator.createPhrase(contactInfo, 6.1f, false); headRowCells[2].Border = 15; //headRowCells[2].HorizontalAlignment = Element.ALIGN_RIGHT; } foreach (var item in headRowCells) { item.FixedHeight = 35f; if (item.Phrase != null) { item.VerticalAlignment = Element.ALIGN_MIDDLE; } } document.Add(headerTable); PdfElementGenerator.AddEmptyParagraphToDocument(this.document, this.sectionMargin); } }
protected override void GenerateSignatures() { if (this.isSignatureShown) { document.NewPage(); float sectionMargin = 10f; float cellVerticalPadding = 4f; this.document.Add(PdfElementGenerator.createSectionTitleParagraph("Electronic Signatures")); PdfPTable signatureTable = PdfElementGenerator.createTable(new float[] { 0.05f, 0.95f }, false, false); for (int i = 0; i < this.signatureList.Count; i++) { PdfPCell[] newRowCells = PdfElementGenerator.AddEmptyRowToTable(signatureTable, true); newRowCells[0].Phrase = PdfElementGenerator.createTableCellContentPhrase((i + 1).ToString()); newRowCells[1].Phrase = PdfElementGenerator.createTableCellContentPhrase(this.signatureList[i].ToString(Common.GlobalProfile.DateTimeFormator)); newRowCells[0].HorizontalAlignment = Element.ALIGN_CENTER; foreach (var item in newRowCells) { item.PaddingTop = cellVerticalPadding; item.PaddingBottom = cellVerticalPadding; } } this.document.Add(PdfElementGenerator.createSectionFrameTable(signatureTable, false, true)); this.rowsInfectedBySignature = (int)((30 + signatureTable.TotalHeight + sectionMargin * 3) / this.dataListContentCellHeight); PdfElementGenerator.AddEmptyParagraphToDocument(this.document, this.sectionMargin); } }
protected override void GenerateLoggingSummary() { this.document.Add(PdfElementGenerator.createSectionTitleParagraph("Logging Summary")); IDictionary <string, string[]> loggingSummaryContents = this.reportdataGenerator.GetLoggingSummaryColumsContents(this.device, this.deviceDataFrom); string[] column1Contents = loggingSummaryContents["column1Contents"]; string[] column2Contents = loggingSummaryContents["column2Contents"]; PdfPTable loggingSummaryTable = PdfElementGenerator.createTable(new float[2] { 0.5f, 0.5f }); PdfPCell[] firstRowCells = loggingSummaryTable.Rows[0].GetCells(); firstRowCells[0].Phrase = PdfElementGenerator.createTableCellContentPhrase(column1Contents[0] + "\n\r" + column1Contents[1] + "\n\r" + column1Contents[2] + "\n\r" + column1Contents[3] + "\n\r" + column1Contents[4]); firstRowCells[1].Phrase = PdfElementGenerator.createTableCellContentPhrase(column2Contents[0] + "\n\r" + column2Contents[1] + "\n\r" + column2Contents[2] + "\n\r" + column2Contents[3] + "\n\r" + column2Contents[4]); this.document.Add(PdfElementGenerator.createSectionFrameTable(loggingSummaryTable)); PdfElementGenerator.AddEmptyParagraphToDocument(this.document, this.sectionMargin); }
protected override void GenerateReportTitle() { PdfPTable titleTable = null; if (this.reportTitleIconStatus == ReportTitleIconStatus.Alarm) { titleTable = PdfElementGenerator.createTable(new float[] { 0.84f, 0.04f, 0.12f }); } else if (this.reportTitleIconStatus == ReportTitleIconStatus.OK) { titleTable = PdfElementGenerator.createTable(new float[] { 0.89f, 0.04f, 0.07f }); } else { titleTable = PdfElementGenerator.createTable(new float[] { 0.89f, 0.04f, 0.07f }); } PdfPCell[] rowCells = titleTable.Rows[0].GetCells(); if (!string.IsNullOrWhiteSpace(this.Title)) { rowCells[0].Phrase = PdfElementGenerator.createDocumentTitlePhrase(this.Title.Trim() == ReportConstString.TitleDefaultString ? "" : this.Title); } if (this.reportTitleIconStatus == ReportTitleIconStatus.Alarm && reportCrossSmall != null) { rowCells[1].Image = this.getImage(Utils.CopyToBinary(reportCrossSmall)); rowCells[1].FixedHeight = 18; rowCells[2].Phrase = PdfElementGenerator.createDocumentTitlePhrase(ReportConstString.TitleAlarmString); } else if (this.reportTitleIconStatus == ReportTitleIconStatus.OK && reportOkSmall != null) { rowCells[1].Image = this.getImage(Utils.CopyToBinary(reportOkSmall)); rowCells[1].FixedHeight = 18; rowCells[2].Phrase = PdfElementGenerator.createDocumentTitlePhrase(ReportConstString.TitleOkString); } else { // nothing to do } rowCells[2].PaddingBottom = 0; rowCells[2].VerticalAlignment = Element.ALIGN_MIDDLE; document.Add(titleTable); PdfElementGenerator.AddEmptyParagraphToDocument(this.document, this.sectionMargin); }
protected override void GenerateAlarms() { IDictionary <string, string[]> alarmDataContents = this.reportdataGenerator.GetAlarmRowContents(this.device); string[] highRowContents = alarmDataContents["highRowContents"]; string[] lowRowContents = alarmDataContents["lowRowContents"]; string[] a1RowContents = alarmDataContents["a1RowContents"]; string[] a2RowContents = alarmDataContents["a2RowContents"]; string[] a3RowContents = alarmDataContents["a3RowContents"]; string[] a4RowContents = alarmDataContents["a4RowContents"]; string[] a5RowContents = alarmDataContents["a5RowContents"]; string[] a6RowContents = alarmDataContents["a6RowContents"]; int totalRows = 6; this.document.Add(PdfElementGenerator.createSectionTitleParagraph(this.reportdataGenerator.GetAlarmSectionTitle(this.device))); PdfPTable alarmTable = PdfElementGenerator.createTable(new float[] { 0.18f, 0.19f, 0.17f, 0.10f, 0.23f, 0.13f }, true, false); if (this.device.AlarmMode == 0) { PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, false); alarmTable.Rows[0].GetCells()[0].FixedHeight = 40f; } else if (this.device.AlarmMode == 1) { PdfPCell[] tableHeaderRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, false); tableHeaderRowCells[0].Phrase = PdfElementGenerator.createTableHeaderPhrase("Alarm Zones"); tableHeaderRowCells[1].Phrase = PdfElementGenerator.createTableHeaderPhrase("Alarm Delay"); tableHeaderRowCells[2].Phrase = PdfElementGenerator.createTableHeaderPhrase("Total Time"); tableHeaderRowCells[3].Phrase = PdfElementGenerator.createTableHeaderPhrase("Events"); tableHeaderRowCells[4].Phrase = PdfElementGenerator.createTableHeaderPhrase("First Triggered"); tableHeaderRowCells[5].Phrase = PdfElementGenerator.createTableHeaderPhrase("Alarm Status"); tableHeaderRowCells[5].HorizontalAlignment = Element.ALIGN_RIGHT; if (reportdataGenerator.IsStringArrayNotEmpty(highRowContents)) { PdfPCell[] firstRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, false); PdfElementGenerator.SetTableCellContentValue(firstRowCells, highRowContents); totalRows--; } if (reportdataGenerator.IsStringArrayNotEmpty(lowRowContents)) { PdfPCell[] secondRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, false); PdfElementGenerator.SetTableCellContentValue(secondRowCells, lowRowContents); totalRows--; } } else if (this.device.AlarmMode == 2) { PdfPCell[] tableHeaderRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, false); tableHeaderRowCells[0].Phrase = PdfElementGenerator.createTableHeaderPhrase("Alarm Zones"); tableHeaderRowCells[1].Phrase = PdfElementGenerator.createTableHeaderPhrase("Alarm Delay"); tableHeaderRowCells[2].Phrase = PdfElementGenerator.createTableHeaderPhrase("Total Time"); tableHeaderRowCells[3].Phrase = PdfElementGenerator.createTableHeaderPhrase("Events"); tableHeaderRowCells[4].Phrase = PdfElementGenerator.createTableHeaderPhrase("First Triggered"); tableHeaderRowCells[5].Phrase = PdfElementGenerator.createTableHeaderPhrase("Alarm Status"); tableHeaderRowCells[5].HorizontalAlignment = Element.ALIGN_RIGHT; if (reportdataGenerator.IsStringArrayNotEmpty(a1RowContents)) { PdfPCell[] firstRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, true); PdfElementGenerator.SetTableCellContentValue(firstRowCells, a1RowContents); totalRows--; } if (reportdataGenerator.IsStringArrayNotEmpty(a2RowContents)) { PdfPCell[] secondRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, true); PdfElementGenerator.SetTableCellContentValue(secondRowCells, a2RowContents); totalRows--; } if (reportdataGenerator.IsStringArrayNotEmpty(a3RowContents)) { PdfPCell[] thirdRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, true); PdfElementGenerator.SetTableCellContentValue(thirdRowCells, a3RowContents); totalRows--; } if (reportdataGenerator.IsStringArrayNotEmpty(a4RowContents)) { PdfPCell[] fourthRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, true); PdfElementGenerator.SetTableCellContentValue(fourthRowCells, a4RowContents); totalRows--; } if (reportdataGenerator.IsStringArrayNotEmpty(a5RowContents)) { PdfPCell[] fifthRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, true); PdfElementGenerator.SetTableCellContentValue(fifthRowCells, a5RowContents); totalRows--; } if (reportdataGenerator.IsStringArrayNotEmpty(a6RowContents)) { PdfPCell[] sixthRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, true); PdfElementGenerator.SetTableCellContentValue(sixthRowCells, a6RowContents); totalRows--; } } for (int i = 0; i < totalRows; i++) { string[] emptyRow = new string[6] { " ", " ", " ", " ", " ", " " }; PdfPCell[] emptyRowCells = PdfElementGenerator.AddEmptyRowToTable(alarmTable, false, true, true); PdfElementGenerator.SetTableCellContentValue(emptyRowCells, emptyRow); } this.document.Add(PdfElementGenerator.createSectionFrameTable(alarmTable, true)); PdfElementGenerator.AddEmptyParagraphToDocument(this.document, this.sectionMargin); }
protected override void GenerateDeviceConfigurationAndTripInfomation() { PdfPTable generalTable = PdfElementGenerator.createTable(new float[] { 0.49f, 0.02f, 0.49f }); PdfPCell[] firstRowCells = generalTable.Rows[0].GetCells(); // 生成两个版块的标题 firstRowCells[0].Phrase = PdfElementGenerator.createSectionTitlePhrase("Device Configuration"); PdfPTable tripInfoTitleTable = PdfElementGenerator.createTable(new float[2] { 0.4f, 0.6f }, false, false); PdfPCell[] tripInfoTitleRowCells = PdfElementGenerator.AddEmptyRowToTable(tripInfoTitleTable, false, false); tripInfoTitleRowCells[0].Phrase = PdfElementGenerator.createSectionTitlePhrase("Trip Information"); tripInfoTitleRowCells[1].Phrase = PdfElementGenerator.createTableCellContentPhrase(reportdataGenerator.GetLocalTimeZoneString()); tripInfoTitleRowCells[1].HorizontalAlignment = Element.ALIGN_RIGHT; firstRowCells[2] = new PdfPCell(tripInfoTitleTable); firstRowCells[2].Border = 0; firstRowCells[0].PaddingBottom = 4f; firstRowCells[2].PaddingBottom = 4f; //PdfElementGenerator.AddEmptyRowToTable(generalTable); // 填充Device Configuration的内容 IDictionary <string, string[]> deviceConfigurationContents = this.reportdataGenerator.GetDeviceConfigurationTripInfoRowsContents(this.device); string[] row1Contents = deviceConfigurationContents["row1Contents"]; string[] row2Contents = deviceConfigurationContents["row2Contents"]; string[] row3Contents = deviceConfigurationContents["row3Contents"]; string[] tripInfoContents = deviceConfigurationContents["tripInfoContents"]; PdfPTable deviceConfigTable = PdfElementGenerator.createTable(new float[] { 0.42f, 0.58f }); PdfPCell[] deviceRowCells = deviceConfigTable.Rows[0].GetCells(); deviceRowCells[0].Phrase = PdfElementGenerator.createTableCellContentPhrase(row1Contents[0] + "\n\r" + row2Contents[0] + "\n\r" + row3Contents[0]); deviceRowCells[1].Phrase = PdfElementGenerator.createTableCellContentPhrase(row1Contents[1] + "\n\r" + row2Contents[1] + "\n\r" + row3Contents[1]); // 填充Trip Information的内容 PdfPTable tripInfoTable = PdfElementGenerator.createTable(new float[] { 0.185f, 0.815f }); IList <PdfPCell> tripInfoCells = tripInfoTable.Rows[0].GetCells(); tripInfoCells[0].Colspan = 2; tripInfoCells[0].Phrase = PdfElementGenerator.createTableCellContentPhrase("Trip Number: " + tripInfoContents[0]); PdfPCell[] descriptionRowCells = PdfElementGenerator.AddEmptyRowToTable(tripInfoTable, false, true, false); descriptionRowCells[0].Phrase = PdfElementGenerator.createTableCellContentPhrase(tripInfoContents[1].Trim()); descriptionRowCells[1].Phrase = PdfElementGenerator.createTableCellContentPhrase(tripInfoContents[2]); descriptionRowCells[0].PaddingTop = 6f; descriptionRowCells[1].PaddingTop = 6f; PdfPCell[] sencondRowCells = PdfElementGenerator.AddEmptyRowToTable(generalTable, false); sencondRowCells[0] = new PdfPCell(PdfElementGenerator.createSectionFrameTable(deviceConfigTable, false, false)); sencondRowCells[2] = new PdfPCell(PdfElementGenerator.createSectionFrameTable(tripInfoTable, false, false)); document.Add(generalTable); PdfElementGenerator.AddEmptyParagraphToDocument(this.document, this.sectionMargin); }