Пример #1
0
        public static void Start()
        {
            logger.Info("Conectandose a las bases de datos...");

            CreateRepositories();

            var cronExpression = ConfigurationManager.AppSettings["scheduleConfig"];

            logger.InfoFormat("Configurando servicio con la expresión '{0}'...", cronExpression);

            _schedulingService            = new SchedulingService();
            _schedulingService.LogFactory = new LogFactory();

            _schedulingService.At(cronExpression).Run(() =>
            {
                if (!_isRunning)
                {
                    _isRunning = true;

                    return(new ClientJob(
                               _clientRepository,
                               () =>
                    {
                        _isRunning = false;
                    }));
                }
                return(new DumClientJob());
            });
            _schedulingService.Start();

            logger.Info("Servicio corriendo...");
        }
Пример #2
0
 private static void ServiceSetup(ISchedulingService service)
 {
     var crontab = ConfigurationManager.AppSettings["crontab"];
     service
         .At(crontab)
         .Run<Job>()
         .Named("mongo");
 }
Пример #3
0
        static void ServiceSetup(ISchedulingService service)
        {
            service.LogFactory = new NCron.Integration.log4net.LogFactory();

            string cron = ConfigurationManager.AppSettings["cron"].ToString();

            service.At(cron).Run <MyJob>();
        }
Пример #4
0
 /// <summary>
 /// Creates a new schedule executing once every month.
 /// </summary>
 /// <param name="service">The service to which the schedule should be added.</param>
 /// <returns>A part that allows chained fluent method calls.</returns>
 public static SchedulePart Monthly(this ISchedulingService service)
 {
     return(service.At("42 4 1 * *"));
 }
Пример #5
0
 /// <summary>
 /// Creates a new schedule executing once every week.
 /// </summary>
 /// <param name="service">The service to which the schedule should be added.</param>
 /// <returns>A part that allows chained fluent method calls.</returns>
 public static SchedulePart Weekly(this ISchedulingService service)
 {
     return(service.At("22 4 * * 0"));
 }
Пример #6
0
 /// <summary>
 /// Creates a new schedule executing once every day.
 /// </summary>
 /// <param name="service">The service to which the schedule should be added.</param>
 /// <returns>A part that allows chained fluent method calls.</returns>
 public static SchedulePart Daily(this ISchedulingService service)
 {
     return(service.At("02 4 * * *"));
 }
Пример #7
0
 /// <summary>
 /// Creates a new schedule executing once every hour.
 /// </summary>
 /// <param name="service">The service to which the schedule should be added.</param>
 /// <returns>A part that allows chained fluent method calls.</returns>
 public static SchedulePart Hourly(this ISchedulingService service)
 {
     return(service.At("01 * * * *"));
 }
Пример #8
0
        /// <summary>
        /// Creates a new schedule based on a crontab expression (eg: 0 0 * * *).
        /// Please refer to the project wiki for examples.
        /// </summary>
        /// <param name="service">The service to which the schedule should be added.</param>
        /// <param name="crontab">A crontab expression describing the schedule.</param>
        /// <returns>A part that allows chained fluent method calls.</returns>
        public static SchedulePart At(this ISchedulingService service, string crontab)
        {
            var schedule = CrontabSchedule.Parse(crontab);

            return(service.At(schedule.GetNextOccurrence));
        }
Пример #9
0
 static void ServiceSetup(ISchedulingService service)
 {
     service.At("*/5 * * * *").Run(() => new ReceiverJob());
     service.At("*/5 * * * *").Run(() => new PublisherJob());
 }
Пример #10
0
 private static void ServiceSetup(ISchedulingService schedulingService)
 {
     var taskCreator = IoC.Resolve<ITaskCreator>();
     schedulingService.At("10 * * * *").Run(() => new CreateTaskJob(taskCreator));
 }
Пример #11
0
 static void ServiceSetup(ISchedulingService service)
 {
     service.At("*/5 * * * *").Run(() => new ReceiverJob());
     service.At("*/5 * * * *").Run(() => new PublisherJob());
 }