public ActionResult _Microblog_Attachments(long microblogId, long?forwardMicroblogId) { MicroblogEntity microblog = microBlogService.Get(microblogId); if (microblog == null) { return(new EmptyResult()); } if (microblog.HasPhoto) { IEnumerable <Attachment> attachments = attachementService.GetsByAssociateId(microblog.MicroblogId); if (attachments != null && attachments.Count() > 0) { microblog.ImageUrl = SiteUrls.Instance().ImageUrl(attachments.First(), TenantTypeIds.Instance().Microblog(), ImageSizeTypeKeys.Instance().Medium()); ViewData["imageCount"] = attachments.Count(); } } if (microblog.HasVideo) { ParsedMedia parsedMedia = parsedMediaService.Get(microblog.VideoAlias); if (parsedMedia != null) { ViewData["videoThumbnailUrl"] = parsedMedia.ThumbnailUrl; } } ViewData["ForwardMicroblogId"] = forwardMicroblogId; return(View(microblog)); }
/// <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>())); }
/// <summary> /// 800像素等宽等比例缩放(即按照宽度缩放,不按照高度缩放),主要用于相册阅读模式及照片详情页 /// </summary> public static string P800(this ImageSizeTypeKeys auditItemKeys) { return("P800"); }
/// <summary> /// 获取某人通过验证的身份认证标识 /// </summary> /// <param name="htmlHelper"></param> /// <param name="userId">用户Id</param> /// <returns></returns> public static MvcHtmlString IdentificationType(this HtmlHelper htmlHelper, long userId) { if (userId <= 0) { return(MvcHtmlString.Empty); } //获取某人通过验证的身份认证 IdentificationService identificationService = new IdentificationService(); var identificationTypes = identificationService.GetIdentificationTypes(userId); if (identificationTypes == null) { return(MvcHtmlString.Empty); } StringBuilder builder = new StringBuilder(); TagBuilder imgBuilder; foreach (var identificationType in identificationTypes) { imgBuilder = new TagBuilder("img"); imgBuilder.MergeAttribute("src", SiteUrls.Instance().LogoUrl(identificationType.IdentificationTypeLogo, TenantTypeIds.Instance().IdentificationType(), ImageSizeTypeKeys.Instance().Small())); imgBuilder.MergeAttribute("alt", identificationType.Name); imgBuilder.MergeAttribute("title", identificationType.Name); builder.Append(imgBuilder.ToString()); } return(MvcHtmlString.Create(builder.ToString())); }
/// <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> /// haierSns-2-liucg /// </summary> /// <returns></returns> public static string _WikiList_InHome_Big(this ImageSizeTypeKeys auditItemKeys) { return("_WikiList_InHome_Big"); }
public ActionResult _GetOnePhoto(long photoId) { Photo photo = photoService.GetPhoto(photoId); if (!authorizer.Photo_View(photo)) { return(Json(null, JsonRequestBehavior.AllowGet)); } if (photo == null) { return(Json(null, JsonRequestBehavior.AllowGet)); } return(Json(new { photoId = photo.PhotoId.ToString(), photoUrl = SiteUrls.Instance().ImageUrl(photo.RelativePath, TenantTypeIds.Instance().Photo(), ImageSizeTypeKeys.Instance().Original()), dateCreated = photo.DateCreated.ToFriendlyDate(), isEssential = photo.IsEssential, isCover = photo.Album.CoverId == photo.PhotoId }, JsonRequestBehavior.AllowGet)); }