Esempio n. 1
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="address"></param>
 /// <param name="name"></param>
 public static void CreateContainer(string name)
 {
     using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
     {
         OleDbCommand myCommandd = new OleDbCommand("insert into [container](ContainerName) values ( '" + name + "')", objConnection);
         myCommandd.ExecuteNonQuery();
     }
 }
Esempio n. 2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="address"></param>
 /// <param name="ID"></param>
 public static void Delete(string ID)
 {
     using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
     {
         OleDbCommand myCommandd = new OleDbCommand("delete from [storage] where id = " + ID, objConnection);
         myCommandd.ExecuteNonQuery();
     }
 }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="fileName"></param>
        /// <param name="size"></param>
        /// <param name="fileType"></param>
        /// <param name="isPublished"></param>
        /// <param name="ContainerID"></param>
        public static void Create(string fileName, int size, string fileType, bool isPublished, int ContainerID)
        {
            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                string       sql        = string.Format("insert into [storage]([Name],[Size],[Type],[IsPublished],[ContainerID]) values ( '{0}',{1},'{2}',{3},{4})", fileName, size, fileType, isPublished, ContainerID);
                OleDbCommand myCommandd = new OleDbCommand(sql, objConnection);

                myCommandd.ExecuteNonQuery();
            }
        }
Esempio n. 4
0
        public static void DeleteStorageItem(string containerName, string storageItemName)
        {
            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbCommand command = new OleDbCommand("DELETE from [storage] where [storage].[Name]='" + storageItemName +
                                                        "' and [storage].[ContainerID] IN (SELECT [ID] from [container] where [container].[ContainerName] = '" + containerName + "')",
                                                        objConnection);

                command.ExecuteNonQuery();
            }
        }
Esempio n. 5
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="address"></param>
 /// <returns></returns>
 public static DataSet Select()
 {
     using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
     {
         OleDbDataAdapter myCommandd = new OleDbDataAdapter(
             "select [storage].[ID],[storage].[Name],[storage].[Size],[storage].[Type],[container].[CDNUri],[storage].[IsPublished],[container].[ContainerName] from [storage],[container] where [storage].[ContainerID] = [container].[ID]", objConnection);
         DataSet ds = new DataSet();
         myCommandd.Fill(ds);
         return(ds);
     }
 }
Esempio n. 6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="containerName"></param>


        /// <summary>
        ///
        /// </summary>
        /// <param name="containerName"></param>
        public static void MakeContainerPrivate(string containerName)
        {
            string sqlContainerName = containerName.Replace("'", "''");

            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbCommand myCommandd = new OleDbCommand(
                    "update [container] set IsPublished = false, CDNUri = '' where [container].[ContainerName]='"
                    + sqlContainerName + "'", objConnection);
                myCommandd.ExecuteNonQuery();
            }
        }
Esempio n. 7
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <param name="containerID"></param>
        /// <returns></returns>
        public static int ContainerIncludeFile(string name, int containerID)
        {
            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbCommand command = new OleDbCommand("select * from [storage] where [storage].[Name]='" + name + "' and [storage].[ContainerID]= " + containerID, objConnection);

                OleDbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    return(Convert.ToInt32(reader[0].ToString()));
                }
                return(-1);
            }
        }
Esempio n. 8
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int SelectContainerID(string name)
        {
            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbCommand command = new OleDbCommand("select [container].[ID],[container].[ContainerName] from [container] where ContainerName='" + name + "'", objConnection);

                OleDbDataReader reader = command.ExecuteReader();
                while (reader.Read())
                {
                    return(Convert.ToInt32(reader[0].ToString()));
                }
                return(-1);
            }
        }
Esempio n. 9
0
        public static bool GetContainerStatus(string containerName)
        {
            bool isPublished = false;

            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbCommand    cmm    = new OleDbCommand("select IsPublished from [container] where ContainerName='" + containerName + "'", objConnection);
                OleDbDataReader reader = cmm.ExecuteReader();

                while (reader.Read())
                {
                    isPublished = Convert.ToBoolean(reader[0].ToString());
                }
            }
            return(isPublished);
        }
Esempio n. 10
0
        public static List <string> GetPublicContainers()
        {
            List <string> containers = new List <string>();

            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbCommand    cmm    = new OleDbCommand("Select ContainerName from [container] where IsPublished=TRUE", objConnection);
                OleDbDataReader reader = cmm.ExecuteReader();

                while (reader.Read())
                {
                    containers.Add(reader["ContainerName"].ToString());
                }
            }

            return(containers);
        }
Esempio n. 11
0
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        public static List <string> GetAllContainerNames()
        {
            List <string> containerList = new List <string>();

            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbDataAdapter myCommandd = new OleDbDataAdapter("select [container].[ContainerName] from [container]", objConnection);
                DataSet          ds         = new DataSet();
                myCommandd.Fill(ds);

                foreach (DataRow dt in ds.Tables[0].Rows)
                {
                    string containerName = dt["ContainerName"].ToString();
                    containerList.Add(containerName);
                }
            }

            return(containerList);
        }
Esempio n. 12
0
        public static void DeleteContainer(string containerName)
        {
            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                // First delete the container's storage items (if any)
                string sql = "DELETE from [storage] where " +
                             "[storage].[ContainerID] IN (SELECT [ID] from [container] where [container].[ContainerName] = '" + containerName + "')";
                using (OleDbCommand command = new OleDbCommand(sql, objConnection))
                {
                    command.ExecuteNonQuery();
                }

                // Now delete the container itself
                sql = "DELETE FROM [container] where [container].[ContainerName] = '" + containerName + "'";
                using (OleDbCommand command = new OleDbCommand(sql, objConnection))
                {
                    command.ExecuteNonQuery();
                }
            }
        }
Esempio n. 13
0
        public static List <string> GetStorageItems(string containerName)
        {
            containerName = containerName.Replace("'", "''");

            List <string> storageItemList = new List <string>();

            using (OleDbConnection objConnection = SQLDatabaseHelper.GetConnection())
            {
                OleDbDataAdapter myCommand = new OleDbDataAdapter(
                    "select [storage].[Name] from [storage], [container] where [storage].ContainerID = [container].ID and [container].ContainerName = '" + @containerName + "'", objConnection);
                DataSet ds = new DataSet();
                myCommand.Fill(ds);

                foreach (DataRow dt in ds.Tables[0].Rows)
                {
                    string itemName = dt["Name"].ToString();
                    storageItemList.Add(itemName);
                }
            }

            return(storageItemList);
        }