Example #1
0
        /// <summary/>
        /// <exclude/>
        /// <devdoc>
        /// Initialization of the service.  Start the queue listener and write status to event log.
        /// </devdoc>
        public void InitializeComponent()
        {
            try
            {
                // Use the default settings for log name and application name.
                // This is done to ensure the Windows service starts correctly.
                this.ApplicationName = DefaultApplicationName;

                this.eventLogger = new DistributorEventLogger();
                this.eventLogger.AddMessage(Resources.InitializeComponentStartedMessage, Resources.InitializeComponentStarted);
                this.status = ServiceStatus.OK;

                IConfigurationSource configurationSource = GetConfigurationSource();

                MsmqDistributorSettings distributorSettings = MsmqDistributorSettings.GetSettings(configurationSource);
                if (distributorSettings == null)
                {
                    throw new ConfigurationErrorsException(string.Format(
                                                               CultureInfo.CurrentCulture,
                                                               Resources.ExceptionCouldNotFindConfigurationSection,
                                                               MsmqDistributorSettings.SectionName));
                }

                this.queueListener = CreateListener(this, distributorSettings.QueueTimerInterval, distributorSettings.MsmqPath);

                this.ApplicationName = this.ServiceName;
                this.ApplicationName = distributorSettings.ServiceName;
                this.eventLogger.AddMessage(NameTag, this.ApplicationName);

                this.eventLogger.EventSource = this.ApplicationName;
                this.eventLogger.AddMessage(Resources.InitializeComponentCompletedMessage, Resources.InitializeComponentCompleted);
            }
            catch (LoggingException loggingException)
            {
                this.eventLogger.LogServiceFailure(
                    string.Format(CultureInfo.CurrentCulture, Resources.ServiceStartError, this.ApplicationName),
                    loggingException,
                    TraceEventType.Error);

                throw;
            }
            catch (Exception ex)
            {
                this.eventLogger.LogServiceFailure(
                    string.Format(CultureInfo.CurrentCulture, Resources.ServiceStartError, this.ApplicationName),
                    ex,
                    TraceEventType.Error);

                throw new LoggingException(Resources.ErrorInitializingService, ex);
            }
        }
Example #2
0
        /// <summary/>
        /// <exclude/>
        /// <devdoc>
        /// Initialization of the service.  Start the queue listener and write status to event log.
        /// </devdoc>
        public void InitializeComponent()
        {
            try
            {
                // Use the default settings for log name and application name.
                // This is done to ensure the windows service starts correctly.
                this.ApplicationName = DefaultApplicationName;

                this.eventLogger = new DistributorEventLogger();
                this.eventLogger.AddMessage(SR.InitializeComponentStartedMessage, SR.InitializeComponentStarted);
                this.status = ServiceStatus.OK;

                DistributorSettings distributorSettings = (DistributorSettings)ConfigurationManager.GetConfiguration(DistributorSettings.SectionName);

                this.queueListener = new MsmqListener(this, distributorSettings.DistributorService.QueueTimerInterval);

                //this.ApplicationName = this.ServiceName;
                this.ApplicationName = distributorSettings.DistributorService.ServiceName;
                this.eventLogger.AddMessage("name", this.ApplicationName);

                this.eventLogger.ApplicationName = this.ApplicationName;
                this.eventLogger.AddMessage(SR.InitializeComponentCompletedMessage, SR.InitializeComponentCompleted);
            }
            catch (LoggingException loggingException)
            {
                this.eventLogger.AddMessage(Header, SR.ServiceStartError(this.ApplicationName));

                this.eventLogger.WriteToLog(loggingException, Severity.Error);
                throw;
            }
            catch (Exception ex)
            {
                this.eventLogger.AddMessage(Header, SR.ServiceStartError(this.ApplicationName));

                this.eventLogger.WriteToLog(ex, Severity.Error);
                throw new LoggingException(SR.ErrorInitializingService, ex);
            }
            catch
            {
                throw new LoggingException(SR.ErrorInitializingService);
            }
        }
