public string PauseOrResume(SysJob Table_entity) { try { if (Table_entity.Status == "0") { Table_entity.Status = "1"; Upd(Table_entity); DeleteJob(Table_entity); } else { Table_entity.Status = "0"; Upd(Table_entity); AddJob(Table_entity); } } catch (Exception ex) { Result.Status = false; Result.Message = ex.Message; } return(JsonHelper.Instance.Serialize(Result)); }
public string Upd(SysJob Table_entity) { try { if (string.IsNullOrEmpty(Table_entity.MethodParams)) { throw new Exception("参数不能为空!"); } if (string.IsNullOrEmpty(Table_entity.CronExpression)) { throw new Exception("cron表达式不能为空!"); } if (Table_entity.Status == "0") { CronExpression cronExpression = new CronExpression(Table_entity.CronExpression); Table_entity.NextFireTime = cronExpression.GetNextValidTimeAfter(DateTime.Now).Value.ToLocalTime().DateTime; } _app.Upd(Table_entity); if (Table_entity.Status == "0") { UpdateJob(Table_entity); } } catch (Exception ex) { Result.Status = false; Result.Message = ex.Message; } return(JsonHelper.Instance.Serialize(Result)); }
public ResponseMessage <string> Insert([FromBody] SysJob sysJob) { UserInfo user = GetCurrentUser.GetUserInfo(HttpContext); sysJob.created_by = user.id; sysJob.created_time = DateTime.Now; return(new ResponseMessage <string> { data = _sysJobService.Insert(sysJob) }); }
public async Task <ResponseMessage <int> > UpdateAsync([FromBody] SysJob sysJob) { //SysJob entity = await _sysJobService.GetByIdAsync(sysJob.id); //Utils.CommmonUtils.EntityToEntity(sysJob, entity, null); //return new ResponseMessage<int> { data = await _sysJobService.UpdateAsync(entity) }; return(new ResponseMessage <int> { data = await _sysJobService.UpdateAsync(sysJob) }); }
public ResponseMessage <int> Update([FromBody] SysJob sysJob) { SysJob entity = _sysJobService.GetById(sysJob.id); Utils.CommmonUtils.EntityToEntity(sysJob, entity, null); return(new ResponseMessage <int> { data = _sysJobService.Update(entity) }); //return new ResponseMessage<int> { data = _sysJobService.Update(sysJob) }; }
public TableData Query(SysJob entity) { var result = new TableData(); var data = _app.Find(EntityToExpression <SysJob> .GetExpressions(entity)); GetData(data, result); result.count = data.Count(); return(result); }
/// <summary> /// 删除定时器任务 /// </summary> /// <param name="Table_entity">任务实体</param> private void DeleteJob(SysJob Table_entity) { try { _sched.PauseTrigger(new TriggerKey(Table_entity.JobName)).Wait(); _sched.UnscheduleJob(new TriggerKey(Table_entity.JobName)).Wait(); _sched.DeleteJob(new JobKey(Table_entity.JobName)).Wait(); } catch (Exception e) { throw e; } }
public string DelByIds(int[] ids) { try { foreach (var item in ids) { SysJob Table_entity = _app.FindSingle(u => u.Id == item); _app.DelByIds(new int[] { item }); DeleteJob(Table_entity); } } catch (Exception ex) { Result.Status = false; Result.Message = ex.Message; } return(JsonHelper.Instance.Serialize(Result)); }
public Response ImportIn(IFormFile excelfile) { Response result = new Infrastructure.Response(); List <SysJob> exp = imp.ConvertToModel <SysJob>(excelfile); string sErrorMsg = ""; for (int i = 0; i < exp.Count; i++) { try { SysJob e = exp[i]; e.Id = null; _app.Add(e); } catch (Exception ex) { sErrorMsg += "第" + (i + 2) + "行:" + ex.Message + "<br>"; result.Message = sErrorMsg; break; } } if (sErrorMsg.Equals(string.Empty)) { if (exp.Count == 0) { sErrorMsg += "没有发现有效数据, 请确定模板是否正确, 或是否有填充数据!"; result.Message = sErrorMsg; } else { result.Message = "导入完成"; } } else { result.Status = false; result.Message = result.Message; } return(result); }
///<summary> ///新增 ///</summary> public string Insert(SysJob sysJob) { return(SysJobRepository.Insert(sysJob)); }
public void Ins(SysJob entity) { _app.Add(entity); }
public void Upd(SysJob entity) { _app.Update(entity); }
///<summary> ///更新 ///</summary> public int Update(SysJob sysJob) { return(SysJobRepository.Update(sysJob)); }
public TableData Load(PageReq pageRequest, SysJob entity) { return(_app.Load(pageRequest, entity)); }
public string Load(PageReq pageRequest, SysJob entity) { return(JsonHelper.Instance.Serialize(_app.Load(pageRequest, entity))); }
public TableData ExportData(SysJob entity) { return(_app.ExportData(entity)); }
/// <summary> /// 修改定时器任务 /// </summary> /// <param name="Table_entity">任务实体</param> private void UpdateJob(SysJob Table_entity) { DeleteJob(Table_entity); AddJob(Table_entity); }
///<summary> ///异步更新 ///</summary> public async Task <int> UpdateAsync(SysJob sysJob) { return(await SysJobRepository.UpdateAsync(sysJob)); }
/// <summary> /// 新增定时器任务 /// </summary> /// <param name="Table_entity">任务实体</param> private void AddJob(SysJob Table_entity) { try { var jobDataMap = new JobDataMap(); string methodParams = Table_entity.MethodParams; JObject json = null; json = JObject.Parse(methodParams); if (json != null) { foreach (var item in json) { jobDataMap.Add(item.Key, item.Value.ToString()); } } string methodName = Table_entity.MethodName ?? ""; IJobDetail job = null; if (methodName.ToLower().Equals("ClearLogJob".ToLower())) { job = JobBuilder.Create <ClearLogJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("GetCurrentStockJob".ToLower())) { job = JobBuilder.Create <GetCurrentStockJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("GetICSInventoryJob".ToLower())) { job = JobBuilder.Create <GetICSInventoryJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("AGVJob".ToLower())) { job = JobBuilder.Create <AGVJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("OrderAlertJob".ToLower())) { job = JobBuilder.Create <OrderAlertJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("CreateMaterialDemandJob".ToLower())) { job = JobBuilder.Create <CreateMaterialDemandJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("CreateDistributeTaskJob".ToLower())) { job = JobBuilder.Create <CreateDistributeTaskJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("SendAGVTaskJob".ToLower())) { job = JobBuilder.Create <SendAGVTaskJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("ClearFinishOrderJob".ToLower())) { job = JobBuilder.Create <ClearFinishOrderJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } else if (methodName.ToLower().Equals("ReaderInterfaceTableJob".ToLower())) { job = JobBuilder.Create <ReaderInterfaceTableJob>().WithIdentity(Table_entity.JobName).UsingJobData(jobDataMap).Build(); } if (job != null) { var trigger = TriggerBuilder.Create().WithIdentity(Table_entity.JobName).WithCronSchedule(Table_entity.CronExpression).Build(); _sched.ScheduleJob(job, trigger).Wait(); } } catch (Exception e) { throw e; } }
///<summary> ///异步新增 ///</summary> public async Task <string> InsertAsync(SysJob sysJob) { return(await SysJobRepository.InsertAsync(sysJob)); }
public async Task <ResponseMessage <string> > InsertAsync([FromBody] SysJob sysJob) { return(new ResponseMessage <string> { data = await _sysJobService.InsertAsync(sysJob) }); }