Exemplo n.º 1
0
        /// <summary>
        /// 删除照片
        /// </summary>
        /// <remarks>
        /// 1.更新所属相册计数PhotoCount-1
        /// 2.更新用户内容计数OwnerData-1
        /// 3.如果照片是封面,需要将相册的CoverId属性重置为0
        /// 4.需要调用TagService.ClearTagsFromItem删除标签关联
        /// 5.需要同步删除照片圈人
        /// 6.通过EventModule处理动态和积分的变化;
        /// 7.需要触发的事件:1)Delete的OnBefore、OnAfter;2)审核状态变更
        /// </remarks>
        /// <param name="photo">照片对象</param>
        public void DeletePhoto(Photo photo)
        {
            //删除与标签的关联
            TagService tagService = new TagService(TenantTypeIds.Instance().Photo());

            tagService.ClearTagsFromItem(photo.PhotoId, photo.UserId);

            //删除照片推荐
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(photo.PhotoId, TenantTypeIds.Instance().Photo());

            //相册计数PhotoCount-1及封面
            Album album = photo.Album;

            album.PhotoCount--;
            if (photo.PhotoId == album.CoverId)
            {
                album.CoverId = 0;
            }
            albumRepository.Update(album);

            //删除圈人
            IEnumerable <PhotoLabel> photoLabels = this.GetLabelsOfPhoto(null, photo.PhotoId);

            foreach (PhotoLabel photolabel in photoLabels)
            {
                photoLabelRepository.Delete(photolabel);
            }

            //删除照片磁盘物理文件
            if (!string.IsNullOrEmpty(photo.RelativePath))
            {
                TenantAttachmentSettings tenantAttachmentSettings = TenantAttachmentSettings.GetRegisteredSettings(TenantTypeIds.Instance().Photo());
                IStoreProvider           storeProvider            = DIContainer.ResolveNamed <IStoreProvider>(tenantAttachmentSettings.StoreProviderName);
                string relativePath = storeProvider.GetRelativePath(photo.RelativePath, true);
                string fileName     = photo.RelativePath.Remove(0, relativePath.Length).Trim('\\').Trim('/');
                storeProvider.DeleteFiles(relativePath, fileName);
            }

            photoRepository.Delete(photo);

            EventBus <Photo> .Instance().OnBefore(photo, new CommonEventArgs(EventOperationType.Instance().Delete()));

            //用户内容计数OwnerData-1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(photo.UserId, OwnerDataKeys.Instance().PhotoCount(), -1);

            //通过EventModule处理动态和积分的变化;
            EventBus <Photo> .Instance().OnAfter(photo, new CommonEventArgs(EventOperationType.Instance().Delete()));

            EventBus <Photo, AuditEventArgs> .Instance().OnAfter(photo, new AuditEventArgs(photo.AuditStatus, null));
        }
Exemplo n.º 2
0
        /// <summary>
        /// 创建兑换记录
        /// </summary>
        /// <remarks>
        /// 1.冻结相应积分
        /// </remarks>
        /// <param name="record">记录对象</param>
        /// <returns></returns>
        public long CreateRecord(PointGiftExchangeRecord record)
        {
            if (record.Price > 0)
            {
                userService.FreezeTradePoints(record.PayerUserId, record.Price);

                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(record.PayerUserId, OwnerDataKeys.Instance().PostCount(), 1);
            }
            recordRepository.Insert(record);
            return(record.RecordId);
        }
Exemplo n.º 3
0
        /// <summary>
        /// 获取问答用户统计数据
        /// </summary>
        /// <remarks>
        /// 需统计:问题数、回答数、回答被采纳数、赞同数
        /// 无需缓存
        /// </remarks>
        /// <param name="userId">用户id</param>
        /// <returns>用户统计数据</returns>
        public Dictionary <string, long> GetUserStatisticData(long userId)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            Dictionary <string, long> userStatisticData = new Dictionary <string, long>();

            userStatisticData.Add(OwnerDataKeys.Instance().QuestionCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().QuestionCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().AnswerCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().AnswerCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().AnswerAcceptCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().AnswerAcceptCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().AnswerSupportCount(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().AnswerSupportCount()));
            userStatisticData.Add(OwnerDataKeys.Instance().UserAskReputation(), ownerDataService.GetLong(userId, OwnerDataKeys.Instance().UserAskReputation()));

            return(userStatisticData);
        }
Exemplo n.º 4
0
        public async Task<IHttpActionResult> GetOwners()
        {
            var ownerService = new OwnerDataService();
            var processingResult = await ownerService.GetAllWhere(LoggedInUser.ClientID);
            if (!processingResult.IsSuccessful)
            {
                processingResult.Error = new ProcessingError("An error occurred while getting Owner.", "Could not Owner, please try again. If the problem persists contact support.", true);
                return Ok(processingResult);
            }

            processingResult.Data = processingResult.Data;

            return Ok(processingResult);
        }
