public async Task CreateIndex(IMongoStorage storage) { if (!IndexCreated) { var stateCollection = storage.GetCollection <BsonDocument>(EventDataBase, SnapshotCollection); var stateIndex = await stateCollection.Indexes.ListAsync(); var stateIndexList = await stateIndex.ToListAsync(); if (!stateIndexList.Exists(p => p["name"] == "State")) { await stateCollection.Indexes.CreateOneAsync(new CreateIndexModel <BsonDocument>("{'StateId':1}", new CreateIndexOptions { Name = "State", Unique = true })); } var collection = storage.GetCollection <BsonDocument>(EventDataBase, C_CName); var index = await collection.Indexes.ListAsync(); var indexList = await index.ToListAsync(); if (!indexList.Exists(p => p["name"] == "Name")) { await collection.Indexes.CreateOneAsync(new CreateIndexModel <BsonDocument>("{'Name':1}", new CreateIndexOptions { Name = "Name", Unique = true })); } IndexCreated = true; } }
public StorageServico( IMongoStorage gridStorage, IStorageRepositorio storageRepository) { this.gridStorage = gridStorage; this.storageRepository = storageRepository; }
public StorageConfig(IMongoStorage storage, string database, string eventCollection, string snapshotCollection, int subTableMinutesInterval = 40) { Storage = storage; DataBase = database; EventCollection = eventCollection; SnapshotCollection = snapshotCollection; SubTableMillionSecondsInterval = subTableMinutesInterval * 24 * 60 * 60 * 1000; }
public SampleControllerTests() { mongoStorage = new MongoStorage(new MongoSettings()); var storage = new EntityStorage <SampleEntity>(mongoStorage, new Indexes <SampleEntity>()); var mapper = new Mapper <ApiSample, SampleEntity>(); service = new EntityService <ApiSample, SampleEntity>(storage, mapper); }
public CollectionWrapper( IMongoStorageFactory factory, INotifyToSubscribers notifyToSubscribers ) { _notifyToSubscribers = notifyToSubscribers; _storage = factory.GetCollection <TModel, TKey>(); }
public EntityServiceTests() { this.mongoStorage = new MongoStorage(new MongoSettings()); var storage = new MongoRepository <SampleEntity>(this.mongoStorage, new Indexes <SampleEntity>()); var mapper = new Mapper <ApiSample, SampleEntity>(); this.service = new EntityService <ApiSample, SampleEntity>(storage, mapper); }
public CollectionWrapper( IMongoStorageFactory factory, INotifyToSubscribers notifyToSubscribers ) { _notifyToSubscribers = notifyToSubscribers; _storage = factory.GetCollection <TModel, TKey>(); _pollableSecondaryIndexCounter = DateTime.UtcNow.Ticks; }
public MongoGrainConfig(IMongoStorage storage, string database, string eventCollection, string snapshotCollection, DateTime splitCollectionStartTime, bool sharding = false, int shardingDays = 90) { DataBase = database; EventCollection = eventCollection; SnapshotCollection = snapshotCollection; Storage = storage; this.sharding = sharding; this.shardingDays = shardingDays; SplitStartTime = splitCollectionStartTime; }
public ArquivosController() { this.sessaoDoUsuario = InversionControl.Current.Resolve<ISessaoDoUsuario>(); this.salvarConteudoServico = InversionControl.Current.Resolve<SalvarConteudoServico>(); this.versaoDocumentoRepositorio = InversionControl.Current.Resolve<IVersaoDocumentoRepositorio>(); this.documentoRepositorio = InversionControl.Current.Resolve<IDocumentoRepositorio>(); this.storageServico = InversionControl.Current.Resolve<StorageServico>(); this.mongoStorage = InversionControl.Current.Resolve<IMongoStorage>(); this.openOfficeTransformer = InversionControl.Current.Resolve<OpenOfficeTransformer>(); this.logarAcaoSistema = InversionControl.Current.Resolve<LogarAcaoDoSistema>(); }
public StorageConfig(IMongoStorage storage, string database, string eventCollection, string snapshotCollection, bool isFollow = false, string followName = null, bool sharding = false, int shardingDays = 90) { DataBase = database; EventCollection = eventCollection; SnapshotCollection = snapshotCollection; Storage = storage; FollowName = followName; this.sharding = sharding; IsFollow = isFollow; shardingMinutes = shardingDays * 24 * 60; }
public ArquivosController() { this.sessaoDoUsuario = InversionControl.Current.Resolve <ISessaoDoUsuario>(); this.salvarConteudoServico = InversionControl.Current.Resolve <SalvarConteudoServico>(); this.versaoDocumentoRepositorio = InversionControl.Current.Resolve <IVersaoDocumentoRepositorio>(); this.documentoRepositorio = InversionControl.Current.Resolve <IDocumentoRepositorio>(); this.storageServico = InversionControl.Current.Resolve <StorageServico>(); this.mongoStorage = InversionControl.Current.Resolve <IMongoStorage>(); this.openOfficeTransformer = InversionControl.Current.Resolve <OpenOfficeTransformer>(); this.logarAcaoSistema = InversionControl.Current.Resolve <LogarAcaoDoSistema>(); }
public async Task CreateCollectionIndex(IMongoStorage storage) { var collectionService = storage.GetCollection <BsonDocument>(EventDataBase, C_CName); var index = await collectionService.Indexes.ListAsync(); var indexList = await index.ToListAsync(); if (!indexList.Exists(p => p["name"] == "Name")) { await collectionService.Indexes.CreateOneAsync("{'Name':1}", new CreateIndexOptions { Name = "Name", Unique = true }); } }
public async Task CreateStateIndex(IMongoStorage storage) { var collectionService = storage.GetCollection <BsonDocument>(EventDataBase, SnapshotCollection); CancellationTokenSource cancel = new CancellationTokenSource(1); var index = await collectionService.Indexes.ListAsync(); var indexList = await index.ToListAsync(); if (!indexList.Exists(p => p["name"] == "State")) { await collectionService.Indexes.CreateOneAsync("{'StateId':1}", new CreateIndexOptions { Name = "State", Unique = true }); } }
public CollectionInfo GetCollection(IMongoStorage storage, DateTime sysStartTime, DateTime eventTime) { CollectionInfo lastCollection = null; var cList = GetAllCollectionList(storage); if (cList.Count > 0) { lastCollection = cList.Last(); } //如果不需要分表,直接返回 if (lastCollection != null && !this.sharding) { return(lastCollection); } var subTime = eventTime.Subtract(sysStartTime); var cVersion = subTime.TotalDays > 0 ? Convert.ToInt32(Math.Floor(subTime.TotalDays / shardingDays)) : 0; if (lastCollection == null || cVersion > lastCollection.Version) { lock (collectionLock) { if (lastCollection == null || cVersion > lastCollection.Version) { var collection = new CollectionInfo { Id = ObjectId.GenerateNewId().ToString(), Version = cVersion, Type = EventCollection, CreateTime = DateTime.UtcNow, Name = EventCollection + "_" + cVersion }; try { storage.GetCollection <CollectionInfo>(EventDataBase, C_CName).InsertOne(collection); collectionList.Add(collection); lastCollection = collection; CreateEventIndex(storage, collection.Name).GetAwaiter().GetResult(); } catch (MongoWriteException ex) { if (ex.WriteError.Category == ServerErrorCategory.DuplicateKey) { collectionList = null; return(GetCollection(storage, sysStartTime, eventTime)); } } } } } return(lastCollection); }
public List <CollectionInfo> GetAllCollectionList(IMongoStorage storage) { if (collectionList == null) { lock (collectionLock) { if (collectionList == null) { collectionList = storage.GetCollection <CollectionInfo>(EventDataBase, C_CName).Find <CollectionInfo>(c => c.Type == EventCollection).ToList(); } } } return(collectionList); }
#pragma warning disable S2436 // Classes and methods should not have too many generic parameters public static async Task <List <TModel> > FindByPropertyAsListAsync <TModel, TKey, TValue>( #pragma warning restore S2436 // Classes and methods should not have too many generic parameters this IMongoStorage <TModel, TKey> storage, Expression <Func <TModel, TValue> > propertySelector, TValue value) where TModel : class, IReadModelEx <TKey> { List <TModel> retValue = new List <TModel>(); Func <TModel, Task> wrapper = m => { retValue.Add(m); return(Task.CompletedTask); }; await storage.FindByPropertyAsync(propertySelector, value, wrapper).ConfigureAwait(false); return(retValue); }
public async Task CreateEventIndex(IMongoStorage storage, string collectionName) { var collectionService = storage.GetCollection <BsonDocument>(EventDataBase, collectionName); var indexList = (await collectionService.Indexes.ListAsync()).ToList(); if (!indexList.Exists(p => p["name"] == "State_Version") && !indexList.Exists(p => p["name"] == "State_UniqueId")) { await collectionService.Indexes.CreateManyAsync( new List <CreateIndexModel <BsonDocument> >() { new CreateIndexModel <BsonDocument>("{'StateId':1,'Version':1}", new CreateIndexOptions { Name = "State_Version", Unique = true }), new CreateIndexModel <BsonDocument>("{'StateId':1,'TypeCode':1,'UniqueId':1}", new CreateIndexOptions { Name = "State_UniqueId", Unique = true }) } ); } }
public List <CollectionInfo> GetCollectionList(IMongoStorage storage, DateTime sysStartTime, DateTime?startTime = null) { List <CollectionInfo> list = null; if (startTime == null) { list = GetAllCollectionList(storage); } else { var collection = GetCollection(storage, sysStartTime, startTime.Value); list = GetAllCollectionList(storage).Where(c => c.Version >= collection.Version).ToList(); } if (list == null || list.Count == 0) { list = new List <CollectionInfo>() { GetCollection(storage, sysStartTime, DateTime.UtcNow) }; } return(list); }
private static void InternalCanDropCollection(IMongoStorage mongoStorage) { var filter = new BsonDocument("name", StorageTestConstants.EntityCollectionName); try { mongoStorage.Database.CreateCollection(StorageTestConstants.EntityCollectionName); } catch (MongoCommandException) { } var collections = mongoStorage.Database.ListCollections(new ListCollectionsOptions { Filter = filter }); Assert.IsTrue(collections.Any()); mongoStorage.DropCollection <WithCollectionAttributeEntity, Guid>(); collections = mongoStorage.Database.ListCollections(new ListCollectionsOptions { Filter = filter }); Assert.IsFalse(collections.Any()); }
public EntitiesRepository(IMongoStorage<Entity> entitiesStorage) { _entitiesStorage = entitiesStorage; }
public EntityNetworkRepository(IMongoStorage<EntityNetwork> storage) { _storage = storage; }
public RevokeKeyRepository(IMongoStorage <RevokeKeyEntity> table) { _table = table; }
public MongoReaderForProjections(IMongoStorageFactory factory) { _storage = factory.GetCollection <TModel, TKey>(); }
public TransactionSignRequestRepository(IMongoStorage <TransactionSignRequestEntity> table) { _table = table; }
public MongoEventStorage(IMongoStorage mongoStorage, ILogger <MongoEventStorage <K> > logger, MongoGrainConfig grainConfig) { this.mongoStorage = mongoStorage; this.grainConfig = grainConfig; this.logger = logger; }
public SegwitPrivateWalletRepository(IMongoStorage <SegwitPrivateWalletEntity> table) { _table = table; }
public MongoEventStorage(IMongoStorage mongoStorage, ILogger <MongoEventStorage <K> > logger, MongoStorageAttribute mongoAttr) { this.mongoStorage = mongoStorage; this.mongoAttr = mongoAttr; this.logger = logger; }
public MongoStateStorage(IMongoStorage mongoStorage, string database, string collection) { this.mongoStorage = mongoStorage; this.database = database; this.collection = collection; }
public CommitmentBroadcastRepository(IMongoStorage <CommitmentBroadcastEntity> table) { _table = table; }
public CallBackRepository(IMongoStorage <CallBackEntity> storage) { _storage = storage; }
public BroadcastedTransactionRepository(IMongoStorage <BroadcastedTransactionEntity> storage) { _storage = storage; }
public EntityStorage(IMongoStorage mongoStorage, IIndexes <TEntity> indexes) { Collection = mongoStorage.GetCollection <TEntity>(); indexes.CreateIndexes(Collection); }
public OffchainChannelRepository(IMongoStorage <OffchainChannelEntity> table) { _table = table; }