/// <summary>
 /// 详细页面地址
 /// </summary>
 /// <param name="itemId">推荐内容Id</param>
 /// <returns></returns>
 public string RecommendItemDetail(long itemId)
 {
     Comment comment = new CommentService().Get(itemId);
     if (comment == null)
         return string.Empty;
     return SiteUrls.Instance().Comments(comment.CommentedObjectId, comment.Id);
 }
        public AssociatedInfo GetAssociatedInfo(long associateId, string tenantTypeId = "")
        {
            Comment comment = new CommentService().Get(associateId);
            if (comment != null && comment.User() != null)
            {
                ICommentUrlGetter commentUrlGetter = CommentUrlGetterFactory.Get(comment.TenantTypeId);
                CommentedObject commentObject = commentUrlGetter.GetCommentedObject(comment.CommentedObjectId);
                return new AssociatedInfo()
                {
                    DetailUrl = commentUrlGetter.GetCommentDetailUrl(comment.CommentedObjectId, comment.Id,commentObject.UserId),
                    Subject = Tunynet.Utilities.HtmlUtility.TrimHtml(comment.Body, 12)
                };
            }

            return null;
        }
Пример #3
0
        public ActionResult Comment(MicroblogCommentEditModel model)
        {
            string message = string.Empty;
            if (ModelState.HasBannedWord(out message))
            {
                return Json(new StatusMessageData(StatusMessageType.Error, message));
            }

            IUser currentUser = UserContext.CurrentUser;
            long userId = microblogService.Get(model.CommentedObjectId).UserId;
            //被评论用户的隐私判断

            if (!privacyService.Validate(userId, currentUser != null ? currentUser.UserId : 0, PrivacyItemKeys.Instance().Comment()))
            {
                return Json(new StatusMessageData(StatusMessageType.Hint, "该用户不允许你评论他的内容!"));
            }

            CommentService commentService = new CommentService();
            if (model.IsValidate)
            {
                Comment comment = model.AsComment();
                //todo:bianchx,by zhengw:可以考虑在model.AsComment方法中处理IsPrivate问题
                if (comment.ParentId != 0)
                {
                    Comment parentComment = commentService.Get(comment.ParentId);
                    if (parentComment != null)
                        comment.IsPrivate = parentComment.IsPrivate ? true : comment.IsPrivate;
                }

                if (commentService.Create(comment))
                {
                    if (model.CommentOriginalAuthor)
                    {
                        MicroblogEntity entity = microblogService.Get(comment.CommentedObjectId);
                        //todo:bianchx,by zhengw:应判断entity.User是否为null

                        if (entity != null)
                        {
                            Comment originalAuthorComment = model.AsComment();
                            entity = entity.OriginalMicroblog;
                            if (entity != null)
                            {
                                originalAuthorComment.ToUserId = entity.UserId;
                                originalAuthorComment.ToUserDisplayName = entity.User.DisplayName;
                                originalAuthorComment.CommentedObjectId = entity.MicroblogId;
                                commentService.Create(originalAuthorComment);
                            }
                        }
                    }
                    if (model.ForwardMicrobo)
                    {
                        MicroblogEntity microblogEntity = microblogService.Get(model.CommentedObjectId);
                        if (microblogEntity != null)
                        {
                            MicroblogEntity microblog = MicroblogEntity.New();
                            microblog.Body = "转发微博";
                            microblog.Author = currentUser.DisplayName;
                            microblog.UserId = currentUser.UserId;
                            microblog.OwnerId = currentUser.UserId;
                            microblog.TenantTypeId = TenantTypeIds.Instance().User();

                            microblog.ForwardedMicroblogId = microblogEntity.MicroblogId;
                            microblog.OriginalMicroblogId = microblogEntity.OriginalMicroblogId > 0 ? microblogEntity.OriginalMicroblogId : microblog.ForwardedMicroblogId;

                            long toUserId = microblog.UserId;

                            MicroblogEntity entity = microblogService.Get(microblog.OriginalMicroblogId);
                            long toOriginalUserId = entity == null ? 0 : entity.UserId;

                            long microblogId = 0;
                            microblogService.Forward(microblog, false, false, toUserId, toOriginalUserId, out microblogId);
                        }
                    }
                    return Json(new { commentid = comment.Id });
                }
            }
            WebUtility.SetStatusCodeForError(Response);
            return Json(new StatusMessageData(StatusMessageType.Error, "创建留言失败了!"));
        }
Пример #4
0
        /// <summary>
        /// 获取一条评论
        /// </summary>
        /// <param name="id">评论id</param>
        /// <returns>获取一条评论</returns>
        public ActionResult _OneComment(long id)
        {
            Comment comment = new CommentService().Get(id);
            if (comment == null)
                return Content(string.Empty);

            return View(comment);
        }
Пример #5
0
 public ActionResult _CommentList(string tenantType, long commentedObjectId, int? pageIndex = null, SortBy_Comment sortBy = SortBy_Comment.DateCreatedDesc, long? commentId = null, bool showBefore = true, bool showAfter = false)
 {
     ViewData["tenantType"] = tenantType;
     ViewData["commentedObjectId"] = commentedObjectId;
     if (commentId.HasValue)
     {
         pageIndex = new CommentService().GetPageIndexForCommentInCommens(commentId.Value, tenantType, commentedObjectId, sortBy);
         showAfter = true;
         showBefore = true;
     }
     if (!pageIndex.HasValue)
         pageIndex = 1;
     ViewData["ShowBefore"] = showBefore;
     ViewData["ShowAfter"] = showAfter;
     return View(new CommentService().GetRootComments(tenantType, commentedObjectId, pageIndex.Value, sortBy));
 }
