示例#1
0
 /// <summary>
 /// 获取相册列表(用于频道)
 /// </summary>
 /// <remarks>
 /// 缓存周期:常用对象集合,不用维护即时性
 /// </remarks>
 /// <param name="tenantTypeId">租户类型</param>
 /// <param name="ownerId">所有者ID</param>
 /// <param name="sortBy">排序依据</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>返回相册分页列表</returns>
 public PagingDataSet <Album> GetAlbums(string tenantTypeId, long?ownerId, SortBy_Album sortBy, int pageSize, int pageIndex)
 {
     return(GetPagingEntities(pageSize, pageIndex, CachingExpirationType.UsualObjectCollection, () =>
     {
         return string.Format("GetAlbums::TenantTypeId-{0};OwnerId-{1};SortBy-{2}", tenantTypeId, ownerId ?? 0, sortBy);
     }, () =>
     {
         return GetSql_GetAlbums(tenantTypeId, ownerId, null, false, null, null, sortBy);
     }));
 }
示例#2
0
文件: SiteUrls.cs 项目: x1987624/SNS
        /// <summary>
        /// 我的相册列表
        /// </summary>
        /// <param name="spaceKey">用户标识</param>
        /// <param name="sortBy">排序</param>
        /// <returns></returns>
        public static string Albums(this SiteUrls siteUrls, string spaceKey, SortBy_Album sortBy = SortBy_Album.DateCreated_Desc)
        {
            RouteValueDictionary dic = new RouteValueDictionary();

            if (sortBy != SortBy_Album.DateCreated_Desc)
            {
                dic.Add("sortBy", sortBy);
            }
            dic.Add("spaceKey", spaceKey);
            return(CachedUrlHelper.Action("Albums", "UserSpacePhoto", PhotoAreaName, dic));
        }
示例#3
0
        public ActionResult Albums(string spaceKey, SortBy_Album sortBy = SortBy_Album.DateCreated_Desc, int pageIndex = 1, int pageSize = 20)
        {
            IUser user = userService.GetUser(spaceKey);

            if (user == null)
            {
                return(HttpNotFound());
            }

            bool  ignoreAuditAndPrivacy = false;
            IUser currentUser           = UserContext.CurrentUser;

            if (currentUser != null && currentUser.UserName == spaceKey)
            {
                ignoreAuditAndPrivacy = true;
            }

            PagingDataSet <Album> albumList = photoService.GetUserAlbums(TenantTypeIds.Instance().User(), user.UserId, ignoreAuditAndPrivacy, sortBy, pageSize, pageIndex);

            pageResourceManager.InsertTitlePart(GetTitle(spaceKey) + "的相册");

            return(View(albumList));
        }
示例#4
0
 /// <summary>
 /// 获取相册列表(用于群组)
 /// </summary>
 /// <remarks>
 /// 缓存周期:对象集合,使用分区缓存
 /// </remarks>
 /// <param name="tenantTypeId">租户类型</param>
 /// <param name="ownerId">所有者ID</param>
 /// <param name="ignoreAuditAndPrivacy">是否忽略审核状态和隐私,相册主人查看时为true</param>
 /// <param name="sortBy">排序依据</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>返回相册分页列表</returns>
 public PagingDataSet <Album> GetOwnerAlbums(string tenantTypeId, long ownerId, bool ignoreAuditAndPrivacy, SortBy_Album sortBy = SortBy_Album.DateCreated_Desc, int pageSize = 20, int pageIndex = 1)
 {
     return(albumRepository.GetOwnerAlbums(tenantTypeId, ownerId, ignoreAuditAndPrivacy, sortBy, pageSize, pageIndex));
 }
示例#5
0
 /// <summary>
 /// 获取相册列表(用于频道)
 /// </summary>
 /// <remarks>
 /// 缓存周期:常用对象集合,不用维护即时性
 /// </remarks>
 /// <param name="tenantTypeId">租户类型</param>
 /// <param name="ownerId">所有者ID</param>
 /// <param name="sortBy">排序依据</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>返回相册分页列表</returns>
 public PagingDataSet <Album> GetAlbums(string tenantTypeId, long?ownerId, SortBy_Album sortBy = SortBy_Album.DateCreated_Desc, int pageSize = 20, int pageIndex = 1)
 {
     return(albumRepository.GetAlbums(tenantTypeId, ownerId, sortBy, pageSize, pageIndex));
 }
