/// <summary>
        /// Loads the parts for the specfied media item
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemId">Unique identifier of the media item</param>
        /// <param name="mediaItemType">Type of the media item</param>
        /// <returns>Collection of parts belonging to the specified media item, sorted ascendingly</returns>
        public static Business.MediaItemPartCollection GetMediaItemPartsById(SqlConnection conn, Int64 mediaItemId, Business.MediaItemTypeEnum mediaItemType)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("MediaItemId", DbType.Int64, mediaItemId));
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));

                sp.DataTable table = SqlDbObject.ExecuteReader("GetMediaItemPartsById", CommandType.StoredProcedure, parameters.ToArray(), conn);
                Business.MediaItemPartCollection parts = new Business.MediaItemPartCollection();

                foreach (sp.DataRow row in table)
                {
                    IntelligentString location     = (String)row["Location"];
                    Int64             size         = (Int64)row["Size"];
                    Int32             milliseconds = (Int32)row["Duration"];
                    Int16             index        = (Int16)row["Index"];

                    parts.Add(location, size, milliseconds, index);
                }

                parts.Sort();
                return(parts);
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load play history for media item", e);
            }
        }
        /// <summary>
        /// Determines whether a root folder already exists with specified type and path
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemType">Type associated with the desired root folders</param>
        /// <param name="path">Path to the desired root folder</param>
        /// <returns>True if a root folder already exists with specified type and path, false if not</returns>
        public static Boolean RootFolderPathExists(SqlConnection conn, Business.MediaItemTypeEnum mediaItemType, String path)
        {
            List <sp.Parameter> parameters = new List <sp.Parameter>();

            parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));
            parameters.Add(new sp.Parameter("Path", DbType.String, path));

            return((Boolean)SqlDbObject.ExecuteScalar("RootFolderPathExists", CommandType.StoredProcedure, parameters.ToArray(), conn));
        }
 /// <summary>
 /// Updates a root folder in the database
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="rootFolder">Root folder being updated</param>
 public static void UpdateRootFolder(SqlConnection conn, Business.RootFolder rootFolder)
 {
     try
     {
         SqlDbObject.ExecuteNonQuery("UpdateRootFolder", CommandType.StoredProcedure, rootFolder.GetParametersForStoredProcedure(true), conn);
     }
     catch (System.Exception e)
     {
         throw new UpdateSqlDbObjectException("Could not update root folder", e);
     }
 }
 /// <summary>
 /// Adds a new root folder to the database
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="rootFolder">Root folder being added</param>
 /// <returns>Priority of the new root folder</returns>
 public static Int16 AddRootFolder(SqlConnection conn, Business.RootFolder rootFolder)
 {
     try
     {
         return((Int16)SqlDbObject.ExecuteScalar("AddRootFolder", CommandType.StoredProcedure, rootFolder.GetParametersForStoredProcedure(false), conn));
     }
     catch (System.Exception e)
     {
         throw new AddSqlDbObjectException("Could not add root folder", e);
     }
 }
Exemple #5
0
 /// <summary>
 /// Deletes the file type with the specified Id from the database
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="fileTypeId">Unique identifier of the file type being deleted</param>
 public static void DeleteFileType(SqlConnection conn, Int16 fileTypeId)
 {
     try
     {
         SqlDbObject.ExecuteNonQuery("DeleteFileType", CommandType.StoredProcedure, new sp.Parameter("FileTypeId", DbType.Int64, fileTypeId), conn);
     }
     catch (System.Exception e)
     {
         throw new DeleteSqlDbObjectException("Could not delete file tye from database", e);
     }
 }
Exemple #6
0
 /// <summary>
 /// Adds the specified file type to the database and returns the Id that was generated
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="fileType">FileType object being added to the database</param>
 /// <returns>New unique identifier of the file type</returns>
 public static Int16 AddFileType(SqlConnection conn, Business.FileType fileType)
 {
     try
     {
         return((Int16)SqlDbObject.ExecuteScalar("AddFileType", CommandType.StoredProcedure, fileType.GetParametersForStoredProcedure(false), conn));
     }
     catch (System.Exception e)
     {
         throw new AddSqlDbObjectException("Could not file type video to database", e);
     }
 }
