Esempio n. 1
0
        private void ValidateJobConfig(JobConfigDto jobConfig)
        {
            if (string.IsNullOrEmpty(jobConfig.JobName))
            {
                throw new SpriteException("JobName必须填写");
            }
            if (string.IsNullOrEmpty(jobConfig.JobGroup))
            {
                jobConfig.JobGroup = "Default";
            }

            if (jobConfig.JobExecType == EJobExecType.Api && !string.IsNullOrEmpty(jobConfig.Params))
            {
                try
                {
                    var tempParams = JsonConvert.DeserializeObject <CallApiParam>(jobConfig.Params);
                }
                catch (Exception ex)
                {
                    throw new SpriteException($"api 方法参数传递错误,{ex.Message}");
                }
            }

            switch (jobConfig.TriggerType)
            {
            case ETriggerType.Simple:
                if (!jobConfig.SimpleIntervalUnit.HasValue)
                {
                    throw new SpriteException("简单执行类型Job的需要指定循环单位");
                }
                if (!jobConfig.SimpleIntervalValue.HasValue)
                {
                    throw new SpriteException("简单执行类型Job的需要指定循环值");
                }
                break;

            case ETriggerType.Cron:
                if (string.IsNullOrEmpty(jobConfig.CronConfig))
                {
                    throw new SpriteException("Cron执行类型Job的CronConfig字段必须填写");
                }
                break;

            case ETriggerType.At:
                if (!jobConfig.StartTime.HasValue)
                {
                    throw new SpriteException("具体时间执行类型Job的需要指定执行时间");
                }
                break;
            }
        }
Esempio n. 2
0
 public async Task UpdateJob(JobConfigDto jobConfig)
 {
     ValidateJobConfig(jobConfig);
     await _jobManagerDomainService.UpdateJob(Mapper.Map <JobConfig>(jobConfig));
 }