Ejemplo n.º 1
0
        private void btnJobStart_Click(object sender, EventArgs e)
        {
            if (string.IsNullOrEmpty(txtTaskID.Text))
            {
                MessageBox.Show("任务ID不能为空");
                return;
            }

            string taskID = txtTaskID.Text.Trim();

            TaskEntity taskEntity = taskBll.Find(taskID);

            if (taskEntity == null)
            {
                MessageBox.Show("任务ID系统中不存在");
                return;
            }

            FtpConfigEntity ftpConfigEntity = ftpBll.GetFirstFtpInfo();

            taskEntity.FtpConfig = ftpConfigEntity;

            //构造数据文件产品并执行
            DbFileProductDirector director       = new DbFileProductDirector();
            ADbFileProductBuilder productBuilder = new DbFileProductBuilder();

            director.ConstructProduct(productBuilder);
            DbFileProduct product = productBuilder.GetDbFileProduct();

            product.Execute(taskEntity, cts.Token);
        }
Ejemplo n.º 2
0
        public void Execute(IJobExecutionContext context)
        {
            try
            {
                TaskEntity        orgTaskEntity = context.JobDetail.JobDataMap["TaskParam"] as TaskEntity;
                TaskEntity        taskEntity    = QuartzBase.GetCurrentTaskList().Find(item => item.TaskID == orgTaskEntity.TaskID);
                CancellationToken ct            = (CancellationToken)context.JobDetail.JobDataMap["CanellationTokenParam"];

                //构造数据文件产品并执行
                DbFileProductDirector director       = new DbFileProductDirector();
                ADbFileProductBuilder productBuilder = Common.GetDbFileProductBuilder();
                director.ConstructProduct(productBuilder);
                DbFileProduct product = productBuilder.GetDbFileProduct();
                product.Execute(taskEntity, ct);
            }
            catch (Exception ex)
            {
                LogUtil.WriteLog($"TaskJob作业类出现异常,异常信息:[{ex.Message}][{ex.StackTrace}]");

                JobExecutionException jex = new JobExecutionException(ex);
                //立即重新执行任务
                jex.RefireImmediately = true;
            }
        }