Exemple #1
0
 public void RemoveEvent(EventScheduled @event, string userName)
 {
     if (_db.Storage.ContainsKey(userName))
     {
         _db.Storage[userName].Events.Remove(@event);
     }
 }
Exemple #2
0
 public void AddEvent(EventScheduled @event, string userName)
 {
     if (_db.Storage.ContainsKey(userName))
     {
         _db.Storage[userName]?.Events.Add(@event);
     }
 }
Exemple #3
0
        public void UpdateEvent(EventScheduled @event, string userName)
        {
            if (!_db.Storage.ContainsKey(userName))
            {
                return;
            }

            _db.Storage[userName].Events.Remove(_db.Storage[userName].Events.FirstOrDefault(x => x.Id == @event.Id));
            _db.Storage[userName].Events.Add(@event);
        }
        public void Schedule(IEvent @event, Time time, Func <int, bool> maySchedule)
        {
            var scheduled = new ScheduledEvent(@event, time);

            Task.Run(async() =>
            {
                EventScheduled?.Invoke(this, scheduled);

                while (maySchedule(scheduled.TimesExecuted))
                {
                    await waiter.Wait(scheduled.TimeUntil.TotalMilliseconds());

                    @event.Execute();
                    scheduled.TimesExecuted++;
                }

                EventFinished?.Invoke(this, scheduled);
            });
        }
Exemple #5
0
 public void UpdateEvent(EventScheduled @event, string userName)
 {
     _repository.UpdateEvent(@event, userName);
 }
Exemple #6
0
 public void RemoveEvent(EventScheduled @event, string userName)
 {
     _repository.RemoveEvent(@event, userName);
 }
Exemple #7
0
 public void AddEvent(EventScheduled @event, string userName)
 {
     _repository.AddEvent(@event, userName);
 }