Пример #1
0
        public ArrayList find(string db, string collection, int skip, int limit, int batch_size, Hashtable json_query, Hashtable json_fields)
        {
            var _db         = _mongoserver.GetDatabase(db);
            var _collection = _db.GetCollection <MongoDB.Bson.BsonDocument>(collection) as MongoDB.Driver.MongoCollection <MongoDB.Bson.BsonDocument>;

            MongoDB.Driver.QueryDocument _query = new MongoDB.Driver.QueryDocument(json_query);

            MongoDB.Driver.MongoCursor <MongoDB.Bson.BsonDocument> c = null;
            if (json_fields != null)
            {
                MongoDB.Driver.FieldsDocument _fields = new MongoDB.Driver.FieldsDocument(json_fields);
                c = _collection.FindAs <MongoDB.Bson.BsonDocument>(_query).SetSkip(skip).SetLimit(limit).SetBatchSize(batch_size).SetFields(_fields);
            }
            else
            {
                c = _collection.FindAs <MongoDB.Bson.BsonDocument>(_query).SetSkip(skip).SetLimit(limit).SetBatchSize(batch_size);
            }

            ArrayList _list = new ArrayList();

            foreach (var data in c)
            {
                var _data = data.ToHashtable();
                _data.Remove("_id");
                _list.Add(_data);
            }

            return(_list);
        }
Пример #2
0
        public static StationDetail GetDetail()
        {
            string baseurl = NetworkHelper.GetBaseURL();

            StationDetail status = new StationDetail
            {
                location      = baseurl,
                diskusage     = new List <DiskUsage>(),
                upnp          = PublicPortMapping.Instance.GetUPnPInfo(),
                computer_name = Environment.MachineName,
                version       = Assembly.GetExecutingAssembly().GetName().Version.ToString()
            };

            MongoDB.Driver.MongoCursor <Driver> drivers = DriverCollection.Instance.FindAll();

            foreach (Driver driver in drivers)
            {
                FileStorage storage = new FileStorage(driver);
                foreach (UserGroup group in driver.groups)
                {
                    status.diskusage.Add(new DiskUsage {
                        group_id = group.group_id,
                        used     = storage.GetUsedSize(),
                        avail    = storage.GetAvailSize()
                    });
                }
            }

            return(status);
        }
 public void Read()
 {
     collection = base.Collection.FindAllAs<Products>();
 }