private void StartJob(JobBase job)
        {
            try
            {
                JobBase detailJobInfo = LoadDetailJobInfo(job.JobID, job.JobType);
                detailJobInfo.Start();
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception ex)
            {
                WriteJobException(job, this.Params.Log, "执行", ex);
            }
            finally
            {
                job.SetCurrentJobEndStatus();
                string logDetail = string.Format("定时任务[{0},{1}]在[{2}]时执行]", job.Name,
                                                 job.JobType.ToString(), DateTime.Now.ToString());

                UserOperationLog log = new UserOperationLog()
                {
                    ResourceID           = job.JobID,
                    OperationDateTime    = DateTime.Now,
                    Subject              = "定时任务执行",
                    OperationName        = job.Name,
                    OperationDescription = logDetail
                };
                UserOperationLogAdapter.Instance.Update(log);
            }
        }
Beispiel #2
0
        private async Task HandleQueue()
        {
            foreach (var job in _jobs.GetConsumingEnumerable())
            {
                _activeJob = job;

                try
                {
                    _logger.Info($"Starting the execution of job with id: {_activeJob.Id}");

                    await _activeJob.Start();
                }
                catch (Exception e)
                {
                    _logger.Error($"The exception was thrown during handling job with Id: {_activeJob.Id}", e);
                }
                finally
                {
                    _activeJob = null;
                }

                if (_isDisposed)
                {
                    break;
                }
            }
        }
Beispiel #3
0
        public void InvokeWebServiceJobTest()
        {
            WfServiceInvoker.InvokeContext["callerID"] = UuidHelper.NewUuidString();

            JobBase job = CreateInvokeServiceJob();

            job.Schedules.Add(CreateSingleTimeSchedule());

            bool canStart = job.CanStart(TimeSpan.FromSeconds(60));

            Console.WriteLine("上次执行时间{0}", job.LastExecuteTime);
            Console.WriteLine("是否可以执行{0}", canStart);
            Console.WriteLine("job [{0}] try to running...", job.Name);
            //Console.WriteLine("下次执行时间{0}", job.NextExecuteTime);

            Assert.IsTrue(canStart);
            job.Start();

            string returnValue = WfServiceInvoker.InvokeContext.GetValueRecursively("Version", string.Empty);

            Console.WriteLine("Version: {0}", returnValue);

            Assert.IsTrue(returnValue.IndexOf(WfServiceInvoker.InvokeContext.GetValue("callerID", string.Empty)) >= 0);
        }