iSchedulerHangfire.cs 1.49 KB
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Hangfire;
using Vrh.iScheduler;

namespace Vrh.Web.iScheduler
{
    public class iSchedulerHangfire
    {
        public iSchedulerHangfire(BackgroundJobServer backgroundserver)
        {
            string ischedulerMonitorXml = "config=ALMiSchedulerMonitor";//TODO:hogy lehet ezt paraméterben átadni??????
            string ischedulerXml = ""; // vagy "config=ALMiScheduler;"; 
            var m_xmlp = new iSchedulerXMLProcessor(ischedulerMonitorXml, ischedulerXml);
            if (m_xmlp.EnableWebAppExecution && m_xmlp.CheckInterval > 0)
            {
                string intervalcron = Cron.MinuteInterval((int)(m_xmlp.CheckInterval / 60));//"*/1 * * * *"

                //C:\Windows\system32>%windir%\system32\inetsrv\appcmd set config /section:applicationPools /[name='Log4ProIS'].autoStart:true

                _backgroundJobServer = backgroundserver ?? (new BackgroundJobServer());
                BackgroundJob.Enqueue(() => new Monitor(m_xmlp).Examination(null));
                //RecurringJob.AddOrUpdate("ischedulermonitorcycle", () => new Monitor(m_xmlp).Examination(null), intervalcron); //minutes interval
                //RecurringJob.AddOrUpdate("ischedulermonitorcycle", () => new Monitor(m_xmlp).Examination(null), $"{(int)(m_xmlp.CheckInterval / 60)} * * * *"); // cron expression
            }
        }
        private BackgroundJobServer _backgroundJobServer;
    }
}