Beispiel #1
0
 public void EmitScriptEvent(string eventAlias, params object[] args)
 {
     using (var session = database.OpenSession())
     {
         EmitScriptEvent(session, eventAlias, args);
     }
 }
Beispiel #2
0
 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})"));
     }
 }
Beispiel #3
0
        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);
            }
        }
Beispiel #5
0
        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);
                        }
                    }
                }
            }
        }
Beispiel #6
0
 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));
 }