Exemplo n.º 1
0
        public ActionResult CompleteUpload(string spaceKey, IEnumerable <string> photoDesctitions, IEnumerable <long> photoIds)
        {
            string errorMessage = string.Empty;

            if (!authorizer.Photo_Create(photoService.GetAlbum(photoService.GetPhoto(photoIds.First()).AlbumId), out errorMessage))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = errorMessage,
                    Title = "没有权限",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            long albumId = 0;

            for (int i = 0; i < photoIds.Count(); i++)
            {
                Photo photo = photoService.GetPhoto(photoIds.ElementAt(i));
                albumId           = photo.AlbumId;
                photo.Description = photoDesctitions.ElementAt(i);
                photoService.UpdatePhoto(photo, UserIdToUserNameDictionary.GetUserId(spaceKey));
                //设标签
                string tags = Request.Form.Get <string>("commonTag");
                tags += Request.Form.Get <string>("photoTags" + photoIds.ElementAt(i));
                if (!string.IsNullOrEmpty(tags))
                {
                    tagService.AddTagsToItem(tags, UserIdToUserNameDictionary.GetUserId(spaceKey), photoIds.ElementAt(i));
                }
            }

            return(Redirect(SiteUrls.Instance().AlbumDetailList(spaceKey, albumId)));
        }
Exemplo n.º 2
0
        public ActionResult BlockGroups(string spaceKey, List <long> groupIds)
        {
            int addCount = 0;

            long             userId  = UserIdToUserNameDictionary.GetUserId(spaceKey);
            UserBlockService service = new UserBlockService();

            if (userId > 0 && groupIds != null && groupIds.Count > 0)
            {
                foreach (var groupId in groupIds)
                {
                    GroupEntity group = groupService.Get(groupId);
                    if (group == null || service.IsBlockedGroup(userId, groupId))
                    {
                        continue;
                    }
                    service.BlockGroup(userId, group.GroupId, group.GroupName);
                    addCount++;
                }
            }
            if (addCount > 0)
            {
                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, string.Format("成功添加{0}个群组添加到屏蔽列表", addCount));
            }
            else
            {
                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "没有任何群组被添加到屏蔽列表中");
            }
            return(Redirect(SiteUrls.Instance().BlockGroups(spaceKey)));
        }
Exemplo n.º 3
0
        /// <summary>
        /// 删除用户记录(删除用户时使用)
        /// </summary>
        /// <param name="userId">被删除用户</param>
        /// <param name="takeOverUserName">接管用户名</param>
        /// <param name="takeOverAll">是否接管被删除用户的所有内容</param>
        public void DeleteUser(long userId, string takeOverUserName, bool takeOverAll)
        {
            long              takeOverUserId    = UserIdToUserNameDictionary.GetUserId(takeOverUserName);
            IUserService      userService       = DIContainer.Resolve <IUserService>();
            User              takeOver          = userService.GetFullUser(takeOverUserId);
            BarSectionService barSectionService = new BarSectionService();
            BarThreadService  barThreadService  = new BarThreadService();
            BarPostService    barPostService    = new BarPostService();

            //删除用户时,不删除贴吧,把贴吧转让,如果没有指定转让人,那就转给网站初始管理员
            if (takeOver == null)
            {
                takeOverUserId = new SystemDataService().GetLong("Founder");
                takeOver       = userService.GetFullUser(takeOverUserId);
            }

            barThreadRepository.DeleteUser(userId, takeOver, takeOverAll);
            if (takeOver != null)
            {
                if (!takeOverAll)
                {
                    barThreadService.DeletesByUserId(userId);
                    barPostService.DeletesByUserId(userId);
                }
            }
            //else
            //{
            //    barSectionService.DeletesByUserId(userId);
            //    barThreadService.DeletesByUserId(userId);
            //    barPostService.DeletesByUserId(userId);
            //}
        }
