public CompanyNotifier() { eventObservable = DbObservable <BiContext> .FromInserted <EventEntity>() .Where(entry => entry.Entity.Body is CompanyEvent); // eventObservable.Where(entry => entry.Entity.Body is CompanyUpdatedEvt) // .Subscribe(onUpdated); }
public IObservable <MessageEntity> UserMessages(long userId) { var obs = DbObservable <BiContext> .FromInserted <MessageEntity>() .Where(m => m.Entity.Group.UsersList.Any(u => u.UserId == m.Entity.UserId)) .Select(n => n.Entity); return(obs); }
private static void ObserveNewPeople() { Console.WriteLine("thread"); var o = DbObservable <Context> .FromInserted <Person>(); using (var p = o.Where(x => x.Entity.DateOfBirth.Month == DateTime.Today.Month && x.Entity.DateOfBirth.Day == DateTime.Today.Day) .Subscribe(entry => Console.WriteLine($"Happy birthday to {entry.Entity.Name}!"))) { Thread.Sleep(5000); } }
private static void ObserveNewBlog() { Console.WriteLine("thread"); var o = DbObservable <BloggingContext> .FromInserted <Blog>(); o.Where(x => x.Entity.DateOfBirth.Month == DateTime.Today.Month && x.Entity.DateOfBirth.Day == DateTime.Today.Day) .Subscribe(entry => Console.WriteLine($"Happy birthday to {entry.Entity.Url}!")); o.Subscribe(entry => Console.WriteLine(entry.Entity)); Thread.Sleep(500); }
public UserEventProcessor() { eventObservable = DbObservable <BiContext> .FromInserting <EventEntity>() .Where(e => e.Entity.Body is UserEvent); eventObservable.Where(e => e.Entity.Body is UserCreatedEvt) .Subscribe(onCreate); eventObservable.Where(e => e.Entity.Body is UserUpdatedEvt) .Subscribe(onUpdate); eventObservable.Where(e => e.Entity.Body is PasswordChangedEvt) .Subscribe(onPasswordChange); }
public PermissionEventProcessor() { eventObservable = DbObservable <BiContext> .FromInserting <EventEntity>() .Where(entry => entry.Entity.Body is PermissionEvent); eventObservable .Where(entry => entry.Entity.Body is PermissionGivenEvt) .Subscribe(onGiven); eventObservable .Where(entry => entry.Entity.Body is RoleRemovedEvt) .Subscribe(onRoleRemoved); eventObservable .Where(entry => entry.Entity.Body is PermissionsRevokedEvt) .Subscribe(onRevoked); }
private void ConfigureServices() { DbObservable <AlarmEntity, LocalDbContext> .FromInserted() .Merge <IEntry>(DbObservable <AlarmEntity, LocalDbContext> .FromDeleted()) .Merge(DbObservable <AlarmEntity, LocalDbContext> .FromUpdated()) .Cast <object>() .Merge(DbObservable <LessonEntity, LocalDbContext> .FromInserted()) .Merge(DbObservable <LessonEntity, LocalDbContext> .FromUpdated()) .Merge(DbObservable <LessonEntity, LocalDbContext> .FromDeleted()) .TakeUntil(_destroySubject) .ObserveOnDispatcher(DispatcherPriority.Background) .Subscribe(_ => StartTimer()); StartTimer(); StartBackupService(); }
public IObservable <IEnumerable <DbChange <T> > > ChangeListener <T>(int delayMs = 1000) where T : class { var changeSource = Observable.Merge ( DbObservable <GeneralDbContext> .FromInserted <T>() .Select(entry => new DbChange <T>(entry.Entity, ChangeReason.Insert)), DbObservable <GeneralDbContext> .FromDeleted <T>() .Select(entry => new DbChange <T>(entry.Entity, ChangeReason.Delete)), DbObservable <GeneralDbContext> .FromUpdated <T>() .Select(entry => new DbChange <T>(entry.Entity, ChangeReason.Update)) ); var throttle = changeSource.Throttle(TimeSpan.FromMilliseconds(delayMs)); return(changeSource.Buffer(throttle)); }
public CotationSeed(IntranetDbContext ctx, ApiSettings settings, IMapper mapper) : base(ctx, settings, mapper) { _cotationPieceObserveInserting = DbObservable <IntranetDbContext> .FromInserting <CotationPiece>(); _cotationPieceObserveInserting.Subscribe(entry => { var _params = Context.Parametres.Local.Where(p => p.CodePrimaire == Settings.CodePrimaire.Format && p.CodeSecondaire > 0).ToList(); foreach (var _param in _params) { var cotpiecform = Mapper.Map <CotationPieceFormat>(_param); if (cotpiecform == null) { continue; } cotpiecform.Piece = entry.Entity; } }); }
public CompanyEventProcessor() { eventObservable = DbObservable <BiContext> .FromInserting <EventEntity>() .Where(entry => entry.Entity.Body is CompanyEvent); eventObservable .Where(entry => entry.Entity.Body is CompanyCreatedEvt) .Subscribe(onCreate); eventObservable .Where(entry => entry.Entity.Body is CompanyUpdatedEvt) .Subscribe(onUpdate); eventObservable .Where(entry => entry.Entity.Body is ModuleAddedEvt) .Subscribe(onAddModule); eventObservable .Where(entry => entry.Entity.Body is CompanyDeletedEvt) .Subscribe(onDelete); }
private void Initialize() { // Random rnd = new Random(); joueurSpidObserveInserted = DbObservable <OldPingDbContext> .FromInserted <Joueur>(); joueurSpidObserveInserted.Subscribe(entry => { var joueur = entry.Entity; var extra = new JoueurExtra() { Licence = joueur.Licence }; joueur.Extra = extra; }); /* organismeObserveInserted = DbObservable<PingDbContext>.FromInserted<Organisme>(); * organismeObserveInserted.Subscribe(entry => * { * entry.Entity.Id = rnd.Next().ToString(); * });*/ }
private void Initialize() { _cotationPieceObserveInserted = DbObservable <IntranetDbContext> .FromInserting <CotationPiece>(); _cotationPieceObserveInserted.Subscribe(entry => { var _params = this.Parametres.Local.Where(p => p.CodePrimaire == _settings.CodePrimaire.Format && p.CodeSecondaire > 0).ToList(); foreach (var _param in _params) { var cotpiecform = _mapper.Map <CotationPieceFormat>(_param); if (cotpiecform == null) { continue; } cotpiecform.Piece = entry.Entity; entry.Entity.Formats.Add(cotpiecform); CotationsPiecesFormats.Add(cotpiecform); } }); }
public ReportNotifier() { var eventObs = DbObservable <BiContext> .FromInserted <EventEntity>(); eventObs.Where(evt => evt.Entity.Body is ReportUpdatedEvt).Subscribe(OnUpdated); }
public IObservable <NotificationEntity> Listen(long userId) { return(DbObservable <BiContext> .FromInserted <NotificationEntity>() .Where(n => n.Entity.Receivers.Any(u => u.UserId == userId)) .Select(n => n.Entity)); }
public ReportEventProcessor() { var eventObs = DbObservable <BiContext> .FromInserting <EventEntity>(); eventObs.Where(evt => evt.Entity.Body is ReportUpdatedEvt).Subscribe(OnUpdate); }
public EventRepository(BiContext context) { this.context = context; this.evtObs = DbObservable <BiContext> .FromInserting <EventEntity>(); }