コード例 #1
0
        /**
         * @method Perform data processing.
         * @params None
         * @returns None; output will be generated as a result of this activity.
         */
        public void Run()
        {
            // Try to load our database from the on-disk cache.
            Data.Database database = _databaseCache.Load();

            // Did we succeed?  If not, load it manually via a connection to the database.
            if (database == null)
            {
                // Create a database to populate.
                database = new Data.Database(_configuration);

                Console.WriteLine("Gathering input data...");

                // Populate the database using our input shim.
                _inputShim.SetDatabase(database);
                _inputShim.Run();

                Console.WriteLine("All input data gathered.");

                // Save cache.
                _databaseCache.Save(database);
            }
            else
            {
                Console.WriteLine("Loaded cached input data from " + _databaseCache.Name);
            }

            // Create the object capable of projecting ticket scenarios into the future.
            Projector projector = new Projector(_configuration, database);

            // Start data processing.
            Start();

            // Which scenarios will we test?
            List <ProjectionScenario> projectionScenarios = _configuration.GetProjectionScenarios();

            foreach (ProjectionScenario projectionScenario in projectionScenarios)
            {
                // Project this scenario.
                ProjectedFuture projectionFuture = projector.Project(projectionScenario);

                // Inform our output shims of the result of this projection.
                OnProjectionScenarioCompleted(projectionScenario, projectionFuture);
            }

            // Finish data processing.
            End();
        }