Пример #1
0
        /// <summary>
        /// 内容处理
        /// </summary>
        /// <param name="body">待处理内容</param>
        /// <param name="associateId">待处理相关项Id</param>
        /// <param name="userId">相关项作者</param>
        /// <param name="tenantTypeId">租户类型Id</param>
        /// <returns></returns>
        public string Process(string body, string tenantTypeId, long associateId, long userId)
        {
            tenantTypeId = TenantTypeIds.Instance().Comment();

            AtUserService atUserService = new AtUserService(tenantTypeId);
            atUserService.ResolveBodyForEdit(body, userId, associateId);
            body = atUserService.ResolveBodyForDetail(body, associateId, userId, AtUserTagGenerate);

            EmotionService emotionService = DIContainer.Resolve<EmotionService>();
            body = emotionService.EmoticonTransforms(body);

            return body;
        }
Пример #2
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;
        }
Пример #3
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;
        }