Exemplo n.º 4
0
        public ActionResult _DeleteAlbum(string spaceKey, long albumId)
        {
            long              userId     = UserIdToUserNameDictionary.GetUserId(spaceKey);
            Album             album      = photoService.GetAlbum(albumId);
            long              albumCount = photoService.GetAlbums(TenantTypeIds.Instance().User(), userId).TotalRecords;
            StatusMessageData message    = null;

            try
            {
                if (albumCount > 1)
                {
                    if (!authorizer.Album_Edit(album))
                    {
                        return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                        {
                            Body = "没有删除相册的权限",
                            Title = "没有权限",
                            StatusMessageType = StatusMessageType.Hint
                        })));
                    }
                    photoService.DeleteAlbum(album);
                    message = new StatusMessageData(StatusMessageType.Success, "删除相册成功!");
                }
                else
                {
                    message = new StatusMessageData(StatusMessageType.Hint, "至少要保留一个相册!");
                }
            }
            catch
            {
                message = new StatusMessageData(StatusMessageType.Error, "删除相册失败!");
            }

            return(Json(message));
        }
Exemplo n.º 5
0
        /// <summary>
        /// 页头
        /// </summary>
        /// <returns></returns>
        public ActionResult _Header(string spaceKey)
        {
            if (UserContext.CurrentUser != null)
            {
                MessageService    messageService    = new MessageService();
                InvitationService invitationService = new InvitationService();
                NoticeService     noticeService     = new NoticeService();

                long userId = UserIdToUserNameDictionary.GetUserId(UserContext.CurrentUser.UserName);
                int  count  = 0;
                count  = invitationService.GetUnhandledCount(userId);
                count += messageService.GetUnreadCount(userId);
                count += noticeService.GetUnhandledCount(userId);
                ViewData["PromptCount"] = count;
            }

            //获取当前是在哪个应用下搜索
            RouteValueDictionary routeValueDictionary = Request.RequestContext.RouteData.DataTokens;
            string areaName = routeValueDictionary.Get <string>("area", null) + "Search";

            ViewData["search"] = areaName;

            //查询用于快捷搜索的搜索器
            IEnumerable <ISearcher> searchersQuickSearch = SearcherFactory.GetQuickSearchers(4);

            ViewData["searchersQuickSearch"] = searchersQuickSearch;

            NavigationService service = new NavigationService();

            ViewData["Navigations"] = service.GetRootNavigations(PresentAreaKeysOfBuiltIn.Channel).Where(n => n.IsVisible(UserContext.CurrentUser) == true);

            return(PartialView());
        }
        /// <summary>
        /// 关注的用户菜单控件
        /// </summary>
        /// <returns></returns>
        public ActionResult _TopFollowedUsers(string spaceKey, int topNumber)
        {
            Dictionary <long, bool> isFollowesUser = new Dictionary <long, bool>();

            long userId        = UserIdToUserNameDictionary.GetUserId(spaceKey);
            long currentUserId = UserContext.CurrentUser.UserId;

            FollowService      followService = new FollowService();
            IEnumerable <long> ids           = followService.GetTopFollowedUserIds(userId, topNumber);

            foreach (var id in ids)
            {
                isFollowesUser[id] = followService.IsFollowed(currentUserId, id);
            }

            ViewData["isFollowesUser"] = isFollowesUser;

            if (currentUserId == userId)
            {
                ViewData["isSameUser"] = true;
            }

            ViewData["gender"] = (userService.GetUser(spaceKey) as User).Profile.Gender;
            IEnumerable <User> users = userService.GetFullUsers(ids);

            return(View(users));
        }
Exemplo n.º 7
0
        public ActionResult BlockTopics(string spaceKey, List <long> topicIds)
        {
            int addCount = 0;

            long             userId  = UserIdToUserNameDictionary.GetUserId(spaceKey);
            UserBlockService service = new UserBlockService();

            if (userId > 0 && topicIds != null && topicIds.Count > 0)
            {
                foreach (var topicId in topicIds)
                {
                    TopicEntity topic = topicService.Get(topicId);
                    if (topic == null || service.IsBlockedTopic(userId, topicId))
                    {
                        continue;
                    }
                    service.BlockTopic(userId, topic.TopicId, topic.TopicName);
                    addCount++;
                }
            }
            if (addCount > 0)
            {
                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, string.Format("成功添加{0}个专题添加到屏蔽列表", addCount));
            }
            else
            {
                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "没有任何专题被添加到屏蔽列表中");
            }
            return(Redirect(SiteUrls.Instance().BlockGroups(spaceKey)));
        }
