예제 #1
0
        }         // IsNormalMode

        private static void SendReport(DateTime oDate, ASafeLog oLog)
        {
            oLog.Debug("Generating reconciliation report...");

            var oDB = new SqlConnection();

            oLog.Debug("Loading Pacnet report metadata from db...");

            var pacnet = new Report(oDB, "RPT_PACNET_RECONCILIATION");

            oLog.Debug("Loading Paypoint report metadata from db...");

            var paypoint = new Report(oDB, "RPT_PAYPOINT_RECONCILIATION");

            var rh = new BaseReportHandler(oDB, oLog);

            var sender = new ReportDispatcher(oDB, oLog);

            var email = new ReportEmail();

            oLog.Debug("Generating Pacnet report...");

            email.ReportBody.Append(new H2().Append(new Text(pacnet.GetTitle(oDate))));

            email.ReportBody.Append(
                rh.TableReport(new ReportQuery(pacnet, oDate, oDate))
                );

            oLog.Debug("Generating Paypoint report...");

            email.ReportBody.Append(new H2().Append(new Text(paypoint.GetTitle(oDate))));

            email.ReportBody.Append(
                rh.TableReport(new ReportQuery(paypoint, oDate, oDate))
                );

            var sTo = new StringBuilder();

            sTo.Append(pacnet.ToEmail);

            if (pacnet.ToEmail != "")
            {
                sTo.Append(",");
            }

            sTo.Append(paypoint.ToEmail);

            oLog.Debug("Sending report...");

            sender.Dispatch(
                "Reconciliation " + oDate.ToString("MMMM d yyyy", CultureInfo.InvariantCulture),
                oDate,
                email.HtmlBody,
                null,
                sTo.ToString()
                );

            oLog.Debug("Reconciliation report generation complete.");
        }         // SendReport
예제 #2
0
        }         // HandleGenericReport

        private void BuildReport(
            Report report,
            DateTime fromDate,
            DateTime toDate,
            string period,
            ReportDispatcher sender,
            DateTime oReportGenerationDate,
            Func <Report, DateTime, DateTime, List <string>, ATag> oBuildHtml,
            Func <Report, DateTime, DateTime, ExcelPackage> oBuildXls
            )
        {
            Debug("Building report {0} for period {1}", report.Title, period);

            var email = new ReportEmail();

            switch (period)
            {
            case DailyPerdiod:
                email.Title.Append(new Text(period + " " + report.GetTitle(fromDate, " for ")));
                break;

            case WeeklyPerdiod:
                email.Title.Append(new Text(period + " " + report.GetTitle(fromDate, " for ", toDate)));
                break;

            case MonthlyPerdiod:
                email.Title.Append(new Text(period + " " + report.GetMonthTitle(fromDate)));
                break;

            case MonthToDatePerdiod:
                email.Title.Append(new Text(period + " " + report.GetMonthTitle(fromDate, toDate)));
                break;
            }             // switch

            var rptDef = new ReportQuery(report, fromDate, toDate);

            ATag oBody = oBuildHtml == null
                                ? TableReport(rptDef, false, email.Title.ToString())
                                : oBuildHtml(report, fromDate, toDate, null);

            ExcelPackage oXls = oBuildXls == null
                                ? XlsReport(rptDef, email.Title.ToString())
                                : oBuildXls(report, fromDate, toDate);

            email.ReportBody.Append(oBody);

            sender.Dispatch(
                report.Title,
                oReportGenerationDate,
                email.HtmlBody,
                oXls,
                report.ToEmail,
                period
                );
        }         // BuildReport
예제 #3
0
        private static void TestLoanStats(AConnection oDB, ASafeLog log)
        {
            var sender = new ReportDispatcher(oDB, log);

            sender.Dispatch("loan_stats", DateTime.Today, null, new LoanStats(oDB, log).Xls(), ReportDispatcher.ToDropbox);
        }
