Ejemplo n.º 1
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            var builder = new ContainerBuilder();

            builder.RegisterControllers(typeof(MvcApplication).Assembly).PropertiesAutowired();
            Assembly asmService = Assembly.Load("TestService");

            builder.RegisterAssemblyTypes(asmService).Where(t => !t.IsAbstract).AsImplementedInterfaces();

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));
            IScheduler    sched        = new StdSchedulerFactory().GetScheduler();
            JobDetailImpl jdBossReport = new JobDetailImpl("jdTest", typeof(TestJob));

            CalendarIntervalScheduleBuilder scbuilder = CalendarIntervalScheduleBuilder.Create();

            scbuilder.WithInterval(5, IntervalUnit.Second);
            IMutableTrigger triggerBossReport = scbuilder.Build();

            triggerBossReport.Key = new TriggerKey("triggerTest");
            sched.ScheduleJob(jdBossReport, triggerBossReport);
            sched.Start();
        }
Ejemplo n.º 2
0
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            RouteConfig.RegisterRoutes(RouteTable.Routes);

            var builder = new ContainerBuilder();

            //将当前程序集中的Controller都注册
            builder.RegisterControllers(typeof(MvcApplication).Assembly).PropertiesAutowired();


            Assembly assembly = Assembly.Load("Service");

            builder.RegisterAssemblyTypes(assembly).Where(t => !t.IsAbstract && t.Name.EndsWith("Server"))
            .AsImplementedInterfaces().PropertiesAutowired();

            var container = builder.Build();

            DependencyResolver.SetResolver(new AutofacDependencyResolver(container));


            IScheduler    scheduler     = new StdSchedulerFactory().GetScheduler();
            JobDetailImpl jobDetailImpl = new JobDetailImpl("jdTest", typeof(TestJob));
            //IMutableTrigger mutableTrigger = CronScheduleBuilder.DailyAtHourAndMinute(0, 1).Build();

            CalendarIntervalScheduleBuilder scBuilder = CalendarIntervalScheduleBuilder.Create();

            scBuilder.WithInterval(10, IntervalUnit.Second);
            IMutableTrigger mutableTrigger = scBuilder.Build();

            mutableTrigger.Key = new TriggerKey("triggerTest");
            scheduler.ScheduleJob(jobDetailImpl, mutableTrigger);
            scheduler.Start();
        }
Ejemplo n.º 3
0
        private void StartQuartz()
        {
            IScheduler sched = new StdSchedulerFactory().GetScheduler();

            JobDetailImpl jobAutoConfirm            = new JobDetailImpl("jobAutoConfirm", typeof(AutoConfirmJob));
            CalendarIntervalScheduleBuilder builder = CalendarIntervalScheduleBuilder.Create();

            builder.WithInterval(2, IntervalUnit.Minute);
            IMutableTrigger triggerAutoConfirm = builder.Build();

            triggerAutoConfirm.Key = new TriggerKey("triggerAutoConfirm");
            sched.ScheduleJob(jobAutoConfirm, triggerAutoConfirm);

            sched.Start();
        }
        private IScheduleBuilder CreateScheduleWithAmountAndIntervalUnit(string amountString, string intervalUnitString, TimeZoneInfo timeZone)
        {
            var intervalUnit = GrammarHelper.GetIntervalUnitValueFromString(intervalUnitString);

            int amount = 1;

            if (amountString != null)
            {
                amount = GrammarHelper.GetAmountValueFromString(amountString);
            }

            CalendarIntervalScheduleBuilder b = CalendarIntervalScheduleBuilder.Create();

            b.WithInterval(amount, intervalUnit);

            b.PreserveHourOfDayAcrossDaylightSavings(true);
            b.SkipDayIfHourDoesNotExist(false);
            b.InTimeZone(timeZone);
            return(b);
        }
Ejemplo n.º 5
0
        void Application_Start(object sender, EventArgs e)
        {
            // 在应用程序启动时运行的代码
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            IScheduler    sched        = new StdSchedulerFactory().GetScheduler();
            JobDetailImpl jdBossReport = new JobDetailImpl("jdTest", typeof(TestJob));

            CalendarIntervalScheduleBuilder builder =
                CalendarIntervalScheduleBuilder.Create();

            builder.WithInterval(5, IntervalUnit.Second);


            IMutableTrigger triggerBossReport = builder.Build();

            triggerBossReport.Key = new TriggerKey("triggerTest");
            sched.ScheduleJob(jdBossReport, triggerBossReport);
            sched.Start();
        }