Example #1
0
        public IActionResult OnGet(int id)
        {
            Task = _taskManager.GeTask(id);
            if (Task == null)
            {
                return(NotFound());
            }
            TaskInterval interval = Task.Interval;

            DefaultInterval = interval.ToHtmlString();
            Input           = new InputModel {
                Id = Task.Id, Interval = Task.TaskArgument.Interval ?? Task.Interval
            };
            return(Page());
        }
Example #2
0
        public async Task <IActionResult> OnPost()
        {
            TaskInterval interval = null;

            if (!string.IsNullOrEmpty(Input.Interval))
            {
                try
                {
                    interval = Input.Interval;
                }
                catch (Exception)
                {
                    ModelState.AddModelError("Input.Interval", "时间间隔格式错误,请输入正确的格式!");
                    return(Error());
                }
            }

            Task = _taskManager.GeTask(Input.Id);
            if (await _taskManager.SaveArgumentIntervalAsync(Input.Id, interval?.ToString()))
            {
                interval = Task.Interval;
                await EventLogger.LogCoreAsync("将后台服务 {2} 的时间间隔由 {0} 修改为 {1}。", Task.ToHtmlInterval().ToString(), interval.ToHtmlString().ToString(),
                                               Task.Name);

                return(Success("你已经成功更改了时间间隔!"));
            }
            return(Error());
        }