Exemplo n.º 5
0
        /// <summary>
        /// 删除群组下的成员
        /// </summary>
        /// <param name="groupId"></param>
        public void DeleteMembersByGroupId(long groupId)
        {
            IEnumerable <GroupMember> groupMembers = groupMemberRepository.GetAllMembersOfGroup(groupId);

            foreach (var groupMember in groupMembers)
            {
                int affectCount = groupMemberRepository.Delete(groupMember);
                if (affectCount > 0)
                {
                    EventBus <GroupMember> .Instance().OnAfter(groupMember, new CommonEventArgs(EventOperationType.Instance().Delete()));

                    //用户的参与群组数-1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(groupMember.UserId, OwnerDataKeys.Instance().JoinedGroupCount(), -1);
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 删除记录
        /// </summary>
        /// <remarks>
        /// 1.管理员无权删除兑换记录
        /// 2.记录已经批准则不能删除记录
        /// 3.冻结积分返还
        /// </remarks>
        /// <param name="record">记录对象</param>
        public bool CancelRecord(PointGiftExchangeRecord record)
        {
            if (record.Status == ApproveStatus.Pending)
            {
                userService.UnfreezeTradePoints(record.PayerUserId, record.Price);

                //处理统计数据
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(record.PayerUserId, OwnerDataKeys.Instance().PostCount(), -1);

                recordRepository.Delete(record);
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemplo n.º 7
0
        /// <summary>
        /// 创建主题帖
        /// </summary>
        /// <param name="thread">主题帖</param>
        public bool Create(BarThread thread)
        {
            BarSectionService barSectionService = new BarSectionService();

            EventBus <BarThread> .Instance().OnBefore(thread, new CommonEventArgs(EventOperationType.Instance().Create()));

            //设置审核状态
            auditService.ChangeAuditStatusForCreate(thread.UserId, thread);
            long id = 0;

            long.TryParse(barThreadRepository.Insert(thread).ToString(), out id);

            if (id > 0)
            {
                new AttachmentService(TenantTypeIds.Instance().BarThread()).ToggleTemporaryAttachments(thread.UserId, TenantTypeIds.Instance().BarThread(), id);
                BarSection barSection = barSectionService.Get(thread.SectionId);
                if (barSection != null)
                {
                    //计数
                    CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                    countService.ChangeCount(CountTypes.Instance().ThreadCount(), barSection.SectionId, barSection.UserId, 1, true);
                    countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, 1, true);
                    if (thread.TenantTypeId == TenantTypeIds.Instance().Group())
                    {
                        //群组内容计数+1
                        OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group());
                        groupOwnerDataService.Change(thread.SectionId, OwnerDataKeys.Instance().ThreadCount(), 1);
                    }
                }
                if (thread.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //用户内容计数+1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(thread.UserId, OwnerDataKeys.Instance().ThreadCount(), 1);
                }
                AtUserService atUserService = new AtUserService(TenantTypeIds.Instance().BarThread());
                atUserService.ResolveBodyForEdit(thread.GetBody(), thread.UserId, thread.ThreadId);

                EventBus <BarThread> .Instance().OnAfter(thread, new CommonEventArgs(EventOperationType.Instance().Create()));

                EventBus <BarThread, AuditEventArgs> .Instance().OnAfter(thread, new AuditEventArgs(null, thread.AuditStatus));
            }
            return(id > 0);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 撰写词条
        /// </summary>
        /// <param name="wikiPage">词条实体</param>
        public bool Create(WikiPage wikiPage, string body)
        {
            EventBus <WikiPage> .Instance().OnBefore(wikiPage, new CommonEventArgs(EventOperationType.Instance().Create()));

            //设置审核状态,草稿的审核状态为待审核
            AuditService auditService = new AuditService();

            auditService.ChangeAuditStatusForCreate(wikiPage.UserId, wikiPage);

            long pageId = 0;

            long.TryParse(wikiPageRepository.Insert(wikiPage).ToString(), out pageId);

            if (pageId > 0)
            {
                WikiPageVersion wikiPageVersion = WikiPageVersion.New();
                wikiPageVersion.PageId       = pageId;
                wikiPageVersion.TenantTypeId = wikiPage.TenantTypeId;
                wikiPageVersion.OwnerId      = wikiPage.OwnerId;
                wikiPageVersion.VersionNum   = 1;
                wikiPageVersion.Title        = wikiPage.Title;
                wikiPageVersion.UserId       = wikiPage.UserId;
                wikiPageVersion.Author       = wikiPage.Author;
                wikiPageVersion.Summary      = StringUtility.Trim(Tunynet.Utilities.HtmlUtility.StripHtml(body, true, false).Replace("\r", "").Replace("\n", ""), 200);
                wikiPageVersion.Body         = body;
                wikiPageVersion.AuditStatus  = AuditStatus.Success;
                wikiPageVersionRepository.Insert(wikiPageVersion);
                //转换临时附件
                AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().WikiPage());
                attachmentService.ToggleTemporaryAttachments(wikiPage.OwnerId, TenantTypeIds.Instance().WikiPage(), wikiPageVersion.PageId);

                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(wikiPage.UserId, OwnerDataKeys.Instance().PageCount(), 1);

                EventBus <WikiPage> .Instance().OnAfter(wikiPage, new CommonEventArgs(EventOperationType.Instance().Create()));

                EventBus <WikiPage, AuditEventArgs> .Instance().OnAfter(wikiPage, new AuditEventArgs(null, wikiPage.AuditStatus));

                return(true);
            }

            return(false);
        }
Exemplo n.º 9
0
        /// <summary>
        /// 创建微博
        /// </summary>
        /// <param name="microblog">待创建微博实体</param>
        /// <returns></returns>
        public long Create(MicroblogEntity microblog)
        {
            EventBus <MicroblogEntity> .Instance().OnBefore(microblog, new CommonEventArgs(EventOperationType.Instance().Create()));

            //设置审核状态
            auditService.ChangeAuditStatusForCreate(microblog.UserId, microblog);

            string videoAlias = string.Empty, audioAlias = string.Empty;

            microblog.Body       = parsedMediaService.ResolveBodyForEdit(microblog.Body, out videoAlias, out audioAlias);
            microblog.HasVideo   = !string.IsNullOrEmpty(videoAlias);
            microblog.HasMusic   = !string.IsNullOrEmpty(audioAlias);
            microblog.VideoAlias = videoAlias;
            microblog.AudioAlias = audioAlias;

            long id = 0;

            long.TryParse(microblogRepository.Insert(microblog).ToString(), out id);

            if (id > 0)
            {
                string tenantTypeId = TenantTypeIds.Instance().Microblog();

                OwnerDataService ownerDataService = new OwnerDataService(microblog.TenantTypeId);
                ownerDataService.Change(microblog.OwnerId, OwnerDataKeys.Instance().ThreadCount(), 1);


                //将临时附件转换为正式附件
                attachmentService.ToggleTemporaryAttachments(microblog.UserId, tenantTypeId, id);

                AtUserService atUserService = new AtUserService(tenantTypeId);
                atUserService.ResolveBodyForEdit(microblog.Body, microblog.UserId, microblog.MicroblogId);

                TagService tagService = new TagService(tenantTypeId);
                tagService.ResolveBodyForEdit(microblog.Body, microblog.OwnerId, microblog.MicroblogId, tenantTypeId);

                EventBus <MicroblogEntity> .Instance().OnAfter(microblog, new CommonEventArgs(EventOperationType.Instance().Create()));

                EventBus <MicroblogEntity, AuditEventArgs> .Instance().OnAfter(microblog, new AuditEventArgs(null, microblog.AuditStatus));
            }

            return(id);
        }
Exemplo n.º 10
0
        /// <summary>
        /// 删除回复贴
        /// </summary>
        /// <param name="postId">回复贴Id</param>
        public void Delete(long postId)
        {
            BarPost post = barPostRepository.Get(postId);

            if (post == null)
            {
                return;
            }
            BarSectionService barSectionService = new BarSectionService();
            BarSection        barSection        = barSectionService.Get(post.SectionId);

            if (barSection == null)
            {
                return;
            }
            EventBus <BarPost> .Instance().OnBefore(post, new CommonEventArgs(EventOperationType.Instance().Delete()));

            int affectCount = barPostRepository.Delete(post);

            if (affectCount > 0)
            {
                //更新帖吧的计数
                CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, -1 - post.ChildPostCount, true);
                if (post.TenantTypeId == TenantTypeIds.Instance().Group())
                {
                    //群组内容计数-1
                    OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group());
                    groupOwnerDataService.Change(post.SectionId, OwnerDataKeys.Instance().PostCount(), -1);
                }
                else if (post.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //用户内容计数-1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(post.UserId, OwnerDataKeys.Instance().PostCount(), -1);
                }

                EventBus <BarPost> .Instance().OnAfter(post, new CommonEventArgs(EventOperationType.Instance().Delete()));

                EventBus <BarPost, AuditEventArgs> .Instance().OnAfter(post, new AuditEventArgs(post.AuditStatus, null));
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// 创建照片
        /// </summary>
        /// <remarks>
        /// 1.更新相册的PhotoCount+1
        /// 2.更新用户内容计数OwnerData+1
        /// 3.需要同步相册的TenantTypeId、OwnerId、UserId、Author、PrivacyStatus字段
        /// 4.注意在EventModule中处理动态、积分;
        /// 5.使用AuditService.ChangeAuditStatusForCreate设置审核状态;
        /// 6.需要触发的事件:1)Create的OnBefore、OnAfter;2)审核状态变更;
        /// </remarks>
        /// <param name="photo">照片对象</param>
        /// <param name="file">上传文件</param>
        /// <returns>返回是否成功创建</returns>
        public bool CreatePhoto(Photo photo, HttpPostedFileBase file)
        {
            EventBus <Photo> .Instance().OnBefore(photo, new CommonEventArgs(EventOperationType.Instance().Create()));

            Album album = photo.Album;

            //需要同步相册的TenantTypeId、OwnerId、UserId、Author、PrivacyStatus字段
            photo.TenantTypeId  = album.TenantTypeId;
            photo.OwnerId       = album.OwnerId;
            photo.UserId        = album.UserId;
            photo.Author        = photo.User != null ? photo.User.DisplayName : album.Author;
            photo.PrivacyStatus = album.PrivacyStatus;

            //设置审核状态
            new AuditService().ChangeAuditStatusForCreate(album.UserId, photo);

            //创建照片
            photoRepository.Insert(photo);
            this.UploadPhoto(photo, file);
            photoRepository.Update(photo);

            //更新相册PhotoCount,LastUploadDate
            album.PhotoCount++;
            album.LastUploadDate = photo.DateCreated;
            albumRepository.Update(album);

            //用户内容计数OwnerData+1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(photo.UserId, OwnerDataKeys.Instance().PhotoCount(), 1);

            //处理积分动态
            EventBus <Album> .Instance().OnAfter(album, new CommonEventArgs(EventOperationType.Instance().Create()));

            EventBus <Album, AuditEventArgs> .Instance().OnAfter(album, new AuditEventArgs(null, photo.AuditStatus));

            EventBus <Photo, AuditEventArgs> .Instance().OnAfter(photo, new AuditEventArgs(null, photo.AuditStatus));

            EventBus <Photo> .Instance().OnAfter(photo, new CommonEventArgs(EventOperationType.Instance().Create()));

            return(photo.PhotoId > 0);
        }
 //todo:mazq,by zhengw:走查以下代码:用户关注帖吧时,要追溯该帖吧的动态
 /// <summary>
 /// 关注帖吧事件处理程序
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="eventArgs"></param>
 void SubscribeBarSectionEventModule_After(long sender, SubscribeEventArgs eventArgs)
 {
     if (eventArgs.TenantTypeId != TenantTypeIds.Instance().BarSection())
         return;
     ActivityService activityService = new ActivityService();
     if (EventOperationType.Instance().Create() == eventArgs.EventOperationType)
     {
         activityService.TraceBackInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection());
         //用户内容计数
         OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
         ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), 1);
     }
     else if (EventOperationType.Instance().Delete() == eventArgs.EventOperationType)
     {
         activityService.RemoveInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection());
         //用户内容计数
         OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
         ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), -1);
     }
 }
