示例#1
0
        private static void AddCaseReportDataToTable(PdfPTable table, CaseReportForListing caseReport)
        {
            var time   = caseReport.Timestamp.ToString("yyyy MMMM dd, HH:mm:ss");
            var status = caseReport.HealthRiskId != null;

            var dataCollector = caseReport.DataCollectorDisplayName != "Unknown"
                ? caseReport.DataCollectorDisplayName
                : "Origin: " + caseReport.Origin;

            var latLong = caseReport.Location != null && caseReport.Location != Location.NotSet
                ? caseReport.Location.ToString()
                : "";

            table.AddCell(time);
            table.AddCell(status ? "Success" : "Error");
            table.AddCell(dataCollector);

            if (status)
            {
                var healthRisk = caseReport.HealthRisk;

                var malesUnder5 = caseReport.NumberOfMalesUnder5.ToString();
                var malesOver5  = caseReport.NumberOfMalesAged5AndOlder.ToString();

                var femalesUnder5 = caseReport.NumberOfFemalesUnder5.ToString();

                var femalesOver5 = caseReport.NumberOfFemalesAged5AndOlder.ToString();

                table.AddCell(healthRisk);
                table.AddCell(malesUnder5);
                table.AddCell(malesOver5);
                table.AddCell(femalesUnder5);
                table.AddCell(femalesOver5);
            }
            else
            {
                var message = caseReport.Message;

                var errorMessages = string.Join(", ", caseReport.ParsingErrorMessage != null ? String.Join(".", caseReport.ParsingErrorMessage) : "");

                var cellText = message + "\nErrors: " + errorMessages;

                var cell = new PdfPCell(new Phrase(cellText))
                {
                    Colspan = 5
                };

                table.AddCell(cell);
            }

            table.AddCell(latLong);
        }
示例#2
0
        void WriteRow(ExcelWorksheet worksheet, int row, CaseReportForListing report)
        {
            worksheet.Cells[row, 1].Value  = report.Timestamp.DateTime;
            worksheet.Cells[row, 2].Value  = report.Timestamp.DateTime;
            worksheet.Cells[row, 19].Value = report.Message;

            var isoyear = GetIsoYear(report.Timestamp.DateTime);
            var isoweek = GetIsoWeek(report.Timestamp.DateTime);

            worksheet.Cells[row, 21].Value = isoyear;
            worksheet.Cells[row, 22].Value = isoweek;
            worksheet.Cells[row, 23].Value = isoyear + "-" + isoweek;

            if (report.DataCollectorId != DataCollectorId.NotSet)
            {
                worksheet.Cells[row, 4].Value = report.DataCollectorDisplayName;
                worksheet.Cells[row, 5].Value = report.DataCollectorRegion;
                worksheet.Cells[row, 6].Value = report.DataCollectorDistrict;
                worksheet.Cells[row, 7].Value = report.DataCollectorVillage;
            }
            else
            {
                worksheet.Cells[row, 4].Value = "Origin: " + report.Origin;
            }

            if (report.HealthRiskId != HealthRiskId.NotSet)
            {
                worksheet.Cells[row, 3].Value  = "Success";
                worksheet.Cells[row, 8].Value  = report.HealthRisk;
                worksheet.Cells[row, 9].Value  = report.NumberOfMalesUnder5;
                worksheet.Cells[row, 10].Value = report.NumberOfMalesAged5AndOlder;
                worksheet.Cells[row, 11].Value = report.NumberOfFemalesUnder5;
                worksheet.Cells[row, 12].Value = report.NumberOfFemalesAged5AndOlder;

                worksheet.Cells[row, 13].Value = report.NumberOfMalesUnder5 + report.NumberOfFemalesUnder5;
                worksheet.Cells[row, 14].Value = report.NumberOfMalesAged5AndOlder + report.NumberOfFemalesAged5AndOlder;
                worksheet.Cells[row, 15].Value = report.NumberOfFemalesUnder5 + report.NumberOfFemalesAged5AndOlder;
                worksheet.Cells[row, 16].Value = report.NumberOfMalesUnder5 + report.NumberOfMalesAged5AndOlder;
                worksheet.Cells[row, 17].Value = report.NumberOfMalesUnder5 + report.NumberOfMalesAged5AndOlder + report.NumberOfFemalesUnder5 + report.NumberOfFemalesAged5AndOlder;
            }
            else
            {
                worksheet.Cells[row, 3].Value  = "Error";
                worksheet.Cells[row, 20].Value = string.Join(", ", report.ParsingErrorMessage);
            }

            if (report.Location != Location.NotSet)
            {
                worksheet.Cells[row, 18].Value = $"{report.Location.Latitude.ToString("F4")}/{report.Location.Longitude.ToString("F4")}";
            }
        }