示例#1
0
 /// <summary>
 /// Process the status information.
 /// </summary>
 /// <param name="statusRecorder"> The status recorder with status information. .</param>
 /// <param name="configItems"> The given all configuration items. .</param>
 private void SkipFinishedModules(StatusRecorder statusRecorder, Dictionary<string, ConfigurationModule> configItems)
 {
     foreach (ConfigurationModule configItem in configItems.Values)
     {
         if (statusRecorder.FinishedSteps.IndexOf(configItem.Name) > -1)
         {
             configItem.Skip = true;
         }
     }
 }
示例#2
0
        /// <summary>
        /// Initializes a new instance of the FlowEngine class.
        /// </summary>
        /// <param name="configItems"> The given all configuration items. .</param>
        /// <param name="logFile"> The given file name to store the log. .</param>
        /// <param name="statusRecorder"> The status recorder for the engine. .</param>
        public FlowEngine(Dictionary<string, ConfigurationModule> configItems, string logFile, StatusRecorder statusRecorder)
        {
            if (configItems == null)
            {
                throw new ArgumentNullException("configItems");
            }

            if (string.IsNullOrEmpty(logFile))
            {
                throw new ArgumentNullException("logFile");
            }

            // Initializes the loggers.
            Helper.TestWritable(logFile);
            _detailLogger = new TextLogger(logFile, Encoding.Unicode);
            _compactLogger = new ConsoleLogger();

            if (statusRecorder != null)
            {
                SkipFinishedModules(statusRecorder, configItems);
            }

            // Creates the object to place the items.
            _items = new Dictionary<string, FlowItem>();

            try
            {
                // Setups the pipeline.
                foreach (ConfigurationModule config in configItems.Values)
                {
                    // Creates the item.
                    FlowItem item = new FlowItem(config);
                    item.Handler.StepStatusRecorder = statusRecorder;

                    // Initializes the inputs.
                    item.InitializeInputs(_items);

                    // Updates the implicit inputs.
                    item.UpdateImplictInputs(_items);

                    // Initializes the loggers.
                    item.InitializeLogger(_detailLogger, _compactLogger);

                    // Adds the item into the pipeline.
                    _items.Add(item.Name, item);
                }
            }
            catch (ConfigurationException e)
            {
                Log("Failed to setup the pipeline because of exception - {0}{1}.", Environment.NewLine,
                    Helper.BuildExceptionMessage(e));
                throw;
            }

            Log("All configuration loaded and pipeline is ready.");
            _detailLogger.LogLine("The configuration file can be re-written as:");
            _detailLogger.LogLine("{0}{1}", ToString(), Environment.NewLine);
        }