コード例 #1
0
ファイル: Startup.cs プロジェクト: sepehr500/WeatherMob
        // 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)
        {
            loggerFactory.AddConsole(Configuration.GetSection("Logging"));
            loggerFactory.AddDebug();


            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseDatabaseErrorPage();
                app.UseBrowserLink();
            }
            else
            {
                app.UseExceptionHandler("/Home/Error");
            }
            app.UseHangfireServer();
            RecurringJob.AddOrUpdate(() => RecordActualWeather.GetActualWeather(), Cron.MinuteInterval(1));
            RecurringJob.AddOrUpdate(() => DayUpdate.Update(), Cron.HourInterval(1));
            app.UseHangfireDashboard();
            app.UseStaticFiles();

            app.UseIdentity();

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

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });
        }
コード例 #2
0
        private DayUpdate CreateRemainingAndTotalAndDistractions()
        {
            DayUpdate previousUpdate = null;

            for (int ix = 0; ix < updates.Count; ix++)
            {
                if (ix == 0)
                {
                    previousUpdate = new DayUpdate
                    {
                        Hours = tasks.Sum(t => t.Hours)
                    };
                }
                else
                {
                    previousUpdate = updates[ix - 1];
                }

                var update    = updates[ix];
                var worked    = previousUpdate.Hours - update.Hours;
                var remaining = hoursPerDay - worked;

                RemainingHours.Updates.Add(new TaskTotalUpdateViewModel
                {
                    Date  = update.Date.Date,
                    Hours = update.Hours
                });

                TotalWorked.Updates.Add(new TaskTotalUpdateViewModel
                {
                    Date  = update.Date.Date,
                    Hours = worked
                });

                Distractions.Updates.Add(new TaskTotalUpdateViewModel
                {
                    Date  = update.Date.Date,
                    Hours = remaining
                });
            }
            return(previousUpdate);
        }