Exemple #7
0
 /// <summary>
 /// Updates the specified file type in the database
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="fileType">FileType object being updated in the database</param>
 public static void UpdateFileType(SqlConnection conn, Business.FileType fileType)
 {
     try
     {
         SqlDbObject.ExecuteNonQuery("UpdateFileType", CommandType.StoredProcedure, fileType.GetParametersForStoredProcedure(true), conn);
     }
     catch (System.Exception e)
     {
         throw new UpdateSqlDbObjectException("Could not update file type in database", e);
     }
 }
Exemple #8
0
 /// <summary>
 /// Updates the specified song in the database
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="song">Song object being updated in the database</param>
 public static void UpdateSong(SqlConnection conn, Business.Song song)
 {
     try
     {
         SqlDbObject.ExecuteNonQuery("UpdateSong", CommandType.StoredProcedure, song.GetMediaItemParametersForStoredProcedure(true), conn);
     }
     catch (System.Exception e)
     {
         throw new UpdateSqlDbObjectException("Could not update song in database", e);
     }
 }
Exemple #9
0
 /// <summary>
 /// Adds the specified song to the database and returns the Id that was generated
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="song">Song object being added to the database</param>
 /// <returns>New unique identifier of the song</returns>
 public static Int64 AddSong(SqlConnection conn, Business.Song song)
 {
     try
     {
         return((Int64)SqlDbObject.ExecuteScalar("AddSong", CommandType.StoredProcedure, song.GetMediaItemParametersForStoredProcedure(false), conn));
     }
     catch (System.Exception e)
     {
         throw new AddSqlDbObjectException("Could not add song to database", e);
     }
 }
Exemple #10
0
 /// <summary>
 /// Deletes a deleted song iTunes ID from the database
 /// </summary>
 /// <param name="conn">Open connection to the database</param>
 /// <param name="iTunesId">iTunes ID being deleted from the database</param>
 public static void DeleteDeletedSongITunesId(SqlConnection conn, Int16 iTunesId)
 {
     try
     {
         SqlDbObject.ExecuteNonQuery("DeleteDeletedSongITunesId", CommandType.StoredProcedure, new sp.Parameter("iTunesId", DbType.Int16, iTunesId), conn);
     }
     catch (System.Exception e)
     {
         throw new DeleteSqlDbObjectException("Could not delete deleted song iTunes ID", e);
     }
 }
Exemple #11
0
        /// <summary>
        /// Deletes the media item with the specified Id from the database
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemId">Unique identifier of the media item being deleted</param>
        /// <param name="type">Type of media item being deleted</param>
        public static void DeleteMediaItem(SqlConnection conn, Int64 mediaItemId, Business.MediaItemTypeEnum type)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("MediaItemId", DbType.Int64, mediaItemId));
                parameters.Add(new sp.Parameter("Type", DbType.Int16, Convert.ToInt16(type)));

                SqlDbObject.ExecuteNonQuery("DeleteMediaItem", CommandType.StoredProcedure, parameters.ToArray(), conn);
            }
            catch (System.Exception e)
            {
                throw new DeleteSqlDbObjectException("Could not delete media item from database", e);
            }
        }
Exemple #12
0
        /// <summary>
        /// Removes an extension from a file type
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="fileTypeId">Unique identifier of the file type the extension is being removed from</param>
        /// <param name="extension">Extension being removed from the file type</param>
        public static void RemoveExtensionFromFileType(SqlConnection conn, Int16 fileTypeId, String extension)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("FileTypeId", DbType.Int16, fileTypeId));
                parameters.Add(new sp.Parameter("Extension", DbType.String, extension));

                SqlDbObject.ExecuteNonQuery("RemoveExtensionFromFileType", CommandType.StoredProcedure, parameters.ToArray(), conn);
            }
            catch (System.Exception e)
            {
                throw new RemoveChildSqlDbObjectFromParentException("Could not remove file type extension", e);
            }
        }
