예제 #1
0
        static void Main(string[] args)
        {
            DonerCollection data;
            try
            {
                logger = Logger.CreateLogger(true);
                //Test();
                // string filePath = @"TestData\";
                string filePath = System.Configuration.ConfigurationManager.AppSettings["SpreadSheetLocation"];
                string[] files = Directory.GetFiles(filePath, "*.xls*");
                data = new DonerCollection();
                ReadExcel(files, data);
                //TestMerge();
                //TestLogger();
                //TestFileNames(files);
                //TestDonationQueries();
                data.PrintDoners();
               // TestPrintDonationsOfAaron(data);
                data.ConsolidateDoners();
                data.PrintDoners();
                data.PrintDonationCollectionDates();
                if (reportTypes.Contains("Donors"))
                    CreateReportForDoners(data);

                if (reportTypes.Contains("Monthly"))
                    CreateMonthlyReports(data);
                //TestExcelWriter(ref data);
               
            }
            catch (Exception e)
            {
                logger.WriteError("Exception occurred during execution: \n {0}, {1}", e.Message, e.StackTrace);
            }
            finally
            {
                logger.Close();
            }
        }
예제 #2
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 ******************");
        }