public void should_return_current_on_active_notifications() { var fakeNotification = new ProgressNotification("Title"); _notificationProvider.Register(fakeNotification); _notificationProvider.GetCurrent().Should().Be(fakeNotification); }
private void Execute(JobQueueItem queueItem) { var jobImplementation = _jobs.SingleOrDefault(t => t.GetType() == queueItem.JobType); if (jobImplementation == null) { logger.Error("Unable to locate implementation for '{0}'. Make sure it is properly registered.", queueItem.JobType); return; } var settings = All().Where(j => j.TypeName == queueItem.JobType.ToString()).Single(); using (_notification = new ProgressNotification(jobImplementation.Name)) { try { logger.Debug("Starting {0}. Last execution {1}", queueItem, settings.LastExecution); var sw = Stopwatch.StartNew(); _notificationProvider.Register(_notification); jobImplementation.Start(_notification, queueItem.Options); _notification.Status = ProgressNotificationStatus.Completed; settings.LastExecution = DateTime.Now; settings.Success = true; sw.Stop(); logger.Debug("Job {0} successfully completed in {1:0}.{2} seconds.", queueItem, sw.Elapsed.TotalSeconds, sw.Elapsed.Milliseconds / 100, sw.Elapsed.Seconds); } catch (ThreadAbortException) { throw; } catch (Exception e) { logger.ErrorException("An error has occurred while executing job [" + jobImplementation.Name + "].", e); _notification.Status = ProgressNotificationStatus.Failed; _notification.CurrentMessage = jobImplementation.Name + " Failed."; settings.LastExecution = DateTime.Now; settings.Success = false; } } //Only update last execution status if was triggered by the scheduler if (queueItem.Options == null) { SaveDefinition(settings); } }