Exemple #13
0
 /// <summary>
 /// Initialises a new instance of the DeletedSongITunesIdCollection class
 /// </summary>
 public DeletedSongITunesIdCollection()
 {
     using (SqlConnection conn = SqlDbObject.GetConnection())
     {
         try
         {
             conn.Open();
             deletedSongITunesIds = new List <Int16>(Data.DeletedSongITunesIdCollection.GetDeletedSongITunesIds(conn));
         }
         finally
         {
             conn.Close();
         }
     }
 }
        /// <summary>
        /// Deletes a root folder from the database
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemType">Type associated with the root folder being deleted</param>
        /// <param name="priority">Priority of the root folder being deleted</param>
        public static void DeleteRootFolder(SqlConnection conn, Business.MediaItemTypeEnum mediaItemType, Int16 priority)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));
                parameters.Add(new sp.Parameter("Priority", DbType.Int16, priority));

                SqlDbObject.ExecuteNonQuery("DeleteRootFolder", CommandType.StoredProcedure, parameters.ToArray(), conn);
            }
            catch (System.Exception e)
            {
                throw new DeleteSqlDbObjectException("Could not delete root folder", e);
            }
        }
Exemple #15
0
        /// <summary>
        /// Adds a tag to the specfied media item
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemId">Unique identifier of the media item the tag is being added to</param>
        /// <param name="mediaItemType">Type of media item the tag is being added to</param>
        /// <param name="tag">Tag being added to the media item</param>
        public static void AddMediaItemTag(SqlConnection conn, Int64 mediaItemId, Business.MediaItemTypeEnum mediaItemType, String tag)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("MediaItemId", DbType.Int64, mediaItemId));
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));
                parameters.Add(new sp.Parameter("Tag", DbType.String, tag));

                SqlDbObject.ExecuteNonQuery("AddMediaItemTag", CommandType.StoredProcedure, parameters.ToArray(), conn);
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not add tag to media item", e);
            }
        }
        /// <summary>
        /// Deletes a tag from the specfied root folder
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemType">Type associated with the root folder the tag is being deleted from</param>
        /// <param name="rootFolderPriority">Priority of the root folder the tags are being loaded for</param>
        /// <param name="tag">Tag being added to the root folder</param>
        public static void DeleteRootFolderTag(SqlConnection conn, Business.MediaItemTypeEnum mediaItemType, Int16 rootFolderPriority, String tag)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("RootFolderPriority", DbType.Int16, rootFolderPriority));
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));
                parameters.Add(new sp.Parameter("Tag", DbType.String, tag));

                SqlDbObject.ExecuteNonQuery("DeleteRootFolderTag", CommandType.StoredProcedure, parameters.ToArray(), conn);
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not delete tag from root folder", e);
            }
        }
