/// <summary> /// Loads the configuration. /// </summary> /// <param name="xmlNodeConfig">The XML node config.</param> public virtual void LoadConfiguration(XmlNode xmlNodeConfig) { try { // Load request subscriber general settings isEnabled = Convert.ToBoolean(xmlNodeConfig.Attributes["Enabled"].Value); stopOnFail = Convert.ToBoolean(xmlNodeConfig.Attributes["StopOnFailed"].Value); stopOnConsume = Convert.ToBoolean(xmlNodeConfig.Attributes["StopOnConsumed"].Value); stopOnProcessed = Convert.ToBoolean(xmlNodeConfig.Attributes["StopOnProcessed"].Value); regexLabel = new Regex(xmlNodeConfig.Attributes["Label"].Value); regexBody = new Regex(xmlNodeConfig.Attributes["Body"].Value); regexOperator = xmlNodeConfig.Attributes["Operator"].Value; type = xmlNodeConfig.Attributes["Type"].Value; // See if we're tracing if (this.RequestProcessor.RequestManager.RequestController.Trace) { // String builder message StringBuilder logMessage = new StringBuilder(); logMessage.AppendFormat("Loaded Request Subscriber configuration."); logMessage.AppendFormat("<br>Type: {0}", this.GetType().ToString()); logMessage.AppendFormat("<br>Enabled: {0}", isEnabled); logMessage.AppendFormat("<br>Stop On Fail: {0}", stopOnFail); logMessage.AppendFormat("<br>Stop on Consume: {0}", stopOnConsume); logMessage.AppendFormat("<br>Stop On Processed: {0}", stopOnProcessed); logMessage.AppendFormat("<br>Reg Ex Label: {0}", regexLabel); logMessage.AppendFormat("<br>Reg Ex Body: {0}", regexBody); logMessage.AppendFormat("<br>Reg Ex Operator: {0}", regexOperator); // Log debug information (using HTML file format) Logger.Write(new LogEntry( logMessage.ToString(), "Request Management Trace", 0, 0, TraceEventType.Information, "Request Management Trace", null)); } // If we're enabled load remaining settings if (IsEnabled) { // Load subscriber custom settings RequestController.LoadCustomSettings(xmlNodeConfig.SelectSingleNode("CustomSettings"), customSettings); // Load the filters for this subscriber LoadFilters(xmlNodeConfig.SelectSingleNode("Filters")); } } catch (Exception ex) { // Log that we failed to start if (ExceptionPolicy.HandleException(ex, "Request Management")) { // Rethrow the exception throw; } } }
/// <summary> /// Loads the configuration. /// </summary> /// <param name="xmlNodeConfig">The XML node config.</param> internal virtual void LoadConfiguration(XmlNode xmlNodeConfig) { // Load request manager general settings isEnabled = Convert.ToBoolean(xmlNodeConfig.Attributes["Enabled"].Value); description = xmlNodeConfig.Attributes["Description"].Value; processorType = xmlNodeConfig.Attributes["ProcessorType"].Value; minThreads = Math.Max(Convert.ToInt32(xmlNodeConfig.Attributes["MinThreads"].Value), 1); maxThreads = Math.Max(Convert.ToInt32(xmlNodeConfig.Attributes["MaxThreads"].Value), 1); workPauseSeconds = Math.Min(Convert.ToDecimal(xmlNodeConfig.Attributes["WorkPauseSeconds"].Value), 10); shutdownPauseSeconds = Math.Min(Convert.ToDecimal(xmlNodeConfig.Attributes["ShutdownPauseSeconds"].Value), 10); consumeUnprocessed = Convert.ToBoolean(xmlNodeConfig.Attributes["ConsumeUnprocessed"].Value); maxErrors = Math.Max(Convert.ToInt32(xmlNodeConfig.Attributes["MaxErrors"].Value), 0); // See if we're tracing if (this.RequestController.Trace) { // String builder message StringBuilder logMessage = new StringBuilder(); logMessage.AppendFormat("Loaded Request Manager <b>\"{0}\"</b> configuration.", description); logMessage.AppendFormat("<br>Type: {0}", processorType); logMessage.AppendFormat("<br>Enabled: {0}", isEnabled); logMessage.AppendFormat("<br>Description: {0}", description); logMessage.AppendFormat("<br>Min Threads: {0}", minThreads); logMessage.AppendFormat("<br>Max Threads: {0}", maxThreads); logMessage.AppendFormat("<br>Work Pause Secs: {0}", workPauseSeconds); logMessage.AppendFormat("<br>Shutdown Pause Secs: {0}", shutdownPauseSeconds); logMessage.AppendFormat("<br>Consume Unprocessed: {0}", consumeUnprocessed); logMessage.AppendFormat("<br>Max Errors: {0}", maxErrors); // Log debug information (using HTML file format) Logger.Write(new LogEntry( logMessage.ToString(), "Request Management Trace", 0, 0, TraceEventType.Information, "Request Management Trace", null)); } // If we're enabled load remaining settings if (IsEnabled) { // Load request manager custom settings RequestController.LoadCustomSettings(xmlNodeConfig.SelectSingleNode("CustomSettings"), customSettings); // The constructor for request processors ConstructorInfo requestProcessorConstructor = null; // Use reflection to store the constructor of the class that implements DataProvider Type t = Type.GetType(processorType, true); // Get public instance constructor that takes a RequestManager requestProcessorConstructor = t.GetConstructor(new Type[] { typeof(RequestManager) }); // Create the request processors, one for each thread for (int i = 0; i < maxThreads; i++) { // Create the request processor and pass this request manager RequestProcessor reqProcessor = (RequestProcessor)requestProcessorConstructor.Invoke(new Object[] { this }); // See if we're tracing if (this.RequestController.Trace) { // Log debug information (using HTML file format) Logger.Write(new LogEntry( string.Format("Loading Subscribers for Request Processor <b>#{0}</b> for Request Manager <b>\"{1}\"</b>", i + 1, description), "Request Management Trace", 0, 0, TraceEventType.Information, "Request Management Trace", null)); } // Get the request processor to load its configuration reqProcessor.LoadConfiguration(xmlNodeConfig.SelectSingleNode("Subscribers")); // Add the request processor to our list of processors requestProcessors.Add(reqProcessor); } } }