Exemplo n.º 13
0
        /// <summary>
        /// 移除群组成员
        /// </summary>
        /// <param name="groupId">群组Id</param>
        /// <param name="userId">用户Id</param>
        public void DeleteGroupMember(long groupId, long userId)
        {
            GroupMember groupMember = groupMemberRepository.GetMember(groupId, userId);

            if (groupMember == null)
            {
                return;
            }

            int affectCount = groupMemberRepository.Delete(groupMember);

            if (affectCount > 0)
            {
                EventBus <GroupMember> .Instance().OnAfter(groupMember, new CommonEventArgs(EventOperationType.Instance().Delete()));

                //用户的参与群组数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(userId, OwnerDataKeys.Instance().JoinedGroupCount(), -1);
            }
        }
Exemplo n.º 14
0
        /// <summary>
        /// 发布回答
        /// </summary>
        /// <remarks>
        /// 1.每个回答者针对每个问题只能回答一次,创建回答前需做重复检查
        /// 2.注意维护相关问题的回答数,AnswerCount++
        /// 3.注意需要在EventModule中处理动态、积分、通知、自动关注(回答者自动关注该问题)
        /// 4.注意使用AuditService.ChangeAuditStatusForCreate设置审核状态;
        /// 5.注意调用AttachmentService转换临时附件;
        /// 6.需要触发的事件:1)Create的OnBefore、OnAfter;2)审核状态变更;
        /// </remarks>
        /// <param name="answer">回答实体</param>
        /// <returns>是否创建成功</returns>
        public bool CreateAnswer(AskAnswer answer)
        {
            //先查询当前用户是否已经回答了指定问题
            if (GetUserAnswerByQuestionId(answer.UserId, answer.QuestionId) == null)
            {
                EventBus <AskAnswer> .Instance().OnBefore(answer, new CommonEventArgs(EventOperationType.Instance().Create()));

                //设置审核状态
                new AuditService().ChangeAuditStatusForCreate(answer.UserId, answer);

                askAnswerRepository.Insert(answer);

                if (answer.AnswerId > 0)
                {
                    //维护相关问题的内容
                    AskQuestion question = askQuestionRepository.Get(answer.QuestionId);
                    question.LastAnswerUserId = answer.UserId;
                    question.LastAnswerAuthor = answer.Author;
                    question.LastAnswerDate   = answer.DateCreated;
                    question.AnswerCount++;

                    //调用Service中的Update方法,以触发相应的事件,但是不更新审核状态
                    this.UpdateQuestion(question, false);

                    //将临时附件转换为正式附件
                    AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().AskAnswer());
                    attachmentService.ToggleTemporaryAttachments(answer.UserId, TenantTypeIds.Instance().AskAnswer(), answer.AnswerId);

                    //用户回答数计数
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().AnswerCount(), 1);

                    EventBus <AskAnswer> .Instance().OnAfter(answer, new CommonEventArgs(EventOperationType.Instance().Create()));

                    EventBus <AskAnswer, AuditEventArgs> .Instance().OnAfter(answer, new AuditEventArgs(null, answer.AuditStatus));
                }
            }

            return(answer.AnswerId > 0);
        }
Exemplo n.º 15
0
        /// <summary>
        /// 创建ContentItem
        /// </summary>
        /// <param name="contentItem"></param>
        public void Create(ContentItem contentItem)
        {
            //设置审核状态
            if (contentItem.IsContributed && contentItem.ContentFolder != null && contentItem.ContentFolder.NeedAuditing)
            {
                new AuditService().ChangeAuditStatusForCreate(contentItem.UserId, contentItem);
            }
            else
            {
                contentItem.AuditStatus = AuditStatus.Success;
            }

            //执行事件
            EventBus <ContentItem> .Instance().OnBefore(contentItem, new CommonEventArgs(EventOperationType.Instance().Create()));

            contentItemRepository.Insert(contentItem);
            //转换临时附件
            AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().ContentItem());

            attachmentService.ToggleTemporaryAttachments(contentItem.UserId, TenantTypeIds.Instance().ContentItem(), contentItem.ContentItemId);
            if (contentItem.AdditionalProperties.Get <bool>("FirstAsTitleImage", false))
            {
                IEnumerable <Attachment> attachments = new AttachmentService(TenantTypeIds.Instance().ContentItem()).GetsByAssociateId(contentItem.ContentItemId);
                Attachment fristImage = attachments.Where(n => n.MediaType == MediaType.Image).FirstOrDefault();
                if (fristImage != null)
                {
                    contentItem.FeaturedImageAttachmentId = fristImage.AttachmentId;
                    contentItem.FeaturedImage             = fristImage.GetRelativePath() + "\\" + fristImage.FileName;
                }
            }
            //用户投稿计数+1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(contentItem.UserId, OwnerDataKeys.Instance().ContributeCount(), 1);
            //执行事件
            EventBus <ContentItem> .Instance().OnAfter(contentItem, new CommonEventArgs(EventOperationType.Instance().Create(), ApplicationIds.Instance().CMS()));

            EventBus <ContentItem, AuditEventArgs> .Instance().OnAfter(contentItem, new AuditEventArgs(null, contentItem.AuditStatus));
        }
Exemplo n.º 16
0
        /// <summary>
        /// 关注帖吧事件处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        void SubscribeBarSectionEventModule_After(long sender, SubscribeEventArgs eventArgs)
        {
            if (eventArgs.TenantTypeId != TenantTypeIds.Instance().BarSection())
            {
                return;
            }
            ActivityService activityService = new ActivityService();

            if (EventOperationType.Instance().Create() == eventArgs.EventOperationType)
            {
                activityService.TraceBackInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection());
                //用户内容计数
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), 1);
            }
            else if (EventOperationType.Instance().Delete() == eventArgs.EventOperationType)
            {
                activityService.RemoveInboxAboutOwner(eventArgs.UserId, sender, ActivityOwnerTypes.Instance().BarSection());
                //用户内容计数
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(eventArgs.UserId, OwnerDataKeys.Instance().FollowSectionCount(), -1);
            }
        }
Exemplo n.º 17
0
        /// <summary>
        /// 创建群组
        /// </summary>
        /// <param name="userId">当前操作人</param>
        /// <param name="group"><see cref="GroupEntity"/></param>
        /// <param name="logoFile">群组标识图</param>
        /// <returns>创建成功返回true,失败返回false</returns>
        public bool Create(long userId, GroupEntity group)
        {
            //设计要点
            //1、使用AuditService设置审核状态;
            //2、需要触发的事件参见《设计说明书-日志》     
            //3、单独调用标签服务设置标签
            //4、使用 IdGenerator.Next() 生成GroupId
            EventBus<GroupEntity>.Instance().OnBefore(group, new CommonEventArgs(EventOperationType.Instance().Create()));
            //设置审核状态
            auditService.ChangeAuditStatusForCreate(userId, group);
            long id = 0;
            long.TryParse(groupRepository.Insert(group).ToString(), out id);

            if (id > 0)
            {
                EventBus<GroupEntity>.Instance().OnAfter(group, new CommonEventArgs(EventOperationType.Instance().Create()));
                EventBus<GroupEntity, AuditEventArgs>.Instance().OnAfter(group, new AuditEventArgs(null, group.AuditStatus));
                //用户的创建群组数+1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(group.UserId, OwnerDataKeys.Instance().CreatedGroupCount(), 1);
            }
            return id > 0;
        }
Exemplo n.º 18
0
        /// <summary>
        /// 删除群组
        /// </summary>
        /// <param name="groupId">群组Id</param>
        public void Delete(long groupId)
        {
            //设计要点
            //1、需要删除:群组成员、群组申请、Logo;
            GroupEntity group = groupRepository.Get(groupId);

            if (group == null)
            {
                return;
            }

            CategoryService categoryService = new CategoryService();

            categoryService.ClearCategoriesFromItem(groupId, null, TenantTypeIds.Instance().Group());


            EventBus <GroupEntity> .Instance().OnBefore(group, new CommonEventArgs(EventOperationType.Instance().Delete()));

            int affectCount = groupRepository.Delete(group);

            if (affectCount > 0)
            {
                //删除访客记录
                new VisitService(TenantTypeIds.Instance().Group()).CleanByToObjectId(groupId);
                //用户的创建群组数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(group.UserId, OwnerDataKeys.Instance().CreatedGroupCount(), -1);
                //删除Logo
                LogoService logoService = new LogoService(TenantTypeIds.Instance().Group());
                logoService.DeleteLogo(groupId);
                //删除群组下的成员
                DeleteMembersByGroupId(groupId);
                EventBus <GroupEntity> .Instance().OnAfter(group, new CommonEventArgs(EventOperationType.Instance().Delete()));

                EventBus <GroupEntity, AuditEventArgs> .Instance().OnAfter(group, new AuditEventArgs(group.AuditStatus, null));
            }
        }
