Beispiel #1
0
        public void Execute(SlashCommand command)
        {
            try
            {
                Entities.Merge merge = Slack.MessageParser.ForMerge(command);

                merge.Verify();

                Entities.Queue queue = new Entities.Queue() { MaxWokers = 1, Name = merge.Target };
                queueBLL.Insert(queue);

                long enqueuedCount = Hangfire.JobStorage.Current.GetMonitoringApi().EnqueuedCount(queue.Name);

                IBackgroundJobClient client = new BackgroundJobClient();
                IState state = new EnqueuedState(queue.Name);

                client.Create<BusinessLogic.Merge.Base.ITrigger>(x => x.Execute(command), state);

                if(enqueuedCount > 0)
                {
                    slackBLL.DirectMessage(command, $"There {(enqueuedCount > 1 ? "are" : "is")} {enqueuedCount} {(enqueuedCount > 1 ? "merges" : "merge")} ahead of yours.");
                }
            }
            catch(ArgumentException ex)
            {
                slackBLL.DirectMessage(command, $"Failed to schedule merge: {ex.Message}");
            }
        }
Beispiel #2
0
        private static void HandleInput(ConsoleKeyInfo input )
        {


            /*if (input.KeyChar.Equals('s'))
            {


                var newInput = Console.ReadKey();
                HandleInput(newInput);
            }
            else*/ if (input.KeyChar.Equals('q'))
            {
                BackgroundJobClient c = new BackgroundJobClient(_storage);

                //RecurringJob.AddOrUpdate(()=>MyJob.DoSomething(),Cron.
                var b = new BackgroundJobClient(_storage);
                //b.Enqueue(() => Console.WriteLine("my job"));

                c.Enqueue(() => LaunchAppJob.Launch(@"C:\TFSDATA\KissTheFuture\Trunk\shopping.lacage.be\shoppingconsole.lacage.be\bin\Debug\shoppingconsole.lacage.be.exe"));//, new Hangfire.States.EnqueuedState("backgroundsynchro"));
                //c.Enqueue(() => Console.Write('q'));
                Console.WriteLine("Hangfire job enqueued. Press any key to exit...");
                       //Thread.Sleep(5000);                               

                var newInput = Console.ReadKey();
                HandleInput(newInput);
            }


        }
Beispiel #3
0
 public void CreateInEnqueuedState()
 {
     #region EnqueuedState #1
     var client = new BackgroundJobClient();
     var state = new EnqueuedState("critical"); // Use the "critical" queue
      
     client.Create(() => Console.WriteLine("Hello!"), state);
     #endregion
 }
Beispiel #4
0
        public void CreateInScheduledState()
        {
            #region ScheduledState
            var client = new BackgroundJobClient();
            var state = new ScheduledState(TimeSpan.FromHours(2));

            client.Create(() => Console.WriteLine("Hello!"), state);
            #endregion
        }
Beispiel #5
0
        public void ChangeToDeletedState()
        {
            #region DeletedState
            var client = new BackgroundJobClient();
            var jobId = client.Enqueue(() => Console.WriteLine("Hello"));

            var state = new DeletedState();
            client.ChangeState(jobId, state, EnqueuedState.StateName);
            #endregion
        }
Beispiel #6
0
        public void ChangeToEnqueuedState()
        {
            var jobId = "someid";

            #region EnqueuedState #2
            var client = new BackgroundJobClient();
            var state = new EnqueuedState(); // Use the default queue
            
            client.ChangeState(jobId, state, FailedState.StateName);
            #endregion
        }