public static void StartUp()
 {
     using (var context = new ScheduleMasterContext())
     {
         var jobs = context.JobConfigurations.Take(10).ToList();
     }
 }
Exemplo n.º 2
0
        public void Configuration(IAppBuilder app)
        {
            //just to create db very quick
            using (var db = new ScheduleMasterContext())
            {
                var a = db.ActionConfigurations.OfType <EmailActionConfiguration>().FirstOrDefault();
            }

            //Hangfire
            app.UseHangfireDashboard("/hangfire", new DashboardOptions
            {
                AuthorizationFilters = new[] { new HangfireRestrictiveAuthorizationFilter() }
            });
        }
Exemplo n.º 3
0
        public bool Execute(int jobId)
        {
            var jobConfiguration = new ScheduleMasterContext().JobConfigurations.Include(c => c.ActionConfigurations).SingleOrDefault(p => p.Id == jobId);

            using (var sqsClient = CreateSqsClient(jobConfiguration))
            {
                var messages = sqsClient.Pop(jobConfiguration.NumberOfDequeueMessages);

                if (messages.Count == 0)
                {
                    return(false);
                }

                var commands = GetCommands(jobConfiguration, messages.ToArray());

                var tasks = new List <Task <bool> >();

                foreach (var command in commands)
                {
                    tasks.Add(command.ExecuteAsync());
                }

                Task.WaitAll(tasks.ToArray());

                if (tasks.Any(p => p.Result == false))
                {
                    return(false);
                }

                if (jobConfiguration.DeleteMessageAfterSuccess)
                {
                    DeleteMessagesFromQueue(sqsClient, messages);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
 protected BaseController()
 {
     _database = new ScheduleMasterContext();
 }