Пример #1
0
        public static void Main(string[] args)
        {
            IHost host            = CreateHostBuilder(args).Build();
            var   serviceProvider = host.Services.CreateScope().ServiceProvider;

            NotificationScheduler.Start(serviceProvider);
            host.Run();
        }
Пример #2
0
        public static void Main(string[] args)
        {
            var logger = NLogBuilder.ConfigureNLog("nlog.config").GetCurrentClassLogger();

            try
            {
                logger.Debug("init main");
                var host = BuildWebHost(args);
                using (var scope = host.Services.CreateScope())
                {
                    var serviceProvider = scope.ServiceProvider;
                    try
                    {
                        var userManager     = serviceProvider.GetRequiredService <UserManager <ApplicationUser> >();
                        var roleManager     = serviceProvider.GetRequiredService <RoleManager <IdentityRole> >();
                        var operatorManager = serviceProvider.GetRequiredService <IOperatorManager>();
                        var codeManager     = serviceProvider.GetRequiredService <ICodeManager>();
                        var tariffManager   = serviceProvider.GetRequiredService <ITariffManager>();
                        var stopWordManager = serviceProvider.GetRequiredService <IStopWordManager>();
                        var unitOfWork      = serviceProvider.GetRequiredService <IUnitOfWork>();

                        IdentityDataInitializer.SeedData(userManager, roleManager, operatorManager, codeManager, tariffManager, stopWordManager, unitOfWork);

                        // Start Notification scheduler

                        NotificationScheduler.Start(scope.ServiceProvider);
                        MailingScheduler.Start(scope.ServiceProvider);
                    }
                    catch (Exception ex)
                    {
                        logger.Error(ex, "Stopped program because of exception");
                    }
                }
                host.Run();
            }
            catch (Exception ex)
            {
                //NLog: catch setup errors
                logger.Error(ex, "Stopped program because of exception");
                throw;
            }
            finally
            {
                // Ensure to flush and stop internal timers/threads before application-exit (Avoid segmentation fault on Linux)
                NLog.LogManager.Shutdown();
            }
        }
Пример #3
0
        public ActionResult Vote(long id)
        {
            try
            {
                NotificationScheduler.Start();
                Vote vote = _voteService.RegisterVote(User.Identity.Name, id);

                HomeViewModel model = new HomeViewModel();
                model.ScoreBoard = _voteService.GetAllTodayVotesGroupByRestaurant();
                model.SetListToJson();
                HungryUp.Mvc.Helpers.ScoreHub.Static_Send(model.ScoreBoardJson);
            }
            catch (Exception ex)
            {
                TempData["VoteMessage"] = ex.Message;
            }
            return(RedirectToAction("Index"));
        }