public static void CreateCronJob(UserConnection userConnection, string cronExpression, string jobName,
                                  string jobGroupName, string processName, IDictionary <string, object> parameters,
                                  bool isSystemUser = false, bool useMisfireInstructionFireOnceNow = false)
 {
     MailingSchedulerUtilities.CreateCronJob(userConnection, cronExpression, jobName, jobGroupName,
                                             processName, parameters, isSystemUser, useMisfireInstructionFireOnceNow);
 }
Example #2
0
        /// <summary>
        /// Creates instance of the handler.
        /// </summary>
        /// <param name="userConnection">Instance of user connection.</param>
        public override void CreateInstance(UserConnection userConnection)
        {
            int interval = GetInterval(userConnection);

            MailingSchedulerUtilities.CreateJob(userConnection, JobName, JobGroupName, ProcessName, interval,
                                                null, false, true);
        }
 public static void CreateJob(UserConnection userConnection, string jobName, string jobGroupName,
                              string processName, int periodInMinutes, IDictionary <string, object> parameters = null,
                              bool isSystemUser = false,
                              bool useMisfireInstructionFireOnceNow = false)
 {
     MailingSchedulerUtilities.CreateJob(userConnection, jobName, jobGroupName, processName, periodInMinutes,
                                         parameters, isSystemUser, useMisfireInstructionFireOnceNow);
 }
Example #4
0
 private void CreateCronJob(UserConnection userConnection)
 {
     if (IsScheduledJobExists())
     {
         RemoveInstance();
     }
     MailingSchedulerUtilities.CreateCronJob(userConnection, CronExpression, JobName, JobGroupName,
                                             ProcessName, null, false, true);
 }
Example #5
0
        private void CreateScheduledJob(UserConnection userConnection)
        {
            if (IsCronJobExists())
            {
                RemoveInstance();
            }
            int hoursInterval    = GetInterval(userConnection);
            int minutelyInterval = ConvertHoursToMinutes(hoursInterval);

            MailingSchedulerUtilities.CreateJob(userConnection, JobName, JobGroupName, ProcessName,
                                                minutelyInterval, null, false, true);
        }
 /// <summary>
 /// Creates instance of the handler.
 /// </summary>
 /// <param name="userConnection">Instance of user connection.</param>
 public override void CreateInstance(UserConnection userConnection)
 {
     try {
         MailingSchedulerUtilities.CreateCronJob(userConnection, CronExpression, JobName, JobGroupName,
                                                 ProcessName, null, true, true);
         MailingUtilities.Log.InfoFormat("[ActiveContactsHandler.CreateInstance]: Job {0} " +
                                         "for process {1} scheduled", JobName, ProcessName);
     } catch (Exception exception) {
         MailingUtilities.Log.ErrorFormat("[ActiveContactsHandler.CreateInstance]: Error while scheduling " +
                                          "job {0}", exception, JobName);
         throw;
     }
 }
