当前位置: 首页>>代码示例>>C#>>正文


C# IAlbum.GetChildGalleryObjects方法代码示例

本文整理汇总了C#中IAlbum.GetChildGalleryObjects方法的典型用法代码示例。如果您正苦于以下问题:C# IAlbum.GetChildGalleryObjects方法的具体用法?C# IAlbum.GetChildGalleryObjects怎么用?C# IAlbum.GetChildGalleryObjects使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IAlbum的用法示例。


在下文中一共展示了IAlbum.GetChildGalleryObjects方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: DisplayThumbnails

		public void DisplayThumbnails(IAlbum album)
		{
			string msg = string.Empty;

			//Get the data associated with the album and display
			IGalleryObjectCollection albumObjects;
			if (this.PageBase.IsAnonymousUser)
			{
				albumObjects = album.GetChildGalleryObjects(true, true);
			}
			else
			{
				albumObjects = album.GetChildGalleryObjects(true);
			}

			if (albumObjects.Count > 0)
			{
				// At least one album or media object in album.
				msg = String.Format(CultureInfo.CurrentCulture, "<p class='addtopmargin2'>{0}</p>", Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_With_Objects);
				phMsg.Controls.Add(new LiteralControl(msg));
			}
			else if (this.PageBase.UserCanAddMediaObject)
			{
				// No objects, user has permission to add media objects.
				string innerMsg = String.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_No_Objects_User_Has_Add_MediaObject_Permission, album.Id);
				msg = String.Format(CultureInfo.CurrentCulture, "<p class='addtopmargin2 msgfriendly'>{0}</p>", innerMsg);
				phMsg.Controls.Add(new LiteralControl(msg));
			}
			else
			{
				// No objects, user doesn't have permission to add media objects.
				msg = String.Format(CultureInfo.CurrentCulture, "<p class='addtopmargin2 msgfriendly'>{0}</p>", Resources.GalleryServerPro.UC_ThumbnailView_Intro_Text_No_Objects);
				phMsg.Controls.Add(new LiteralControl(msg));
			}

			this.PageBase.SetThumbnailCssStyle(albumObjects);

			rptr.DataSource = albumObjects;
			rptr.DataBind();
		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:40,代码来源:thumbnailview.ascx.cs

