Пример #1
0
        /// <summary>
        /// 任务停止(删除Job)
        /// 先将当前线程中任务删除,然后更新任务表中的状态为4(停止状态)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnStopJob_Click(object sender, EventArgs e)
        {
            try
            {
                string             missionid = txtHiddenText.Text;
                Model.TimerMission model     = _bll.GetModel(new Guid(missionid));
                //删除任务
                bool issuccess = _missionControl.DeleteJob(model.GroupName, model.MissionName);
                UiHelper.Alert(this, issuccess ? "任务已停止!" : "操作失败,请重试!");
                if (issuccess)
                {
                    UiHelper.Alert(this, "任务已停止!");
                    model.MissionState = MissionStateEnum.YiTingZhi.GetEnumValueEx();
                    _bll.Update(model);//更新数据
                }
                else
                {
                    UiHelper.Alert(this, "操作失败,请重试!");
                }

                NewDatabind(Convert.ToInt32(countDDL.SelectedValue));
            }
            catch (Exception)
            {
                UiHelper.Alert(this, "操作失败,请重试!");
                throw;
            }
        }
Пример #2
0
        public void ProcessRequest(HttpContext context)
        {
            TimerMission bll = new TimerMission();

            context.Response.ContentType = "text/plain";

            //获取当前任务ID,用于查询
            string missionid = HttpContext.Current.Request.Params["missionid"];

            if (missionid == null)
            {
                throw new ArgumentNullException("context");
            }

            //获取Model
            Model.TimerMission model = bll.GetModel(new Guid(missionid));
            //JSON输出
            JavaScriptSerializer scriptSerializer = new JavaScriptSerializer();

            if (model != null)
            {
                var states = EnumDescriptionExtension.GetDescription(typeof(MissionStateEnum), value: model.MissionState.ToString(), key: "show");

                //只显示状态名称,不显示图标
                model.StateString  = states.Substring(states.IndexOf("</i>", StringComparison.Ordinal) + 4);
                model.StartTimeStr = model.StartTime.ToString();
                model.EndTimeStr   = model.EndTime.ToString();
                string missionjson = scriptSerializer.Serialize(model);

                //输出JSON
                HttpContext.Current.Response.Write(missionjson);
            }
            HttpContext.Current.Response.End();
        }
Пример #3
0
        /// <summary>
        /// 任务重启
        /// 将任务重启,并更新当前的任务状态为1
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnPauseResume_Click(object sender, EventArgs e)
        {
            try
            {
                string             missionid = txtHiddenText.Text;
                Model.TimerMission model     = _bll.GetModel(new Guid(missionid));
                bool issuccess = _missionControl.ReStart(model.GroupName, model.MissionName);
                if (issuccess)
                {
                    UiHelper.Alert(this, "任务重启成功!");
                    model.MissionState = MissionStateEnum.YunXingZhong.GetEnumValueEx();
                    _bll.Update(model); //更新数据
                }
                else
                {
                    UiHelper.Alert(this, "操作失败,请重试!");
                }

                NewDatabind(Convert.ToInt32(countDDL.SelectedValue));
            }
            catch (Exception)
            {
                UiHelper.Alert(this, "操作失败,请重试!");
                throw;
            }
        }
