Beispiel #1
0
        //Insert
        public virtual async Task Insert(List <SignalBounce <ObjectId> > messages)
        {
            var options = new InsertManyOptions()
            {
                IsOrdered = false
            };

            await _collectionFactory
            .GetCollection <SignalBounce <ObjectId> >()
            .InsertManyAsync(messages, options)
            .ConfigureAwait(false);
        }
        //methods
        public virtual async Task Insert(List <StoredNotification <ObjectId> > items)
        {
            var options = new InsertManyOptions()
            {
                IsOrdered = true
            };

            await _collectionFactory
            .GetCollection <StoredNotification <ObjectId> >()
            .InsertManyAsync(items, options)
            .ConfigureAwait(false);
        }
Beispiel #3
0
        //methods
        public virtual async Task Insert(List <TTopic> settings)
        {
            var options = new InsertManyOptions()
            {
                IsOrdered = false
            };

            await _collectionFactory
            .GetCollection <TTopic>()
            .InsertManyAsync(settings, options)
            .ConfigureAwait(false);
        }
Beispiel #4
0
        //methods
        public virtual async Task Insert(List <SubscriberScheduleSettings <ObjectId> > periods)
        {
            var options = new InsertManyOptions()
            {
                IsOrdered = false
            };

            await _collectionFactory
            .GetCollection <SubscriberScheduleSettings <ObjectId> >()
            .InsertManyAsync(periods, options)
            .ConfigureAwait(false);
        }
Beispiel #5
0
        //Insert
        public virtual async Task Insert(List <SignalDispatch <ObjectId> > items)
        {
            foreach (SignalDispatch <ObjectId> item in items)
            {
                item.SignalDispatchId = ObjectId.GenerateNewId();
            }

            var options = new InsertManyOptions()
            {
                IsOrdered = false
            };

            await _collectionFactory
            .GetCollection <SignalDispatch <ObjectId> >(CollectionNames.DISPATCHES)
            .InsertManyAsync(items, options)
            .ConfigureAwait(false);
        }
Beispiel #6
0
        //methods
        public virtual Task Insert(List <TCategory> settings)
        {
            var options = new InsertManyOptions()
            {
                IsOrdered = false
            };

            return(_collectionFactory
                   .GetCollection <TCategory>()
                   .InsertManyAsync(settings, options));
        }
Beispiel #7
0
        //methods
        public Task Insert(List <DispatchTemplate <ObjectId> > items)
        {
            var options = new InsertManyOptions()
            {
                IsOrdered = true
            };

            return(_collectionFactory
                   .GetCollection <DispatchTemplate <ObjectId> >()
                   .InsertManyAsync(items, options));
        }
Beispiel #8
0
        //methods
        public virtual Task Insert(List <EventSettings <ObjectId> > items)
        {
            foreach (EventSettings <ObjectId> item in items)
            {
                item.EventSettingsId = ObjectId.GenerateNewId();
            }

            var options = new InsertManyOptions()
            {
                IsOrdered = false
            };

            return(_collectionFactory.GetCollection <EventSettings <ObjectId> >()
                   .InsertManyAsync(items, options));
        }
Beispiel #9
0
        protected virtual Task <List <Subscriber <ObjectId> > > LookupStartingWithTopics(
            SubscriptionParameters parameters, SubscribersRangeParameters <ObjectId> subscribersRange)
        {
            var pipeline = new EmptyPipelineDefinition <TTopic>()
                           .As <TTopic, TTopic, TTopic>();

            var pipeline2 = pipeline.Match(ToTopicSettingsFilter(parameters, subscribersRange))
                            .As <TTopic, TTopic, BsonDocument>();

            pipeline2 = AddCategoryLookupStages(pipeline2, parameters, subscribersRange);
            pipeline2 = AddDeliveryTypeLookupStages(pipeline2, parameters, subscribersRange);

            //var bsonDocs = _collectionFactory.GetCollection<TTopic>().Aggregate(pipeline2).ToList();
            //string jsonResults = bsonDocs.Select(x => x.ToJsonIntended()).Join(",");
            //return null;

            PipelineDefinition <TTopic, Subscriber <ObjectId> > pipelineProjected =
                AddSubscribersProjectionAndLimitStage(pipeline2, subscribersRange);

            return(_collectionFactory.GetCollection <TTopic>()
                   .Aggregate(pipelineProjected)
                   .ToListAsync());
        }
        //methods
        public virtual Task Insert(List <TCategory> settings)
        {
            if (settings == null || settings.Count == 0)
            {
                return(Task.CompletedTask);
            }

            var options = new InsertManyOptions()
            {
                IsOrdered = false
            };

            var deliveryTypeGroups = settings
                                     .GroupBy(x => new { x.SubscriberId, x.DeliveryType });

            var writeOperations = new List <WriteModel <TDeliveryType> >();

            foreach (var deliveryTypeGroup in deliveryTypeGroups)
            {
                var filter = Builders <TDeliveryType> .Filter.Where(
                    p => p.SubscriberId == deliveryTypeGroup.Key.SubscriberId &&
                    p.DeliveryType == deliveryTypeGroup.Key.DeliveryType);

                var update = Builders <TDeliveryType> .Update
                             .AddToSetEach(x => x.SubscriberCategorySettings, deliveryTypeGroup);

                var updateModel = new UpdateOneModel <TDeliveryType>(filter, update);;
                writeOperations.Add(updateModel);
            }

            return(_collectionFactory
                   .GetCollection <TDeliveryType>()
                   .BulkWriteAsync(writeOperations, new BulkWriteOptions
            {
                IsOrdered = false
            }));
        }
 //ctor
 public MongoDbSignalDispatchHistoryQueries(ICollectionFactory collectionFactory)
 {
     _collection = collectionFactory.GetCollection <SignalDispatch <ObjectId> >(CollectionNames.DISPATCHES_HISTORY);
 }
 //ctor
 public MongoDbConsolidationLockQueries(ICollectionFactory collectionFactory)
 {
     _collection = collectionFactory.GetCollection <ConsolidationLock <ObjectId> >();
 }