Пример #1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, NFineCoreDbContext context, IOptions <SenparcSetting> senparcSetting, IOptions <SenparcWeixinSetting> senparcWeixinSetting)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseAuthentication();//使用Cookie的中间件
            app.UseSession();
            app.UseStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "SystemManage",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                routes.MapRoute(
                    name: "SystemSecurity",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
                routes.MapRoute(
                    name: "WeixinManage",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "ExampleManage",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
            });

            IRegisterService register = RegisterService.Start(env, senparcSetting.Value).UseSenparcGlobal(); // 启动 CO2NET 全局注册,必须!

            register.UseSenparcWeixin(senparcWeixinSetting.Value, senparcSetting.Value);                     //微信全局注册,必须!
            register.RegisterTraceLog(ConfigTraceLog);                                                       //配置TraceLog

            #region Hangfire 定时任务
            var jobOptions = new BackgroundJobServerOptions
            {
                Queues      = new[] { "test", "default", "jobs" }, //队列名称,只能为小写
                WorkerCount = Environment.ProcessorCount * 5,      //并发任务数
                ServerName  = "hangfire1",                         //服务器名称
            };
            app.UseHangfireServer(jobOptions);
            app.UseHangfireDashboard();
            #endregion
            app.UseStatusCodePagesWithRedirects("/Errors/Http{0}"); // 绝对路径
            app.UseStaticHttpContext();
            AutoMapperConfig.RegisterMappings();
        }
Пример #2
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IHostingEnvironment env, NFineCoreDbContext context)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseAuthentication();//使用Cookie的中间件
            app.UseSession();
            app.UseStaticFiles();
            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "SystemManage",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "WeixinManage",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");

                routes.MapRoute(
                    name: "ExampleManage",
                    template: "{area:exists}/{controller=Home}/{action=Index}/{id?}");
            });

            #region Hangfire 定时任务
            app.UseHangfireServer(new BackgroundJobServerOptions {
                WorkerCount = 1
            });
            app.UseHangfireDashboard();
            //RecurringJob.AddOrUpdate<OperateLogService>(a => a.TestAsync1(), "*/1 * * * *");  //间隔1分钟执行
            //RecurringJob.AddOrUpdate<OperateLogService>(a => a.TestAsync2(), "*/2 * * * *");  //间隔2分钟执行
            //RecurringJob.AddOrUpdate<OperateLogService>(a => a.TestAsync3(), "*/3 * * * *");  //间隔3分钟执行
            //RecurringJob.AddOrUpdate<OperateLogService>(a => a.TestAsync4(), "*/4 * * * *");  //间隔4分钟执行
            //RecurringJob.AddOrUpdate<OperateLogService>(a => a.TestAsync5(), "*/5 * * * *");  //间隔5分钟执行
            #endregion

            app.UseStaticHttpContext();
            AutoMapperConfig.RegisterMappings();
        }