public JsonResult QzJoin(int id)
        {
            try
            {
                Models.api_quartz entity = dbhelper.FindById(id);
                if (entity != null)
                {
                    if (entity.quartzstatus == "启动")
                    {
                        entity.quartzstatus = "停止";
                        dbhelper.Update(entity);
                        dbhelper.SaveChanges();
                    }
                    else
                    {
                        entity.quartzstatus = "启动";
                        dbhelper.Update(entity);
                        dbhelper.SaveChanges();
                    }
                }

                return(Json(new { access = true }));
            }
            catch (Exception exp)
            {
                return(Json(new { access = false, msg = exp.Message }));
            }
        }
        public JsonResult dataSave(Models.api_quartz entity)
        {
            try
            {
                if (entity != null)
                {
                    entity.mod_date = DateTime.Now;
                }

                if (entity.id <= 0)
                {
                    dbhelper.Insert(entity);
                    dbhelper.SaveChanges();
                    dbhelper.SaveChanges();
                }
                else
                {
                    dbhelper.Update(entity);
                    dbhelper.SaveChanges();
                }
                return(Json(new { access = true }));
            }
            catch (Exception exp)
            {
                return(Json(new { access = false, msg = exp.Message }));
            }
        }
Exemplo n.º 3
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));
        }
        public ActionResult Edit(int id)
        {
            //Models.Model_QuartzNetItem entity = new Models.Model_QuartzNetItem();
            Models.api_quartz entity = dbhelper.FindById(id);
            if (entity == null)
            {
                entity = new Models.api_quartz();
                //新增;
                entity.quartzname = "新建";

                entity.crontrigger  = "/5 * * ? * *";
                entity.quartzstatus = "停止";
                entity.quartznote   = "每5秒钟执行一次";

                entity.jobtype = "Http";
                entity.jobpars = "http://";
                ViewBag.entity = entity;
            }
            else
            {
                ViewBag.entity = entity;
            }
            return(View());//
        }