Exemple #17
0
        /// <summary>
        /// Adds a date and time to the specified media item
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemId">Unique identifier of the media item having it's play history updated</param>
        /// <param name="mediaItemType">Type of media item having it's play history updated</param>
        /// <param name="datePlayed">Date and time the media item was played to the end</param>
        public static void AddMediaItemPlayHistory(SqlConnection conn, Int64 mediaItemId, Business.MediaItemTypeEnum mediaItemType, DateTime datePlayed)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("MediaItemId", DbType.Int64, mediaItemId));
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));
                parameters.Add(new sp.Parameter("DatePlayed", DbType.DateTime, datePlayed));

                SqlDbObject.ExecuteNonQuery("AddMediaItemPlayHistory", CommandType.StoredProcedure, parameters.ToArray(), conn);
            }
            catch (System.Exception e)
            {
                throw new AddChildSqlDbObjectToParentException("Could not add play history item", e);
            }
        }
        /// <summary>
        /// Updates a media item part in the database
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemId">Unique identifier of the media item the part belongs to</param>
        /// <param name="type">Type of media item being the part belongs to</param>
        /// <param name="part">The media item part being updated in the database</param>
        public static void UpdateMediaItemPart(SqlConnection conn, Int64 mediaItemId, Business.MediaItemTypeEnum mediaItemType, Business.MediaItemPart part)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("Location", DbType.String, part.Location.Value));
                parameters.Add(new sp.Parameter("MediaItemId", DbType.Int64, mediaItemId));
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));
                parameters.Add(new sp.Parameter("Size", DbType.Int64, part.Size));
                parameters.Add(new sp.Parameter("Duration", DbType.Int32, part.Duration.TotalMilliseconds));
                parameters.Add(new sp.Parameter("Index", DbType.Int16, part.Index));

                SqlDbObject.ExecuteNonQuery("UpdateMediaItemPart", CommandType.StoredProcedure, parameters.ToArray(), conn);
            }
            catch (System.Exception e)
            {
                throw new UpdateSqlDbObjectException("Could not update media item part", e);
            }
        }
Exemple #19
0
        /// <summary>
        /// Gets all file types in the system
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <returns>All file types in the system</returns>
        public static Business.FileType[] GetFileTypes(SqlConnection conn)
        {
            try
            {
                sp.DataTable             dt        = SqlDbObject.ExecuteReader("GetFileTypes", CommandType.StoredProcedure, conn);
                List <Business.FileType> fileTypes = new List <Business.FileType>();

                foreach (sp.DataRow dr in dt)
                {
                    fileTypes.Add(Business.FileType.FromDataRow(conn, dr));
                }

                fileTypes.Sort();
                return(fileTypes.ToArray());
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load file types", e);
            }
        }
Exemple #20
0
        /// <summary>
        /// Loads a song from the database
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="songId">Unique identifier of the song being loaded</param>
        /// <returns>Song object loaded from the database</returns>
        public static Business.Song GetSongById(SqlConnection conn, Int64 songId)
        {
            try
            {
                sp.DataTable dt = SqlDbObject.ExecuteReader("GetSongById", CommandType.StoredProcedure, new sp.Parameter("SongId", DbType.Int64, songId), conn);

                if (dt.RowCount == 1)
                {
                    return(Business.MediaItem.FromDataRow(conn, dt[0]) as Business.Song);
                }
                else
                {
                    throw new SpecifiedSqlDbObjectNotFoundException("GetSongById returned " + dt.RowCount.ToString() + " rows");
                }
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load specified song", e);
            }
        }
Exemple #21
0
        /// <summary>
        /// Gets the extensions in the database for the specified file type
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="fileType">File type who's extensions are being loaded</param>
        /// <returns>Extensions in the database for the specified file type</returns>
        public static Business.FileExtensionCollection GetExtensionsByFileTypeId(SqlConnection conn, Int16 fileTypeId)
        {
            try
            {
                sp.DataTable dt = SqlDbObject.ExecuteReader("GetExtensionsByFileTypeId", CommandType.StoredProcedure, new sp.Parameter("FileTypeId", DbType.Int16, fileTypeId), conn);
                Business.FileExtensionCollection extensions = new Business.FileExtensionCollection();

                foreach (sp.DataRow dr in dt)
                {
                    extensions.extensions.Add((String)dr["Extension"]);
                }

                extensions.Sort();
                return(extensions);
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load extensions for file type", e);
            }
        }