示例2: CreateVideoInstance

		/// <summary>
		/// Create a minimally populated <see cref="Video" /> instance from the specified parameters. 
		/// </summary>
		/// <param name="videoFile">A <see cref="System.IO.FileInfo" /> object representing a supported video type. The file must already
		/// exist in the album's directory. If the file has a matching record in the data store, a reference to the existing 
		/// object is returned; otherwise, a new instance is returned. However, if the forceNew parameter is specified and is
		/// set to true, then a new, unsaved media object with no assigned parent album is always returned, regardless of the existence of the file.
		/// Otherwise, a new instance is returned. For new instances, call <see cref="IGalleryObject.Save" /> to persist the object to the data store.</param>
		/// <param name="parentAlbum">The album in which the video exists (for media objects that already exist
		/// in the data store), or should be added to (for new media objects which need to be inserted into the 
		/// data store).</param>
		/// <param name="forceNew">Indicates whether to initialize a new, unsaved media object even if the imageFile
		/// parameter refers to an existing file in the album's directory. Typically used when copying an existing media 
		/// object where a subsequent operation will copy the existing file to the destination album, thus resulting in a
		/// new, independent media object.</param>
		/// <returns>Returns a <see cref="Video" /> instance corresponding to the specified parameters.</returns>
		/// <exception cref="UnsupportedMediaObjectTypeException">Thrown when
		/// <paramref name="videoFile"/> has a file extension that Gallery Server Pro is configured to reject, or it is
		/// associated with a non-video MIME type.</exception>
		/// <exception cref="InvalidMediaObjectException">Thrown when   
		/// <paramref name="videoFile"/> refers to a file that is not in the same directory as the parent album's directory.</exception>
		public static IGalleryObject CreateVideoInstance(System.IO.FileInfo videoFile, IAlbum parentAlbum, bool forceNew)
		{
#if DEBUG
			tt.Tools.StartingMethod(videoFile, parentAlbum, forceNew);
#endif

			// Validation check: Make sure the configuration settings allow for this particular type of file to be added.
			if (!HelperFunctions.IsFileAuthorizedForAddingToGallery(videoFile.Name))
				throw new UnsupportedMediaObjectTypeException(videoFile.FullName);

			// If the file belongs to an existing media object, return a reference to it.
			if (!forceNew)
			{
				foreach (IGalleryObject childMediaObject in parentAlbum.GetChildGalleryObjects(GalleryObjectType.Video))
				{
					if (childMediaObject.Original.FileNamePhysicalPath == videoFile.FullName)
						return childMediaObject;
				}
			}

			if (forceNew) parentAlbum = null;

			// Create a new video object, which will cause a new record to be inserted in the data store when Save() is called.
			return new Video(videoFile, parentAlbum);
		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:46,代码来源:Factory.cs

示例3: SynchronizeExternalMediaObjects

 private void SynchronizeExternalMediaObjects(IAlbum album)
 {
     foreach (IGalleryObject mediaObject in album.GetChildGalleryObjects(GalleryObjectType.External))
     {
         // Check for existence of thumbnail.
         if (this.OverwriteThumbnail || !File.Exists(mediaObject.Thumbnail.FileNamePhysicalPath))
         {
             mediaObject.RegenerateThumbnailOnSave = true;
             HelperFunctions.UpdateAuditFields(mediaObject, this._userName);
             mediaObject.Save();
             mediaObject.IsSynchronized = true;
         }
     }
 }
开发者ID:xusun,项目名称:GalleryServerPro,代码行数:14,代码来源:SynchronizationManager.cs

示例4: DeleteOrphanedImages

        /// <summary>
        /// Delete any thumbnail and optimized images that do not have matching media objects.
        /// This can occur when a user manually transfers (e.g. uses Windows Explorer)
        /// original images to a new directory and leaves the thumbnail and optimized
        /// images in the original directory or when a user deletes the original media file in 
        /// Explorer. This function *only* deletes files that begin the the thumbnail and optimized
        /// prefix (e.g. zThumb_, zOpt_).
        /// </summary>
        /// <param name="album">The album whose directory is to be processed for orphaned image files.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="album" /> is null.</exception>
        private void DeleteOrphanedImages(IAlbum album)
        {
            if (album == null)
                throw new ArgumentNullException("album");

            // STEP 1: Get list of directories that may contain thumbnail or optimized images for the current album
            string originalPath = album.FullPhysicalPathOnDisk;
            string thumbnailPath = HelperFunctions.MapAlbumDirectoryStructureToAlternateDirectory(album.FullPhysicalPathOnDisk, GallerySettings.FullThumbnailPath, GallerySettings.FullMediaObjectPath);
            string optimizedPath = HelperFunctions.MapAlbumDirectoryStructureToAlternateDirectory(album.FullPhysicalPathOnDisk, GallerySettings.FullOptimizedPath, GallerySettings.FullMediaObjectPath);

            List<string> albumPaths = new List<string>(3);

            // The original path may contain thumbnails or optimized images when the thumbnail/optimized path is the same as the original path
            if ((GallerySettings.FullThumbnailPath.Equals(GallerySettings.FullMediaObjectPath, StringComparison.OrdinalIgnoreCase)) ||
                (GallerySettings.FullOptimizedPath.Equals(GallerySettings.FullMediaObjectPath, StringComparison.OrdinalIgnoreCase)))
            {
                albumPaths.Add(originalPath);
            }

            if (!albumPaths.Contains(thumbnailPath))
                albumPaths.Add(thumbnailPath);

            if (!albumPaths.Contains(optimizedPath))
                albumPaths.Add(optimizedPath);

            string thumbnailPrefix = GallerySettings.ThumbnailFileNamePrefix;
            string optimizedPrefix = GallerySettings.OptimizedFileNamePrefix;

            IGalleryObjectCollection mediaObjects = album.GetChildGalleryObjects(GalleryObjectType.MediaObject);

            // STEP 2: Loop through each path and make sure all thumbnail and optimized files in each directory have
            // matching media objects. Delete any files that do not.
            foreach (string albumPath in albumPaths)
            {
                if (!Directory.Exists(albumPath))
                    return;

                DirectoryInfo directory = new DirectoryInfo(albumPath);

                // Loop through each file in the directory.
                FileInfo[] files;
                try
                {
                    files = directory.GetFiles();
                }
                catch (UnauthorizedAccessException)
                {
                    return;
                }

                foreach (FileInfo file in files)
                {
                    if ((file.Name.StartsWith(thumbnailPrefix, StringComparison.OrdinalIgnoreCase)) || (file.Name.StartsWith(optimizedPrefix, StringComparison.OrdinalIgnoreCase)))
                    {
                        // This file is a thumbnail or optimized file. Check to see if any media object in this album
                        // refers to it.
                        bool foundMediaObject = false;
                        foreach (IGalleryObject mediaObject in mediaObjects)
                        {
                            if ((mediaObject.Optimized.FileName.Equals(file.Name, StringComparison.OrdinalIgnoreCase)) ||
                                (mediaObject.Thumbnail.FileName.Equals(file.Name, StringComparison.OrdinalIgnoreCase)))
                            {
                                foundMediaObject = true;
                                break;
                            }
                        }

                        if (!foundMediaObject)
                        {
                            // No media object in this album refers to this thumbnail or optimized image. Smoke it!
                            try
                            {
                                file.Delete();
                            }
                            catch (IOException ex)
                            {
                                // An exception occurred, probably because the account ASP.NET is running under does not
                                // have permission to delete the file. Let's record the error, but otherwise ignore it.
                                Error.Record(ex, this._galleryId, Factory.LoadGallerySettings(), AppSetting.Instance);
                            }
                            catch (System.Security.SecurityException ex)
                            {
                                // An exception occurred, probably because the account ASP.NET is running under does not
                                // have permission to delete the file. Let's record the error, but otherwise ignore it.
                                Error.Record(ex, this._galleryId, Factory.LoadGallerySettings(), AppSetting.Instance);
                            }
                            catch (UnauthorizedAccessException ex)
                            {
                                // An exception occurred, probably because the account ASP.NET is running under does not
                                // have permission to delete the file. Let's record the error, but otherwise ignore it.
//.........这里部分代码省略.........
开发者ID:xusun,项目名称:GalleryServerPro,代码行数:101,代码来源:SynchronizationManager.cs

示例5: AddZipEntry

		/// <summary>
		/// Adds the media objects in the <paramref name="album"/> to the ZIP archive. Only media objects associated with a 
		/// physical file are added (that is, external media objects are excluded).
		/// </summary>
		/// <param name="zos">The ZipOutputStream (ZIP archive) the media object file is to be added to.</param>
		/// <param name="album">The album to be added to the ZIP archive.</param>
		/// <param name="imageSize">Size of the image to add to the ZIP archive. This parameter applies only to <see cref="Image"/> 
		/// media objects.</param>
		/// <param name="basePath">The full path to the directory containing the highest-level media file to be added
		/// to the ZIP archive. Must include trailing slash. Ex: C:\Inetpub\wwwroot\galleryserverpro\mediaobjects\Summer 2005\sunsets\</param>
		/// <param name="applyWatermark">Indicates whether to apply a watermark to images as they are added to the archive.
		/// Applies only for media objects in the <see cref="album"/> that are an <see cref="Image"/>.</param>
		private void AddZipEntry(ZipOutputStream zos, IAlbum album, DisplayObjectType imageSize, string basePath, bool applyWatermark)
		{
			foreach (IAlbum childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album, false, !this._isAuthenticated))
			{
				AddZipEntry(zos, childAlbum, imageSize, basePath, applyWatermark);
			}

			foreach (IGalleryObject mediaObject in album.GetChildGalleryObjects(GalleryObjectType.MediaObject, false, !this._isAuthenticated))
			{
				AddFileZipEntry(zos, mediaObject, imageSize, basePath, applyWatermark);
			}
		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:24,代码来源:ZipUtility.cs

示例6: AssignAlbumThumbnail

        /// <summary>
        /// Assign a thumbnail image to the album. Use the thumbnail image of the first media object in the album or,
        /// if no objects exist in the album, the first image in any child albums, searching recursively. If no images
        /// can be found, set <see cref="ThumbnailMediaObjectId" /> = 0.
        /// </summary>
        /// <param name="album">The album whose thumbnail image is to be assigned.</param>
        /// <param name="recursivelyAssignParentAlbums">Specifies whether to recursively iterate through the
        /// parent, grandparent, and so on until the root album, assigning a thumbnail, if necessary, to each
        /// album along the way.</param>
        /// <param name="recursivelyAssignChildrenAlbums">Specifies whether to recursively iterate through
        /// all children albums of this album, assigning a thumbnail to each child album, if necessary, along
        /// the way.</param>
        /// <param name="userName">The user name for the logged on user. This is used for the audit fields.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="album" /> is null.</exception>
        public static void AssignAlbumThumbnail(IAlbum album, bool recursivelyAssignParentAlbums, bool recursivelyAssignChildrenAlbums, string userName)
        {
            if (album == null)
                throw new ArgumentNullException("album");

            if (!album.IsWritable)
            {
                album = Factory.LoadAlbumInstance(album.Id, false, true);
            }

            if ((!album.IsRootAlbum) && (!System.IO.File.Exists(album.Thumbnail.FileNamePhysicalPath)))
            {
                album.ThumbnailMediaObjectId = GetIdOfFirstMediaObject(album);
                HelperFunctions.UpdateAuditFields(album, userName);
                album.Save();
            }

            if (recursivelyAssignChildrenAlbums)
            {
                foreach (IAlbum childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album))
                {
                    AssignAlbumThumbnail(childAlbum, false, recursivelyAssignChildrenAlbums, userName);
                }
            }

            if (recursivelyAssignParentAlbums)
            {
                while (!(album.Parent is NullObjects.NullGalleryObject))
                {
                    Album.AssignAlbumThumbnail((IAlbum)album.Parent, recursivelyAssignParentAlbums, false, userName);
                    album = (IAlbum)album.Parent;
                }
            }
        }
开发者ID:KuduApps,项目名称:GalleryServerPro,代码行数:48,代码来源:Album.cs

示例7: OnBeforeAlbumDelete

        /// <summary>
        /// Performs any necessary actions that must occur before an album is deleted. Specifically, it deletes the owner role 
        /// if one exists for the album, but only when this album is the only one assigned to the role. It also clears out  
        /// <see cref="IGallerySettings.UserAlbumParentAlbumId" /> if the album's ID matches it. This function recursively calls
        /// itself to make sure all child albums are processed.
        /// </summary>
        /// <param name="album">The album to be deleted, or one of its child albums.</param>
        private static void OnBeforeAlbumDelete(IAlbum album)
        {
            // If there is an owner role associated with this album, and the role is not assigned to any other albums, delete it.
            if (!String.IsNullOrEmpty(album.OwnerRoleName))
            {
                IGalleryServerRole role = RoleController.GetGalleryServerRoles().GetRole(album.OwnerRoleName);

                if ((role != null) && (role.AllAlbumIds.Count == 1) && role.AllAlbumIds.Contains(album.Id))
                {
                    RoleController.DeleteGalleryServerProRole(role.RoleName);
                }
            }

            // If the album is specified as the user album container, clear out the setting. The ValidateBeforeAlbumDelete()
            // function will throw an exception if user albums are enabled, so this should only happen when user albums
            // are disabled, so it is safe to clear it out.
            int userAlbumParentAlbumId = Factory.LoadGallerySetting(album.GalleryId).UserAlbumParentAlbumId;
            if (album.Id == userAlbumParentAlbumId)
            {
                IGallerySettings gallerySettingsWriteable = Factory.LoadGallerySetting(album.GalleryId, true);
                gallerySettingsWriteable.UserAlbumParentAlbumId = 0;
                gallerySettingsWriteable.Save();
            }

            // Recursively validate child albums.
            foreach (IGalleryObject childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album))
            {
                OnBeforeAlbumDelete((IAlbum)childAlbum);
            }
        }
开发者ID:Jiyuu,项目名称:galleryserverpro,代码行数:37,代码来源:AlbumController.cs

示例8: ToAlbumEntity

        /// <summary>
        /// Gets a data entity containing album information for the specified <paramref name="album" />. Returns an object with empty
        /// properties if the user does not have permission to view the specified album. The instance can be JSON-parsed and sent to the
        /// browser.
        /// </summary>
        /// <param name="album">The album to convert to an instance of <see cref="GalleryServerPro.Web.Entity.Album" />.</param>
        /// <param name="perms">The permissions the current user has for the album.</param>
        /// <param name="options">Specifies options for configuring the return data. To use default
        /// settings, specify an empty instance with properties left at default values.</param>
        /// <returns>
        /// Returns an <see cref="GalleryServerPro.Web.Entity.Album" /> object containing information about the requested album.
        /// </returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="album" /> is null.</exception>
        /// <exception cref="System.ArgumentNullException"></exception>
        public static Entity.Album ToAlbumEntity(IAlbum album, Entity.Permissions perms, Entity.GalleryDataLoadOptions options)
        {
            if (album == null)
                throw new ArgumentNullException("album");

            var albumEntity = new Entity.Album();

            albumEntity.Id = album.Id;
            albumEntity.GalleryId = album.GalleryId;
            albumEntity.Title = album.Title;
            albumEntity.Caption = album.Caption;
            albumEntity.Owner = (perms.AdministerGallery ? album.OwnerUserName : null);
            albumEntity.InheritedOwners = (perms.AdministerGallery ? String.Join(", ", album.InheritedOwners) : null);
            albumEntity.DateStart = album.DateStart;
            albumEntity.DateEnd = album.DateEnd;
            albumEntity.IsPrivate = album.IsPrivate;
            albumEntity.VirtualType = (int)album.VirtualAlbumType;
            albumEntity.RssUrl = GetRssUrl(album);
            albumEntity.Permissions = perms;
            albumEntity.MetaItems = GalleryObjectController.ToMetaItems(album.MetadataItems.GetVisibleItems(), album);
            albumEntity.NumAlbums = album.GetChildGalleryObjects(GalleryObjectType.Album, !Utils.IsAuthenticated).Count;

            // Optionally load gallery items
            if (options.LoadGalleryItems)
            {
                var albumSortDef = ProfileController.GetProfile().AlbumProfiles.Find(album.Id);

                IList<IGalleryObject> items;
                if (albumSortDef != null)
                {
                    items = album
                        .GetChildGalleryObjects(options.Filter, !Utils.IsAuthenticated)
                        .ToSortedList(albumSortDef.SortByMetaName, albumSortDef.SortAscending, album.GalleryId);

                    albumEntity.SortById = (int)albumSortDef.SortByMetaName;
                    albumEntity.SortUp = albumSortDef.SortAscending;
                }
                else
                {
                    if (album.IsVirtualAlbum)
                    {
                        items = album.GetChildGalleryObjects(options.Filter, !Utils.IsAuthenticated).ToSortedList(album.SortByMetaName, album.SortAscending, album.GalleryId);
                    }
                    else
                    {
                        // Real (non-virtual) albums are already sorted on their Seq property, so return items based on that.
                        items = album.GetChildGalleryObjects(options.Filter, !Utils.IsAuthenticated).ToSortedList();
                    }

                    albumEntity.SortById = (int)album.SortByMetaName;
                    albumEntity.SortUp = album.SortAscending;
                }

                if (options.NumGalleryItemsToRetrieve > 0)
                    items = items.Skip(options.NumGalleryItemsToSkip).Take(options.NumGalleryItemsToRetrieve).ToList();

                albumEntity.GalleryItems = GalleryObjectController.ToGalleryItems(items);
                albumEntity.NumGalleryItems = albumEntity.GalleryItems.Length;
            }
            else
            {
                albumEntity.NumGalleryItems = album.GetChildGalleryObjects(options.Filter, !Utils.IsAuthenticated).Count;
            }

            // Optionally load media items
            if (options.LoadMediaItems)
            {
                IList<IGalleryObject> items;

                if (album.IsVirtualAlbum)
                {
                    items = album.GetChildGalleryObjects(GalleryObjectType.MediaObject, !Utils.IsAuthenticated).ToSortedList(album.SortByMetaName, album.SortAscending, album.GalleryId);
                }
                else
                {
                    // Real (non-virtual) albums are already sorted on their Seq property, so return items based on that.
                    items = album.GetChildGalleryObjects(GalleryObjectType.MediaObject, !Utils.IsAuthenticated).ToSortedList();
                }

                //IList<IGalleryObject> items = album.GetChildGalleryObjects(GalleryObjectType.MediaObject, !Utils.IsAuthenticated).ToSortedList();
                albumEntity.NumMediaItems = items.Count;
                albumEntity.MediaItems = GalleryObjectController.ToMediaItems(items);
            }
            else
            {
                albumEntity.NumMediaItems = album.GetChildGalleryObjects(GalleryObjectType.MediaObject, !Utils.IsAuthenticated).Count;
//.........这里部分代码省略.........
开发者ID:Jiyuu,项目名称:galleryserverpro,代码行数:101,代码来源:AlbumController.cs

示例9: CreateAudioInstance

        /// <summary>
        /// Create a minimally populated <see cref="Audio" /> instance from the specified parameters.
        /// </summary>
        /// <param name="audioFile">A <see cref="System.IO.FileInfo" /> object representing a supported audio type. The file must already
        /// exist in the album's directory. If the file has a matching record in the data store, a reference to the existing 
        /// object is returned; otherwise, a new instance is returned. Otherwise, a new instance is returned. For new instances, 
        ///		call <see cref="IGalleryObject.Save" /> to persist the object to the data store.</param>
        /// <param name="parentAlbum">The album in which the audio exists (for media objects that already exist
        /// in the data store), or should be added to (for new media objects which need to be inserted into the 
        /// data store).</param>
        /// <returns>Returns an <see cref="Audio" /> instance corresponding to the specified parameters.</returns>
        /// <exception cref="InvalidMediaObjectException">Thrown when 
        /// <paramref name = "audioFile" /> refers to a file that is not in the same directory as the parent album's directory.</exception>
        /// <exception cref="UnsupportedMediaObjectTypeException">Thrown when
        /// <paramref name = "audioFile" /> has a file extension that Gallery Server Pro is configured to reject, or it is
        /// associated with a non-audio MIME type.</exception>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name = "audioFile" /> or <paramref name = "parentAlbum" /> is null.</exception>
        public static IGalleryObject CreateAudioInstance(FileInfo audioFile, IAlbum parentAlbum)
        {
            if (audioFile == null)
                throw new ArgumentNullException("audioFile");

            if (parentAlbum == null)
                throw new ArgumentNullException("parentAlbum");

            // Validation check: Make sure the configuration settings allow for this particular type of file to be added.
            if (!HelperFunctions.IsFileAuthorizedForAddingToGallery(audioFile.Name, parentAlbum.GalleryId))
                throw new UnsupportedMediaObjectTypeException(audioFile.FullName);

            // If the file belongs to an existing media object, return a reference to it.
            foreach (IGalleryObject childMediaObject in parentAlbum.GetChildGalleryObjects(GalleryObjectType.Audio))
            {
                if (childMediaObject.Original.FileNamePhysicalPath == audioFile.FullName)
                    return childMediaObject;
            }

            // Create a new audio object, which will cause a new record to be inserted in the data store when Save() is called.
            return new Audio(audioFile, parentAlbum);
        }
开发者ID:raquelsa,项目名称:GalleryServerProWeb,代码行数:39,代码来源:Factory.cs

示例10: DeleteHiResImagesFromAlbum

        private static void DeleteHiResImagesFromAlbum(IAlbum album)
        {
            // Delete the hi-res image for each image in the album. Then recursively do the same thing to all child albums.
            foreach (GalleryServerPro.Business.Image image in album.GetChildGalleryObjects(GalleryObjectType.Image))
            {
                image.DeleteHiResImage();

                GalleryObjectController.SaveGalleryObject(image);
            }

            foreach (IAlbum childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album))
            {
                DeleteHiResImagesFromAlbum(childAlbum);
            }
        }
开发者ID:KuduApps,项目名称:GalleryServerPro,代码行数:15,代码来源:deletehires.ascx.cs

示例11: DeleteSupportFilesOnly

        /// <summary>
        /// Deletes the thumbnail and optimized images associated with this album and all its children, but do not delete the 
        /// album's directory or the any other files it contains.
        /// </summary>
        /// <param name="album">The album.</param>
        private static void DeleteSupportFilesOnly(IAlbum album)
        {
            foreach (IGalleryObject childGalleryObject in album.GetChildGalleryObjects(GalleryObjectType.MediaObject))
            {
                DeleteThumbnailAndOptimizedImagesFromFileSystem(childGalleryObject);
            }

            foreach (IAlbum childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album))
            {
                DeleteSupportFilesOnly(childAlbum);
            }
        }
开发者ID:raquelsa,项目名称:GalleryServerProWeb,代码行数:17,代码来源:AlbumDeleteBehavior.cs

示例12: getAlbumStats

		private string getAlbumStats(IAlbum album)
		{
			//Create a string like: (12 objects, created 3/24/04)
			int numObjects = album.GetChildGalleryObjects(false, GalleryPage.IsAnonymousUser).Count;

			if (album.IsVirtualAlbum)
				return string.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.UC_Album_Header_Stats_Without_Date_Text, numObjects);
			else
				return string.Format(CultureInfo.CurrentCulture, Resources.GalleryServerPro.UC_Album_Header_Stats_Text, numObjects, album.DateAdded);
		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:10,代码来源:albumheader.ascx.cs

示例13: SynchronizeMediaObjectFiles

		private void SynchronizeMediaObjectFiles(DirectoryInfo directory, IAlbum album)
		{
			#region Parameter validation

			if (album == null)
				throw new ArgumentNullException("album");

			if (directory.FullName != album.FullPhysicalPath)
				throw new ArgumentException("Error in SynchronizeMediaObjectFiles().");

			#endregion

			//Update the media object table in the database with the file attributes of all
			//files in the directory passed to this function. Skip any hidden files.

			foreach (FileInfo file in directory.GetFiles())
			{
				if ((file.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden)
				{
					this._synchStatus.SkippedMediaObjects.Add(new KeyValuePair<string, string>(file.FullName.Remove(0, _mediaObjectPhysicalPathLength + 1), Resources.SynchronizationStatus_Hidden_File_Msg));
					continue;
				}

				#region Process thumbnail or optimized image

				if (file.Name.StartsWith(_thumbnailPrefix, StringComparison.OrdinalIgnoreCase))
				{
					// We have a thumbnail image. If we are storing thumbnails in a different directory, delete the file. The user may have just 
					// specified a new thumbnail path, and we need to delete all the previous thumbnails from their original location.
					if (_thumbnailRootPath != AppSetting.Instance.MediaObjectPhysicalPath)
					{
						File.Delete(file.FullName);
					}
					continue;
				}

				if (file.Name.StartsWith(_optimizedPrefix, StringComparison.OrdinalIgnoreCase))
				{
					// We have an optimized image. If we are storing optimized images in a different directory, delete the file. The user may have 
					// just specified a new optimized path, and we need to delete all the previous optimized images from their original location.
					if (_optimizedRootPath != AppSetting.Instance.MediaObjectPhysicalPath)
					{
						File.Delete(file.FullName);
					}
					continue;
				}

				#endregion

				IGalleryObject mediaObject = null;
				// See if this file is an existing media object. First look in the album's children. If not there, search the hash
				// keys - maybe it was moved from another directory.
				foreach (IGalleryObject existingMO in album.GetChildGalleryObjects(GalleryObjectType.MediaObject))
				{
					if (existingMO.Original.FileNamePhysicalPath == file.FullName)
					{
						mediaObject = existingMO;
						break;
					}
				}

				if ((mediaObject != null) || ((mediaObject == null) && this._mediaObjectsFromDataStore.TryGetValue(HelperFunctions.GetHashKey(file), out mediaObject)))
				{
					// Found an existing media object matching the file on disk. Update properties, but only if its file extension
					// is enabled. (If this is a media object that had been added to Gallery Server but its file type was 
					// subsequently disabled, we do not want to synchronize it - we want its info in the data store to be deleted.)
					if (HelperFunctions.IsFileAuthorizedForAddingToGallery(file.Name))
					{
						UpdateExistingMediaObject(album, mediaObject);
					}
				}
				else
				{
					// No media object exists for this file. Create a new one.
					CreateNewMediaObject(album, file);
				}

				int newFileIndex = this._synchStatus.CurrentFileIndex + 1;
				if (newFileIndex < this._synchStatus.TotalFileCount)
				{
					UpdateStatus(newFileIndex, file.DirectoryName, file.Name);
				}

				if (this._synchStatus.ShouldTerminate)
				{
					this._synchStatus.ShouldTerminate = false;
					throw new GalleryServerPro.ErrorHandler.CustomExceptions.SynchronizationTerminationRequestedException();
				}
			}
		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:90,代码来源:SynchronizationManager.cs

示例14: AddChildAlbumsAndGalleryObjectsAndSetToUnsynchronized

		/// <summary>
		/// Add the child albums and media objects as stored on disk to the specified dictionary objects. Set
		/// IsSynchronized = false for each album and media object. This will be set to true as each is processed.
		/// This method calls itself recursively if IsRecursive = true.
		/// </summary>
		/// <param name="albums">A Dictionary object containing relevant albums for this synchronization. The album specified
		/// in the parentAlbum parameter will be added to this object.</param>
		/// <param name="mediaObjects">A Dictionary object containing relevant media objects for this synchronization.
		/// Media objects within the parentAlbum parameter will be added to this object.</param>
		/// <param name="parentAlbum">The album used as the source for populating the albums and mediaObjects
		/// parameters.</param>
		private void AddChildAlbumsAndGalleryObjectsAndSetToUnsynchronized(Dictionary<string, IAlbum> albums, Dictionary<string, IGalleryObject> mediaObjects, IAlbum parentAlbum)
		{
			foreach (IAlbum childAlbum in parentAlbum.GetChildGalleryObjects(GalleryObjectType.Album))
			{
				childAlbum.IsSynchronized = false;
				childAlbum.RegenerateThumbnailOnSave = this.OverwriteThumbnail;

				try
				{
					// There can be situations where the database becomes corrupt, and the same album has two records. When this happens,
					// the following line will fail. Instead of letting the exception cause the synch to fail, we swallow the exception.
					// This will cause the album that caused the exception to eventually be deleted, which is what we want.
					albums.Add(childAlbum.FullPhysicalPathOnDisk, childAlbum);
				}
				catch (System.ArgumentException) { }

				foreach (IGalleryObject mediaObject in childAlbum.GetChildGalleryObjects(GalleryObjectType.MediaObject))
				{
					if (!String.IsNullOrEmpty(mediaObject.Hashkey))
					{
						mediaObject.IsSynchronized = false;
						mediaObject.RegenerateOptimizedOnSave = this.OverwriteOptimized;
						mediaObject.RegenerateThumbnailOnSave = this.OverwriteThumbnail;
						mediaObject.RegenerateMetadataOnSave = this.RegenerateMetadata;

						try
						{
							// There may be situations where the database becomes corrupt, and the same media object has two records. When this happens,
							// the following line will fail. Instead of letting the exception cause the synch to fail, we swallow the exception.
							// This will cause the media object that caused the exception to eventually be deleted, which is what we want.
							mediaObjects.Add(mediaObject.Hashkey, mediaObject);
						}
						catch (System.ArgumentException) { }
					}
				}

				if (this._isRecursive)
				{
					AddChildAlbumsAndGalleryObjectsAndSetToUnsynchronized(albums, mediaObjects, childAlbum);
				}
			}

		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:54,代码来源:SynchronizationManager.cs

示例15: GetChildAlbumIds

        /// <summary>
        /// Gets the IDs of the child albums of the specified <paramref name="album" />, acting recursively.
        /// </summary>
        /// <param name="album">The album.</param>
        /// <returns>Returns an enumerable list of album ID values.</returns>
        private static IEnumerable<int> GetChildAlbumIds(IAlbum album)
        {
            List<int> albumIds = new List<int>();

            foreach (IGalleryObject childAlbum in album.GetChildGalleryObjects(GalleryObjectType.Album))
            {
                albumIds.Add(childAlbum.Id);
                albumIds.AddRange(GetChildAlbumIds((IAlbum)childAlbum));
            }

            return albumIds;
        }
开发者ID:xusun,项目名称:GalleryServerPro,代码行数:17,代码来源:SqlCeGalleryServerProProvider.cs


注:本文中的IAlbum.GetChildGalleryObjects方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。