/// <summary> /// 微博图片模式数据页 /// </summary> /// <param name="pageIndex"></param> /// <param name="tenantTypeId"></param> /// <param name="mediaType"></param> /// <param name="isOriginal"></param> /// <param name="sortBy"></param> /// <returns></returns> public ActionResult _Waterfall(int pageIndex = 1, string tenantTypeId = "", MediaType?mediaType = null, bool?isOriginal = null, SortBy_Microblog sortBy = SortBy_Microblog.DateCreated) { //获取微博分页数据 PagingDataSet <MicroblogEntity> MicroblogEntities = microblogService.GetPagings(pageIndex, tenantTypeId: TenantTypeIds.Instance().User(), mediaType: mediaType, sortBy: sortBy); //获取微博图片 AttachmentService <Attachment> attachementService = new AttachmentService <Attachment>(TenantTypeIds.Instance().Microblog()); foreach (var MicroblogEntity in MicroblogEntities.Where(n => n.HasPhoto)) { IEnumerable <Attachment> attachments = attachementService.GetsByAssociateId(MicroblogEntity.MicroblogId); if (attachments != null && attachments.Count <Attachment>() > 0) { MicroblogEntity.ImageWidth = attachments.First().Width; MicroblogEntity.ImageUrl = SiteUrls.Instance().ImageUrl(attachments.First(), TenantTypeIds.Instance().Microblog(), ImageSizeTypeKeys.Instance().Big()); } } //设置当前登录用户对当前页用户的关注情况 //如果当前登录用户关注了该用户 return(View(MicroblogEntities.AsEnumerable <MicroblogEntity>())); }
/// <summary> /// 微博图片模式数据页 /// </summary> /// <param name="pageIndex"></param> /// <param name="tenantTypeId"></param> /// <param name="mediaType"></param> /// <param name="isOriginal"></param> /// <param name="sortBy"></param> /// <returns></returns> public ActionResult _Waterfall(int pageIndex = 1, string tenantTypeId = "", MediaType?mediaType = null, bool?isOriginal = null, SortBy_Microblog sortBy = SortBy_Microblog.DateCreated) { //获取微博分页数据 PagingDataSet <MicroblogEntity> MicroblogEntities = microblogService.GetPagings(pageIndex, tenantTypeId: TenantTypeIds.Instance().User(), mediaType: mediaType, sortBy: sortBy); //获取微博图片 AttachmentService <Attachment> attachementService = new AttachmentService <Attachment>(TenantTypeIds.Instance().Microblog()); foreach (var MicroblogEntity in MicroblogEntities.Where(n => n.HasPhoto)) { IEnumerable <Attachment> attachments = attachementService.GetsByAssociateId(MicroblogEntity.MicroblogId); if (attachments != null && attachments.Count <Attachment>() > 0) { MicroblogEntity.ImageWidth = attachments.First().Width; MicroblogEntity.ImageUrl = SiteUrls.Instance().ImageUrl(attachments.First(), TenantTypeIds.Instance().Microblog(), ImageSizeTypeKeys.Instance().Big()); } } IUser CurrentUser = UserContext.CurrentUser; if (CurrentUser != null) { //设置当前登录用户对当前页用户的关注情况 Dictionary <long, bool> isCurrentUserFollowDic = new Dictionary <long, bool>(); foreach (var user in MicroblogEntities.Select(m => m.User)) { if (user == null) { continue; } //如果当前登录用户关注了该用户 if (followService.IsFollowed(CurrentUser.UserId, user.UserId)) { if (!isCurrentUserFollowDic.ContainsKey(user.UserId)) { isCurrentUserFollowDic.Add(user.UserId, true); } } else { if (!isCurrentUserFollowDic.ContainsKey(user.UserId)) { isCurrentUserFollowDic.Add(user.UserId, false); } } } ViewData["isCurrentUserFollowDic"] = isCurrentUserFollowDic; } return(View(MicroblogEntities.AsEnumerable <MicroblogEntity>())); }
public ActionResult _OlderMicroblog(int pageIndex = 1, string tenantTypeId = "", MediaType?mediaType = null, bool?isOriginal = null, SortBy_Microblog sortBy = SortBy_Microblog.DateCreated) { //获取微博分页数据 PagingDataSet <MicroblogEntity> microblogEntities = microblogService.GetPagings(pageIndex, tenantTypeId: TenantTypeIds.Instance().User(), sortBy: sortBy); //当第一次加载页面时获取当前页的最新一条微博的ID if (pageIndex == 1) { ViewData["lastMicroblogId"] = microblogEntities.OrderByDescending(m => m.MicroblogId).Select(m => m.MicroblogId).FirstOrDefault(); } ViewData["pageCount"] = microblogEntities.PageCount; return(View("_NewMicroblogList", microblogEntities.AsEnumerable <MicroblogEntity>())); }
/// <summary> /// 翻页获取微博(图片模式 按标签分组搜时) /// </summary> /// <param name="tagGroupId"></param> /// <param name="pageIndex"></param> /// <param name="pageSize"></param> /// <returns></returns> public ActionResult _WaterfallGetMicroblogByTagGroup(long tagGroupId, int pageIndex = 1, int pageSize = 30) { IEnumerable <string> tagNames = tagService.GetTagsOfGroup(tagGroupId); MicroblogFullTextQuery query = new MicroblogFullTextQuery(); query.PageIndex = pageIndex; query.PageSize = pageSize;//每页记录数 query.Keywords = tagNames; //调用搜索器进行搜索 MicroblogSearcher microblogSearcher = (MicroblogSearcher)SearcherFactory.GetSearcher(MicroblogSearcher.CODE); PagingDataSet <MicroblogEntity> microblogEntities = microblogSearcher.Search(query); return(View("_Waterfall", microblogEntities.AsEnumerable <MicroblogEntity>())); }
/// <summary> /// 评论照片动态 /// </summary> /// <param name="ActivityId"></param> /// <returns></returns> //[DonutOutputCache(CacheProfile = "Frequently")] public ActionResult _CommentPhoto(long ActivityId) { //实例化动态 Activity activity = activityService.Get(ActivityId); if (activity == null) { return(Content(string.Empty)); } ViewData["Activity"] = activity; //实例化评论 PagingDataSet <Comment> commentPaging = commentService.GetRootComments(TenantTypeIds.Instance().Photo(), activity.ReferenceId, 1, SortBy_Comment.DateCreatedDesc); //去掉评论作者相同的评论然后取前3个 IEnumerable <long> commentUserIds = commentPaging.AsEnumerable().Select(n => n.UserId).Distinct().Take(3); List <Comment> commentList = new List <Comment>(); foreach (var commentUserId in commentUserIds) { commentList.Add(commentPaging.First(n => n.UserId == commentUserId)); } IEnumerable <Comment> comments = commentList.AsEnumerable(); if (comments == null) { return(Content(string.Empty)); } ViewData["CommentCount"] = commentPaging.Count(); //实例化照片 Photo photo = photoService.GetPhoto(activity.ReferenceId); if (photo == null) { return(Content(string.Empty)); } ViewData["Photo"] = photo; return(View(comments)); }