Esempio n. 1
0
        public CompanyNotifier()
        {
            eventObservable = DbObservable <BiContext> .FromInserted <EventEntity>()
                              .Where(entry => entry.Entity.Body is CompanyEvent);

            // eventObservable.Where(entry => entry.Entity.Body is CompanyUpdatedEvt)
            //     .Subscribe(onUpdated);
        }
Esempio n. 2
0
        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);
        }
Esempio n. 3
0
        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);
            }
        }
Esempio n. 4
0
        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);
        }
Esempio n. 5
0
        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);
        }
Esempio n. 6
0
        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);
        }
Esempio n. 7
0
        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();
        }
Esempio n. 8
0
        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));
        }
Esempio n. 9
0
        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;
                }
            });
        }
Esempio n. 10
0
        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);
        }
Esempio n. 11
0
        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();
             * });*/
        }
Esempio n. 12
0
        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);
                }
            });
        }
Esempio n. 13
0
        public ReportNotifier()
        {
            var eventObs = DbObservable <BiContext> .FromInserted <EventEntity>();

            eventObs.Where(evt => evt.Entity.Body is ReportUpdatedEvt).Subscribe(OnUpdated);
        }
Esempio n. 14
0
 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));
 }
Esempio n. 15
0
        public ReportEventProcessor()
        {
            var eventObs = DbObservable <BiContext> .FromInserting <EventEntity>();

            eventObs.Where(evt => evt.Entity.Body is ReportUpdatedEvt).Subscribe(OnUpdate);
        }
Esempio n. 16
0
 public EventRepository(BiContext context)
 {
     this.context = context;
     this.evtObs  = DbObservable <BiContext> .FromInserting <EventEntity>();
 }