コード例 #1
0
 private static void CreateReportForDoners(DonerCollection data)
 {
     List<Doner> doners = data.GetAllDoners();
     foreach (var item in doners)
     {
         logger.WriteInfo("Processing Doner: {0} ....", item.Name);
         ExcelWriter writer = new ExcelWriter(String.Format("{0}_Donations{1}.xlsx", item.Name, reportingYear), 
             ExcelWriter.ReportType.YearlyDonerReport);
         DonerCollection donationsByDoner = new DonerCollection();
         donationsByDoner.AddDonation(item, data.GetDonationsOfDonerByMonth(item, reportingYear));
         writer.Write(donationsByDoner.GetAllDonations(), item);
     }
 }
コード例 #2
0
 public void Write(DonerCollection donationData)
 {
     string text = "blah blah text to add";
     StringBuilder sb = new StringBuilder();
     sb.AppendLine(String.Format("{0}: \n", donationData.GetAllDoners().FirstOrDefault().Name));
     sb.AppendLine();
     sb.AppendLine(text);
     sb.AppendLine("Your total donations for " +donationData.GetAllDonations().FirstOrDefault().DonationTime.Year + " are: ");
     sb.AppendLine(String.Format("\t{0:C}", donationData.CalculateTotal()));
     sb.AppendLine();
     sb.AppendLine();
     sb.AppendLine("Thank you for your support!");
     sb.AppendLine("--- CGC Finance Dept ---");
     using (StreamWriter file = new StreamWriter(Filename))
     {
         file.Write(sb.ToString());
     }
     
 }
コード例 #3
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());

            }
        }
コード例 #4
0
 private static void TestPrintDonationsOfAaron(DonerCollection data)
 {
     List<Doner> doner = data.GetAllDoners().Where(d => d.Name.Contains("Aaron")).ToList();
     foreach (var item in doner)
     {
         logger.WriteInfo("Printing Donations for {0}", item.Name);
         data.GetDonationsOfDoner(item).ForEach(donation => donation.PrintDonations());
         double donationTotal = 0.0;
         logger.WriteInfo("Total of all donations is ${0}", data.GetDonationsOfDoner(item).Aggregate(donationTotal, (total, variant) => total + variant.CalculateTotal()));
         logger.WriteInfo("Processing Doner: {0} ....", item.Name);
         ExcelWriter writer = new ExcelWriter(String.Format("{0}_Donations2010.xlsx", item.Name), FinanceApplication.ExcelWriter.ReportType.YearlyDonerReport);
         writer.Write(data.GetDonationsOfDoner(item), item);    
     }
 }
コード例 #5
0
 private static bool TestExcelWriter(ref DonerCollection data)
 {
     List<Doner> doners = data.GetAllDoners().Where( d => d.Name.ToLower().Contains("aaron")).ToList();
     foreach (var item in doners)
     {
         logger.WriteInfo("Processing Doner: {0} ....", item.Name);
         ExcelWriter writer = new ExcelWriter(String.Format("{0}_Donations{1}.xlsx", item.Name, reportingYear), 
             FinanceApplication.ExcelWriter.ReportType.YearlyDonerReport);
         writer.Write(data.GetDonationsOfDoner(item), item);
     }
     return true;
 }
コード例 #6
0
        private static void TestDonationQueries()
        {
            string[] files = { @"C:\temp\TestData\03-07-2010.xls",
                             @"C:\temp\TestData\03-8-2010.xls",
                             @"C:\temp\TestData\2-28-2010.xls",
                             @"C:\temp\TestData\8-1-2010.xls",
                            @"C:\temp\TestData\09-01-2010.xls"};
            DonerCollection data = new DonerCollection();
            ReadExcel(files, data);

            logger.WriteInfo("*************ALL DATA START******************");
            data.Print();
            logger.WriteInfo("*************ALL DATA END ******************");

            logger.WriteInfo("*************ALL DONERS START******************");
            data.PrintDoners();
            logger.WriteInfo("*************ALL DONERS END ******************");


            logger.WriteInfo("*************ALL DONATIONS FOR FIRST START******************");
            data.GetDonationsOfDoner(data.GetAllDoners().First()).ForEach( d => d.PrintDonations() );
            logger.WriteInfo("*************ALL DONATIONS FOR FIRST END ******************");

            //logger.WriteInfo("*************ALL DONATIONS FOR FIRST START******************");
            //data.GetCategoryDonations(Donation.Category.Tithes).ForEach(d => d.PrintDonations());
            //logger.WriteInfo("*************ALL DONATIONS FOR FIRST END ******************");

            logger.WriteInfo("*************ALL TITHES START******************");
            data.GetDonationsByCategory(Donation.Category.Tithes).ForEach(d => d.PrintDonations());
            logger.WriteInfo("*************ALL TITHES END ******************");


            logger.WriteInfo("*************RANGE TITHES START******************");
            data.GetDonationsByCategory(Donation.Category.Tithes, new DateTime(2010, 02, 01), new DateTime(2010, 04, 01)).ForEach(d => d.PrintDonations());
            logger.WriteInfo("*************RANGE TITHES END ******************");


            logger.WriteInfo("*************ALL DONATIONS FOR FEB START******************");
            data.GetAllDonersAndDonations(new DateTime(2010, 02, 01), new DateTime(2010, 02, 29))
                .ForEach(d => 
                {
                    Console.WriteLine( "Name: {0}", ((Doner)d.Key).Name);
                    ((Donation)d.Value).PrintDonations(); 
                } );
            logger.WriteInfo("*************ALL DONATIONS FOR FEB END ******************");
        }
コード例 #7
0
        private static void TestMerge()
        {
            string[] files = { @"TestData\1-2-2009.xls" };
            DonerCollection data = new DonerCollection();
            ReadExcel(files, data);

            logger.WriteInfo("*************TIME TO MERGE******************");
            List<Doner> doners = data.GetAllDoners();
            data.MergeDoners(doners.First(), doners.Last());

            data.Print();



        }