Ejemplo n.º 1
0
        public ViewResultBase CalendarEdit(string calendarName)
        {
            var model = new SystemQuartzCalendarModel();

            if (!calendarName.IsNullOrEmpty())
            {
                model.ReplaceExists = true;
                var calendar = (CronCalendar)StdSchedulerManager.GetCalendar(calendarName);
                model.Expression  = calendar.CronExpression.ToString();
                model.Description = calendar.Description;
            }
            return(View(model));
        }
Ejemplo n.º 2
0
        public async Task <JsonResult> CalendarEdit(string calendarName)
        {
            var model = new CalendarInput();

            if (!calendarName.IsNullOrEmpty())
            {
                model.ReplaceExists = true;
                var calendar = await StdSchedulerManager.GetCalendar(calendarName);

                //model.Expression = ((CronCalendar)calendar).CronExpression.ToString();
                model.Description = calendar.Description;
            }
            return(Json(model));
        }
Ejemplo n.º 3
0
        public JsonResult GetCalendar()
        {
            var calendars = StdSchedulerManager.GetCalendarNames().ToList().Select(n => new
            {
                Name     = n,
                Calendar = StdSchedulerManager.GetCalendar(n)
            }).ToDictionary(n => n.Name, n => n.Calendar);
            IList <SystemQuartzCalendarModel> calendarModels = calendars.Select(cal => new SystemQuartzCalendarModel
            {
                Description  = cal.Value.Description,
                CalendarName = cal.Key
            }).ToList();

            return(Json(calendarModels));
        }
Ejemplo n.º 4
0
        public async Task <JsonResult> GetCalendar()
        {
            var getCalendarNames = (await StdSchedulerManager.GetCalendarNames()).ToList();
            var calendars        = getCalendarNames.Select(n => new
            {
                Name     = n,
                Calendar = StdSchedulerManager.GetCalendar(n)
            }).ToDictionary(n => n.Name, n => n.Calendar);
            IList <CalendarInput> calendarModels = calendars.Select(cal => new CalendarInput
            {
                Description  = cal.Value.Result.Description,
                CalendarName = cal.Key
            }).ToList();

            return(JsonForGridLoadOnce(calendarModels));
        }
Ejemplo n.º 5
0
        public JsonResult SaveCalendar(CalendarInput input)
        {
            var status = new OperateStatus();

            try
            {
                if (!input.ReplaceExists && StdSchedulerManager.GetCalendar(input.CalendarName) != null)
                {
                    status.Message = "日历已存在,请换个其它名称或选择替换现有日历";
                    return(Json(status));
                }
                StdSchedulerManager.AddCalendar(input);
                status.ResultSign = ResultSign.Successful;
                status.Message    = "保存日历成功";
            }
            catch (Exception ex)
            {
                status.Message = ex.Message;
            }
            return(Json(status));
        }
Ejemplo n.º 6
0
        /// <summary>
        ///     日历
        /// </summary>
        /// <param name="htmlHelper"></param>
        /// <param name="input"></param>
        /// <returns></returns>
        public static MvcHtmlString LoadQuartzCalendar(this HtmlHelper htmlHelper, BaseDropDownListInput input)
        {
            StringBuilder stringBuilder = new StringBuilder(2000);

            stringBuilder.Append("<select id='" + input.Id + "' name='" + input.Name + "'" + input.HtmlAttributes + ">");
            if (input.NeedDefault)
            {
                stringBuilder.Append("<option value=''>===请选择===</option>");
            }
            var calendars = StdSchedulerManager.GetCalendarNames().ToList().Select(n => new
            {
                Name     = n,
                Calendar = StdSchedulerManager.GetCalendar(n)
            }).ToDictionary(n => n.Name, n => n.Calendar);

            foreach (var item in calendars)
            {
                if (input.SelectedVal != null)
                {
                    if (item.Key == input.SelectedVal)
                    {
                        stringBuilder.Append(" <option value='" + item.Key + "' selected='selected'>" + item.Key + "</option> ");
                    }
                    else
                    {
                        stringBuilder.Append(" <option value='" + item.Key + "' >" + item.Key + "</option> ");
                    }
                }
                else
                {
                    stringBuilder.Append(" <option value='" + item.Key + "' >" + item.Key + "</option> ");
                }
            }
            stringBuilder.Append("</select>");
            return(new MvcHtmlString(stringBuilder.ToString()));
        }