Пример #4
0
 /// <summary>
 /// 得到一个对象实体
 /// </summary>
 private Model.TimerMission DataRowToModel(DataRow row)
 {
     Model.TimerMission model = new Model.TimerMission();
     if (row != null)
     {
         if (row["id"] != null && row["id"].ToString() != "")
         {
             model.ID = new Guid(row["id"].ToString());
         }
         if (row["MissionName"] != null)
         {
             model.MissionName = row["MissionName"].ToString();
         }
         if (row["GroupName"] != null)
         {
             model.GroupName = row["GroupName"].ToString();
         }
         if (row["SqlStr"] != null)
         {
             model.SqlStr = row["SqlStr"].ToString();
         }
         if (row["TimeCorn"] != null)
         {
             model.TimeCorn = row["TimeCorn"].ToString();
         }
         if (row["RepeatCount"] != null && row["RepeatCount"].ToString() != "")
         {
             model.RepeatCount = int.Parse(row["RepeatCount"].ToString());
         }
         if (row["InveralTime"] != null && row["InveralTime"].ToString() != "")
         {
             model.InveralTime = int.Parse(row["InveralTime"].ToString());
         }
         if (row["StartTime"] != null && row["StartTime"].ToString() != "")
         {
             model.StartTime = DateTime.Parse(row["StartTime"].ToString());
         }
         if (row["EndTime"] != null && row["EndTime"].ToString() != "")
         {
             model.EndTime = DateTime.Parse(row["EndTime"].ToString());
         }
         if (row["CreateTime"] != null && row["CreateTime"].ToString() != "")
         {
             model.CreateTime = DateTime.Parse(row["CreateTime"].ToString());
         }
         if (row["MissionExplain"] != null)
         {
             model.MissionExplain = row["MissionExplain"].ToString();
         }
         if (row["MissionState"] != null && row["MissionState"].ToString() != "")
         {
             model.MissionState = int.Parse(row["MissionState"].ToString());
         }
         if (row["IsDel"] != null && row["IsDel"].ToString() != "")
         {
             model.IsDel = int.Parse(row["IsDel"].ToString());
         }
     }
     return(model);
 }
Пример #5
0
        /// <summary>
        /// 添加任务并立即执行
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnMissionBeginNow_Click(object sender, EventArgs e)
        {
            try
            {
                string str = AddTimerMission();
                if (str != "")
                {
                    Model.TimerMission model = _bll.GetModel(new Guid(str));
                    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);//更新数据
                    }
                    else
                    {
                        UiHelper.Alert(this, "操作失败,请重试!");
                    }

                    NewDatabind(Convert.ToInt32(countDDL.SelectedValue));
                }
            }
            catch (Exception)
            {
                UiHelper.Alert(this, "操作失败,请重试!");
                throw;
            }
        }
Пример #6
0
        /// <summary>
        /// 任务添加
        /// 先将当前的任务添加到进程中、然后更新任务表中的状态为1(运行状态)
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnAddJob_Click(object sender, EventArgs e)
        {
            try
            {
                string             missionid = txtHiddenText.Text;
                Model.TimerMission model     = _bll.GetModel(new Guid(missionid));
                if (model != null)
                {
                    //添加任务操作
                    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 = MissionStateEnum.YunXingZhong.GetEnumValueEx();
                        //将任务添加到进程以后,更新在当前数据库中的任务状态
                        _bll.Update(model);
                    }
                    else
                    {
                        UiHelper.Alert(this, "操作失败,请重试!");
                    }

                    NewDatabind(Convert.ToInt32(countDDL.SelectedValue));
                }
                else
                {
                    throw new ArgumentNullException("sender");
                }
            }
            catch
            {
                UiHelper.Alert(this, "操作失败,请重试!");
                throw;
            }
        }