示例#6
0
 /// <summary>
 /// 获取相册列表(用于用户空间)
 /// </summary>
 /// <remarks>
 /// 缓存周期:对象集合,使用分区缓存
 /// </remarks>
 /// <param name="tenantTypeId">租户类型</param>
 /// <param name="userId">用户ID</param>
 /// <param name="ignoreAuditAndPrivacy">是否忽略审核状态和隐私,相册主人查看时为true</param>
 /// <param name="sortBy">排序依据</param>
 /// <param name="pageSize">分页大小</param>
 /// <param name="pageIndex">页码</param>
 /// <returns>返回相册分页列表</returns>
 public PagingDataSet <Album> GetUserAlbums(string tenantTypeId, long userId, bool ignoreAuditAndPrivacy, SortBy_Album sortBy, int pageSize, int pageIndex)
 {
     return(GetPagingEntities(pageSize, pageIndex, CachingExpirationType.ObjectCollection, () =>
     {
         return string.Format("GetUserAlbums::TenantTypeId-{0};UserId-{1};IgnoreAuditAndPrivacy-{2};SortBy-{3}", tenantTypeId, RealTimeCacheHelper.GetListCacheKeyPrefix(CacheVersionType.AreaVersion, "UserId", userId), ignoreAuditAndPrivacy, sortBy);
     }, () =>
     {
         return GetSql_GetAlbums(tenantTypeId, null, userId, ignoreAuditAndPrivacy, null, null, sortBy);
     }));
 }
示例#7
0
        /// <summary>
        /// 获取Sql
        /// </summary>
        /// <param name="tenantTypeId"></param>
        /// <param name="ownerId"></param>
        /// <param name="ignoreAuditAndPrivacy"></param>
        /// <param name="userId"></param>
        /// <param name="nameKeyword"></param>
        /// <param name="auditStatus"></param>
        /// <param name="sortBy"></param>
        /// <returns></returns>
        private Sql GetSql_GetAlbums(string tenantTypeId, long?ownerId, long?userId, bool?ignoreAuditAndPrivacy, string nameKeyword, AuditStatus?auditStatus, SortBy_Album sortBy = SortBy_Album.DateCreated_Desc)
        {
            Sql sql = Sql.Builder
                      .Select("*")
                      .From("spb_Albums");
            Sql sql_Where   = Sql.Builder;
            Sql sql_OrderBy = Sql.Builder;

            if (!string.IsNullOrEmpty(tenantTypeId))
            {
                sql_Where.Where("TenantTypeId = @0", tenantTypeId);
            }

            if (ownerId.HasValue)
            {
                sql_Where.Where("OwnerId = @0", ownerId);
            }

            if (ignoreAuditAndPrivacy.HasValue && !ignoreAuditAndPrivacy.Value)
            {
                sql_Where.Where("PrivacyStatus <> @0", PrivacyStatus.Private);
                switch (this.PubliclyAuditStatus)
                {
                case PubliclyAuditStatus.Again:
                case PubliclyAuditStatus.Fail:
                case PubliclyAuditStatus.Pending:
                case PubliclyAuditStatus.Success:
                    sql_Where.Where("AuditStatus = @0", this.PubliclyAuditStatus);
                    break;

                case PubliclyAuditStatus.Pending_GreaterThanOrEqual:
                case PubliclyAuditStatus.Again_GreaterThanOrEqual:
                    sql_Where.Where("AuditStatus > @0", this.PubliclyAuditStatus);
                    break;
                }
            }

            if (userId.HasValue)
            {
                sql_Where.Where("UserId = @0", userId);
            }

            if (!string.IsNullOrEmpty(nameKeyword))
            {
                sql_Where.Where("AlbumName like @0", "%" + StringUtility.StripSQLInjection(nameKeyword) + "%");
            }

            if (auditStatus.HasValue)
            {
                sql_Where.Where("AuditStatus = @0", auditStatus);
            }

            switch (sortBy)
            {
            case SortBy_Album.DateCreated_Desc:
                sql_OrderBy.OrderBy("AlbumId desc");
                break;

            case SortBy_Album.DateCreated_Asc:
                sql_OrderBy.OrderBy("AlbumId asc");
                break;

            case SortBy_Album.LastUploadDate_Desc:
                sql_OrderBy.OrderBy("LastUploadDate desc");
                break;

            case SortBy_Album.LastUploadDate_Asc:
                sql_OrderBy.OrderBy("LastUploadDate asc");
                break;

            case SortBy_Album.DisplayOrder:
                sql_OrderBy.OrderBy("DisplayOrder");
                break;
            }

            return(sql.Append(sql_Where).Append(sql_OrderBy));
        }