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

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

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

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

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

            return(SiteUrls.Instance().AlbumDetailList(userName, itemId));
        }
Example #4
0
        /// <summary>
        /// 详细页面地址
        /// </summary>
        /// <param name="itemId">推荐内容Id</param>
        /// <returns></returns>
        public string RecommendItemDetail(long itemId)
        {
            BlogThread blogThread = new BlogService().Get(itemId);

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

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

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

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

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

            return(SiteUrls.Instance().PhotoDetail(itemId));
        }
Example #7
0
 /// <summary>
 /// 获取被评论对象url
 /// </summary>
 /// <param name="commentedObjectId">被评论对象Id</param>
 /// <param name="userId">被评论对象作者Id</param>
 /// <returns></returns>
 public string GetCommentedObjectUrl(long commentedObjectId, long?userId = null, string tenantTypeId = null)
 {
     if (!userId.HasValue || userId <= 0)
     {
         return(string.Empty);
     }
     if (tenantTypeId == TenantTypeIds.Instance().BlogThread())
     {
         string userName = UserIdToUserNameDictionary.GetUserName(userId.Value);
         return(SiteUrls.Instance().BlogDetail(userName, commentedObjectId));
     }
     return(string.Empty);
 }
        /// <summary>
        /// 获取链接地址
        /// </summary>
        /// <param name="spaceKey">用户名</param>
        /// <param name="ownerId">用户id</param>
        /// <returns></returns>
        public string GetDataUrl(string spaceKey, long?ownerId = null)
        {
            if (string.IsNullOrEmpty(spaceKey) && ownerId.HasValue)
            {
                spaceKey = UserIdToUserNameDictionary.GetUserName(ownerId.Value);
            }
            return(SiteUrls.Instance().Mine(spaceKey, string.Empty));

            //           string tenantTypeId = TenantTypeIds.Instance().User();
            //           IEnumerable<string> dataKeys = OwnerDataSettings.GetDataKeys(tenantTypeId);
            //            List<OwnerStatisticData> list=new List<OwnerStatisticData>();
            //           foreach (var dataKey in dataKeys)
            //           {
            //OwnerStatisticData data=new OwnerStatisticData();
            //               var getter= OwnerDataGetterFactory.Get(dataKey);
            //               getter.DataName;
            //               var value = new OwnerDataService().GetLong(ownerId, dataKey);
            //               getter.GetDataUrl
            //                   list.Add
            //           }
        }
Example #9
0
        /// <summary>
        /// 回答增删改等触发的事件
        /// </summary>
        private void AskAnswerEventModule_After(AskAnswer answer, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //向关注该问题的用户发送通知
                IEnumerable <long> userIds  = subscribeService.GetUserIdsOfObject(answer.QuestionId);
                AskQuestion        question = answer.Question;
                foreach (var userId in userIds)
                {
                    //通知的对象排除掉自己
                    if (userId == answer.UserId)
                    {
                        continue;
                    }

                    Notice notice = Notice.New();
                    notice.UserId             = userId;
                    notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Reply();
                    notice.LeadingActor       = answer.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(answer.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().NewAnswer();
                    noticeService.Create(notice);
                }

                //自动关注(回答者自动关注[订阅]该问题)
                if (!subscribeService.IsSubscribed(question.QuestionId, answer.UserId))
                {
                    subscribeService.Subscribe(question.QuestionId, answer.UserId);

                    //问题关注数计数,用于“可能感兴趣的问题”关联表查询
                    countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false);
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //删除回答者对问题的关注
                subscribeService.CancelSubscribe(answer.QuestionId, answer.UserId);
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                AskQuestion question = new AskService().GetQuestion(answer.QuestionId);

                if (answer.IsBest && question.Status == QuestionStatus.Resolved && !question.IsTrated)
                {
                    //如果问题有悬赏则悬赏分值转移到回答者的帐户(如有交易税,需要扣除)
                    if (question.Reward > 0)
                    {
                        pointService.Trade(question.UserId, answer.UserId, question.Reward, string.Format(Resource.PointRecord_Pattern_QuestionReward, question.Subject), false);
                    }
                    askService.SetTradeStatus(question, true);

                    //处理采纳回答相关的积分和威望
                    string pointItemKey_AcceptedAnswer = PointItemKeys.Instance().Ask_AcceptedAnswer();

                    //采纳回答时产生积分
                    string description_AcceptedAnswer = string.Format(Resource.PointRecord_Pattern_AcceptedAnswer, question.Subject);
                    pointService.GenerateByRole(question.UserId, pointItemKey_AcceptedAnswer, description_AcceptedAnswer);

                    //记录用户的威望
                    PointItem pointItem_AcceptedAnswer = pointService.GetPointItem(pointItemKey_AcceptedAnswer);
                    ownerDataService.Change(question.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem_AcceptedAnswer.ReputationPoints);


                    //处理回答被采纳相关的积分和威望
                    string pointItemKey_AnswerWereAccepted = PointItemKeys.Instance().Ask_AnswerWereAccepted();

                    //回答被采纳时产生积分
                    string description_AnswerWereAccepted = string.Format(Resource.PointRecord_Pattern_AnswerWereAccepted, question.Subject);
                    pointService.GenerateByRole(answer.UserId, pointItemKey_AnswerWereAccepted, description_AnswerWereAccepted);

                    //记录用户的威望
                    PointItem pointItem_AnswerWereAccepted = pointService.GetPointItem(pointItemKey_AnswerWereAccepted);
                    ownerDataService.Change(answer.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem_AnswerWereAccepted.ReputationPoints);

                    //向关注该问题的用户发送通知
                    IEnumerable <long> userIds = subscribeService.GetUserIdsOfObject(answer.QuestionId);
                    foreach (var userId in userIds)
                    {
                        //通知的对象排除掉自己
                        if (userId == question.UserId)
                        {
                            continue;
                        }

                        Notice notice = Notice.New();
                        notice.UserId             = userId;
                        notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                        notice.TypeId             = NoticeTypeIds.Instance().Hint();
                        notice.LeadingActor       = question.Author;
                        notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(question.UserId)));
                        notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                        notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                        notice.TemplateName       = NoticeTemplateNames.Instance().SetBestAnswer();
                        noticeService.Create(notice);
                    }
                }
            }
        }