Example #3
0
        /// <summary/>
        /// <exclude/>
        /// <devdoc>
        /// Initialization of the service.  Start the queue listener and write status to event log.
        /// </devdoc>
        public void InitializeComponent()
        {
            try
            {
                // Use the default settings for log name and application name.
                // This is done to ensure the windows service starts correctly.
                this.ApplicationName = DefaultApplicationName;

                this.eventLogger = new DistributorEventLogger();
                this.eventLogger.AddMessage(Resources.InitializeComponentStartedMessage, Resources.InitializeComponentStarted);
                this.status = ServiceStatus.OK;

                IConfigurationSource configurationSource = GetConfigurationSource();

                MsmqDistributorSettings distributorSettings = MsmqDistributorSettings.GetSettings(configurationSource);
                if (distributorSettings == null)
                {
                    throw new ConfigurationErrorsException(string.Format(
                            Resources.Culture,
                            Resources.ExceptionCouldNotFindConfigurationSection,
                            MsmqDistributorSettings.SectionName));
                }

                this.queueListener = CreateListener(this, distributorSettings.QueueTimerInterval, distributorSettings.MsmqPath);

                this.ApplicationName = this.ServiceName;
                this.ApplicationName = distributorSettings.ServiceName;
                this.eventLogger.AddMessage(NameTag, this.ApplicationName);

                this.eventLogger.ApplicationName = this.ApplicationName;
                this.eventLogger.AddMessage(Resources.InitializeComponentCompletedMessage, Resources.InitializeComponentCompleted);
            }
            catch (LoggingException loggingException)
            {
                this.eventLogger.LogServiceFailure(
                    string.Format(Resources.Culture, Resources.ServiceStartError, this.ApplicationName),
                    loggingException,
                    TraceEventType.Error);

                throw;
            }
            catch (Exception ex)
            {
                this.eventLogger.LogServiceFailure(
                    string.Format(Resources.Culture, Resources.ServiceStartError, this.ApplicationName),
                    ex,
                    TraceEventType.Error);

                throw new LoggingException(Resources.ErrorInitializingService, ex);
            }
        }
Example #4
0
        /// <summary/>
        /// <exclude/>
        /// <devdoc>
        /// Initialization of the service.  Start the queue listener and write status to event log.
        /// </devdoc>
        public void InitializeComponent()
        {
            try
            {
                // Use the default settings for log name and application name.
                // This is done to ensure the windows service starts correctly.
                this.ApplicationName = DefaultApplicationName;

                this.eventLogger = new DistributorEventLogger();
                this.eventLogger.AddMessage(SR.InitializeComponentStartedMessage, SR.InitializeComponentStarted);
                this.status = ServiceStatus.OK;

                DistributorSettings distributorSettings = (DistributorSettings)ConfigurationManager.GetConfiguration(DistributorSettings.SectionName);

                this.queueListener = new MsmqListener(this, distributorSettings.DistributorService.QueueTimerInterval);

                //this.ApplicationName = this.ServiceName;
                this.ApplicationName = distributorSettings.DistributorService.ServiceName;
                this.eventLogger.AddMessage("name", this.ApplicationName);

                this.eventLogger.ApplicationName = this.ApplicationName;
                this.eventLogger.AddMessage(SR.InitializeComponentCompletedMessage, SR.InitializeComponentCompleted);
            }
            catch (LoggingException loggingException)
            {
                this.eventLogger.AddMessage(Header, SR.ServiceStartError(this.ApplicationName));

                this.eventLogger.WriteToLog(loggingException, Severity.Error);
                throw;
            }
            catch (Exception ex)
            {
                this.eventLogger.AddMessage(Header, SR.ServiceStartError(this.ApplicationName));

                this.eventLogger.WriteToLog(ex, Severity.Error);
                throw new LoggingException(SR.ErrorInitializingService, ex);
            }
            catch
            {
                throw new LoggingException(SR.ErrorInitializingService);
            }
        }