Пример #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, ILoggerFactory loggerFactory,
                              UsersConfig usersConfig)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }

            app.UseStaticFiles();

            app.UseIdentity();

            // Add external authentication middleware below. To configure them please see https://go.microsoft.com/fwlink/?LinkID=532715

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            usersConfig.SeedAsync();
        }
        // TODO: move the localhost address to single place and use that so that we don't need to write it to a million places

        // This method gets called by the runtime. Use this method to add services to the container.
        // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940
        public void ConfigureServices(IServiceCollection services)
        {
            // add MVC
            services.AddMvc();
            // CORS
            services.AddCors();

            // setup IdentityServer to use the in memory configurations
            services.AddIdentityServer()
            .AddDeveloperSigningCredential()
            .AddInMemoryIdentityResources(IdentityResourcesConfig.GetIdentityResources())
            .AddInMemoryClients(ClientsConfig.GetClients())
            .AddTestUsers(UsersConfig.GetUsers());
        }
        /// <summary>
        /// 日报检测
        /// </summary>
        public override void Check()
        {
            if (SetCookies())
            {
                var users = UsersConfig.GetAllUsers();

                users.ForEach(f =>
                {
                    var listModels = GetList(f.Name);
                    var str        = DateTime.Now.ToString("yyyyMMdd");
                    var result     = listModels.Any(p => p.BillDate == str);

                    if (!result)
                    {
                        string title   = $"{DateTime.Now.ToString("yyyy-MM-dd")} 日报填写提醒";
                        string content = $"Hi,{ DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss")} 检测到你没有填写日报,请安排时间前往 http://192.168.1.7/EIPDevManager/Login 填写!";
                        EmailHelper.SendEmail(title, content, f.Name, f.Email);
                    }
                });
            }
        }
 /// <summary>
 /// 通过构造函数注入配置信息。
 /// 当 app.json 有配置时,会进行反序列化。
 /// 若 app.json 没有相关配置或没有 app.json 文件时,会使用默认值
 /// </summary>
 /// <param name="usersConfig"></param>
 public DefaultUserService(UsersConfig usersConfig)
 {
     this.usersConfig = usersConfig;
 }