Example #1
0
        /// <summary>
        /// 启动任务
        /// </summary>
        /// <param name="jobInfo"></param>
        /// <returns></returns>
        public JsonResult RunJob(JobInfo jobInfo)
        {
            if (jobInfo.StartTime < new DateTime(1970, 1, 1, 0, 0, 0))
            {
                jobInfo.StartTime = System.DateTime.Now;
            }
            if (jobInfo.CreateTime < new DateTime(1970, 1, 1, 0, 0, 0))
            {
                jobInfo.StartTime = System.DateTime.Now;
            }

            AjaxResult Res = new AjaxResult();

            try
            {
                Result res1 = new JobLogic().Run(jobInfo);
                if (res1.Code == 200)
                {
                    Res.Result = true;
                }
                else
                {
                    Res.Result   = false;
                    Res.ErrorMsg = res1.Msg;
                }
            }
            catch (Exception ex)
            {
                Res.Result   = false;
                Res.ErrorMsg = ex.ToString();
            }

            return(Json(Res, JsonRequestBehavior.AllowGet));
        }
Example #2
0
        /// <summary>
        /// 更新作业信息
        /// </summary>
        /// <param name="jobInfo"></param>
        /// <returns></returns>
        public JsonResult UpdateJob(JobInfo jobInfo)
        {
            //Result res = new JobLogic().Update(jobInfo);
            //return Json(res);
            AjaxResult ajaxResult = new AjaxResult();

            try
            {
                bool res = new JobLogic().Upgrade(jobInfo);
                if (res)
                {
                    ajaxResult.Result = true;
                }
                else
                {
                    ajaxResult.Result = false;
                }
            }
            catch (Exception ex)
            {
                ajaxResult.Result   = false;
                ajaxResult.ErrorMsg = ex.ToString();
            }
            return(Json(ajaxResult, JsonRequestBehavior.AllowGet));
        }
Example #3
0
        /// <summary>
        /// 停止作业
        /// </summary>
        /// <param name="jobInfo"></param>
        /// <returns></returns>
        public JsonResult Remove(JobInfo jobInfo)
        {
            AjaxResult ajaxResult = new AjaxResult();

            try
            {
                Result res = new JobLogic().Remove(jobInfo);
                if (res.Code == 200)
                {
                    ajaxResult.Result = true;
                }
                else
                {
                    ajaxResult.Result   = false;
                    ajaxResult.ErrorMsg = res.Msg;
                }
            }
            catch (Exception ex)
            {
                ajaxResult.Result   = false;
                ajaxResult.ErrorMsg = ex.ToString();
            }

            return(Json(ajaxResult, JsonRequestBehavior.AllowGet));
        }
Example #4
0
 /// <summary>
 /// 暂停
 /// </summary>
 /// <param name="jobInfo"></param>
 /// <returns></returns>
 public JsonResult Pause(JobInfo jobInfo)
 {
     //Result result = new JobLogic().Pause(jobInfo);
     //return Json(result);
     try
     {
         Result result = new JobLogic().Pause(jobInfo);
         return(Json(new AjaxResult
         {
             Result = true,
             Data = null,
             ErrorMsg = null
         }, JsonRequestBehavior.AllowGet));
     }
     catch (Exception ex)
     {
         return(Json(new AjaxResult
         {
             Result = false,
             ErrorMsg = ex.ToString()
         }, JsonRequestBehavior.AllowGet));
     }
 }