public async Task <IActionResult> Edit(string id, TaskCenterEditModel collection) { if (!ModelState.IsValid) { await Edit(id); return(View(collection)); } var item = new TaskCenter(); if (!string.IsNullOrEmpty(id)) { item = _iTaskCenterService.GetById(id); } Mapper.Initialize(a => a.CreateMap <TaskCenterEditModel, TaskCenter>()); Mapper.Map(collection, item); //await TryUpdateModelAsync(item); _iTaskCenterService.Save(id, item); await _iUnitOfWork.CommitAsync(); return(new EditSuccessResult(id)); }
// GET: /Platform/iDepartment/Edit/5 /// <summary> /// </summary> /// <param name="id"></param> /// <returns></returns> public async Task <IActionResult> Edit(string id) { var item = new TaskCenter(); if (!string.IsNullOrEmpty(id)) { item = await _iTaskCenterService.FindAsync(id); } ViewBag.TaskExecutorId = new SelectList(_iSysUserService.Users.Select(a => new { a.UserName, a.Id }), "Id", "UserName", item.TaskExecutorId); return(View(item)); }
protected void EGV_RowCommand(object sender, GridViewCommandEventArgs e) { switch (e.CommandName) { case "del2": int id = Convert.ToInt32(e.CommandArgument); scheBll.Delete(id); TaskCenter.RemoveTask(id); break; } MyBind(); }
//创建任务 private int AddTask(string content, string title, DateTime etime, ZLEnum.ConStatus status = ZLEnum.ConStatus.Audited) { M_Content_ScheTask scheModel = new M_Content_ScheTask(); scheModel.TaskName = title; scheModel.TaskContent = content; //ID scheModel.TaskType = (int)M_Content_ScheTask.TaskTypeEnum.Content; //根据这个调用不同的方法处理TaskContent scheModel.ExecuteType = (int)M_Content_ScheTask.ExecuteTypeEnum.JustOnce; scheModel.ExecuteTime = etime.ToString(); scheModel.Remind = ((int)status).ToString(); scheModel.AdminID = adminMod.AdminId; scheModel.ID = scheBll.Add(scheModel); TaskCenter.AddTask(scheModel); return(scheModel.ID); }
/// <summary> /// Tworzy modul sieciowy /// </summary> public NetworkModule() { Processor proc = ServiceModule.CreateProcessor(); AssignProcessor(ServiceModule, proc); netQueue = new NetQueue(ServiceModule, proc); netQueue.Start(); _interfaceLink = new InterfaceModuleLink(this); _fileLink = new FileModulelLink(this); NetworkManager = new NetworkManager(this); TaskCenter = new TaskCenter(this); _networkState = new StateDisconnected(this); }
protected void Application_Start() { //WebApiConfig.Register(GlobalConfiguration.Configuration); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); //RouteConfig.RegisterRoutes(RouteTable.Routes); //BundleConfig.RegisterBundles(BundleTable.Bundles); //------------------------------------------------- RegisterRoutes(RouteTable.Routes); log4net.Config.XmlConfigurator.Configure(new FileInfo(Server.MapPath("/Config/log.config"))); //-------- try { TaskCenter.Init(); TaskCenter.Start(); } catch (Exception ex) { ZLLog.L("TaskCenter" + ex.Message); } }
public async Task <IActionResult> EditAsync(string id, TaskCenter collection) { if (!ModelState.IsValid) { await Edit(id); return(View(collection)); } await _iTaskCenterService.SaveAsync(id, collection); await _iSysMessageService.AddAsync(new SysMessageCenter() { Title = collection.Title, Content = collection.Content, AddresseeId = collection.TaskExecutorId }); await _unitOfWork.CommitAsync(); return(new EditSuccessResult(id)); }
public async Task <ActionResult> Edit(string id, TaskCenterEditModel collection) { if (!ModelState.IsValid) { await Edit(id); return(View(collection)); } var item = new TaskCenter(); if (!string.IsNullOrEmpty(id)) { item = _iTaskCenterService.GetById(id); } TryUpdateModel(item); _iTaskCenterService.Save(id, item); await _iUnitOfWork.CommitAsync(); return(new EditSuccessResult(id)); }
protected void StartTask_Btn_Click(object sender, EventArgs e) { //1,非停用的任务,自动忽略, //2.已停用的任务,修改状态并加入任务队列 string ids = Request.Form["idchk"]; if (string.IsNullOrWhiteSpace(ids)) { function.WriteErrMsg("未选定需要操作的任务"); } DataTable dt = scheBll.SelByIDS(ids); foreach (DataRow dr in dt.Rows) { if (Convert.ToInt32(dr["Status"]) == (int)ZLEnum.Common.Stop) { int id = Convert.ToInt32(dr["ID"]); scheBll.UpdateStatus(id.ToString(), (int)ZLEnum.Common.Normal); M_Content_ScheTask model = scheBll.SelReturnModel(id); TaskCenter.AddTask(model); } } function.WriteSuccessMsg("操作成功,已将停用的任务加入队列"); }
protected void Save_Btn_Click(object sender, EventArgs e) { if (Mid > 0) { scheMod = scheBll.GetModel(Mid); } scheMod.TaskName = TaskName_T.Text; //scheMod.ExecuteTime = ExecuteTime_T1.Text; scheMod.Interval = DataConvert.CLng(Interval_T.Text); if (TaskContent_T.Text.StartsWith("/"))//任务内容为脚本路径时 { if (!File.Exists(function.VToP(TaskContent_T.Text))) { function.WriteErrMsg("脚本不存在"); } else { scheMod.TaskContent = TaskContent_T.Text; } } else { scheMod.TaskContent = TaskContent_T.Text; } scheMod.Remind = Remind_T.Text; //任务类型不允许修改 if (Mid <= 0) { scheMod.TaskType = DataConvert.CLng(Request.Form["taskType_rad"]); } scheMod.ExecuteType = DataConvert.CLng(Request.Form["executeType_rad"]); scheMod.Status = DataConvert.CLng(Request.Form["status_rad"]); if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.Interval) { if (scheMod.Interval <= 0) { function.WriteErrMsg("未指定正确的间隔时间"); } } else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.JustOnce) { scheMod.ExecuteTime = ExecuteTime_T1.Text; if (DataConvert.CDate(scheMod.ExecuteTime) < DateTime.Now) { function.WriteErrMsg("执行时间无效"); } } else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.EveryDay) { scheMod.ExecuteTime = ExecuteTime_T2.Text; } else if (scheMod.ExecuteType == (int)M_Content_ScheTask.ExecuteTypeEnum.EveryMonth) { scheMod.ExecuteTime = ExecuteTime_T1.Text; } if (Mid > 0) { scheBll.Update(scheMod); } else { M_AdminInfo adminMod = B_Admin.GetLogin(); scheMod.CDate = DateTime.Now; scheMod.AdminID = adminMod.AdminId; scheMod.ID = scheBll.Add(scheMod); } TaskCenter.AddTask(scheMod); function.WriteSuccessMsg("操作成功", "Default.aspx"); }
//-------------------------------------------------------------------------------------------- protected void InitTask_Btn_Click(object sender, EventArgs e) { TaskCenter.Init(); TaskCenter.Start(); function.WriteSuccessMsg("初始化成功"); }