Exemplo n.º 19
0
        /// <summary>
        /// 删除词条
        /// </summary>
        /// <param name="wikiPage">词条实体</param>
        public void Delete(WikiPage wikiPage)
        {
            if (wikiPage == null)
            {
                return;
            }

            //todo:zhengw:需要处理词条版本

            CategoryService categoryService = new CategoryService();

            //删除站点分类关联(投稿到)
            categoryService.ClearCategoriesFromItem(wikiPage.PageId, 0, TenantTypeIds.Instance().WikiPage());

            //删除标签关联
            TagService tagService = new TagService(TenantTypeIds.Instance().WikiPage());

            tagService.ClearTagsFromItem(wikiPage.PageId, wikiPage.OwnerId);

            //删除推荐记录
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(wikiPage.PageId, wikiPage.TenantTypeId);

            //用户创建词条数-1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(wikiPage.UserId, OwnerDataKeys.Instance().PageCount(), -1);

            EventBus <WikiPage> .Instance().OnBefore(wikiPage, new CommonEventArgs(EventOperationType.Instance().Delete()));

            wikiPageRepository.Delete(wikiPage);

            EventBus <WikiPage> .Instance().OnAfter(wikiPage, new CommonEventArgs(EventOperationType.Instance().Delete()));

            EventBus <WikiPage, AuditEventArgs> .Instance().OnAfter(wikiPage, new AuditEventArgs(wikiPage.AuditStatus, null));
        }
Exemplo n.º 20
0
        /// <summary>
        /// 删除ContentItem
        /// </summary>
        /// <param name="contentItem"></param>
        public void Delete(ContentItem contentItem)
        {
            if (contentItem != null)
            {
                //执行事件
                EventBus <ContentItem> .Instance().OnBefore(contentItem, new CommonEventArgs(EventOperationType.Instance().Delete()));

                contentItemRepository.Delete(contentItem);
                //用户投稿计数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(contentItem.UserId, OwnerDataKeys.Instance().ContributeCount(), -1);

                //删除标签关联
                TagService tagService = new TagService(TenantTypeIds.Instance().ContentItem());
                tagService.ClearTagsFromItem(contentItem.ContentItemId, contentItem.UserId);
                //删除评论
                CommentService commentService = new CommentService();
                commentService.DeleteCommentedObjectComments(contentItem.ContentItemId);
                //执行事件
                EventBus <ContentItem> .Instance().OnAfter(contentItem, new CommonEventArgs(EventOperationType.Instance().Delete(), ApplicationIds.Instance().CMS()));

                EventBus <ContentItem, AuditEventArgs> .Instance().OnAfter(contentItem, new AuditEventArgs(contentItem.AuditStatus, null));
            }
        }
Exemplo n.º 21
0
        /// <summary>
        /// 删除问题
        /// </summary>
        /// <remarks>
        /// 1.只有管理员可删除问题,已解决问题的积分不返还,未解决的问题应该解除冻结积分,通过EventModule处理;
        /// 2.注意需要删除动态,通过EventModule处理;
        /// 3.注意需要扣除发布问题时增加的积分,通过EventModule处理;
        /// 4.注意需要删除所有用户对该问题的关注,通过EventModule处理;
        /// 5.注意删除与标签的关联,其它数据的删除由各模块自动处理
        /// 6.需要触发的事件:1)Delete的OnBefore、OnAfter;2)审核状态变更
        /// </remarks>
        /// <param name="question">问题实体</param>
        public void DeleteQuestion(AskQuestion question)
        {
            EventBus <AskQuestion> .Instance().OnBefore(question, new CommonEventArgs(EventOperationType.Instance().Delete()));

            //删除与标签的关联
            TagService tagService = new TagService(TenantTypeIds.Instance().AskQuestion());

            tagService.ClearTagsFromItem(question.QuestionId, question.UserId);

            //删除问题的所有回答
            int pageSize  = 100;
            int pageIndex = 1;
            int pageCount = 1;

            do
            {
                PagingDataSet <AskAnswer> answers = this.GetAnswersByQuestionId(question.QuestionId, SortBy_AskAnswer.DateCreated_Desc, pageSize, pageIndex);
                foreach (AskAnswer answer in answers)
                {
                    this.DeleteAnswer(answer);
                }
                pageCount = answers.PageCount;
                pageIndex++;
            } while (pageIndex <= pageCount);

            //删除问题
            askQuestionRepository.Delete(question);

            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(question.UserId, OwnerDataKeys.Instance().QuestionCount(), -1);

            EventBus <AskQuestion> .Instance().OnAfter(question, new CommonEventArgs(EventOperationType.Instance().Delete()));

            EventBus <AskQuestion, AuditEventArgs> .Instance().OnAfter(question, new AuditEventArgs(question.AuditStatus, null));
        }
Exemplo n.º 22
0
        /// <summary>
        /// 设置用户是否接受定向提问
        /// </summary>
        /// <remarks>
        /// 使用拥有者数据(OwnerData)存储
        /// </remarks>
        /// <param name="userId">用户id</param>
        /// <param name="accept">接受定向提问</param>
        public void SetAcceptQuestion(long userId, bool accept)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(userId, OwnerDataKeys.Instance().AcceptQuestion(), accept.ToString());
        }
Exemplo n.º 23
0
        /// <summary>
        /// 设置用户在用户在问答中的简介
        /// </summary>
        /// <remarks>
        /// 使用用户数据(OwnerData)存储
        /// </remarks>
        /// <param name="userId">用户id</param>
        /// <param name="description">用户在问答中的简介</param>
        public void SetUserDescription(long userId, string description)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ownerDataService.Change(userId, OwnerDataKeys.Instance().UserDescription(), description);
        }
Exemplo n.º 24
0
        /// <summary>
        /// 更换群主
        /// </summary>
        /// <param name="groupId">群组Id</param>
        /// <param name="newOwnerUserId">新群主UserId</param>
        public void ChangeGroupOwner(long groupId, long newOwnerUserId)
        {
            //更换群主后,原群主转换成群组成员,如果新群主是群组成员则从成员中移除
            GroupEntity group = groupRepository.Get(groupId);
            long oldOwnerUserId = group.UserId;
            group.UserId = newOwnerUserId;
            groupRepository.ChangeGroupOwner(groupId, newOwnerUserId);

            //原群主的群组数-1,加入群组数+1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ownerDataService.Change(oldOwnerUserId, OwnerDataKeys.Instance().CreatedGroupCount(), -1);
            ownerDataService.Change(oldOwnerUserId, OwnerDataKeys.Instance().JoinedGroupCount(), 1);

            //原群主转换成群组成员
            GroupMember groupMember = GroupMember.New();
            groupMember.GroupId = groupId;
            groupMember.UserId = oldOwnerUserId;
            groupMemberRepository.Insert(groupMember);

            //新群主的群组数+1,加入群组数-1
            ownerDataService.Change(newOwnerUserId, OwnerDataKeys.Instance().CreatedGroupCount(), 1);

            //如果新群主是群组成员则从成员中移除
            if (IsMember(groupId, newOwnerUserId))
                DeleteGroupMember(groupId, newOwnerUserId);
        }
Exemplo n.º 25
0
        /// <summary>
        /// 获取用户在用户在问答中的简介
        /// </summary>
        /// <param name="userId">用户id</param>
        /// <returns>用户在问答中的简介</returns>
        public string GetUserDescription(long userId)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            return(ownerDataService.GetString(userId, OwnerDataKeys.Instance().UserDescription()));
        }
Exemplo n.º 26
0
        /// <summary>
        /// 删除微博
        /// </summary>
        /// <param name="microblogId">微博Id</param>
        public void Delete(long microblogId)
        {
            MicroblogEntity entity = Get(microblogId);
            if (entity == null)
                return;

            var sender = new CommentService().GetCommentedObjectComments(microblogId);

            EventBus<MicroblogEntity>.Instance().OnBefore(entity, new CommonEventArgs(EventOperationType.Instance().Delete()));
            int affect = microblogRepository.Delete(entity);
            if (affect > 0)
            {
                //删除微博时评论的积分处理
                if (sender != null)
                    EventBus<Comment>.Instance().OnBatchAfter(sender, new CommonEventArgs(EventOperationType.Instance().Delete()));
                //更新用户数据
                OwnerDataService ownerDataService = new OwnerDataService(entity.TenantTypeId);
                ownerDataService.Change(entity.OwnerId, OwnerDataKeys.Instance().ThreadCount(), -1);

                EventBus<MicroblogEntity>.Instance().OnAfter(entity, new CommonEventArgs(EventOperationType.Instance().Delete()));
                EventBus<MicroblogEntity, AuditEventArgs>.Instance().OnAfter(entity, new AuditEventArgs(entity.AuditStatus, null));
            }
        }
