Пример #1
0
        public SchedulerModule() {
            this.RequiresAuthentication();

            Get["/scheduler"] = x => {
                dynamic vmod = new ExpandoObject();
                vmod.JobList = JobRepository.GetAll();
                return View["page-scheduler", vmod];
            };

            Post["/scheduler/now"] = x => {
                var alias = (string)Request.Form.Alias;
                var command = (string)Request.Form.Command;
                Job.Schedule(alias, command);
                return Response.AsRedirect("/");
            };

            Post["/scheduler/cron"] = x => {
                var alias = (string)Request.Form.Alias;
                var command = (string)Request.Form.Command;
                var cron = (string)Request.Form.CronResult;
                Job.Schedule(alias, command, cron);
                return Response.AsRedirect("/");
            };

            //Post["/scheduler/other"] = x => {
            //    var _alias = (string)Request.Form.Alias;
            //    var _command = (string)Request.Form.Command;
            //    var _cron = (string)Request.Form.CronResult;
            //    Job.Schedule(_alias, _command, _cron);
            //    dynamic model = new ExpandoObject();
            //    return Response.AsRedirect("/");
            //};

            Get["/scheduler/enable/{guid}"] = x => {
                string guid = x.guid;
                JobRepository.Enable(guid);
                return Response.AsJson(true);
            };

            Get["/scheduler/disable/{guid}"] = x => {
                string guid = x.guid;
                JobRepository.Disable(guid);
                return Response.AsJson(true);
            };

            Get["/scheduler/Launch/{guid}"] = x => {
                string guid = x.guid;
                Job.ReSchedule(guid);
                return Response.AsJson(true);
            };

            Get["/scheduler/delete/{guid}"] = x => {
                string guid = x.guid;
                JobRepository.Delete(guid);
                return Response.AsJson(true);
            };
        }