Exemplo n.º 1
0
        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);
        }