예제 #1
0
        public ScheduleMessageState RunTaskUntilFinished(SchedulerTask task)
        {
            ScheduleMessageState stateResult = ScheduleMessageState.None;

            using (var ctx = container.BeginLifetimeScope())
            {
                var stepsCnt = 0;
                do
                {
                    log.Info(String.Format("Starting step {0} for {1}", ++stepsCnt, task));
                    stateResult = task.Execute(ctx).Item2;
                } while (stateResult < ScheduleMessageState.Error && task.ScheduledScripts.Count > 0);
            }
            return(stateResult);
        }
예제 #2
0
        public JsonResult Execute(SchedulerTaskEntity task)
        {
            var            success = true;
            var            message = string.Empty;
            ISchedulerTask taskbll = new SchedulerTask();

            try
            {
                taskbll.Execute(task.TaskName);
            }
            catch (Exception ex)
            {
                success = false;
                message = ex.Message;
            }
            return(Json(new { success, message }));
        }
예제 #3
0
        void Loop()
        {
            while (true)
            {
                SchedulerTask task = null;
                lock (tasks) {
                    if (tasks.Count > 0)
                    {
                        task = tasks.Dequeue();
                    }
                }

                if (task == null)
                {
                    handle.WaitOne();
                }
                else
                {
                    task.Execute();
                }
                Thread.Sleep(10);
            }
        }