Exemplo n.º 8
0
        /// <summary>
        /// 屏蔽群组
        /// </summary>
        /// <param name="spaceKey">空间名</param>
        /// <returns>屏蔽群组名</returns>
        public ActionResult _BlockGroups(string spaceKey)
        {
            long userId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            if (UserContext.CurrentUser == null || (UserContext.CurrentUser.UserId != userId && new Authorizer().IsAdministrator(new TenantTypeService().Get(TenantTypeIds.Instance().Group()).ApplicationId)))
            {
                return(Content(string.Empty));
            }

            IEnumerable <UserBlockedObject> blockedGroups = new UserBlockService().GetBlockedGroups(userId);

            List <UserBlockedObjectViewModel> blockedObjectes = new List <UserBlockedObjectViewModel>();

            if (blockedGroups != null && blockedGroups.Count() > 0)
            {
                groupService.GetGroupEntitiesByIds(blockedGroups.Select(n => n.ObjectId));
                foreach (var item in blockedGroups)
                {
                    GroupEntity group = groupService.Get(item.ObjectId);
                    if (group == null)
                    {
                        continue;
                    }

                    UserBlockedObjectViewModel entitiy = item.AsViewModel();
                    entitiy.Logo = group.Logo;
                    blockedObjectes.Add(entitiy);
                }
            }

            return(View(blockedObjectes));
        }
        public ActionResult Detail(string spaceKey, long microblogId)
        {
            MicroblogEntity entity = microblogService.Get(microblogId);

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

            //验证是否通过审核
            long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            if (!authorizer.IsAdministrator(MicroblogConfig.Instance().ApplicationId) && entity.UserId != currentSpaceUserId &&
                (int)entity.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(MicroblogConfig.Instance().ApplicationId)))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "尚未通过审核",
                    Body = "由于当前微博尚未通过审核,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            IUser user = userService.GetUser(spaceKey);

            if (user == null)
            {
                return(new EmptyResult());
            }


            pageResourceManager.InsertTitlePart(user.DisplayName + "的微博");

            return(View(entity));
        }
        public ActionResult ListReferred(string spaceKey, int?pageIndex)
        {
            pageResourceManager.InsertTitlePart("提到我的");

            long userId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            return(View(microblogService.GetMicroblogsByReferredUser(userId, pageIndex ?? 1)));
        }
        public ActionResult _FollowTopics(string spaceKey, int?topNumber)
        {
            FavoriteService   favoriteService = new FavoriteService(TenantTypeIds.Instance().Tag());
            long              userId          = UserIdToUserNameDictionary.GetUserId(spaceKey);
            IEnumerable <Tag> tags            = new TagService(TenantTypeIds.Instance().Microblog()).GetTags(favoriteService.GetTopObjectIds(userId, topNumber ?? 15));

            return(View(tags));
        }
Exemplo n.º 12
0
        /// <summary>
        /// 获取链接地址
        /// </summary>
        /// <param name="spaceKey">用户名</param>
        /// <param name="ownerId">用户id</param>
        /// <returns></returns>
        public string GetDataUrl(string spaceKey, long?ownerId = null)
        {
            if (string.IsNullOrEmpty(spaceKey) && ownerId.HasValue)
            {
                spaceKey = UserIdToUserNameDictionary.GetUserName(ownerId.Value);
            }

            return(SiteUrls.Instance().Blog(spaceKey));
        }
Exemplo n.º 13
0
        /// <summary>
        /// 获取链接地址
        /// </summary>
        /// <param name="spaceKey">用户名</param>
        /// <param name="ownerId">用户id</param>
        /// <returns></returns>
        public string GetDataUrl(string spaceKey, long?ownerId = null)
        {
            if (!string.IsNullOrEmpty(spaceKey) && ownerId == null)
            {
                ownerId = UserIdToUserNameDictionary.GetUserId(spaceKey);
            }

            return(SiteUrls.Instance().CmsUser(ownerId.Value));
        }
