示例#1
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;
            }
        }
示例#2
0
        /// <summary>
        /// 获取当前可执行产品构造器
        /// </summary>
        /// <returns></returns>
        public static ADbFileProductBuilder GetDbFileProductBuilder()
        {
            SystemConfigService service = new SystemConfigService();

            SystemConfigEntity systemConfig = service.FindSystemConfig((int)SystemConfigs.OpenbookSysType);

            if (systemConfig.Status == 0)
            {
                throw new Exception($"系统未配置开卷系统类型");
            }

            ADbFileProductBuilder productBuilder = null;

            if (systemConfig.Status == 1)
            {
                productBuilder = new DbFileProductBuilder();
            }
            else
            {
                productBuilder = new T8DbFileProductBuilder();
            }

            return(productBuilder);
        }