Exemplo n.º 1
0
        public ActionResult GetAllServiceInfos()
        {
            var list = QuartzHelper.GetServices();
            List <ServiceInfo> infos = new List <ServiceInfo>();

            foreach (var item in list)
            {
                try {
                    infos.Add(QuartzHelper.GetServiceInfo(item, true, true));
                } catch (Exception) { }
            }
            return(Json(new { code = 1, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), items = infos }, JsonRequestBehavior.AllowGet));
        }
Exemplo n.º 2
0
 public ActionResult StopServer(string serviceName)
 {
     try {
         var info = QuartzHelper.GetServiceInfo(serviceName);
         if (info == null)
         {
             return(Json(new { code = 0, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"服务【{serviceName}】不存在!" }, JsonRequestBehavior.AllowGet));
         }
         Process.Start(info.Path, "stop");
         return(Json(new { code = 1, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"服务【{info.NameCn}】结束执行!" }, JsonRequestBehavior.AllowGet));
     } catch (Exception ex) {
         return(Json(new { code = 0, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"服务【{serviceName}】执行出错:" + ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 3
0
 public ActionResult GetServiceInfos(string serviceNames)
 {
     try {
         var sns = serviceNames.Split(",".ToArray(), StringSplitOptions.RemoveEmptyEntries).Distinct().ToList();
         List <ServiceInfo> infos = new List <ServiceInfo>();
         foreach (var item in sns)
         {
             infos.Add(QuartzHelper.GetServiceInfo(item, true, true));
         }
         return(Json(new { code = 1, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), items = infos }, JsonRequestBehavior.AllowGet));
     } catch (Exception ex) {
         return(Json(new { code = 0, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"执行出错:" + ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }
Exemplo n.º 4
0
        public ActionResult EditJob(string serviceName, string jobName, string triggerGroup, string triggerName)
        {
            ViewBag.serviceName  = serviceName;
            ViewBag.jobName      = jobName;
            ViewBag.triggerGroup = triggerGroup;
            ViewBag.triggerName  = triggerName;

            var service = QuartzHelper.GetServiceInfo(serviceName, false, true);
            var job     = service.JobInfos.First(q => q.Name == jobName && q.TriggerGroup == triggerGroup && q.TriggerName == triggerName);

            ViewBag.job = job;

            return(View());
        }
Exemplo n.º 5
0
 public ActionResult RunJob(string serviceName, string jobName)
 {
     try {
         var info = QuartzHelper.GetServiceInfo(serviceName, true);
         if (info == null)
         {
             return(Json(new { code = 0, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"服务【{serviceName}】不存在!" }, JsonRequestBehavior.AllowGet));
         }
         var r = QuartzHelper.GetJob(info.Path, jobName);
         if (r == 0)
         {
             return(Json(new { code = 0, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"任务【{jobName}】不存在!" }, JsonRequestBehavior.AllowGet));
         }
         if (r == 2 && info.IsRun)
         {
             return(Json(new { code = 0, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"任务【{jobName}】将被执行或正在执行!" }, JsonRequestBehavior.AllowGet));
         }
         Process.Start(info.Path, jobName);
         return(Json(new { code = 1, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"任务【{jobName}】开始执行!" }, JsonRequestBehavior.AllowGet));
     } catch (Exception ex) {
         return(Json(new { code = 0, date = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"), msg = $"任务【{jobName}】执行出错:" + ex.Message }, JsonRequestBehavior.AllowGet));
     }
 }