/// <summary> /// 修改任务并立即执行 /// 操作步骤:先将当前进程中任务删除,然后再重新添加到进程中 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnEditMissionBeginNow_Click(object sender, EventArgs e) { try { //获取当前修改的任务的主键 string missionid = EditTimerMission(); if (missionid != "") { //当前的任务模型 Model.TimerMission model = _bll.GetModel(new Guid(missionid)); //删除线程中的任务 _missionControl.DeleteJob(model.GroupName, model.MissionName); bool issuccess = _missionControl.AddSqlExecuteJob(model.SqlStr, Convert.ToDateTime(model.StartTime), Convert.ToDateTime(model.EndTime), model.GroupName, model.MissionName, model.TimeCorn); if (issuccess) { UiHelper.Alert(this, "修改任务成功,当前任务已开始运行!"); model.MissionState = 1; _bll.Update(model); //更新数据 NewDatabind(Convert.ToInt32(countDDL.SelectedValue)); //重新绑定数据 } else { UiHelper.Alert(this, "操作失败,请重试!"); } } else { UiHelper.Alert(this, "操作失败,请重试!"); } } catch (Exception) { UiHelper.Alert(this, "操作失败,未知错误!"); throw; } }
/// <summary> /// 删除当前的任务 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void btnDelete_Click(object sender, EventArgs e) { _control.DeleteJob("group1", "mission2"); }