public async Task <MessageModel <TasksQzDto> > Put(int id, [FromBody] TasksQzDto model) { MessageModel <TasksQzDto> response = new MessageModel <TasksQzDto>(); if (model == null) { throw new ArgumentNullException("model"); } var app = await _tasksQzService.GetAsync(model.Id); if (app == null) { return(new MessageModel <TasksQzDto>() { success = false, msg = "未找到对应的作业项。" }); } //检查一下 任务是否在运行,运行中不能修改 if (app.IsStart) { return(new MessageModel <TasksQzDto>() { success = false, msg = "请先停止作业,再尝试修改。" }); } app = _mapper.Map <TasksQzEntity>(model); if (!app.IsApiUrl) { app.MethodType = 0; } app.UpdateTime = DateTime.Now; var result = await _tasksQzService.UpdateAsync(app); if (result) { response.success = true; response.msg = "修改成功"; response.response = _mapper.Map <TasksQzDto>(app); return(response); } return(new MessageModel <TasksQzDto>() { success = false, msg = !result ? "修改作业失败,请查看错误日志" : "" }); }
public async Task <string> Run(IJobExecutionContext context, int jobid) { var msg = ""; if (jobid > 0) { var model = await _tasksQzServices.GetAsync(jobid); if (model != null) { if (model.IsApiUrl) { if (model.MethodType == 1) //model.MethodType?.ToUpper() == "GET" { var rep = await HttpUtil.HttpGetAsync(model.ApiUrl); msg = rep; } else { var postData = JsonHelper.ToJson(model.RequestValue); var rep = await HttpUtil.HttpPostAsync(model.ApiUrl, postData, null, 30000); msg = rep; } } model.RunTimes += 1; await _tasksQzServices.UpdateAsync(model); } } return(msg); }
public async Task <string> Run(IJobExecutionContext context, int jobid) { if (jobid > 0) { var model = await _tasksQzServices.GetAsync(jobid); if (model != null) { model.RunTimes += 1; await _tasksQzServices.UpdateAsync(model); } } await Console.Out.WriteLineAsync("你好!我是测试Demo1"); return("你好!我是测试Demo1"); }