Exemplo n.º 14
0
        public ActionResult AlbumDetailList(string spaceKey, long albumId, int pageSize = 20, int pageIndex = 1)
        {
            IUser user = userService.GetUser(spaceKey);

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

            Album album = photoService.GetAlbum(albumId);

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

            //验证是否通过审核
            long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            if (!authorizer.IsAdministrator(PhotoConfig.Instance().ApplicationId) && album.UserId != currentSpaceUserId &&
                (int)album.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(PhotoConfig.Instance().ApplicationId)))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "尚未通过审核",
                    Body = "由于当前问题尚未通过审核,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

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

            if (currentUser != null && currentUser.UserId == album.UserId)
            {
                ignoreAuditAndPrivacy = true;
            }

            if (!authorizer.Album_View(album))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Body = "没有查看该相册的权限",
                    Title = "没有权限",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            PagingDataSet <Photo> photos = photoService.GetPhotosOfAlbum(TenantTypeIds.Instance().User(), albumId, ignoreAuditAndPrivacy, pageSize: pageSize, pageIndex: pageIndex);

            ViewData["album"] = album;

            pageResourceManager.InsertTitlePart(album.AlbumName);

            return(View(photos));
        }
Exemplo n.º 15
0
        /// <summary>
        /// 获取被评论对象url
        /// </summary>
        /// <param name="commentedObjectId">被评论对象Id</param>
        /// <param name="userId">被评论对象作者Id</param>
        /// <returns></returns>
        public string GetCommentedObjectUrl(long commentedObjectId, long?userId = null)
        {
            if (!userId.HasValue || userId <= 0)
            {
                return(string.Empty);
            }

            string userName = UserIdToUserNameDictionary.GetUserName(userId.Value);

            return(SiteUrls.Instance().ShowMicroblog(userName, commentedObjectId));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 详细页面地址
        /// </summary>
        /// <param name="itemId">推荐内容Id</param>
        /// <returns></returns>
        public string RecommendItemDetail(long itemId)
        {
            Album album = new PhotoService().GetAlbum(itemId);

            if (album == null)
            {
                return(string.Empty);
            }
            string userName = UserIdToUserNameDictionary.GetUserName(album.UserId);

            return(SiteUrls.Instance().AlbumDetailList(userName, itemId));
        }
Exemplo n.º 17
0
        /// <summary>
        /// 详细页面地址
        /// </summary>
        /// <param name="itemId">推荐内容Id</param>
        /// <returns></returns>
        public string RecommendItemDetail(long itemId)
        {
            TopicEntity group = new TopicService().Get(itemId);

            if (group == null)
            {
                return(string.Empty);
            }
            string userName = UserIdToUserNameDictionary.GetUserName(group.UserId);

            return(SiteUrls.Instance().TopicHome(itemId));
        }
Exemplo n.º 18
0
        /// <summary>
        /// 详细页面地址
        /// </summary>
        /// <param name="itemId">推荐内容Id</param>
        /// <returns></returns>
        public string RecommendItemDetail(long itemId)
        {
            Photo photo = new PhotoService().GetPhoto(itemId);

            if (photo == null)
            {
                return(string.Empty);
            }
            string userName = UserIdToUserNameDictionary.GetUserName(photo.UserId);

            return(SiteUrls.Instance().PhotoDetail(itemId));
        }
Exemplo n.º 19
0
        /// <summary>
        /// 详细页面地址
        /// </summary>
        /// <param name="itemId">推荐内容Id</param>
        /// <returns></returns>
        public string RecommendItemDetail(long itemId)
        {
            BlogThread blogThread = new BlogService().Get(itemId);

            if (blogThread == null)
            {
                return(string.Empty);
            }
            string userName = UserIdToUserNameDictionary.GetUserName(blogThread.UserId);

            return(SiteUrls.Instance().BlogDetail(userName, itemId));
        }
Exemplo n.º 20
0
 /// <summary>
 /// 获取被评论对象url
 /// </summary>
 /// <param name="commentedObjectId">被评论对象Id</param>
 /// <param name="userId">被评论对象作者Id</param>
 /// <returns></returns>
 public string GetCommentedObjectUrl(long commentedObjectId, long?userId = null, string tenantTypeId = null)
 {
     if (!userId.HasValue || userId <= 0)
     {
         return(string.Empty);
     }
     if (tenantTypeId == TenantTypeIds.Instance().BlogThread())
     {
         string userName = UserIdToUserNameDictionary.GetUserName(userId.Value);
         return(SiteUrls.Instance().BlogDetail(userName, commentedObjectId));
     }
     return(string.Empty);
 }
Exemplo n.º 21
0
        /// <summary>
        /// 用户空间日志左侧日志分类
        /// </summary>
        public ActionResult _Categories(string spaceKey)
        {
            IEnumerable<Category> categories = null;
            IUser currentUser = UserContext.CurrentUser;
            if (currentUser != null && currentUser.UserName == spaceKey)
            {
                categories = categoryService.GetOwnerCategories(currentUser.UserId, TenantTypeIds.Instance().BlogThread());
            }
            else
            {
                categories = categoryService.GetOwnerCategories(UserIdToUserNameDictionary.GetUserId(spaceKey), TenantTypeIds.Instance().BlogThread());
            }

            return View(categories);
        }
Exemplo n.º 22
0
        /// <summary>
        /// 资讯详情页
        /// </summary>
        public ActionResult ContentItemDetail(long contentItemId)
        {
            ContentItem contentItem = contentItemService.Get(contentItemId);

            if (contentItem == null || contentItem.User == null)
            {
                return(HttpNotFound());
            }

            //验证是否通过审核
            long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(contentItem.User.UserName);

            if (!authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId) && contentItem.UserId != currentSpaceUserId &&
                (int)contentItem.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(CmsConfig.Instance().ApplicationId)))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "尚未通过审核",
                    Body = "由于当前资讯尚未通过审核,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            AttachmentService <Attachment> attachmentService = new AttachmentService <Attachment>(TenantTypeIds.Instance().ContentItem());


            //更新浏览计数
            CountService countService = new CountService(TenantTypeIds.Instance().ContentItem());

            countService.ChangeCount(CountTypes.Instance().HitTimes(), contentItem.ContentItemId, contentItem.UserId, 1, true);
            if (UserContext.CurrentUser != null)
            {
                //创建访客记录
                VisitService visitService = new VisitService(TenantTypeIds.Instance().ContentItem());
                visitService.CreateVisit(UserContext.CurrentUser.UserId, UserContext.CurrentUser.DisplayName, contentItem.ContentItemId, contentItem.Title);
            }
            //设置SEO信息
            pageResourceManager.InsertTitlePart(contentItem.Title);
            List <string> keywords = new List <string>();

            keywords.AddRange(contentItem.TagNames);
            string keyword = string.Join(" ", keywords.Distinct());

            keyword += " " + string.Join(" ", ClauseScrubber.TitleToKeywords(contentItem.Title));
            pageResourceManager.SetMetaOfKeywords(keyword);
            pageResourceManager.SetMetaOfDescription(contentItem.Summary);
            return(View(contentItem));
        }
