예제 #1
0
        /// <summary>
        /// Retrieve metadata for a given object.
        /// </summary>
        /// <param name="name">The name of the object.</param>
        /// <param name="metadata">Object metadata.</param>
        /// <returns>True if successful.</returns>
        public override bool GetObjectMetadata(string name, out ObjectMetadata metadata)
        {
            if (String.IsNullOrEmpty(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            name     = DedupeCommon.SanitizeString(name);
            metadata = null;

            string    query = "SELECT * FROM ObjectMap WHERE Name = '" + name + "'";
            DataTable result;
            bool      success = false;

            lock (_ObjectLock)
            {
                success = Query(query, out result);
            }

            if (result == null || result.Rows.Count < 1)
            {
                return(false);
            }
            if (!success)
            {
                return(false);
            }

            metadata = ObjectMetadata.FromDataTable(result);
            return(true);
        }
예제 #2
0
 private List <T> DataTableToListObject <T>(DataTable result)
 {
     if (result == null || result.Rows.Count < 1)
     {
         return(new List <T>());
     }
     if (typeof(T) == typeof(ApiKey))
     {
         return(ApiKey.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(UserMaster))
     {
         return(UserMaster.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(Permission))
     {
         return(Permission.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(UrlLock))
     {
         return(UrlLock.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(Container))
     {
         return(Container.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(ObjectMetadata))
     {
         return(ObjectMetadata.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(ContainerKeyValuePair))
     {
         return(ContainerKeyValuePair.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(ObjectKeyValuePair))
     {
         return(ObjectKeyValuePair.FromDataTable(result) as List <T>);
     }
     else if (typeof(T) == typeof(AuditLogEntry))
     {
         return(AuditLogEntry.FromDataTable(result) as List <T>);
     }
     throw new ArgumentException("Unknown object type: " + typeof(T).Name);
 }
예제 #3
0
        public override bool GetObjectMetadata(string name, out ObjectMetadata metadata)
        {
            name     = DedupeCommon.SanitizeString(name);
            metadata = null;

            string    query = "SELECT * FROM ObjectMap WHERE Name = '" + name + "'";
            DataTable result;

            lock (_ObjectLock)
            {
                result = _Database.Query(query);
            }

            if (result == null || result.Rows.Count < 1)
            {
                return(false);
            }

            metadata = ObjectMetadata.FromDataTable(result);
            return(true);
        }