예제 #4
0
        }         // HandleReportsBulk

        private void HandleOneReport(
            DateTime dToday,
            ReportType?nReportTypeToExecute,
            Report report,
            ReportDispatcher sender
            )
        {
            try {
                bool bExecute = (nReportTypeToExecute == null) || (report.Type == nReportTypeToExecute.Value);

                if (!bExecute)
                {
                    Debug(
                        "Skipping {0} report: only {1} requested.",
                        report.Title,
                        nReportTypeToExecute.Value.ToString()
                        );
                    return;
                }                 // if

                Debug("Generating {0} report...", report.Title);

                switch (report.Type)
                {
                case ReportType.RPT_LOAN_STATS:
                    sender.Dispatch(
                        "loan_stats",
                        dToday,
                        null,
                        new LoanStats(DB, this).Xls(),
                        ReportDispatcher.ToDropbox
                        );
                    break;

                case ReportType.RPT_TRAFFIC_REPORT:
                    DateTime dYesterday = dToday.AddDays(-1);
                    HandleGenericReport(report, dYesterday, sender, BuildTrafficReport, BuildTrafficReportXls, dToday);
                    break;

                case ReportType.RPT_NOT_AUTO_APPROVED:
                    HandleGenericReport(report, dToday, sender, BuildNotAutoApprovedReport, BuildNotAutoApprovedXls);
                    break;

                case ReportType.RPT_EARNED_INTEREST:
                    HandleGenericReport(report, dToday, sender, BuildEarnedInterestReport, BuildEarnedInterestXls);
                    break;

                case ReportType.RPT_EARNED_INTEREST_ALL_CUSTOMERS:
                    HandleGenericReport(report, dToday, sender, BuildEarnedInterestAllCustomersReport, BuildEarnedInterestAllCustomersXls);
                    break;

                case ReportType.RPT_FINANCIAL_STATS:
                    HandleGenericReport(report, dToday, sender, BuildFinancialStatsReport, BuildFinancialStatsXls);
                    break;

                case ReportType.RPT_LOANS_GIVEN:
                    HandleGenericReport(report, dToday, sender, BuildLoansIssuedReport, BuildLoansIssuedXls);
                    break;

                case ReportType.RPT_CCI:
                    HandleGenericReport(report, dToday, sender, BuildCciReport, BuildCciXls);
                    break;

                case ReportType.RPT_UI_REPORT:
                    HandleGenericReport(report, dToday, sender, BuildUiReport, BuildUiXls);
                    break;

                case ReportType.RPT_UI_EXT_REPORT:
                    HandleGenericReport(report, dToday, sender, BuildUiExtReport, BuildUiExtXls);
                    break;

                case ReportType.RPT_ACCOUNTING_LOAN_BALANCE:
                    HandleGenericReport(report, dToday, sender, BuildAccountingLoanBalanceReport, BuildAccountingLoanBalanceXls);
                    break;

                case ReportType.RPT_MARKETING_CHANNELS_SUMMARY:
                    HandleGenericReport(report, dToday, sender, BuildMarketingChannelsSummaryReport, BuildMarketingChannelsSummaryXls);
                    break;

                case ReportType.RPT_STRATEGY_RUNNING_TIME:
                    HandleGenericReport(report, dToday, sender, BuildStrategyRunningTimeReport, BuildStrategyRunningTimeXls);
                    break;

                case ReportType.RPT_NEW_UNMATCHED_PAYMENTS:
                    HandleGenericReport(report, dToday, sender, BuildNewUnmatchedPaymentsReport, BuildNewUnmatchedPaymentsXls);
                    break;

                default:
                    HandleGenericReport(report, dToday, sender, null, null);
                    break;
                }                 // switch

                Debug("Generating {0} report complete.", report.Title);
            } catch (Exception ex) {
                Error("Generating {0} report failed \n {1}.", report.Title, ex);

                sender.Dispatch("Report to mail tool: error generating report",
                                DateTime.UtcNow,
                                new Body()
                                .Add <Class>("Body")
                                .Append(new H1()
                                        .Append(new Text(string.Format("Error Generating/Sending report {0}", report.Title)))),
                                null,
                                "*****@*****.**"
                                );
            }     // try
        }         // HandleOneReport