예제 #1
0
        public Models.JobStatus GetJobStatus(int jobId)
        {
            Job job = DataAccess.Job.Load(jobId);

            if (job == null)
            {
                throw new HttpResponseException(HttpStatusCode.NotFound);
            }

            ScheduledJob jobDefinition = SendNewsLetterTask.GetJobDefinition();

            Models.JobStatus status = new JobStatus();
            status.Job           = job.Id;
            status.Name          = job.Name;
            status.EmailsSent    = job.GetWorkItemCountForStatus(JobWorkStatus.Complete);
            status.EmailsFailed  = job.GetWorkItemCountForStatus(JobWorkStatus.Failed);
            status.EmailsNotSent = job.GetWorkItemCountForStatus(JobWorkStatus.NotStarted);
            status.EmailsInQueue = job.GetWorkItemCountForStatus(JobWorkStatus.Sending);

            if (NewsletterConfigurationSection.Instance.IgnoreServiceStatus == false)
            {
                status.SchedulerIsOnline = ScheduledJob.IsServiceOnline;
            }
            else
            {
                // In a load balanced environment, you might not want
                // to report that the scheduler is not enabled, as users
                // could get confused (another server will be responsible)
                status.SchedulerIsOnline = true;
            }


            status.Status = job.Status.ToString();
            if (jobDefinition != null)
            {
                status.ScheduledTaskIsEnabled = jobDefinition.IsEnabled;
                status.ScheduledTaskNextRun   = jobDefinition.NextExecution;
                status.ScheduledTaskIsRunning = jobDefinition.IsRunning;
            }
            else
            {
                status.ScheduledTaskIsEnabled = false;
                status.ScheduledTaskNextRun   = DateTime.MinValue;
                status.ScheduledTaskIsRunning = false;
            }
            status.BatchSize = NewsLetterConfiguration.SendBatchSize;
            status.TimeStamp = DateTime.Now;

            return(status);
        }
예제 #2
0
        public Models.JobStatus GetJobStatus(int jobId)
        {
            Job job = DataAccess.Job.Load(jobId);
            if (job == null)
                throw new HttpResponseException(HttpStatusCode.NotFound);

            ScheduledJob jobDefinition = SendNewsLetterTask.GetJobDefinition();

            Models.JobStatus status = new JobStatus();
            status.Job = job.Id;
            status.Name = job.Name;
            status.EmailsSent = job.GetWorkItemCountForStatus(JobWorkStatus.Complete);
            status.EmailsFailed = job.GetWorkItemCountForStatus(JobWorkStatus.Failed);
            status.EmailsNotSent = job.GetWorkItemCountForStatus(JobWorkStatus.NotStarted);
            status.EmailsInQueue = job.GetWorkItemCountForStatus(JobWorkStatus.Sending);

            if(NewsletterConfigurationSection.Instance.IgnoreServiceStatus == false)
            {
                status.SchedulerIsOnline = ScheduledJob.IsServiceOnline;
            }
            else
            {
                // In a load balanced environment, you might not want
                // to report that the scheduler is not enabled, as users
                // could get confused (another server will be responsible)
                status.SchedulerIsOnline = true;
            }

            status.Status = job.Status.ToString();
            if (jobDefinition != null)
            {
                status.ScheduledTaskIsEnabled = jobDefinition.IsEnabled;
                status.ScheduledTaskNextRun = jobDefinition.NextExecution;
                status.ScheduledTaskIsRunning = jobDefinition.IsRunning;
            }
            else
            {
                status.ScheduledTaskIsEnabled = false;
                status.ScheduledTaskNextRun = DateTime.MinValue;
                status.ScheduledTaskIsRunning = false;
            }
            status.BatchSize = NewsLetterConfiguration.SendBatchSize;
            status.TimeStamp = DateTime.Now;

            return status;
        }