コード例 #1
0
        private static void CreateMonthlyReports(DonerCollection data)
        {
            List<Doner> doners = data.GetAllDoners();
            for (DateTime start = new DateTime(reportingYear, 1, 1); start.Year < reportingYear+1; start = start.AddMonths(1))
            //for (DateTime start = new DateTime(2010, 1, 1); start.Month < 2; start = start.AddMonths(1))
            {
                DateTime end = start.AddMonths(1);
                logger.WriteInfo("Processing Month: {0} ....", CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName( start.Month ));
                var monthData = data.GetDonationsByDate(start, end);
                if (!monthData.Any())
                {
                    logger.WriteWarning("No data found for this month");
                    continue;
                }
                ExcelWriter writer = new ExcelWriter(String.Format("{0}_{1}_TallyReport.xlsx", 
                    CultureInfo.CurrentCulture.DateTimeFormat.GetMonthName( start.Month ), start.Year.ToString()),
                    FinanceApplication.ExcelWriter.ReportType.MonthyTally);
                logger.WriteInfo("Done. Total = {0:C}", writer.Write(monthData, new Doner("nobody")));
                // TEMP CODE FOR DEBUGGING
                //data.GetDonationsByDate(start, end).ForEach(d => d.PrintDonations());

            }
        }