public CustomJsonResult AjaxEdit(ScheduledEvents model) { var key = LRequest.GetFormString("Key"); #region MyRegion ScheduleConfigInfo sci = ScheduleConfigs.GetConfig(); foreach (EventInfo ev1 in sci.Events) { if (ev1.Key == model.Key.Trim()) { ModelState.AddModelError("Key", "消息:计划任务名称已经存在!"); //return RedirectToAction("Index", new { currentPageNum = model.CurrentPageNum, pageSize = model.PageSize }); } } foreach (EventInfo ev1 in sci.Events) { if (ev1.Key == key) { ev1.Key = model.Key.Trim(); ev1.ScheduleType = model.ScheduleType.Trim(); if (model.ExetimeType) { ev1.TimeOfDay = model.hour * 60 + model.minute; ev1.Minutes = sci.TimerMinutesInterval; } else { if (model.timeserval < sci.TimerMinutesInterval) { ev1.Minutes = sci.TimerMinutesInterval; } else { ev1.Minutes = model.timeserval; } ev1.TimeOfDay = -1; } if (!ev1.IsSystemEvent) { ev1.Enabled = model.Enable; } break; } } ScheduleConfigs.SaveConfig(sci); #endregion var result = new Result(true); var json = new CustomJsonResult(); json.JsonRequestBehavior = JsonRequestBehavior.AllowGet; json.Data = result; return(json); }
public ActionResult Edit(AddOrEditViewModel <ScheduledEvents> model, FormCollection collection) { var key = LRequest.GetFormString("Key"); #region MyRegion ScheduleConfigInfo sci = ScheduleConfigs.GetConfig(); foreach (EventInfo ev1 in sci.Events) { if (ev1.Key == model.Entity.Key.Trim()) { ModelState.AddModelError("Key", "消息:计划任务名称已经存在!"); return(RedirectToAction("Index", new { currentPageNum = model.CurrentPageNum, pageSize = model.PageSize })); } } foreach (EventInfo ev1 in sci.Events) { if (ev1.Key == key) { ev1.Key = model.Entity.Key.Trim(); ev1.ScheduleType = model.Entity.ScheduleType.Trim(); if (model.Entity.ExetimeType) { ev1.TimeOfDay = model.Entity.hour * 60 + model.Entity.minute; ev1.Minutes = sci.TimerMinutesInterval; } else { if (model.Entity.timeserval < sci.TimerMinutesInterval) { ev1.Minutes = sci.TimerMinutesInterval; } else { ev1.Minutes = model.Entity.timeserval; } ev1.TimeOfDay = -1; } if (!ev1.IsSystemEvent) { ev1.Enabled = model.Entity.Enable; } break; } } ScheduleConfigs.SaveConfig(sci); #endregion return(RedirectToAction("Index", new { currentPageNum = model.CurrentPageNum, pageSize = model.PageSize })); }