Ejemplo n.º 1
0
        /// <summary>
        /// 新增/修改定时任务
        /// </summary>
        /// <param name="api_Quartz"></param>
        /// <returns></returns>
        public JsonResult TimeTaskAdd(Models.api_quartz api_Quartz)
        {
            api_Quartz.mod_date = DateTime.Now;
            if (api_Quartz.id > 0)
            {
                dbhelper.Update(api_Quartz);
                QuarztHelper.JoinJob(api_Quartz.id);
            }
            else
            {
                dbhelper.Insert(api_Quartz);
                QuarztHelper.JoinJob(api_Quartz.id);
            }
            var m = dbhelper.SaveChanges();

            if (m > 0)
            {
                return(Json(new
                {
                    success = true,
                    message = "保存成功",
                    data = m
                }, JsonRequestBehavior.AllowGet));
            }
            return(Json(new
            {
                success = false,
                message = "保存失败",
            }, JsonRequestBehavior.AllowGet));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 修改定时任务的状态
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public JsonResult TimeTaskStatusbutChange(int id)
        {
            try
            {
                Models.api_quartz entity = dbhelper.FindById(id);
                if (entity != null)
                {
                    if (entity.quartzstatus == "启动")
                    {
                        entity.quartzstatus = "停止";
                        dbhelper.Update(entity);
                    }
                    else
                    {
                        entity.quartzstatus = "启动";
                        dbhelper.Update(entity);
                    }
                    dbhelper.SaveChanges();
                    QuarztHelper.JoinJob(entity.id);
                }

                return(Json(new { access = true }));
            }
            catch (Exception exp)
            {
                return(Json(new { access = false, msg = exp.Message }));
            }
        }