public void EmitScriptEvent(string eventAlias, params object[] args) { using (var session = database.OpenSession()) { EmitScriptEvent(session, eventAlias, args); } }
public void MimimiTimer(DateTime now) { using (var db = database.OpenSession()) { db.Set <SmallPig>().ToList() .ForEach(pig => Logger.LogWarning($"{pig.Name}, size: {pig.Size} ({pig.Id})")); } }
public HttpHandlerResult GetTaskList(HttpRequestParams request) { using (var session = database.OpenSession()) { var list = session.Set <CronTask>() .OrderBy(e => e.Month) .ThenBy(e => e.Day) .ThenBy(e => e.Hour) .ThenBy(e => e.Minute) .Select(ToApiModel) .ToArray(); return(HttpHandlerResult.Json(list)); } }
public HttpHandlerResult GetScriptList(HttpRequestParams request) { using (var session = database.OpenSession()) { var list = session.Set<UserScript>() .Select(x => new { id = x.Id, name = x.Name }) .ToArray(); return HttpHandlerResult.Json(list); } }
public void OnTimerElapsed(DateTime now) { lock (lockObject) { LoadTasks(); var from = now.AddMinutes(-ACTIVE_PERIOD); var min = lastEventTime <= from ? from : lastEventTime; var active = schedule .Where(t => t.IsActive(min, now)) .ToArray(); if (active.Any()) { lastEventTime = now; using (var session = database.OpenSession()) { foreach (var task in active) { Logger.LogInformation($"cron task started: {task.TaskId}"); if (!string.IsNullOrEmpty(task.EventAlias)) { scripts.EmitScriptEvent(session, task.EventAlias); } SafeInvokeAsync(handlers, h => h(task.TaskId)); scripts.EmitScriptEvent(session, "cron:task:started", task.TaskId); } } } } }
public void MimimiTimer(DateTime now) { using var db = database.OpenSession(); db.Set <SmallPig>().ToList() .ForEach(pig => Logger.LogWarning("{Name}, size: {Size} ({Id})", pig.Name, pig.Size, pig.Id)); }