예제 #1
0
        public static UrlLogin GetUrlLogin(MongoConnection connection, string urlName)
        {
            IMongoCollection <UrlLogin>      urlLoginCollection = connection.Database.GetCollection <UrlLogin>(typeof(UrlLogin).Name);
            IFindFluent <UrlLogin, UrlLogin> urlLoginFind       = urlLoginCollection.Find(urlLogin => urlLogin.UrlName == urlName);
            Task <UrlLogin> urlLoginTask = urlLoginFind.SingleAsync();

            return(MongoDataHelper.GetValueOrThrowTimeout(urlLoginTask));
        }
예제 #2
0
        public static Config GetConfig(MongoConnection connection)
        {
            IMongoCollection <Config>    configs    = connection.Database.GetCollection <Config>(typeof(Config).Name);
            IFindFluent <Config, Config> configFind = configs.Find(config => true);
            Task <Config> configTask = configFind.SingleAsync();

            return(MongoDataHelper.GetValueOrThrowTimeout(configTask));
        }
예제 #3
0
        protected static long Count <TDataType>(MongoConnection connection)
            where TDataType : AbstractMongoData
        {
            IMongoCollection <TDataType> dataCollection = connection.Database.GetCollection <TDataType>(typeof(TDataType).Name);
            BsonDocument filter    = new BsonDocument();
            Task <long>  dataCount = dataCollection.CountAsync(filter);

            return(MongoDataHelper.GetValueOrThrowTimeout(dataCount));
        }
예제 #4
0
        public static List <Worker> GetDeadWorkers(MongoConnection mongoConnection, DateTime lastAcceptableWorkerTime)
        {
            IMongoCollection <Worker> collection = mongoConnection.Database.GetCollection <Worker>(typeof(Worker).Name);

            FilterDefinition <Worker> filter = Builders <Worker> .Filter.Lt(worker => worker.LastWorkTime, lastAcceptableWorkerTime);

            IFindFluent <Worker, Worker> find = collection.Find(filter);

            Task <List <Worker> > task = find.ToListAsync();

            return(MongoDataHelper.GetValueOrThrowTimeout(task));
        }