/// <summary>
        /// Runs email mining and schedules next job.
        /// </summary>
        /// <param name="userConnection">User connection.</param>
        /// <param name="parameters">Job parameters.</param>
        public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
        {
            int timeShiftMinutes = 0;

            try {
                if (!SysSettings.GetValue <bool>(userConnection, EnableEmailMiningSysSettingsName, true))
                {
                    _log.InfoFormat("Email mining is disabled. See system settings value {0}",
                                    EnableEmailMiningSysSettingsName);
                    return;
                }
                RunMiner(userConnection);
            } catch (IncorrectConfigurationException ex) {
                _log.Error(ex.Message);
                timeShiftMinutes = IncorrectConfigurationTimeShiftMinutes;
            } catch (Exception ex) {
                LogError(ex);
                throw;
            } finally {
                int periodMin = SysSettings.GetValue(userConnection, JobPeriodSysSettingsName, 0);
                if (periodMin == 0)
                {
                    _log.Info($"SysSetting {JobPeriodSysSettingsName} equals to zero. Job will not be rescheduled.");
                }
                else
                {
                    if (timeShiftMinutes > 0)
                    {
                        _log.Warn($"Next job will be run in {periodMin + timeShiftMinutes} minutes");
                    }
                    SchedulerUtils.ScheduleNextRun(userConnection, EmailMiningAppListener.TargetJobGroupName, this,
                                                   periodMin + timeShiftMinutes);
                }
            }
        }
Example #2
0
        /// <summary>
        /// Executes the job's task.
        /// </summary>
        /// <param name="userConnection">User connection.</param>
        /// <param name="parameters">Job parameters.</param>
        public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
        {
            int frequency = SysSettings.GetValue(userConnection, JobPeriodSysSettingsName, 0);

            if (frequency == 0)
            {
                _log.Info($"SysSetting {JobPeriodSysSettingsName} equals to zero. Task cancelled and job will not be rescheduled.");
                return;
            }
            try {
                ProcessAllModels(userConnection);
            } catch (IncorrectConfigurationException ex) {
                _log.Error(ex.Message);
            } catch (Exception ex) {
                _log.ErrorFormat("Exception was thrown during ML model batch prediction job", ex);
                throw;
            } finally {
                SchedulerUtils.ScheduleNextRun(userConnection, nameof(MLBatchPredictionJob), this, frequency);
            }
        }
Example #3
0
 /// <summary>
 /// Runs ML model trainings and schedules next job.
 /// </summary>
 /// <param name="userConnection">User connection.</param>
 /// <param name="parameters">Job parameters.</param>
 public void Execute(UserConnection userConnection, IDictionary <string, object> parameters)
 {
     try {
         _trainingManager.ProcessAllModels(userConnection);
     } catch (IncorrectConfigurationException ex) {
         _log.Error(ex.Message);
     } catch (Exception ex) {
         LogError(ex);
         throw;
     } finally {
         int frequency = SysSettings.GetValue(userConnection, JobPeriodSysSettingsName, 0);
         if (frequency == 0)
         {
             _log.Info($"SysSetting {JobPeriodSysSettingsName} equals to zero. Job will not be rescheduled.");
         }
         else
         {
             SchedulerUtils.ScheduleNextRun(userConnection, nameof(MLModelTrainerJob), this, frequency);
         }
     }
 }