Exemplo n.º 23
0
        /// <summary>
        /// 侧边栏最新日志
        /// </summary>
        public ActionResult _Newest(string spaceKey, int topNum = 10)
        {
            PagingDataSet<BlogThread> blogs = null;

            IUser currentUser = UserContext.CurrentUser;
            if (currentUser != null && currentUser.UserName == spaceKey)
            {
                blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, null, null, false, topNum, 1);
            }
            else
            {
                blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, null, null, false, topNum, 1);
            }

            return View(blogs);
        }
        public ActionResult ListFavorites(string spaceKey, int?pageIndex)
        {
            pageResourceManager.InsertTitlePart("我的收藏");

            long userId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            PagingDataSet <long>            pdsObjectIds = favoriteService.GetPagingObjectIds(userId, pageIndex ?? 1);
            IEnumerable <MicroblogEntity>   microblogs   = microblogService.GetMicroblogs(pdsObjectIds);
            PagingDataSet <MicroblogEntity> pds          = new PagingDataSet <MicroblogEntity>(microblogs)
            {
                TotalRecords  = pdsObjectIds.TotalRecords,
                PageSize      = pdsObjectIds.PageSize,
                PageIndex     = pdsObjectIds.PageIndex,
                QueryDuration = pdsObjectIds.QueryDuration
            };

            return(View(pds));
        }