Exemplo n.º 27
0
        /// <summary>
        /// 他的资讯/我的资讯
        /// </summary>
        public ActionResult CmsUser(string spaceKey, int? contentFolderId = null, AuditStatus? auditStatus = null, int pageSize = 50, int pageIndex = 1)
        {
            IUser user = null;
            if (string.IsNullOrEmpty(spaceKey))
            {
                user = UserContext.CurrentUser;
                if (user == null)
                {
                    return Redirect(SiteUrls.Instance().Login(true));
                }
                pageResourceManager.InsertTitlePart("我的资讯");
            }
            else
            {
                user = userService.GetFullUser(spaceKey);
                if (user == null)
                {
                    return HttpNotFound();
                }

                if (!new PrivacyService().Validate(user.UserId, UserContext.CurrentUser != null ? UserContext.CurrentUser.UserId : 0, PrivacyItemKeys.Instance().VisitUserSpace()))
                {
                    if (UserContext.CurrentUser == null)
                        return Redirect(SiteUrls.Instance().Login(true));
                    else
                        return Redirect(SiteUrls.Instance().PrivacyHome(user.UserName));
                }

                if (UserContext.CurrentUser != null && user.UserId == UserContext.CurrentUser.UserId)
                {
                    pageResourceManager.InsertTitlePart("我的资讯");
                }
                else
                {
                    pageResourceManager.InsertTitlePart(user.DisplayName + "的资讯");
                }
            }
            ViewData["user"] = user;
            bool hasManagePermission = UserContext.CurrentUser != null && UserContext.CurrentUser.UserId == user.UserId;
            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
                hasManagePermission = true;
            PubliclyAuditStatus? publiclyAuditStatus = null;
            if (hasManagePermission)
            {
                if (auditStatus.HasValue)
                    switch (auditStatus.Value)
                    {
                        case AuditStatus.Again:
                            publiclyAuditStatus = PubliclyAuditStatus.Again;
                            break;
                        case AuditStatus.Fail:
                            publiclyAuditStatus = PubliclyAuditStatus.Fail;
                            break;
                        case AuditStatus.Success:
                            publiclyAuditStatus = PubliclyAuditStatus.Success;
                            break;
                        case AuditStatus.Pending:
                        default:
                            publiclyAuditStatus = PubliclyAuditStatus.Pending;
                            break;
                    }
            }
            else
                publiclyAuditStatus = new AuditService().GetPubliclyAuditStatus(CmsConfig.Instance().ApplicationId);

            PagingDataSet<ContentItem> contentItems = contentItemService.GetUserContentItems(user.UserId, contentFolderId, publiclyAuditStatus, pageSize, pageIndex);
            if (Request.IsAjaxRequest())
                return PartialView("_UserContentItems", contentItems);
            ViewData["hasManagePermission"] = hasManagePermission;
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ViewData["contributeCount"] = ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().ContributeCount());

            return View(contentItems);
        }
Exemplo n.º 28
0
        /// <summary>
        /// 创建微博
        /// </summary>
        /// <param name="microblog">待创建微博实体</param>
        /// <returns></returns>
        public long Create(MicroblogEntity microblog)
        {
            EventBus<MicroblogEntity>.Instance().OnBefore(microblog, new CommonEventArgs(EventOperationType.Instance().Create()));

            //设置审核状态
            auditService.ChangeAuditStatusForCreate(microblog.UserId, microblog);

            string videoAlias = string.Empty, audioAlias = string.Empty;

            microblog.Body = parsedMediaService.ResolveBodyForEdit(microblog.Body, out videoAlias, out audioAlias);
            microblog.HasVideo = !string.IsNullOrEmpty(videoAlias);
            microblog.HasMusic = !string.IsNullOrEmpty(audioAlias);
            microblog.VideoAlias = videoAlias;
            microblog.AudioAlias = audioAlias;

            long id = 0;
            long.TryParse(microblogRepository.Insert(microblog).ToString(), out id);

            if (id > 0)
            {
                string tenantTypeId = TenantTypeIds.Instance().Microblog();

                OwnerDataService ownerDataService = new OwnerDataService(microblog.TenantTypeId);
                ownerDataService.Change(microblog.OwnerId, OwnerDataKeys.Instance().ThreadCount(), 1);

                //将临时附件转换为正式附件
                attachmentService.ToggleTemporaryAttachments(microblog.UserId, tenantTypeId, id);

                AtUserService atUserService = new AtUserService(tenantTypeId);
                atUserService.ResolveBodyForEdit(microblog.Body, microblog.UserId, microblog.MicroblogId);

                TagService tagService = new TagService(tenantTypeId);
                tagService.ResolveBodyForEdit(microblog.Body, microblog.OwnerId, microblog.MicroblogId, tenantTypeId);

                EventBus<MicroblogEntity>.Instance().OnAfter(microblog, new CommonEventArgs(EventOperationType.Instance().Create()));
                EventBus<MicroblogEntity, AuditEventArgs>.Instance().OnAfter(microblog, new AuditEventArgs(null, microblog.AuditStatus));
            }

            return id;
        }
Exemplo n.º 29
0
        /// <summary>
        /// 删除群组
        /// </summary>
        /// <param name="groupId">群组Id</param>
        public void Delete(long groupId)
        {
            //设计要点
            //1、需要删除:群组成员、群组申请、Logo;
            GroupEntity group = groupRepository.Get(groupId);
            if (group == null)
                return;

            CategoryService categoryService = new CategoryService();
            categoryService.ClearCategoriesFromItem(groupId, null, TenantTypeIds.Instance().Group());


            EventBus<GroupEntity>.Instance().OnBefore(group, new CommonEventArgs(EventOperationType.Instance().Delete()));
            int affectCount = groupRepository.Delete(group);
            if (affectCount > 0)
            {
                //删除访客记录
                new VisitService(TenantTypeIds.Instance().Group()).CleanByToObjectId(groupId);
                //用户的创建群组数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(group.UserId, OwnerDataKeys.Instance().CreatedGroupCount(), -1);
                //删除Logo             
                LogoService logoService = new LogoService(TenantTypeIds.Instance().Group());
                logoService.DeleteLogo(groupId);
                //删除群组下的成员
                DeleteMembersByGroupId(groupId);
                EventBus<GroupEntity>.Instance().OnAfter(group, new CommonEventArgs(EventOperationType.Instance().Delete()));
                EventBus<GroupEntity, AuditEventArgs>.Instance().OnAfter(group, new AuditEventArgs(group.AuditStatus, null));
            }
        }
 /// <summary>
 /// 加入的专题数
 /// </summary>
 public static long JoinedTopicCount(this User user)
 {
     OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
     return ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().JoinedTopicCount());
 }
        /// <summary>
        /// 更换群主
        /// </summary>
        /// <param name="groupId">专题Id</param>
        /// <param name="newOwnerUserId">新群主UserId</param>
        public void ChangeTopicOwner(long groupId, long newOwnerUserId)
        {
            //更换群主后,原群主转换成专题成员,如果新群主是专题成员则从成员中移除
            TopicEntity group = topicRepository.Get(groupId);
            long oldOwnerUserId = group.UserId;
            group.UserId = newOwnerUserId;
            topicRepository.ChangeTopicOwner(groupId, newOwnerUserId);

            //原群主的专题数-1,加入专题数+1
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ownerDataService.Change(oldOwnerUserId, OwnerDataKeys.Instance().CreatedTopicCount(), -1);
            ownerDataService.Change(oldOwnerUserId, OwnerDataKeys.Instance().JoinedTopicCount(), 1);

            //原群主转换成专题成员
            TopicMember TopicMember = TopicMember.New();
            TopicMember.TopicId = groupId;
            TopicMember.UserId = oldOwnerUserId;
            TopicMemberRepository.Insert(TopicMember);

            //新群主的专题数+1,加入专题数-1
            ownerDataService.Change(newOwnerUserId, OwnerDataKeys.Instance().CreatedTopicCount(), 1);

            //如果新群主是专题成员则从成员中移除
            if (IsMember(groupId, newOwnerUserId))
                DeleteTopicMember(groupId, newOwnerUserId);
        }
        /// <summary>
        /// 增加专题成员
        /// </summary>
        /// <param name="TopicMember"></param>
        public void CreateTopicMember(TopicMember TopicMember)
        {
            //设计要点:
            //1、同一个专题不允许用户重复加入
            //2、群主不允许成为专题成员
            if (IsMember(TopicMember.TopicId, TopicMember.UserId))
                return;
            if (IsOwner(TopicMember.TopicId, TopicMember.UserId))
                return;
            long id = 0;
            long.TryParse(TopicMemberRepository.Insert(TopicMember).ToString(), out id);

            if (id > 0)
            {
                EventBus<TopicMember>.Instance().OnAfter(TopicMember, new CommonEventArgs(EventOperationType.Instance().Create()));
                //用户的参与专题数+1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(TopicMember.UserId, OwnerDataKeys.Instance().JoinedTopicCount(), 1);
            }
        }