Example #10
0
        /// <summary>
        /// 问题增删改等触发的事件
        /// </summary>
        private void AskQuestionEventModule_After(AskQuestion question, CommonEventArgs eventArgs)
        {
            if (eventArgs.EventOperationType == EventOperationType.Instance().Create())
            {
                //冻结用户的积分
                if (question.AddedReward > 0)
                {
                    userService.FreezeTradePoints(question.UserId, question.AddedReward);
                }

                //向定向提问的目标用户发送通知
                if (question.AskUserId > 0)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = question.AskUserId;
                    notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = question.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(question.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().AskUser();
                    noticeService.Create(notice);
                }

                //自动关注(提问者自动关注[订阅]该问题)
                if (!subscribeService.IsSubscribed(question.QuestionId, question.UserId))
                {
                    subscribeService.Subscribe(question.QuestionId, question.UserId);

                    //问题关注数计数,用于“可能感兴趣的问题”关联表查询
                    countService.ChangeCount(CountTypes.Instance().QuestionFollowerCount(), question.QuestionId, question.UserId, 1, false);
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Delete())
            {
                //已解决问题的积分不返还,未解决/已取消的问题应该解除冻结积分
                if (question.Reward > 0 && question.Status != QuestionStatus.Resolved)
                {
                    userService.UnfreezeTradePoints(question.UserId, question.Reward);
                }

                //删除所有用户对该问题的关注(订阅)
                IEnumerable <long> userIds = subscribeService.GetUserIdsOfObject(question.QuestionId);
                foreach (var userId in userIds)
                {
                    subscribeService.CancelSubscribe(question.QuestionId, userId);
                }
            }
            else if (eventArgs.EventOperationType == EventOperationType.Instance().Update())
            {
                //冻结用户的积分
                if (question.AddedReward != 0)
                {
                    userService.FreezeTradePoints(question.UserId, question.AddedReward);
                }
                if (question.Status == QuestionStatus.Canceled)
                {
                    subscribeService.CancelSubscribe(question.QuestionId, question.UserId);
                    int pageSize = 100;
                    for (int i = 1; i <= question.AnswerCount; i = i + pageSize)
                    {
                        PagingDataSet <AskAnswer> answers = askService.GetAnswersByQuestionId(question.QuestionId, SortBy_AskAnswer.DateCreated_Desc, pageSize, i);
                        foreach (AskAnswer answer in answers)
                        {
                            subscribeService.CancelSubscribe(question.QuestionId, answer.UserId);
                        }
                    }
                }
            }
            //加精时处理积分和威望并产生通知
            else if (eventArgs.EventOperationType == EventOperationType.Instance().SetEssential())
            {
                string pointItemKey = PointItemKeys.Instance().EssentialContent();
                string description  = string.Format(ResourceAccessor.GetString("PointRecord_Pattern_" + eventArgs.EventOperationType), "问题", question.Subject);
                pointService.GenerateByRole(question.UserId, pointItemKey, description);

                if (question.UserId > 0)
                {
                    Notice notice = Notice.New();
                    notice.UserId             = question.UserId;
                    notice.ApplicationId      = AskConfig.Instance().ApplicationId;
                    notice.TypeId             = NoticeTypeIds.Instance().Hint();
                    notice.LeadingActor       = question.Author;
                    notice.LeadingActorUrl    = SiteUrls.FullUrl(SiteUrls.Instance().AskUser(UserIdToUserNameDictionary.GetUserName(question.UserId)));
                    notice.RelativeObjectName = HtmlUtility.TrimHtml(question.Subject, 64);
                    notice.RelativeObjectUrl  = SiteUrls.FullUrl(SiteUrls.Instance().AskQuestionDetail(question.QuestionId));
                    notice.TemplateName       = NoticeTemplateNames.Instance().ManagerSetEssential();
                    noticeService.Create(notice);
                }
                //记录用户的威望
                PointItem pointItem = pointService.GetPointItem(pointItemKey);
                ownerDataService.Change(question.UserId, OwnerDataKeys.Instance().UserAskReputation(), pointItem.ReputationPoints);
            }
        }
Example #11
0
 /// <summary>
 /// 我的资讯
 /// </summary>
 public static string CmsUser(this SiteUrls siteUrls, long userId)
 {
     return(CachedUrlHelper.Action("CmsUser", "ChannelCms", CmsAreaName, new RouteValueDictionary {
         { "spaceKey", UserIdToUserNameDictionary.GetUserName(userId) }
     }));
 }