Esempio n. 1
0
        private void InitializeScheduler()
        {
            _cronObjectList  = new List <CronObject>();
            _serviceSettings = new ServiceSettings("");
            _serviceLogger   = new Logging.TaskLogging();
            if (!_serviceSettings.EnableScheduler)
            {
                _serviceLogger.CreateLogRecord("Shceduller start forbidden by ServiceSettings.enableScheduler");
                return;
            }

            foreach (var type in Tasks.TasksEnumerator.GetTaskEnumertor())
            {
                var task = Activator.CreateInstance(type) as TaskBase;
                foreach (var group in new SettingsGroupsCollection(task.TaskSettings))
                {
                    if (!(bool)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameEnable(task, group)))
                    {
                        continue;
                    }
                    try
                    {
                        _cronObjectList.Add(CreateCronObject(type, group, (string)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameShedule(task, group))));
                    }
                    catch (Exception e)
                    {
                        _serviceLogger.CreateLogRecord(e);
                    }
                }
            }
        }
Esempio n. 2
0
 private void Cron_OnCronTrigger(CronObject cronObject)
 {
     if (cronObject == null)
     {
         return;
     }
     // ReSharper disable once AssignNullToNotNullAttribute
     try
     {
         var cronObjectHelper = (CronObjectHelper)cronObject.Object;
         var task             = Activator.CreateInstance(cronObjectHelper.TaskType) as TaskBase;
         task?.ExecuteTask(cronObjectHelper.GroupName,
                           (bool)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameReport(task, cronObjectHelper.GroupName)),
                           (int)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameSendReportInterval(task, cronObjectHelper.GroupName)) * 60,
                           (System.Diagnostics.EventLogEntryType)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameReportInformationLevel(task, cronObjectHelper.GroupName)),
                           (uint)_serviceSettings.GetPropertyValue(ServiceSettings.GetSettingNameMaxErrorCount(task, cronObjectHelper.GroupName)));
     }
     catch (Exception e) { _serviceLogger.CreateLogRecord(e); }
 }