Exemplo n.º 25
0
        /// <summary>
        /// 获取链接地址
        /// </summary>
        /// <param name="spaceKey">用户名</param>
        /// <param name="ownerId">用户id</param>
        /// <returns></returns>
        public string GetDataUrl(string spaceKey, long?ownerId = null)
        {
            if (string.IsNullOrEmpty(spaceKey) && ownerId.HasValue)
            {
                spaceKey = UserIdToUserNameDictionary.GetUserName(ownerId.Value);
            }
            return(SiteUrls.Instance().Mine(spaceKey, string.Empty));

            //           string tenantTypeId = TenantTypeIds.Instance().User();
            //           IEnumerable<string> dataKeys = OwnerDataSettings.GetDataKeys(tenantTypeId);
            //            List<OwnerStatisticData> list=new List<OwnerStatisticData>();
            //           foreach (var dataKey in dataKeys)
            //           {
            //OwnerStatisticData data=new OwnerStatisticData();
            //               var getter= OwnerDataGetterFactory.Get(dataKey);
            //               getter.DataName;
            //               var value = new OwnerDataService().GetLong(ownerId, dataKey);
            //               getter.GetDataUrl
            //                   list.Add
            //           }
        }
Exemplo n.º 26
0
        /// <summary>
        /// 删除用户记录(删除用户时使用)
        /// </summary>
        /// <param name="userId">被删除用户</param>
        /// <param name="takeOverUserName">接管用户名</param>
        /// <param name="takeOverAll">是否接管被删除用户的所有内容</param>
        public void DeleteUser(long userId, string takeOverUserName, bool takeOverAll)
        {
            //设计要点:
            //1.利用sql转移给接管用户、删除群组成员、群组成员申请;
            //2.删除群组成员时,维护群组的成员数;

            //如果没设置由谁接管群组,就把群组转给网站初始管理员
            long takeOverUserId = 0;

            if (string.IsNullOrEmpty(takeOverUserName))
            {
                takeOverUserId = new SystemDataService().GetLong("Founder");
            }
            else
            {
                takeOverUserId = UserIdToUserNameDictionary.GetUserId(takeOverUserName);
            }


            IUserService userService = DIContainer.Resolve <IUserService>();
            User         takeOver    = userService.GetFullUser(takeOverUserId);

            groupRepository.DeleteUser(userId, takeOver, takeOverAll);
        }
Exemplo n.º 27
0
        public ActionResult Detail(string spaceKey, long threadId, int pageIndex = 1, bool onlyLandlord = false, SortBy_BarPost sortBy = SortBy_BarPost.DateCreated, long?postId = null, long?childPostIndex = null)
        {
            BarThread barThread = barThreadService.Get(threadId);

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

            GroupEntity group = groupService.Get(spaceKey);

            if (group == null)
            {
                return(HttpNotFound());
            }
            BarSection section = barSectionService.Get(barThread.SectionId);

            if (section == null || section.TenantTypeId != TenantTypeIds.Instance().Group())
            {
                return(HttpNotFound());
            }

            //验证是否通过审核
            long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            if (!authorizer.IsAdministrator(BarConfig.Instance().ApplicationId) && barThread.UserId != currentSpaceUserId &&
                (int)barThread.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(BarConfig.Instance().ApplicationId)))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "尚未通过审核",
                    Body = "由于当前帖子尚未通过审核,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }


            pageResourceManager.InsertTitlePart(section.Name);
            pageResourceManager.InsertTitlePart(barThread.Subject);

            Category category = categoryService.Get(barThread.CategoryId ?? 0);
            string   keyWords = string.Join(",", barThread.TagNames);

            pageResourceManager.SetMetaOfKeywords(category != null ? category.CategoryName + "," + keyWords : keyWords); //设置Keyords类型的Meta
            pageResourceManager.SetMetaOfDescription(HtmlUtility.TrimHtml(barThread.GetResolvedBody(), 120));            //设置Description类型的Meta

            ViewData["EnableRating"] = barSettings.EnableRating;

            //更新浏览计数
            CountService countService = new CountService(TenantTypeIds.Instance().BarThread());

            countService.ChangeCount(CountTypes.Instance().HitTimes(), barThread.ThreadId, barThread.UserId, 1, false);

            PagingDataSet <BarPost> barPosts = barPostService.Gets(threadId, onlyLandlord, sortBy, pageIndex);

            if (pageIndex > barPosts.PageCount && pageIndex > 1)
            {
                return(Detail(spaceKey, threadId, barPosts.PageCount));
            }
            if (Request.IsAjaxRequest())
            {
                return(PartialView("~/Applications/Bar/Views/Bar/_ListPost.cshtml", barPosts));
            }

            ViewData["barThread"] = barThread;
            ViewData["group"]     = group;
            return(View(barPosts));
        }
