Beispiel #1
0
		protected override void OnStop()
		{
            // Obtain the processor tu run
            INewsletterProcessor processor =
                (INewsletterProcessor)WindsorAccessor.Instance.Container[typeof(INewsletterProcessor)];
            SendEmail(processor.Name, "Service stopped.");

			timer.Dispose();
			WindsorAccessor.Instance.Container.Dispose();
		}
Beispiel #2
0
		private void OnElapsedTime(object sender)
		{
			// Obtain the processor tu run
			INewsletterProcessor processor =
				(INewsletterProcessor)WindsorAccessor.Instance.Container[typeof( INewsletterProcessor )];

			string errors;
			if( !processor.Execute( out errors ) )
			{
                SendEmail(processor.Name, errors);
                EventLog.WriteEntry(processor.Name, errors, EventLogEntryType.Error);
            }
		}
Beispiel #3
0
		protected override void OnStart(string[] args)
		{
#if DEBUG
			Debugger.Launch( );
			Debugger.Break( );
#endif

			timer = new Timer(
				OnElapsedTime,
				this,
				0,
				Convert.ToInt32(ConfigurationManager.AppSettings["TimeSlice"]));

            // Obtain the processor tu run
            INewsletterProcessor processor =
                (INewsletterProcessor)WindsorAccessor.Instance.Container[typeof(INewsletterProcessor)];

            if (!EventLog.SourceExists(processor.Name))
                EventLog.CreateEventSource(processor.Name, processor.Name);

            SendEmail(processor.Name, "Service started.");
		}