示例#1
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 ******************");
        }