Пример #7
0
        /// <summary>
        /// 更新一条数据
        /// </summary>
        public bool Update(Model.TimerMission model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("update TimerMission set ");
            strSql.Append("MissionName=@MissionName,");
            strSql.Append("GroupName=@GroupName,");
            strSql.Append("SqlStr=@SqlStr,");
            strSql.Append("TimeCorn=@TimeCorn,");
            strSql.Append("RepeatCount=@RepeatCount,");
            strSql.Append("InveralTime=@InveralTime,");
            strSql.Append("StartTime=@StartTime,");
            strSql.Append("EndTime=@EndTime,");
            strSql.Append("CreateTime=@CreateTime,");
            strSql.Append("MissionExplain=@MissionExplain,");
            strSql.Append("MissionState=@MissionState,");
            strSql.Append("IsDel=@IsDel");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@MissionName",    SqlDbType.NVarChar,         50),
                new SqlParameter("@GroupName",      SqlDbType.NChar,            50),
                new SqlParameter("@SqlStr",         SqlDbType.NVarChar,         -1),
                new SqlParameter("@TimeCorn",       SqlDbType.NChar,            50),
                new SqlParameter("@RepeatCount",    SqlDbType.Int,               4),
                new SqlParameter("@InveralTime",    SqlDbType.Int,               4),
                new SqlParameter("@StartTime",      SqlDbType.DateTime),
                new SqlParameter("@EndTime",        SqlDbType.DateTime),
                new SqlParameter("@CreateTime",     SqlDbType.DateTime),
                new SqlParameter("@MissionExplain", SqlDbType.NVarChar,         -1),
                new SqlParameter("@MissionState",   SqlDbType.Int,               4),
                new SqlParameter("@IsDel",          SqlDbType.Int,               4),
                new SqlParameter("@id",             SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value  = model.MissionName;
            parameters[1].Value  = model.GroupName;
            parameters[2].Value  = model.SqlStr;
            parameters[3].Value  = model.TimeCorn;
            parameters[4].Value  = model.RepeatCount;
            parameters[5].Value  = model.InveralTime;
            parameters[6].Value  = model.StartTime;
            parameters[7].Value  = model.EndTime;
            parameters[8].Value  = model.CreateTime;
            parameters[9].Value  = model.MissionExplain;
            parameters[10].Value = model.MissionState;
            parameters[11].Value = model.IsDel;
            parameters[12].Value = model.ID;

            int rows = DbHelper.ExecuteSql(strSql.ToString(), parameters);

            if (rows > 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Пример #8
0
        private void NewDatabind(int count)
        {
            int totalpage   = 0;
            int index       = Convert.ToInt32(Webpageindex);
            int totalrecord = 0;

            Model.TimerMission model = new Model.TimerMission {
                //任务名称(模糊搜索)
                MissionName = txtMissionName.Text.Trim(),
                //任务所在组名称(模糊搜索)
                GroupName = txtGroupName.Text.Trim(),
                //要检索的任务状态
                MissionState = Convert.ToInt32(ddlState.SelectedValue)
            };
            if (txtStartTime.Text.Trim() != "")
            {
                //任务开始执行事件
                model.StartTime = Convert.ToDateTime(txtStartTime.Text.Trim());
            }
            if (txtEndTime.Text.Trim() != "")
            {
                //任务结束时间
                model.EndTime = Convert.ToDateTime(txtEndTime.Text.Trim());
            }
            //分页获取数据方法
            DataTable dt = new Bizlog().GetAllData(model, "createtime", 1, count, Convert.ToInt32(Webpageindex), ref totalpage, ref index, ref totalrecord);

            if (dt != null)
            {
                //要显示出来的数据进行处理
                dt.Columns.Add("StateString", typeof(string));
                foreach (DataRow dr in dt.Rows)
                {
                    try
                    {
                        dr["SqlStr"] = dr["SqlStr"].ToString().Replace("\"", "'");
                        string state = dr["MissionState"].ToString();
                        //获取任务状态的中文名称(当前的任务名称中包含了HTML的图标代码)
                        dr["StateString"] = EnumDescriptionExtension.GetDescription(typeof(MissionStateEnum), state, "show");
                        dr["TimeCorn"]    = dr["TimeCorn"].ToString().Trim();//去除空白
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }

                if (totalpage < index)
                {//如果当前页面比总页面的数值大,则默认设置当前页为总页数最后一页
                    Webpageindex = index;
                }
            }
            WebPageCount  = totalpage;
            Webpagerecord = totalrecord;
            //当前Repeater控件数据绑定
            Repeatergoods.DataSource = dt;
            Repeatergoods.DataBind();
        }
Пример #9
0
 /// <summary>
 /// 删除任务功能
 /// 先删除当前线程中的任务,然后再删除数据库表中的任务状态
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 protected void Delete(object sender, CommandEventArgs e)
 {
     try
     {
         string             missionid = e.CommandArgument.ToString();
         Model.TimerMission model     = _bll.GetModel(new Guid(missionid));
         //删除线程中的任务
         _missionControl.DeleteJob(model.GroupName, model.MissionName);
         //更改存储在数据库中当前的任务状态ISDel=1
         bool isdel = _bll.Delete(new Guid(missionid));
         UiHelper.Alert(this, isdel ? "删除成功" : "删除失败");
         NewDatabind(Convert.ToInt32(countDDL.SelectedValue));
     }
     catch (Exception)
     {
         UiHelper.Alert(this, "删除失败,未知错误");
         throw;
     }
 }
Пример #10
0
        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.TimerMission model)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("insert into TimerMission(");
            strSql.Append("id,MissionName,GroupName,SqlStr,TimeCorn,RepeatCount,InveralTime,StartTime,EndTime,CreateTime,MissionExplain,MissionState,IsDel)");
            strSql.Append(" values (");
            strSql.Append("@id,@MissionName,@GroupName,@SqlStr,@TimeCorn,@RepeatCount,@InveralTime,@StartTime,@EndTime,@CreateTime,@MissionExplain,@MissionState,@IsDel)");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id",             SqlDbType.UniqueIdentifier, 16),
                new SqlParameter("@MissionName",    SqlDbType.NVarChar,         50),
                new SqlParameter("@GroupName",      SqlDbType.NChar,            50),
                new SqlParameter("@SqlStr",         SqlDbType.NVarChar,         -1),
                new SqlParameter("@TimeCorn",       SqlDbType.NChar,            50),
                new SqlParameter("@RepeatCount",    SqlDbType.Int,               4),
                new SqlParameter("@InveralTime",    SqlDbType.Int,               4),
                new SqlParameter("@StartTime",      SqlDbType.DateTime),
                new SqlParameter("@EndTime",        SqlDbType.DateTime),
                new SqlParameter("@CreateTime",     SqlDbType.DateTime),
                new SqlParameter("@MissionExplain", SqlDbType.NVarChar,         -1),
                new SqlParameter("@MissionState",   SqlDbType.Int,               4),
                new SqlParameter("@IsDel",          SqlDbType.Int, 4)
            };
            parameters[0].Value  = model.ID;
            parameters[1].Value  = model.MissionName;
            parameters[2].Value  = model.GroupName;
            parameters[3].Value  = model.SqlStr;
            parameters[4].Value  = model.TimeCorn;
            parameters[5].Value  = model.RepeatCount;
            parameters[6].Value  = model.InveralTime;
            parameters[7].Value  = model.StartTime;
            parameters[8].Value  = model.EndTime;
            parameters[9].Value  = model.CreateTime;
            parameters[10].Value = model.MissionExplain;
            parameters[11].Value = model.MissionState;
            parameters[12].Value = model.IsDel;

            int rows = DbHelper.ExecuteSql(strSql.ToString(), parameters);

            return(rows);
        }
Пример #11
0
        /// <summary>
        /// 得到一个对象实体
        /// </summary>
        public Model.TimerMission GetModel(Guid id)
        {
            StringBuilder strSql = new StringBuilder();

            strSql.Append("select  top 1 id,MissionName,GroupName,SqlStr,TimeCorn,RepeatCount,InveralTime,StartTime,EndTime,CreateTime,MissionExplain,MissionState,IsDel from TimerMission ");
            strSql.Append(" where id=@id ");
            SqlParameter[] parameters =
            {
                new SqlParameter("@id", SqlDbType.UniqueIdentifier, 16)
            };
            parameters[0].Value = id;

            Model.TimerMission model = new Model.TimerMission();
            DataSet            ds    = DbHelper.Query(strSql.ToString(), parameters);

            if (ds.Tables[0].Rows.Count > 0)
            {
                return(DataRowToModel(ds.Tables[0].Rows[0]));
            }
            else
            {
                return(null);
            }
        }
Пример #12
0
 /// <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;
     }
 }
