Beispiel #1
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;
            }
        }
Beispiel #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();
        }