Example #7
0
 /// <summary>
 /// Creates instance of the handler.
 /// </summary>
 /// <param name="userConnection">Instance of user connection.</param>
 public override void CreateInstance(UserConnection userConnection)
 {
     try {
         int interval = GetInterval(userConnection);
         MailingSchedulerUtilities.CreateJob(userConnection, JobName, JobGroupName, ProcessName, interval,
                                             null, true, true);
         MailingUtilities.Log.InfoFormat("[ScheduledMailingsHandler.CreateInstance]: Job {0} for " +
                                         "process {1} with interval {2} scheduled", JobName, ProcessName, interval);
     } catch (Exception exception) {
         MailingUtilities.Log.ErrorFormat("[ScheduledMailingsHandler.CreateInstance]: Error while scheduling " +
                                          "job {0}", exception, JobName);
         throw;
     }
 }
        /// <summary>
        /// Schedules bulk email from send queue to sent.
        /// </summary>
        public void ScheduleBulkEmailsFromSendQueue()
        {
            IEnumerable <Guid> bulkEmailIds = GetBulkEmailsFromSendQueue();

            foreach (Guid entityId in bulkEmailIds)
            {
                string     jobName   = GetJobName(entityId);
                IJobDetail jobDetail = MailingSchedulerUtilities.FindJob(jobName, JobGroupName);
                if (jobDetail != null)
                {
                    continue;
                }
                ShiftTriggerEmailStartDate(entityId, TriggerEmailStartDateShift);
                ScheduleImmediateJob(jobName, entityId);
            }
        }
        /// <summary>
        /// Retrieves all mailing sessions that are broken.
        /// </summary>
        /// <param name="userConnection">The user connection.</param>
        /// <param name="jobGroupName">The name of job group.</param>
        /// <returns>Dictionary with sessisonId as a key and bulkEmailId as a value</returns>
        private Dictionary <Guid, Guid> GetBrokenTriggerEmailSessions(UserConnection userConnection, string jobGroupName)
        {
            var brokenSessions = new Dictionary <Guid, Guid>();
            Dictionary <Guid, Guid> emailSessions = GetTriggerEmailInProgress(userConnection);

            foreach (var session in emailSessions)
            {
                string jobName = MailingSchedulerUtilities.GetTriggerEmailJobName(session.Value, session.Key);
                if (MailingSchedulerUtilities.FindJob(jobName, jobGroupName) != null)
                {
                    continue;
                }
                brokenSessions.Add(session.Key, session.Value);
            }
            return(brokenSessions);
        }
        /// <summary>
        /// Creates immediately job that executes the SendImmediatelyTriggeredEmailProcess process.
        /// </summary>
        /// <param name="userConnection">Instance of the <see cref="Terrasoft.Core.UserConnection"/>.</param>
        /// <param name="parameters">Set of the process parameters.</param>
        public static void CreateSendEmailImmediatelyJob(UserConnection userConnection,
                                                         IDictionary <string, object> parameters)
        {
            var jobName = string.Format(SendEmailImmediatelyJobNamePattern, Guid.NewGuid());

            try {
                MailingSchedulerUtilities.CreateImmediatelyJob(userConnection, jobName,
                                                               SendEmailImmediatelyJobGroupName, SendImmediatelyTriggeredEmailProcessName, parameters);
                MailingUtilities.Log.InfoFormat("[CampaignHelper.CreateSendEmailImmediatelyJob]: " +
                                                "Job {0} for process {1}", jobName, SendImmediatelyTriggeredEmailProcessName);
            } catch (Exception exception) {
                MailingUtilities.Log.ErrorFormat("[CampaignHelper.CreateSendEmailImmediatelyJob]: " +
                                                 "Error while scheduling job {0}", exception, jobName);
                throw;
            }
        }
        private void HandleBrokenTriggerEmailSessions(UserConnection userConnection)
        {
            string jobGroupName = MailingSchedulerUtilities.BulkEmailJobGroupName;
            Dictionary <Guid, Guid> brokenSessions = GetBrokenTriggerEmailSessions(userConnection, jobGroupName);

            if (brokenSessions.Count <= 0)
            {
                return;
            }
            MailingUtilities.Log.InfoFormat("[TriggerEmailFailoverHandler.HandleBrokenTriggerEmailSessions]: " +
                                            "Found {0} broken sessions.", brokenSessions.Count);
            foreach (var session in brokenSessions)
            {
                MailingSchedulerUtilities.CreateCampaignBulkEmailJob(userConnection, session.Value, session.Key);
                MailingUtilities.Log.InfoFormat("[TriggerEmailFailoverHandler.HandleBrokenTriggerEmailSessions]: " +
                                                "Job restored for SessionId: {0} BulkEmailId: {1}", session.Key, session.Value);
            }
        }
 public static void CreateImmediatelyJob(UserConnection userConnection, string jobName, string jobGroupName,
                                         string processName, IDictionary <string, object> parameters)
 {
     MailingSchedulerUtilities.CreateImmediatelyJob(userConnection, jobName, jobGroupName, processName,
                                                    parameters);
 }
 public static IJobDetail FindJob(string jobName, string jobGroupName)
 {
     return(MailingSchedulerUtilities.FindJob(jobName, jobGroupName));
 }