Exemplo n.º 1
0
        /// <summary>
        /// 处理加精操作加积分
        /// </summary>
        /// <param name="blogThread">日志</param>
        /// <param name="eventArgs">事件</param>
        private void BlogThreadPointModuleForManagerOperation_After(BlogThread blogThread, CommonEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            string        pointItemKey  = string.Empty;

            if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential())
            {
                pointItemKey = PointItemKeys.Instance().EssentialContent();

                PointService pointService = new PointService();
                string       description  = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "日志", blogThread.ResolvedSubject);
                pointService.GenerateByRole(blogThread.UserId, pointItemKey, description);
                if (blogThread.UserId > 0)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = blogThread.UserId;
                    notice.ApplicationId      = BlogConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = blogThread.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.FullUrl(SiteUrls.Instance().SpaceHome(blogThread.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(blogThread.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().BlogDetail(blogThread.User.UserName, blogThread.ThreadId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().ManagerSetEssential();
                    noticeService.Create(notice);
                }
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="blogThread"></param>
        /// <param name="eventArgs"></param>
        private void BlogThreadActivityModule_After(BlogThread blogThread, AuditEventArgs eventArgs)
        {
            //生成动态
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();

            bool?auditDirection = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true)
            {
                //初始化Owner为用户的动态
                Activity activityOfUser = Activity.New();
                activityOfUser.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogThread();
                activityOfUser.ApplicationId   = BlogConfig.Instance().ApplicationId;

                //判断是否有图片、音频、视频
                AttachmentService        attachmentService = new AttachmentService(TenantTypeIds.Instance().BlogThread());
                IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(blogThread.ThreadId);
                if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image))
                {
                    activityOfUser.HasImage = true;
                }

                activityOfUser.HasMusic              = false;
                activityOfUser.HasVideo              = false;
                activityOfUser.IsOriginalThread      = !blogThread.IsReproduced;
                activityOfUser.IsPrivate             = blogThread.PrivacyStatus == PrivacyStatus.Private ? true : false;
                activityOfUser.UserId                = blogThread.UserId;
                activityOfUser.ReferenceId           = 0;
                activityOfUser.ReferenceTenantTypeId = string.Empty;
                activityOfUser.SourceId              = blogThread.ThreadId;
                activityOfUser.TenantTypeId          = TenantTypeIds.Instance().BlogThread();
                activityOfUser.OwnerId               = blogThread.UserId;
                activityOfUser.OwnerName             = blogThread.Author;
                activityOfUser.OwnerType             = ActivityOwnerTypes.Instance().User();

                //是否是公开的(用于是否推送站点动态)
                bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false;

                //生成动态
                activityService.Generate(activityOfUser, true, isPublic);
            }
            //删除动态
            else if (auditDirection == false)
            {
                activityService.DeleteSource(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId);
            }
        }
        /// <summary>
        /// 文章操作文章事件处理
        /// </summary>
        private void BlogOperationLogEventModule_After(BlogThread senders, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Delete() ||
                eventArgs.EventOperationType == EventOperationType.Instance().Approved() ||
                eventArgs.EventOperationType == EventOperationType.Instance().Disapproved() ||
                eventArgs.EventOperationType == EventOperationType.Instance().SetEssential() ||
                eventArgs.EventOperationType == EventOperationType.Instance().CancelEssential())
            {
                OperationLogEntry entry = new OperationLogEntry(eventArgs.OperatorInfo);
                entry.ApplicationId       = entry.ApplicationId;
                entry.Source              = BlogConfig.Instance().ApplicationName;
                entry.OperationType       = eventArgs.EventOperationType;
                entry.OperationObjectName = senders.Subject;
                entry.OperationObjectId   = senders.ThreadId;
                entry.Description         = string.Format(ResourceAccessor.GetString("OperationLog_Pattern_" + eventArgs.EventOperationType, entry.ApplicationId), "文章", entry.OperationObjectName);

                OperationLogService logService = Tunynet.DIContainer.Resolve <OperationLogService>();
                logService.Create(entry);
            }
        }
Exemplo n.º 4
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.º 5
0
        /// <summary>
        /// 评论日志动态处理程序
        /// </summary>
        /// <param name="comment"></param>
        /// <param name="eventArgs"></param>
        private void BlogCommentActivityEventModule_After(Comment comment, AuditEventArgs eventArgs)
        {
            NoticeService noticeService = new NoticeService();
            BlogThread    blogThread    = null;

            if (comment.TenantTypeId == TenantTypeIds.Instance().BlogThread())
            {
                //生成动态
                ActivityService activityService = new ActivityService();
                AuditService    auditService    = new AuditService();
                bool?           auditDirection  = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);
                if (auditDirection == true)
                {
                    //创建评论的动态[关注评论者的粉丝可以看到该评论]
                    Activity activity = Activity.New();
                    activity.ActivityItemKey = ActivityItemKeys.Instance().CreateBlogComment();
                    activity.ApplicationId   = BlogConfig.Instance().ApplicationId;

                    BlogService blogService = new BlogService();
                    blogThread = blogService.Get(comment.CommentedObjectId);
                    if (blogThread == null || blogThread.UserId == comment.UserId)
                    {
                        return;
                    }
                    activity.IsOriginalThread      = true;
                    activity.IsPrivate             = false;
                    activity.OwnerId               = comment.UserId;
                    activity.OwnerName             = comment.Author;
                    activity.OwnerType             = ActivityOwnerTypes.Instance().User();
                    activity.ReferenceId           = blogThread.ThreadId;
                    activity.ReferenceTenantTypeId = TenantTypeIds.Instance().BlogThread();
                    activity.SourceId              = comment.Id;
                    activity.TenantTypeId          = TenantTypeIds.Instance().Comment();
                    activity.UserId = comment.UserId;

                    //是否是公开的(用于是否推送站点动态)
                    bool isPublic = blogThread.PrivacyStatus == PrivacyStatus.Public ? true : false;
                    activityService.Generate(activity, false, isPublic);

                    //创建评论的动态[关注该日志的用户可以看到该评论]
                    Activity activityOfBlogComment = Activity.New();
                    activityOfBlogComment.ActivityItemKey       = activity.ActivityItemKey;
                    activityOfBlogComment.ApplicationId         = activity.ApplicationId;
                    activityOfBlogComment.IsOriginalThread      = activity.IsOriginalThread;
                    activityOfBlogComment.IsPrivate             = activity.IsPrivate;
                    activityOfBlogComment.ReferenceId           = activity.ReferenceId;
                    activityOfBlogComment.ReferenceTenantTypeId = activity.ReferenceTenantTypeId;
                    activityOfBlogComment.SourceId     = activity.SourceId;
                    activityOfBlogComment.TenantTypeId = activity.TenantTypeId;
                    activityOfBlogComment.UserId       = activity.UserId;

                    activityOfBlogComment.OwnerId   = blogThread.ThreadId;
                    activityOfBlogComment.OwnerName = blogThread.ResolvedSubject;
                    activityOfBlogComment.OwnerType = ActivityOwnerTypes.Instance().Blog();

                    activityService.Generate(activityOfBlogComment, false, isPublic);
                }
                else if (auditDirection == false)
                {
                    activityService.DeleteSource(TenantTypeIds.Instance().Comment(), comment.Id);
                }
            }
        }