public bool RunScheduledCampaigns(int emailBatchSize, int smsBatchSize) { //campaignService.UpdateCampaignEmails emailCount = 0; smsCount = 0; _emailBatchSize = emailBatchSize; _smsBatchSize = smsBatchSize; var campaigns = campaignService.GetAllScheduledCampaigns(); if (campaigns != null && campaigns.Count() > 0) { var jobService = new JobService(); int jobId = jobService.AddJob(emailBatchSize, smsBatchSize); foreach (var campaign in campaigns) { SendCampaign(campaign); } jobService.FinishJob(jobId, smsCount, emailCount); return true; } return false; }
public bool CanStartJob() { JobService jobService = new JobService(); bool hasJobCompleted = jobService.IsLastJobCompleted(); ScheduleService scheduleService = new ScheduleService(); bool hasScheduledCampaigns = scheduleService.HasScheduledCampaigns(); if (hasJobCompleted && hasScheduledCampaigns) { return true; } return false; }