Ejemplo n.º 1
0
        /// <summary>
        /// Returns the metadata for a dataset
        /// </summary>
        /// <param name="Name">The name of the dataset</param>
        /// <returns>The metadata requested</returns>
        internal CatalogDatasetEntry GetEntry(string Name)
        {
            IMongoQuery  qry    = Query.EQ("Name", BsonValue.Create(Name));
            BsonDocument result = m_Conn[GDB_ITEMS].FindOne(qry);

            if (default(ResultPortionInfo) == result)
            {
                throw new COMException("No metadata for item: " + Name);
            }
            CatalogDatasetEntry retval = new CatalogDatasetEntry(this);

            retval.Load(result);
            return(retval);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Get's Metadata for all datasets stored in the database
        /// </summary>
        /// <returns>Enumerable of CatalogDatasetEntries</returns>
        internal IEnumerable <CatalogDatasetEntry> GetAllEntries()
        {
            List <CatalogDatasetEntry> retVal = new List <CatalogDatasetEntry>();
            var results = m_Conn[GDB_ITEMS].Find(Query.Null);

            List <ObjectId> deleteThese = new List <ObjectId>();

            foreach (var result in results)
            {
                try
                {
                    CatalogDatasetEntry tmp = new CatalogDatasetEntry(this);
                    tmp.Load(result);
                    if (!(String.IsNullOrEmpty(tmp.Name) || (tmp.Fields == null) || (tmp.Extent == null)))
                    {
                        retVal.Add(tmp);
                    }
                    else
                    {
                        deleteThese.Add(result.GetElement(CommonConst.OID).Value.AsObjectId);
                    }
                }
                catch (Exception)
                { }
            }
            if (deleteThese.Count > 0)
            {
                BsonValue[] ids = new BsonValue[deleteThese.Count];
                int         i   = 0;
                foreach (var x in deleteThese)
                {
                    ids[i++] = BsonValue.Create(x);
                }
                m_Conn[GDB_ITEMS].Remove(Query.In(CommonConst.OID, ids));
            }
            return(retVal);
        }