public virtual void RefreshStartup() { if (int.TryParse(WebConfigurationManager.AppSettings[$"Persona_{Name}_UserAutoRefreshHours"], out int UserAutoRefreshHours)) { COREobject core = COREobject.i; CrontabTask task = new CrontabTask { Application = core.Context.Applications.Single(a => a.IsSystem), BlockName = "FSS.Omnius.Modules.Persona.MasterAuth", Executor = $"RefreshAnyAuth/int:{Id}", IsActive = true, IsDeleted = false, Name = $"Scheduler {Name}", Schedule = $"after {UserAutoRefreshHours}hour", ScheduleStart = CrontabTask.ScheduleStartAt.taskStart }; task.Start(); } }
public ActionResult Create(CrontabTask crontabTask) { var context = COREobject.i.Context; if (!ModelState.IsValid) { ViewData["apps"] = context.Applications.Select(app => new { app.DisplayName, app.Name, app.Id }).ToList().Select(app => new SelectListItem { Text = app.DisplayName ?? app.Name, Value = app.Id.ToString() }); return(View(crontabTask)); } context.CrontabTask.Add(crontabTask); context.SaveChanges(); crontabTask.Start(); return(RedirectToRoute("Cortex", new { Controller = "Crontab", Action = "Index" })); }