Пример #6
0
        public ActionResult _ChildComment(long? parentId)
        {
            if (!parentId.HasValue) return HttpNotFound();

            CommentService commentService = new CommentService();
            Comment comment = commentService.Get(parentId.Value);
            if (comment == null) return HttpNotFound();

            MicroblogEntity entity = microblogService.Get(comment.CommentedObjectId);
            if (entity == null) return HttpNotFound();

            MicroblogCommentEditModel editModel = comment.AsMicroblogCommentEditModel();
            editModel.OriginalAuthor = entity.Author;

            return View(editModel);
        }
Пример #7
0
        public ActionResult Home()
        {
            pageResourceManager.InsertTitlePart("后台首页");

            //获得所有应用的应用名
            IEnumerable<ApplicationBase> applications = applicationService.GetAll();
            //初始化待处理应用数组
            List<ApplicationStatisticData> allManageableDatas = new List<ApplicationStatisticData>();
            //初始化数据统计项实体数组
            List<ApplicationStatisticItem> statisticItems = new List<ApplicationStatisticItem>();

            var isApplicationAdmin = !UserContext.CurrentUser.IsInRoles(RoleNames.Instance().SuperAdministrator(), RoleNames.Instance().ContentAdministrator());

            //遍历应用名
            foreach (var application in applications)
            {
                if (isApplicationAdmin)
                {
                    if (!authorizer.IsAdministrator(application.ApplicationId))
                        continue;
                }
                //获取所有待处理数据实体
                IEnumerable<ApplicationStatisticData> manageableDatas = DIContainer.ResolveNamed<IApplicationStatisticDataGetter>(application.ApplicationKey).GetManageableDatas();
                //获取所有数据统计应用数据实体
                IEnumerable<ApplicationStatisticData> applicationStatisticDatas = DIContainer.ResolveNamed<IApplicationStatisticDataGetter>(application.ApplicationKey).GetStatisticDatas();
                //将所有待处理数据实体添加到未处理应用数组
                allManageableDatas.AddRange(manageableDatas);
                //遍历所有应用简称
                foreach (string shortName in applicationStatisticDatas.Select(n => n.ShortName))
                {
                    //如果数组中已存在该应用则继续
                    var item = statisticItems.Where(n => n.ShortName == shortName).FirstOrDefault();
                    if (statisticItems.Contains(item))
                    {
                        continue;
                    }
                    //获取该简称下的应用数组
                    IEnumerable<ApplicationStatisticData> datas = applicationStatisticDatas.Where(n => n.ShortName == shortName);
                    //获取该简称下的总数应用
                    ApplicationStatisticData applicationStatisticDataTotal = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().TotalCount()).FirstOrDefault();
                    //初始化总数
                    long totalCount = 0;
                    //初始化URL
                    string itemUrl = null;
                    //如果存在总数应用
                    if (applicationStatisticDataTotal != null)
                    {
                        //为数据统计项实体总数和url赋值
                        totalCount = applicationStatisticDataTotal.Value;
                        itemUrl = applicationStatisticDataTotal.Url;
                    }
                    //获取该简称下的24小时新增数应用
                    var applicationStatisticDataLast24H = datas.Where(n => n.DataKey == ApplicationStatisticDataKeys.Instance().Last24HCount()).FirstOrDefault();
                    //初始化24小时新增数
                    long Last24H = 0;
                    //如果存在24小时新增数应用
                    if (applicationStatisticDataLast24H != null)
                        //为总数项实体24小时新增数赋值
                        Last24H = applicationStatisticDataLast24H.Value;
                    //实例化数据统计项实体
                    ApplicationStatisticItem appItem = new ApplicationStatisticItem(shortName, totalCount, Last24H);
                    appItem.Url = itemUrl;
                    //添加到数组
                    statisticItems.Add(appItem);
                }
            }
            //获取待处理事项实体数组
            ViewData["allManageableDatas"] = allManageableDatas;

            //增加有多少个待审核评论
            PagingDataSet<Comment> comments = new CommentService().GetComments(PubliclyAuditStatus.Pending, null, null, null, null, 20, 1);
            ViewData["commentsCount"] = comments.TotalRecords;

            //多少未读客服消息
            ViewData["customMessageCount"] = new MessageService().GetUnreadCount((long)BuildinMessageUserId.CustomerService);

            //待处理用户举报
            ViewData["impeachCount"] = new ImpeachReportService().GetsForAdmin(false, null).TotalRecords;

            //待激活的用户
            var userManageableCounts = userService.GetManageableCounts(false, false, false);
            ViewData["activatedUserCount"] = userManageableCounts[UserManageableCountType.IsActivated];

            //24小时新增用户数
            ViewData["userCount24H"] = userManageableCounts[UserManageableCountType.IsLast24];

            //总用户数
            ViewData["userCount"] = userManageableCounts[UserManageableCountType.IsAll];

            //获取系统信息

            SystemInfo systemInfo = new SystemInfo();
            ViewData["systemInfo"] = systemInfo;
            return View(statisticItems);
        }
Пример #8
0
 /// <summary>
 /// 评论详细页中的用户数据(显示用户评论数)
 /// </summary>
 /// <returns></returns>
 public ActionResult _UserComment()
 {
     IUser currentUser = UserContext.CurrentUser;
     CommentService commentService = new CommentService();
     long userCommentCount = commentService.GetUserCommentCount(currentUser.UserId, TenantTypeIds.Instance().ContentItem());
     ViewData["userCommentCount"] = userCommentCount;
     return View();
 }
Пример #9
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));
            }
        }