/// <summary> /// Deletes the specified album/image. /// </summary> /// <param name="upDir"> /// The Upload dir. /// </param> /// <param name="albumID"> /// The album id. /// </param> /// <param name="userID"> /// The user id. /// </param> /// <param name="imageID"> /// The image id. /// </param> public static void Album_Image_Delete([NotNull] object upDir, [CanBeNull] object albumID, int userID, [NotNull] object imageID) { if (albumID != null) { var dt = LegacyDb.album_image_list(albumID, null); foreach (var fullName in from DataRow dr in dt.Rows select "{0}/{1}.{2}.{3}.yafalbum".FormatWith(upDir, userID, albumID, dr["FileName"]) into fullName let file = new FileInfo(fullName) where file.Exists select fullName) { File.Delete(fullName); } LegacyDb.album_delete(albumID); } else { using (DataTable dt = LegacyDb.album_image_list(null, imageID)) { var dr = dt.Rows[0]; var fileName = dr["FileName"].ToString(); var imgAlbumID = dr["albumID"].ToString(); var fullName = "{0}/{1}.{2}.{3}.yafalbum".FormatWith(upDir, userID, imgAlbumID, fileName); var file = new FileInfo(fullName); if (file.Exists) { File.Delete(fullName); } } LegacyDb.album_image_delete(imageID); } }
/// <summary> /// Deletes the specified album/image. /// </summary> /// <param name="upDir"> /// The Upload dir. /// </param> /// <param name="albumID"> /// The album id. /// </param> /// <param name="userID"> /// The user id. /// </param> /// <param name="imageID"> /// The image id. /// </param> public static void Album_Image_Delete( [NotNull] object upDir, [CanBeNull] object albumID, int userID, [NotNull] object imageID) { if (albumID != null) { var dt = LegacyDb.album_image_list(albumID, null); foreach (DataRow dr in dt.Rows) { var fullName = "{0}/{1}.{2}.{3}.yafalbum".FormatWith(upDir, userID, albumID, dr["FileName"]); var file = new FileInfo(fullName); try { if (file.Exists) { File.SetAttributes(fullName, FileAttributes.Normal); File.Delete(fullName); } } finally { LegacyDb.album_image_delete(dr["ImageID"]); } } LegacyDb.album_delete(albumID); } else { using (var dt = LegacyDb.album_image_list(null, imageID)) { var dr = dt.Rows[0]; var fileName = dr["FileName"].ToString(); var imgAlbumId = dr["albumID"].ToString(); var fullName = "{0}/{1}.{2}.{3}.yafalbum".FormatWith(upDir, userID, imgAlbumId, fileName); var file = new FileInfo(fullName); try { if (file.Exists) { File.SetAttributes(fullName, FileAttributes.Normal); File.Delete(fullName); } } finally { LegacyDb.album_image_delete(imageID); } } } }
/// <summary> /// Binds the repeater and title controls and the visibilities of form elements. /// </summary> /// <param name="isNewAlbum">if set to <c>true</c> [is new album].</param> private void BindVariousControls(bool isNewAlbum) { this.Delete.Visible = !isNewAlbum; if (!isNewAlbum) { this.txtTitle.Text = LegacyDb.album_gettitle(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a")); var albumList = LegacyDb.album_image_list(this.Get <HttpRequestBase>().QueryString.GetFirstOrDefault("a"), null); this.List.DataSource = albumList; this.List.Visible = albumList.Rows.Count > 0; } this.DataBind(); }
/// <summary> /// Binds the data. /// </summary> private void BindData() { this.PagerTop.PageSize = this.Get <YafBoardSettings>().AlbumImagesPerPage; string albumTitle = LegacyDb.album_gettitle(this.AlbumID); // if (UserID == PageContext.PageUserID) // ltrTitle.Visible = false; this.ltrTitleOnly.Text = this.HtmlEncode(albumTitle); this.ltrTitle.Text = albumTitle == string.Empty ? this.GetText("ALBUM_CHANGE_TITLE") : this.HtmlEncode(albumTitle); // set the Datatable var dtAlbumImageList = LegacyDb.album_image_list(this.AlbumID, null); var dtAlbum = LegacyDb.album_list(null, this.AlbumID); // Does this album has a cover? this._coverImageID = dtAlbum.Rows[0]["CoverImageID"] == DBNull.Value ? string.Empty : dtAlbum.Rows[0]["CoverImageID"].ToString(); if ((dtAlbumImageList == null) || (dtAlbumImageList.Rows.Count <= 0)) { return; } this.PagerTop.Count = dtAlbumImageList.Rows.Count; // Create paged data source for the album image list var pds = new PagedDataSource { DataSource = dtAlbumImageList.DefaultView, AllowPaging = true, CurrentPageIndex = this.PagerTop.CurrentPageIndex, PageSize = this.PagerTop.PageSize }; this.AlbumImages.DataSource = pds; this.DataBind(); }