Пример #13
0
 /// <summary>
 /// 分页获取任务管理列表
 /// </summary>
 /// <param name="model">任务模型</param>
 /// <param name="orderby">排序字段</param>
 /// <param name="sort">排序方式,0为升序,1为降序</param>
 /// <param name="page">每页多少条记录</param>
 /// <param name="pageindex">指定当前为第几页</param>
 /// <param name="totalpage">返回总页数</param>
 /// <param name="index">返回当前页数</param>
 /// <param name="totalrecord">总记录数</param>
 /// <returns></returns>
 public DataTable GetAllData(Model.TimerMission model, string orderby, int sort, int page, int pageindex, ref int totalpage, ref int index,
                             ref int totalrecord)
 {
     return(_dal.GetAllData(model, orderby, sort, page, pageindex, ref totalpage, ref index,
                            ref totalrecord));
 }
Пример #14
0
        /// <summary>
        /// 数据库翻页获得数据
        /// </summary>
        /// <param name="orderby">排序字段</param>
        /// <param name="sort">排序方式,0为升序,1为降序</param>
        /// <param name="page">每页多少条记录</param>
        /// <param name="pageindex">指定当前为第几页</param>
        /// <param name="totalpage">返回总页数</param>
        /// <param name="index">返回当前页数</param>
        /// <param name="totalrecord">总记录数</param>
        /// <returns></returns>
        // TODO  修改用户名称不同步的BUG
        public DataTable GetAllData(Model.TimerMission model, string orderby, int sort, int page, int pageindex, ref int totalpage, ref int index, ref int totalrecord)
        {
            SqlParameter[] paras =
            {
                new SqlParameter("@TableNames ",  SqlDbType.VarChar, 2000),
                new SqlParameter("@FieldStr ",    SqlDbType.VarChar, 4000),
                new SqlParameter("@SqlWhere ",    SqlDbType.VarChar, 4000),
                new SqlParameter("@OrderBy  ",    SqlDbType.VarChar, 4000),
                new SqlParameter("@Sort ",        SqlDbType.Int,        1),
                new SqlParameter("@PageSize ",    SqlDbType.Int,       40),
                new SqlParameter("@PageIndex ",   SqlDbType.Int,       40),
                new SqlParameter("@TotalPage ",   SqlDbType.Int,       40),
                new SqlParameter("@TotalRecord ", SqlDbType.Int, 40)
            };


            string condition = " 1=1 and IsDel = 0";

            if (!string.IsNullOrEmpty(model.MissionName) && model.MissionName != "")
            {
                condition += " and MissionName like '%" + model.MissionName + "%'";
            }
            if (!string.IsNullOrEmpty(model.GroupName) && model.GroupName != "")
            {
                condition += " and GroupName like '%" + model.GroupName + "%'";
            }
            if (model.MissionState != 0)
            {
                condition += "  and MissionState ='" + model.MissionState + "'";
            }
            if (!string.IsNullOrEmpty(model.StartTime.ToString()) && model.StartTime.ToString() != "")
            {
                condition += "  and CreateTime >='" + model.StartTime + "'";
            }

            if (!string.IsNullOrEmpty(model.EndTime.ToString()) && model.EndTime.ToString() != "")
            {
                condition += "  and CreateTime <='" + model.EndTime + "'";
            }
            //表名(支持多表)
            paras[0].Value = @"TimerMission";
            //字段名(全部字段为*)
            paras[1].Value = "*";
            //条件语句(不用加where)
            paras[2].Value = condition;
            // 排序字段
            paras[3].Value = orderby;
            //排序方法,0为升序,1为降序
            paras[4].Value = sort;
            //  每页多少条记录
            paras[5].Value = page;
            //指定当前为第几页
            paras[6].Value = pageindex;
            //返回总页数 ,固定值
            paras[7].Value = 0;
            // 返回总条数 ,固定值
            paras[8].Value     = 0;
            paras[7].Direction = ParameterDirection.Output;
            paras[8].Direction = ParameterDirection.Output;
            DataTable ds = DbHelper.GetDSer("Proc_PAGING", paras).Tables[0];

            //return DBHelper.GetDt(_connectionStr, "Proc_PAGING", paras);
            if (ds.Rows.Count > 0)
            {
                totalpage   = Convert.ToInt32(paras[7].Value);
                totalrecord = Convert.ToInt32(paras[8].Value);
                index       = index;
                return(ds);
            }
            else
            {
                return(null);
            }
        }