Exemplo n.º 33
0
        private void DeleteUserEventMoudle_After(IUser sender, DeleteUserEventArgs eventArgs)
        {
            IUserService userService = DIContainer.Resolve<IUserService>();

            #region 数据
            //清除应用数据
            applicationService.DeleteUser(sender.UserId, eventArgs.TakeOverUserName, eventArgs.TakeOverAll);

            //删除用户信息
            new UserProfileService().Delete(sender.UserId);

            //清除用户内容计数数据
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ownerDataService.ClearOwnerData(sender.UserId);

            //清除用户关于分类的数据
            CategoryService categoryService = new CategoryService();
            categoryService.CleanByUser(sender.UserId);

            //清除用户动态
            ActivityService activityService = new ActivityService();
            activityService.CleanByUser(sender.UserId);

            //清除用户评论
            new CommentService().DeleteUserComments(sender.UserId, false);

            #endregion

            #region 消息

            //清除用户关于私信的数据
            MessageService messageService = new MessageService();
            messageService.ClearSessionsFromUser(sender.UserId);

            //清除请求的用户数据
            InvitationService invitationService = new InvitationService();
            invitationService.CleanByUser(sender.UserId);

            //清除通知的用户数据
            NoticeService noticeService = new NoticeService();
            noticeService.CleanByUser(sender.UserId);

            InviteFriendService inviteFriendService = new InviteFriendService();
            inviteFriendService.CleanByUser(sender.UserId);

            //清除站外提醒的用户数据
            ReminderService reminderService = new ReminderService();
            reminderService.CleanByUser(sender.UserId);

            #endregion

            #region 关注/访客

            //清除用户关于关注用户的数据
            FollowService followService = new FollowService();
            followService.CleanByUser(sender.UserId);

            //清除访客记录的用户数据
            VisitService visitService = new VisitService(string.Empty);
            visitService.CleanByUser(sender.UserId);

            #endregion

            #region 帐号

            //清除帐号绑定数据
            var accountBindingService = new AccountBindingService();
            var accountBindings = new AccountBindingService().GetAccountBindings(sender.UserId);
            foreach (var accountBinding in accountBindings)
            {
                accountBindingService.DeleteAccountBinding(accountBinding.UserId, accountBinding.AccountTypeKey);
            }

            #endregion

            #region 装扮

            //调整皮肤文件使用次数
            var user = userService.GetFullUser(sender.UserId);
            if (user == null)
                return;
            var presentArea = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.UserSpace);
            string defaultThemeAppearance = string.Join(",", presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey);
            if (!user.IsUseCustomStyle)
                new ThemeService().ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.UserSpace, null, !string.IsNullOrEmpty(user.ThemeAppearance) ? user.ThemeAppearance : defaultThemeAppearance);

            #endregion
        }
Exemplo n.º 34
0
        /// <summary>
        /// 创建的群组数
        /// </summary>
        public static long CreatedGroupCount(this User user)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            return(ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().CreatedGroupCount()));
        }
Exemplo n.º 35
0
        /// <summary>
        /// 撰写日志/转载日志
        /// </summary>
        /// <param name="blogThread">日志实体</param>
        public bool Create(BlogThread blogThread, string privacyStatus1 = null, string privacyStatus2 = null)
        {
            //设计要点
            //1、使用AuditService设置审核状态;
            //2、注意调用AttachmentService转换临时附件;
            //3、需要触发的事件参见《设计说明书-日志》
            //4、草稿的审核状态为待审核;
            //5、转载的日志还需要为原日志转载数+1(调用计数服务);

            EventBus <BlogThread> .Instance().OnBefore(blogThread, new CommonEventArgs(EventOperationType.Instance().Create()));

            //设置审核状态,草稿的审核状态为待审核
            if (blogThread.IsDraft)
            {
                blogThread.AuditStatus = AuditStatus.Pending;
            }
            else
            {
                AuditService auditService = new AuditService();
                auditService.ChangeAuditStatusForCreate(blogThread.UserId, blogThread);
            }

            long threadId = 0;

            long.TryParse(blogThreadRepository.Insert(blogThread).ToString(), out threadId);

            if (threadId > 0)
            {
                //转换临时附件
                AttachmentService attachmentService = new AttachmentService(TenantTypeIds.Instance().BlogThread());
                attachmentService.ToggleTemporaryAttachments(blogThread.OwnerId, TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId);

                //原日志转载数+1
                if (blogThread.IsReproduced)
                {
                    CountService countService = new CountService(TenantTypeIds.Instance().BlogThread());
                    countService.ChangeCount(CountTypes.Instance().ReproduceCount(), blogThread.OriginalThreadId, blogThread.OwnerId, 1, true);
                }

                //用户内容计数+1
                if (!blogThread.IsDraft)
                {
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(blogThread.UserId, OwnerDataKeys.Instance().ThreadCount(), 1);
                }

                AtUserService atUserService = new AtUserService(TenantTypeIds.Instance().BlogThread());
                atUserService.ResolveBodyForEdit(blogThread.GetBody(), blogThread.UserId, blogThread.ThreadId);

                //设置隐私状态
                UpdatePrivacySettings(blogThread, privacyStatus1, privacyStatus2);

                EventBus <BlogThread> .Instance().OnAfter(blogThread, new CommonEventArgs(EventOperationType.Instance().Create()));

                EventBus <BlogThread, AuditEventArgs> .Instance().OnAfter(blogThread, new AuditEventArgs(null, blogThread.AuditStatus));

                return(true);
            }

            return(false);
        }
Exemplo n.º 36
0
        /// <summary>
        /// 加入的专题数
        /// </summary>
        public static long JoinedTopicCount(this User user)
        {
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            return(ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().JoinedTopicCount()));
        }
        /// <summary>
        /// 用户数据
        /// </summary>
        /// <param name="userId">用户Id</param>
        /// <param name="displayTemplate">用户数据内容块显示模板</param>
        /// <returns></returns>
        public ActionResult _UserData(long userId, DisplayTemplate_UserData displayTemplate = DisplayTemplate_UserData.Side)
        {
            User user = userService.GetFullUser(userId);
            if (user == null)
                return HttpNotFound();
            if (displayTemplate == DisplayTemplate_UserData.Side)
            {
                IEnumerable<long> sectionIds = subscribeService.GetAllObjectIds(userId);
                IEnumerable<BarSection> barSections = barSectionService.GetBarsections(sectionIds);
                ViewData["barSections"] = barSections;
            }
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ViewData["userThreadCount"] = ownerDataService.GetLong(userId, OwnerDataKeys.Instance().ThreadCount());
            ViewData["userPostCount"] = ownerDataService.GetLong(userId, OwnerDataKeys.Instance().PostCount());
            ViewData["userFollowSectionCount"] = ownerDataService.GetLong(userId, OwnerDataKeys.Instance().FollowSectionCount());

            #region 身份认证
            List<Identification> identifications = identificationService.GetUserIdentifications(user.UserId);
            if (identifications.Count() > 0)
            {
                ViewData["identificationTypeVisiable"] = true;
            }
            #endregion

            return PartialView("_UserData_" + displayTemplate.ToString(), user);
        }
Exemplo n.º 38
0
 /// <summary>
 /// 删除群组下的成员
 /// </summary>
 /// <param name="groupId"></param>
 public void DeleteMembersByGroupId(long groupId)
 {
     IEnumerable<GroupMember> groupMembers = groupMemberRepository.GetAllMembersOfGroup(groupId);
     foreach (var groupMember in groupMembers)
     {
         int affectCount = groupMemberRepository.Delete(groupMember);
         if (affectCount > 0)
         {
             EventBus<GroupMember>.Instance().OnAfter(groupMember, new CommonEventArgs(EventOperationType.Instance().Delete()));
             //用户的参与群组数-1
             OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
             ownerDataService.Change(groupMember.UserId, OwnerDataKeys.Instance().JoinedGroupCount(), -1);
         }
     }
 }
