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


C# IAlbum.Save方法代码示例

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


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

示例1: ValidateRoleExistsForAlbumOwner

		/// <summary>
		/// Verify that any role needed for album ownership exists and is properly configured. If an album owner
		/// is specified and the album is new (IsNew == true), the album is persisted to the data store. This is 
		/// required because the ID is not assigned until it is saved, and a valid ID is required to configure the
		/// role.
		/// </summary>
		/// <param name="album">The album to validate for album ownership. If a null value is passed, the function
		/// returns without error or taking any action.</param>
		public static void ValidateRoleExistsForAlbumOwner(IAlbum album)
		{
			// For albums, verify that any needed roles for album ownership are present. Create/update as needed.
			if (album == null)
				return;

			if (String.IsNullOrEmpty(album.OwnerUserName))
			{
				// If owner role is specified, delete it.
				if (!String.IsNullOrEmpty(album.OwnerRoleName))
				{
					DeleteGalleryServerProRole(album.OwnerRoleName);
					album.OwnerRoleName = String.Empty;
				}
			}
			else
			{
				// If this is a new album, save it before proceeding. We will need its album ID to configure the role, 
				// and it is not assigned until it is saved.
				if (album.IsNew)
					album.Save();

				// Verify that a role exists that corresponds to the owner.
				IGalleryServerRole role = Factory.LoadGalleryServerRoles().GetRoleByRoleName(album.OwnerRoleName);
				if (role == null)
				{
					// No role exists. Create it.
					album.OwnerRoleName = CreateAlbumOwnerRole(album);
				}
				else
				{
					// Role exists. Make sure album is assigned to role and owner is a member.
					if (!role.RootAlbumIds.Contains(album.Id))
					{
						// Current album is not a member. This should not typically occur, but just in case
						// it does let's add the current album to it and save it.
						role.RootAlbumIds.Add(album.Id);
						role.Save();
					}

					string[] rolesForUser = GetRolesForUser(album.OwnerUserName);
					if (Array.IndexOf<string>(rolesForUser, role.RoleName) < 0)
					{
						// Owner is not a member. Add.
						AddUserToRole(album.OwnerUserName, role.RoleName);
					}
				}
			}
		}
开发者ID:haimon74,项目名称:KanNaim,代码行数:57,代码来源:RoleController.cs

示例2: 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


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