Exemple #22
0
        /// <summary>
        /// Loads a file type from the database
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="fileTypeId">Unique identifier of the file type being loaded</param>
        /// <returns>FileType object loaded from the database</returns>
        public static Business.FileType GetFileTypeById(SqlConnection conn, Int16 fileTypeId)
        {
            try
            {
                sp.DataTable dt = SqlDbObject.ExecuteReader("GetFileTypeById", CommandType.StoredProcedure, new sp.Parameter("FileTypeId", DbType.Int16, fileTypeId), conn);

                if (dt.RowCount == 1)
                {
                    return(Business.FileType.FromDataRow(conn, dt[0]));
                }
                else
                {
                    throw new SpecifiedSqlDbObjectNotFoundException("GetFileTypeById returned " + dt.RowCount.ToString() + " rows");
                }
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load specified file type", e);
            }
        }
        /// <summary>
        /// Gets all root folders in the system that are associated with the specified type
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemType">Type associated with the desired root folders</param>
        /// <returns>All root folders in the system that are associated with the specified type</returns>
        public static Business.RootFolder[] GetRootFoldersByType(SqlConnection conn, Business.MediaItemTypeEnum mediaItemType)
        {
            try
            {
                sp.DataTable dt = SqlDbObject.ExecuteReader("GetRootFoldersByType", CommandType.StoredProcedure, new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)), conn);
                List <Business.RootFolder> rootFolders = new List <Business.RootFolder>();

                foreach (sp.DataRow row in dt)
                {
                    rootFolders.Add(Business.RootFolder.FromDataRow(conn, row));
                }

                rootFolders.Sort();
                return(rootFolders.ToArray());
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load root folders", e);
            }
        }
Exemple #24
0
        /// <summary>
        /// Gets all deleted song iTunes IDs from the database
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <returns>All deleted song iTunes IDs from the database</returns>
        public static Int16[] GetDeletedSongITunesIds(SqlConnection conn)
        {
            try
            {
                sp.DataTable table = SqlDbObject.ExecuteReader("GetDeletedSongITunesIds", CommandType.StoredProcedure, conn);

                List <Int16> deletedSongITunesIds = new List <Int16>();

                foreach (sp.DataRow row in table)
                {
                    deletedSongITunesIds.Add((Int16)row["iTunesId"]);
                }

                deletedSongITunesIds.Sort();
                return(deletedSongITunesIds.ToArray());
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not get deleted song iTunes IDs", e);
            }
        }
Exemple #25
0
        /// <summary>
        /// Gets all media items in the system
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <returns>All media items in the system</returns>
        public static Business.MediaItem[] GetMediaItems(SqlConnection conn)
        {
            try
            {
                sp.DataTable dt = SqlDbObject.ExecuteReader("GetMediaItems", CommandType.StoredProcedure, conn);
                List <Business.MediaItem> mediaItems = new List <Business.MediaItem>();

                foreach (sp.DataRow dr in dt)
                {
                    mediaItems.Add(Business.MediaItem.FromDataRow(conn, dr));
                }

                mediaItems.Sort();

                return(mediaItems.ToArray());
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load media items", e);
            }
        }
Exemple #26
0
        /// <summary>
        /// Removes the specified iTunes ID from the collection
        /// </summary>
        /// <param name="iTunesId">iTunes ID being removed from the collection</param>
        public void Remove(Int16 iTunesId)
        {
            if (!deletedSongITunesIds.Any(p => p == iTunesId))
            {
                throw new ArgumentException("iTunes ID does not exist");
            }

            using (SqlConnection conn = SqlDbObject.GetConnection())
            {
                try
                {
                    conn.Open();
                    Data.DeletedSongITunesIdCollection.DeleteDeletedSongITunesId(conn, iTunesId);
                }
                finally
                {
                    conn.Close();
                }
            }

            deletedSongITunesIds.Remove(iTunesId);
        }