Exemplo n.º 39
0
        public ActionResult _App_Panel(string spaceKey, AvatarSizeType? avatarSizeType)
        {
            User user = userService.GetFullUser(spaceKey);
            if (user == null)
                return new EmptyResult();

            int currentNavigationId = RouteData.Values.Get<int>("CurrentNavigationId", 0);

            NavigationService navigationService = DIContainer.Resolve<NavigationService>();
            Navigation navigation = navigationService.GetNavigation(PresentAreaKeysOfBuiltIn.UserSpace, currentNavigationId, user.UserId);

            IEnumerable<Navigation> navigations = new List<Navigation>();

            if (navigation != null)
            {
                if (navigation.Depth == 0)
                {
                    navigations = navigation.Children;
                    ViewData["ParentNavigation"] = navigation;
                }
                else if (navigation.Parent != null)
                {
                    navigations = navigation.Parent.Children;
                    ViewData["ParentNavigation"] = navigation.Parent;
                }

                ApplicationModel app = applicationService.Get(navigation.ApplicationId);
                if (app != null)
                {
                    ViewData["Application"] = app;
                    ViewData["AppCount"] = new OwnerDataService(TenantTypeIds.Instance().User()).GetLong(user.UserId, app.ApplicationKey + "-ThreadCount");
                }
                IEnumerable<ApplicationManagementOperation> applicationManagementOperations = new ManagementOperationService().GetShortcuts(PresentAreaKeysOfBuiltIn.UserSpace, false);

                ViewData["ApplicationManagementOperations"] = applicationManagementOperations.Where(n => n.ApplicationId == navigation.ApplicationId && n.PresentAreaKey == PresentAreaKeysOfBuiltIn.UserSpace);
            }

            ViewData["User"] = user;
            ViewData["AvatarSizeType"] = avatarSizeType;

            return View(navigations);
        }
Exemplo n.º 40
0
        private void DeleteUserEventMoudle_After(IUser sender, DeleteUserEventArgs eventArgs)
        {
            IUserService userService = DIContainer.Resolve <IUserService>();

            IUser takeOverUser = userService.GetUser(eventArgs.TakeOverUserName);

            if (takeOverUser != null)
            {
                //将sender的内容转交给takeOverUser,同时还可根据eventArgs.TakeOverAll判断是否接管被删除用户的全部内容
            }



            #region 数据
            //清除应用数据
            ApplicationService applicationService = new ApplicationService();
            applicationService.DeleteUser(sender.UserId, eventArgs.TakeOverUserName, eventArgs.TakeOverAll);

            //删除用户信息
            new UserProfileService().Delete(sender.UserId);

            //清除用户内容计数数据
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
            ownerDataService.ClearOwnerData(sender.UserId);



            //清除用户关于分类的数据
            CategoryService categoryService = new CategoryService();
            categoryService.CleanByUser(sender.UserId);

            //清除用户动态
            ActivityService activityService = new ActivityService();
            activityService.CleanByUser(sender.UserId);

            //清除用户评论
            new CommentService().DeleteUserComments(sender.UserId, false);

            #endregion

            #region 消息


            //清除用户关于私信的数据
            MessageService messageService = new MessageService();
            messageService.ClearSessionsFromUser(sender.UserId);

            //清除请求的用户数据
            InvitationService invitationService = new InvitationService();
            invitationService.CleanByUser(sender.UserId);

            //清除通知的用户数据
            NoticeService noticeService = new NoticeService();
            noticeService.CleanByUser(sender.UserId);

            InviteFriendService inviteFriendService = new InviteFriendService();
            inviteFriendService.CleanByUser(sender.UserId);

            //清除站外提醒的用户数据
            ReminderService reminderService = new ReminderService();
            reminderService.CleanByUser(sender.UserId);

            #endregion

            #region 关注/访客


            //清除用户关于关注用户的数据
            FollowService followService = new FollowService();
            followService.CleanByUser(sender.UserId);


            //清除访客记录的用户数据
            VisitService visitService = new VisitService(string.Empty);
            visitService.CleanByUser(sender.UserId);

            #endregion

            #region 帐号

            //清除帐号绑定数据
            var accountBindingService = new AccountBindingService();
            var accountBindings       = new AccountBindingService().GetAccountBindings(sender.UserId);
            foreach (var accountBinding in accountBindings)
            {
                accountBindingService.DeleteAccountBinding(accountBinding.UserId, accountBinding.AccountTypeKey);
            }

            #endregion

            #region 装扮

            //调整皮肤文件使用次数
            var user = userService.GetFullUser(sender.UserId);
            if (user == null)
            {
                return;
            }
            var    presentArea            = new PresentAreaService().Get(PresentAreaKeysOfBuiltIn.UserSpace);
            string defaultThemeAppearance = string.Join(",", presentArea.DefaultThemeKey, presentArea.DefaultAppearanceKey);
            if (!user.IsUseCustomStyle)
            {
                new ThemeService().ChangeThemeAppearanceUserCount(PresentAreaKeysOfBuiltIn.UserSpace, null, !string.IsNullOrEmpty(user.ThemeAppearance) ? user.ThemeAppearance : defaultThemeAppearance);
            }

            #endregion
        }
Exemplo n.º 41
0
 /// <summary>
 /// 创建的群组数
 /// </summary>
 public static long CreatedGroupCount(this User user)
 {
     OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
     return ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().CreatedGroupCount());
 }
Exemplo n.º 42
0
        /// <summary>
        /// 删除主题帖
        /// </summary>
        /// <param name="threadId">主题帖Id</param>
        public void Delete(long threadId)
        {
            BarThread thread = barThreadRepository.Get(threadId);

            if (thread == null)
            {
                return;
            }

            EventBus <BarThread> .Instance().OnBefore(thread, new CommonEventArgs(EventOperationType.Instance().Delete()));

            BarSectionService barSectionService = new BarSectionService();
            BarSection        barSection        = barSectionService.Get(thread.SectionId);

            if (barSection != null)
            {
                //帖子标签
                TagService tagService = new TagService(TenantTypeIds.Instance().BarThread());
                tagService.ClearTagsFromItem(threadId, barSection.SectionId);

                //帖子分类
                CategoryService categoryService = new CategoryService();
                categoryService.ClearCategoriesFromItem(threadId, barSection.SectionId, TenantTypeIds.Instance().BarThread());
            }

            //删除回帖
            BarPostService barPostService = new BarPostService();

            barPostService.DeletesByThreadId(threadId);

            //删除推荐记录
            RecommendService recommendService = new RecommendService();

            recommendService.Delete(threadId, TenantTypeIds.Instance().BarThread());

            int affectCount = barThreadRepository.Delete(thread);

            if (affectCount > 0)
            {
                //更新帖吧的计数
                CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                countService.ChangeCount(CountTypes.Instance().ThreadCount(), barSection.SectionId, barSection.UserId, -1, true);
                countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, -1, true);

                if (thread.TenantTypeId == TenantTypeIds.Instance().Group())
                {
                    //群组内容计数-1
                    OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group());
                    groupOwnerDataService.Change(thread.SectionId, OwnerDataKeys.Instance().ThreadCount(), -1);
                }
                else if (thread.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //用户内容计数-1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(thread.UserId, OwnerDataKeys.Instance().ThreadCount(), -1);
                }
                EventBus <BarThread> .Instance().OnAfter(thread, new CommonEventArgs(EventOperationType.Instance().Delete()));

                EventBus <BarThread, AuditEventArgs> .Instance().OnAfter(thread, new AuditEventArgs(thread.AuditStatus, null));
            }


            //BarThread删除可能影响的:
            //1、附件 (看到了)
            //2、BarPost(看到了)
            //3、BarRating(看到了)
            //4、相关计数对象(看到了)
            //5、用户在应用中的数据(看到了)
            //6、@用户(看到了)
        }
Exemplo n.º 43
0
        /// <summary>
        /// 创建主题帖
        /// </summary>
        /// <param name="thread">主题帖</param>
        public bool Create(BarThread thread)
        {
            BarSectionService barSectionService = new BarSectionService();
            EventBus<BarThread>.Instance().OnBefore(thread, new CommonEventArgs(EventOperationType.Instance().Create()));
            //设置审核状态
            auditService.ChangeAuditStatusForCreate(thread.UserId, thread);
            long id = 0;
            long.TryParse(barThreadRepository.Insert(thread).ToString(), out id);

            if (id > 0)
            {
                new AttachmentService(TenantTypeIds.Instance().BarThread()).ToggleTemporaryAttachments(thread.UserId, TenantTypeIds.Instance().BarThread(), id);
                BarSection barSection = barSectionService.Get(thread.SectionId);
                if (barSection != null)
                {
                    //计数
                    CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                    countService.ChangeCount(CountTypes.Instance().ThreadCount(), barSection.SectionId, barSection.UserId, 1, true);
                    countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, 1, true);
                    if (thread.TenantTypeId == TenantTypeIds.Instance().Group())
                    {
                        //群组内容计数+1
                        OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group());
                        groupOwnerDataService.Change(thread.SectionId, OwnerDataKeys.Instance().ThreadCount(), 1);
                    }
                }
                if (thread.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //用户内容计数+1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(thread.UserId, OwnerDataKeys.Instance().ThreadCount(), 1);
                }
                AtUserService atUserService = new AtUserService(TenantTypeIds.Instance().BarThread());
                atUserService.ResolveBodyForEdit(thread.GetBody(), thread.UserId, thread.ThreadId);

                EventBus<BarThread>.Instance().OnAfter(thread, new CommonEventArgs(EventOperationType.Instance().Create()));
                EventBus<BarThread, AuditEventArgs>.Instance().OnAfter(thread, new AuditEventArgs(null, thread.AuditStatus));
            }
            return id > 0;
        }
