Esempio n. 1
0
        public LiteDbContext(ILiteDatabase liteDatabase)
        {
            _database = liteDatabase ?? throw new ArgumentNullException(nameof(liteDatabase));

            Applications = new LiteDbCollection <Application>(_database);
            Applications.EnsureIndex(x => x.HierarchyPath);
        }
Esempio n. 2
0
        public MongoDbService(MongoDBConfig dBConfig)
        {
            _dBConfig = dBConfig;
            _client   = new MongoClient(new MongoClientSettings()
            {
                Server     = MongoServerAddress.Parse(_dBConfig.Host),
                Credential = string.IsNullOrEmpty(_dBConfig.AuthMechanism)
                    ? null
                    : MongoCredential.CreateCredential(
                    _dBConfig.AuthSource,
                    _dBConfig.Username,
                    _dBConfig.Password
                    )
            });
            _dB = _client.GetDatabase(_dBConfig.Database);

            _data   = _dB.GetCollection <CcData>(_dBConfig.CollectionData);
            _events = _dB.GetCollection <CcEvent>(_dBConfig.CollectionEvents);
            _groups = _dB.GetCollection <CcGroup>(_dBConfig.CollectionGroups);


            Data   = new MongoCollection <CcData>(_data);
            Events = new MongoCollection <CcEvent>(_events);
            Groups = new MongoCollection <CcGroup>(_groups);
        }
Esempio n. 3
0
        //Scoped模式
        public BaseService(IContext context)
        {
            this.context    = context;
            this.repository = Repository <T> .Instance;
            this.collection = repository.GetCollection();

            if (this.GetContext() != null && this.GetContext().IsUseCache)
            {
                cache = LocalCache <T> .Instance;
                RebuildCache();
            }
        }
Esempio n. 4
0
        //Scoped模式
        public BaseService(IContext context)
        {
            this.context    = context;
            this.repository = Repository <T> .Instance;
            this.collection = repository.GetCollection(DatabaseManager.Instance.GetDbName(typeof(T)));

            if (this.GetContext().IsUseCache)
            {
                cache = LocalCache <T> .Instance;
                RebuildCache();
            }
        }
Esempio n. 5
0
        public static async Task <long> MarkAsReadAsync(this IDbCollection <CcEvent> collection, IEnumerable <CcEvent> documents)
        {
            var i = 0L;

            foreach (var document in documents.Where(j => j.IsNew))
            {
                document.IsNew = false;
                await collection.UpdateDocumentAsync(document);

                i++;
            }

            return(i);
        }
Esempio n. 6
0
        //Singleton模式
        public BaseService(IContextRepository contextRepository)
        {
            this.contextRepository = contextRepository;
            this.repository        = Repository <T> .Instance;
            this.collection        = repository.GetCollection();

            //if (this.GetContext() != null && this.GetContext().IsUseCache)
            //{
            //    cache = LocalCache<T>.Instance;
            //    RebuildCache();
            //}

            cache = LocalCache <T> .Instance;
            RebuildCache();
        }
Esempio n. 7
0
        //Singleton模式
        public BaseService(IContextRepository contextRepository)
        {
            this.contextRepository = contextRepository;
            this.repository        = Repository <T> .Instance;
            this.collection        = repository.GetCollection(DatabaseManager.Instance.GetDbName(typeof(T)));

            if (this.GetContext().IsUseCache)
            {
                cache = LocalCache <T> .Instance;
                RebuildCache();
            }

            if (_historyService == null)
            {
                _historyService = new HistoryService();
            }
        }
Esempio n. 8
0
 public AccountManager(IDbCollection dbCollection)
 {
     this.AccountCollection = dbCollection;
 }
 public ModelsEntityRepository(ILoggerFactory logger, IDatabaseContext context)
 {
     _logger = logger.CreateLogger <ModelsEntityRepository>();
     _models = context.GetCollection <ModelsEntity>(CollectionName);
 }
Esempio n. 10
0
 public UserRepository(ILoggerFactory logger, IDatabaseContext context)
 {
     _logger = logger.CreateLogger <UserRepository>();
     _users  = context.GetCollection <User>(CollectionName);
 }
Esempio n. 11
0
 private Repository()
 {
     db         = DatabaseManager.Instance.GetDatabase(GetDbName(typeof(T).FullName));
     collection = db.GetCollection <T>();
 }
Esempio n. 12
0
 public BaseService()
 {
     this.contextRepository = null;
     this.repository        = Repository <T> .Instance;
     this.collection        = repository.GetCollection(DatabaseManager.Instance.GetDbName(typeof(T)));
 }
Esempio n. 13
0
 public TemplateEntityRepository(ILoggerFactory logger, IDatabaseContext context)
 {
     _logger    = logger.CreateLogger <TemplateEntityRepository>();
     _Templates = context.GetCollection <TemplateEntity>(CollectionName);
 }