Exemplo n.º 28
0
        /// <summary>
        /// 日志列表
        /// </summary>
        public ActionResult List(string spaceKey, ListType listType, string tag = null, int year = 0, int month = 0, long categoryId = 0, int pageIndex = 1)
        {
            PagingDataSet <BlogThread> blogs = null;
            IUser  currentUser = UserContext.CurrentUser;
            string title       = string.Empty;

            switch (listType)
            {
            case ListType.Archive:
                ArchivePeriod archivePeriod = ArchivePeriod.Year;
                if (month > 0)
                {
                    archivePeriod = ArchivePeriod.Month;
                }

                ArchiveItem archiveItem = new ArchiveItem();
                archiveItem.Year  = year;
                archiveItem.Month = month;

                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, archivePeriod, archiveItem, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, archivePeriod, archiveItem, 20, pageIndex);
                }

                title = "归档:" + year + "年";
                if (month > 0)
                {
                    title += month + "月";
                }

                break;

            case ListType.Category:
                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, categoryId, null, false, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, categoryId, null, false, 20, pageIndex);
                }

                Category category = categoryService.Get(categoryId);
                title = "分类:" + category.CategoryName;

                break;

            case ListType.Tag:
                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, null, tag, false, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, null, tag, false, 20, pageIndex);
                }

                title = "标签:" + tag;

                break;

            default:
                break;
            }

            ViewData["title"] = title;
            pageResourceManager.InsertTitlePart(title);

            return(View(blogs));
        }
Exemplo n.º 29
0
        /// <summary>
        /// 日志详细页
        /// </summary>
        public ActionResult Detail(string spaceKey, long threadId)
        {
            BlogThread blogThread = blogService.Get(threadId);

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

            if (!authorizer.BlogThread_View(blogThread))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "没有权限",
                    Body = "由于空间主人的权限设置,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            long currentSpaceUserId = UserIdToUserNameDictionary.GetUserId(spaceKey);

            if (!authorizer.IsAdministrator(BlogConfig.Instance().ApplicationId) && blogThread.UserId != currentSpaceUserId &&
                (int)blogThread.AuditStatus < (int)(new AuditService().GetPubliclyAuditStatus(BlogConfig.Instance().ApplicationId)))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "尚未通过审核",
                    Body = "由于当前日志尚未通过审核,您无法浏览当前内容。",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            //附件信息
            IEnumerable <Attachment> attachments = attachmentService.GetsByAssociateId(threadId);

            if (attachments != null && attachments.Count() > 0)
            {
                ViewData["attachments"] = attachments.Where(n => n.MediaType == MediaType.Other);
            }

            //更新浏览计数
            CountService countService = new CountService(TenantTypeIds.Instance().BlogThread());

            countService.ChangeCount(CountTypes.Instance().HitTimes(), blogThread.ThreadId, blogThread.UserId, 1, false);

            //设置SEO信息
            pageResourceManager.InsertTitlePart(blogThread.Author);
            pageResourceManager.InsertTitlePart(blogThread.ResolvedSubject);

            List <string> keywords = new List <string>();

            keywords.AddRange(blogThread.TagNames);
            keywords.AddRange(blogThread.OwnerCategoryNames);
            string keyword = string.Join(" ", keywords.Distinct());

            if (!string.IsNullOrEmpty(blogThread.Keywords))
            {
                keyword += " " + blogThread.Keywords;
            }

            pageResourceManager.SetMetaOfKeywords(keyword);

            if (!string.IsNullOrEmpty(blogThread.Summary))
            {
                pageResourceManager.SetMetaOfDescription(HtmlUtility.StripHtml(blogThread.Summary, true, false));
            }


            return(View(blogThread));
        }
Exemplo n.º 30
0
        /// <summary>
        /// 用户空间日志左侧存档列表
        /// </summary>
        public ActionResult _Archives(string spaceKey)
        {
            IEnumerable <ArchiveItem> archiveItems = null;
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser != null && currentUser.UserName == spaceKey)
            {
                archiveItems = blogService.GetArchiveItems(TenantTypeIds.Instance().User(), currentUser.UserId, true, false);
            }
            else
            {
                archiveItems = blogService.GetArchiveItems(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true);
            }

            return(View(archiveItems));
        }