Exemplo n.º 44
0
        /// <summary>
        /// 增加群组成员
        /// </summary>
        /// <param name="groupMember"></param>
        public void CreateGroupMember(GroupMember groupMember)
        {
            //设计要点:
            //1、同一个群组不允许用户重复加入
            //2、群主不允许成为群组成员
            if (IsMember(groupMember.GroupId, groupMember.UserId))
                return;
            if (IsOwner(groupMember.GroupId, groupMember.UserId))
                return;
            long id = 0;
            long.TryParse(groupMemberRepository.Insert(groupMember).ToString(), out id);

            if (id > 0)
            {
                EventBus<GroupMember>.Instance().OnAfter(groupMember, new CommonEventArgs(EventOperationType.Instance().Create()));
                //用户的参与群组数+1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(groupMember.UserId, OwnerDataKeys.Instance().JoinedGroupCount(), 1);
            }
        }
Exemplo n.º 45
0
        /// <summary>
        /// 删除主题帖
        /// </summary>
        /// <param name="threadId">主题帖Id</param>
        public void Delete(long threadId)
        {
            BarThread thread = barThreadRepository.Get(threadId);
            if (thread == null)
                return;

            EventBus<BarThread>.Instance().OnBefore(thread, new CommonEventArgs(EventOperationType.Instance().Delete()));

            BarSectionService barSectionService = new BarSectionService();
            BarSection barSection = barSectionService.Get(thread.SectionId);
            if (barSection != null)
            {
                //帖子标签
                TagService tagService = new TagService(TenantTypeIds.Instance().BarThread());
                tagService.ClearTagsFromItem(threadId, barSection.SectionId);

                //帖子分类
                CategoryService categoryService = new CategoryService();
                categoryService.ClearCategoriesFromItem(threadId, barSection.SectionId, TenantTypeIds.Instance().BarThread());
            }

            //删除回帖
            BarPostService barPostService = new BarPostService();
            barPostService.DeletesByThreadId(threadId);

            //删除推荐记录
            RecommendService recommendService = new RecommendService();
            recommendService.Delete(threadId, TenantTypeIds.Instance().BarThread());

            int affectCount = barThreadRepository.Delete(thread);

            if (affectCount > 0)
            {
                //更新帖吧的计数
                CountService countService = new CountService(TenantTypeIds.Instance().BarSection());
                countService.ChangeCount(CountTypes.Instance().ThreadCount(), barSection.SectionId, barSection.UserId, -1, true);
                countService.ChangeCount(CountTypes.Instance().ThreadAndPostCount(), barSection.SectionId, barSection.UserId, -1, true);

                if (thread.TenantTypeId == TenantTypeIds.Instance().Group())
                {
                    //群组内容计数-1
                    OwnerDataService groupOwnerDataService = new OwnerDataService(TenantTypeIds.Instance().Group());
                    groupOwnerDataService.Change(thread.SectionId, OwnerDataKeys.Instance().ThreadCount(), -1);
                }
                else if (thread.TenantTypeId == TenantTypeIds.Instance().Bar())
                {
                    //用户内容计数-1
                    OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                    ownerDataService.Change(thread.UserId, OwnerDataKeys.Instance().ThreadCount(), -1);
                }
                EventBus<BarThread>.Instance().OnAfter(thread, new CommonEventArgs(EventOperationType.Instance().Delete()));
                EventBus<BarThread, AuditEventArgs>.Instance().OnAfter(thread, new AuditEventArgs(thread.AuditStatus, null));
            }

            //BarThread删除可能影响的:
            //1、附件 (看到了)
            //2、BarPost(看到了)
            //3、BarRating(看到了)
            //4、相关计数对象(看到了)
            //5、用户在应用中的数据(看到了)
            //6、@用户(看到了)
        }
Exemplo n.º 46
0
        /// <summary>
        /// 他的资讯/我的资讯
        /// </summary>
        public ActionResult CmsUser(string spaceKey, int?contentFolderId = null, AuditStatus?auditStatus = null, int pageSize = 50, int pageIndex = 1)
        {
            IUser user = null;

            if (string.IsNullOrEmpty(spaceKey))
            {
                user = UserContext.CurrentUser;
                if (user == null)
                {
                    return(Redirect(SiteUrls.Instance().Login(true)));
                }
                pageResourceManager.InsertTitlePart("我的资讯");
            }
            else
            {
                user = userService.GetFullUser(spaceKey);
                if (user == null)
                {
                    return(HttpNotFound());
                }

                if (!new PrivacyService().Validate(user.UserId, UserContext.CurrentUser != null ? UserContext.CurrentUser.UserId : 0, PrivacyItemKeys.Instance().VisitUserSpace()))
                {
                    if (UserContext.CurrentUser == null)
                    {
                        return(Redirect(SiteUrls.Instance().Login(true)));
                    }
                    else
                    {
                        return(Redirect(SiteUrls.Instance().PrivacyHome(user.UserName)));
                    }
                }

                if (UserContext.CurrentUser != null && user.UserId == UserContext.CurrentUser.UserId)
                {
                    pageResourceManager.InsertTitlePart("我的资讯");
                }
                else
                {
                    pageResourceManager.InsertTitlePart(user.DisplayName + "的资讯");
                }
            }
            ViewData["user"] = user;
            bool hasManagePermission = UserContext.CurrentUser != null && UserContext.CurrentUser.UserId == user.UserId;

            if (authorizer.IsAdministrator(CmsConfig.Instance().ApplicationId))
            {
                hasManagePermission = true;
            }
            PubliclyAuditStatus?publiclyAuditStatus = null;

            if (hasManagePermission)
            {
                if (auditStatus.HasValue)
                {
                    switch (auditStatus.Value)
                    {
                    case AuditStatus.Again:
                        publiclyAuditStatus = PubliclyAuditStatus.Again;
                        break;

                    case AuditStatus.Fail:
                        publiclyAuditStatus = PubliclyAuditStatus.Fail;
                        break;

                    case AuditStatus.Success:
                        publiclyAuditStatus = PubliclyAuditStatus.Success;
                        break;

                    case AuditStatus.Pending:
                    default:
                        publiclyAuditStatus = PubliclyAuditStatus.Pending;
                        break;
                    }
                }
            }
            else
            {
                publiclyAuditStatus = new AuditService().GetPubliclyAuditStatus(CmsConfig.Instance().ApplicationId);
            }

            PagingDataSet <ContentItem> contentItems = contentItemService.GetUserContentItems(user.UserId, contentFolderId, publiclyAuditStatus, pageSize, pageIndex);

            if (Request.IsAjaxRequest())
            {
                return(PartialView("_UserContentItems", contentItems));
            }
            ViewData["hasManagePermission"] = hasManagePermission;
            OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());

            ViewData["contributeCount"] = ownerDataService.GetLong(user.UserId, OwnerDataKeys.Instance().ContributeCount());

            return(View(contentItems));
        }
Exemplo n.º 47
0
        /// <summary>
        /// 移除群组成员
        /// </summary>
        /// <param name="groupId">群组Id</param>
        /// <param name="userId">用户Id</param>
        public void DeleteGroupMember(long groupId, long userId)
        {



            GroupMember groupMember = groupMemberRepository.GetMember(groupId, userId);
            if (groupMember == null)
                return;

            int affectCount = groupMemberRepository.Delete(groupMember);
            if (affectCount > 0)
            {
                EventBus<GroupMember>.Instance().OnAfter(groupMember, new CommonEventArgs(EventOperationType.Instance().Delete()));
                //用户的参与群组数-1
                OwnerDataService ownerDataService = new OwnerDataService(TenantTypeIds.Instance().User());
                ownerDataService.Change(userId, OwnerDataKeys.Instance().JoinedGroupCount(), -1);
            }
        }