Exemple #27
0
        /// <summary>
        /// Adds a new iTunes ID to the collection
        /// </summary>
        /// <param name="iTunesId">iTunes ID being added to the collection</param>
        public void Add(Int16 iTunesId)
        {
            if (deletedSongITunesIds.Any(p => p == iTunesId))
            {
                throw new ArgumentException("iTunes ID already exists");
            }

            using (SqlConnection conn = SqlDbObject.GetConnection())
            {
                try
                {
                    conn.Open();
                    Data.DeletedSongITunesIdCollection.AddDeletedSongITunesId(conn, iTunesId);
                }
                finally
                {
                    conn.Close();
                }
            }

            deletedSongITunesIds.Add(iTunesId);
            deletedSongITunesIds.Sort();
        }
Exemple #28
0
        /// <summary>
        /// Loads the play history for the specfied media item
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemId">Unique identifier of the media item having it's play history loaded</param>
        /// <param name="mediaItemType">Type of media item having it's play history loaded</param>
        /// <returns>Collection of dates and times the specified media item has been played, sorted ascendingly</returns>
        public static DateTime[] GetMediaItemPlayHistoryById(SqlConnection conn, Int64 mediaItemId, Business.MediaItemTypeEnum mediaItemType)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("MediaItemId", DbType.Int64, mediaItemId));
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));

                sp.DataTable    table       = SqlDbObject.ExecuteReader("GetMediaItemPlayHistoryById", CommandType.StoredProcedure, parameters.ToArray(), conn);
                List <DateTime> playHistory = new List <DateTime>();

                foreach (sp.DataRow row in table)
                {
                    playHistory.Add((DateTime)row["DatePlayed"]);
                }

                playHistory.Sort();
                return(playHistory.ToArray());
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load play history for media item", e);
            }
        }
        /// <summary>
        /// Loads the tags for the specfied root folder
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemType">Type associated with the root folder the tags are being loaded for</param>
        /// <param name="rootFolderPriority">Priority of the root folder the tags are being loaded for</param>
        /// <returns>Collection of tags assigned to the specified root folder, sorted ascendingly</returns>
        public static IntelligentString[] GetRootFolderTagsByPriority(SqlConnection conn, Business.MediaItemTypeEnum mediaItemType, Int16 rootFolderPriority)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("RootFolderPriority", DbType.Int16, rootFolderPriority));
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));

                sp.DataTable             table = SqlDbObject.ExecuteReader("GetRootFolderTagsByPriority", CommandType.StoredProcedure, parameters.ToArray(), conn);
                List <IntelligentString> tags  = new List <IntelligentString>();

                foreach (sp.DataRow row in table)
                {
                    tags.Add((String)row["Tag"]);
                }

                tags.Sort();
                return(tags.ToArray());
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load tags for root folder", e);
            }
        }
        /// <summary>
        /// Gets the root folder from the database with the specified priority
        /// </summary>
        /// <param name="conn">Open connection to the database</param>
        /// <param name="mediaItemType">Type of media item the desired root folder is associated with</param>
        /// <param name="priority">Priority of the desired root folder</param>
        /// <returns>Root folder in the database with the specified priority</returns>
        public static Business.RootFolder GetRootFolderByPriority(SqlConnection conn, Business.MediaItemTypeEnum mediaItemType, Int16 priority)
        {
            try
            {
                List <sp.Parameter> parameters = new List <sp.Parameter>();
                parameters.Add(new sp.Parameter("MediaItemType", DbType.Int16, Convert.ToInt16(mediaItemType)));
                parameters.Add(new sp.Parameter("Priority", DbType.Int16, priority));

                sp.DataTable dt = SqlDbObject.ExecuteReader("GetRootFolderByPriority", CommandType.StoredProcedure, parameters.ToArray(), conn);

                if (dt.RowCount == 1)
                {
                    return(Business.RootFolder.FromDataRow(conn, dt[0]));
                }
                else
                {
                    throw new SpecifiedSqlDbObjectNotFoundException("GetRootFolderByPriority returned " + dt.RowCount.ToString() + " rows");
                }
            }
            catch (System.Exception e)
            {
                throw new SpecifiedSqlDbObjectNotFoundException("Could not load specified root folder", e);
            }
        }