Пример #15
0
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public bool Update(Model.TimerMission model)
 {
     return(_dal.Update(model));
 }
Пример #16
0
        ///设置当前的备注信息

        #region  BasicMethod

        /// <summary>
        /// 增加一条数据
        /// </summary>
        public int Add(Model.TimerMission model)
        {
            return(_dal.Add(model));
        }
Пример #17
0
        /// <summary>
        /// TimerMission表数据添加
        /// </summary>
        /// <returns></returns>
        private string AddTimerMission()
        {
            try
            {
                #region 校验非空错误提示
                string strErr = "";
                if (this.txtAddMissionName.Text.Trim().Length == 0)
                {
                    strErr += "任务名称不能为空!\\n";
                }
                if (this.txtAddGroupName.Text.Trim().Length == 0)
                {
                    strErr += "组名称不能为空!\\n";
                }
                if (this.txtAddSqlStr.Text.Trim().Length == 0)
                {
                    strErr += "SQL执行语句不能为空!\\n";
                }
                if (this.txtAddTimeCorn.Text.Trim().Length == 0)
                {
                    strErr += "时间调度表达式不能为空!\\n";
                }

                if (this.txtAddMissionStartTime.Text.Trim().Length == 0)
                {
                    strErr += "任务开始时间不能为空!\\n";
                }
                if (this.txtAddMissionEndTime.Text.Trim().Length == 0)
                {
                    strErr += "任务结束时间不能为空!\\n";
                }
                if (Convert.ToDateTime(this.txtAddMissionStartTime.Text.Trim()) >= Convert.ToDateTime(this.txtAddMissionEndTime.Text.Trim()))
                {
                    strErr += "任务开始时间不可大于结束时间\\n";
                }
                if (strErr != "")
                {
                    UiHelper.Alert(this, strErr);
                    return("");
                }
                #endregion

                string missionName = this.txtAddMissionName.Text;
                string groupName   = this.txtAddGroupName.Text;
                bool   isrepeat    = _bll.TestRepeat(missionName, groupName);
                if (isrepeat) //判断当前任务名和组名是否重复
                {
                    UiHelper.Alert(this, "当前已存在重复的任务组名和任务名,请修改后再进行添加!");
                    return("");
                }
                else
                {
                    Model.TimerMission model = new Model.TimerMission {
                        ID             = Guid.NewGuid(),
                        MissionName    = missionName,
                        GroupName      = groupName,
                        SqlStr         = this.txtAddSqlStr.Text,
                        TimeCorn       = this.txtAddTimeCorn.Text,
                        RepeatCount    = int.Parse(this.txtAddRepeatCount.Text),
                        StartTime      = DateTime.Parse(this.txtAddMissionStartTime.Text),
                        EndTime        = DateTime.Parse(this.txtAddMissionEndTime.Text),
                        CreateTime     = DateTime.Now,
                        InveralTime    = 0,
                        MissionExplain = this.txtAddMissionExplain.Text,
                        MissionState   = 2//默认设置当前的MissionState为空
                    };
                    //数据添加
                    int issuccess = _bll.Add(model);
                    UiHelper.Alert(this, issuccess > 0 ? "保存成功!" : "数据添加失败,请校验数据后重试!");
                    if (issuccess > 0)
                    {
                        //重新进行数据绑定
                        NewDatabind(Convert.ToInt32(countDDL.SelectedValue));
                        //清空原有的输入框数据
                        foreach (object item in this.form1.Controls)
                        {
                            var box = item as TextBox;
                            if (box != null)
                            {
                                TextBox tbx = box; tbx.Text = "";
                            }
                        }
                    }
                    if (issuccess > 0)
                    {
                        return(model.ID.ToString());
                    }
                    else
                    {
                        return("");
                    }
                }
            }
            catch (Exception)
            {
                UiHelper.Alert(this, "未知原因,操作失败!");
                return("");

                throw;
            }
        }