Ejemplo n.º 1
0
        /// <summary>
        /// 照片排行瀑布流
        /// </summary>
        public ActionResult _Photos(string tagName = null, bool?isEssential = null, SortBy_Photo sortBy = SortBy_Photo.DateCreated_Desc, int pageSize = 20, int pageIndex = 1)
        {
            PagingDataSet <Photo> photos = photoService.GetPhotos(TenantTypeIds.Instance().User(), tagName, isEssential, sortBy, pageSize, pageIndex);

            return(View(photos));
        }
Ejemplo n.º 2
0
        public ActionResult _Reproduce(string spaceKey, BlogThreadEditModel model)
        {
            IUser currentUser = UserContext.CurrentUser;

            BlogThread blogThread = blogService.Get(model.ThreadId);

            if (blogThread == null)
            {
                return(HttpNotFound());
            }

            BlogThread reproducedBlogThread = BlogThread.New();

            reproducedBlogThread.IsDraft                   = false;
            reproducedBlogThread.IsReproduced              = true;
            reproducedBlogThread.Keywords                  = blogThread.Keywords;
            reproducedBlogThread.Subject                   = blogThread.Subject;
            reproducedBlogThread.Body                      = blogThread.GetBody();
            reproducedBlogThread.Summary                   = blogThread.Summary;
            reproducedBlogThread.UserId                    = currentUser.UserId;
            reproducedBlogThread.OwnerId                   = currentUser.UserId;
            reproducedBlogThread.TenantTypeId              = TenantTypeIds.Instance().User();
            reproducedBlogThread.Author                    = currentUser.DisplayName;
            reproducedBlogThread.OriginalAuthorId          = blogThread.OriginalAuthorId;
            reproducedBlogThread.PrivacyStatus             = model.PrivacyStatus;
            reproducedBlogThread.FeaturedImage             = blogThread.FeaturedImage;
            reproducedBlogThread.FeaturedImageAttachmentId = blogThread.FeaturedImageAttachmentId;
            reproducedBlogThread.OriginalThreadId          = blogThread.ThreadId;


            //替换附件
            IEnumerable <Attachment> attachments = attachmentService.GetsByAssociateId(blogThread.ThreadId);

            if (attachments != null && attachments.Count() > 0)
            {
                foreach (var attachment in attachments)
                {
                    Attachment newAttachment = null;
                    //如果该附件有售价并且该用户没有购买过(下载过)该附件则不转载附件
                    if (attachment.Price > 0 && !attachmentDownloadService.IsDownloaded(currentUser.UserId, attachment.AttachmentId))
                    {
                        string oldAttach = "[attach:" + attachment.AttachmentId + "]";
                        reproducedBlogThread.Body = reproducedBlogThread.Body.Replace(oldAttach, "");
                    }
                    else
                    {
                        newAttachment = attachmentService.CloneForUser(attachment, currentUser.UserId);
                        string oldAttach = "[attach:" + attachment.AttachmentId + "]";
                        string newAttach = "[attach:" + newAttachment.AttachmentId + "]";
                        reproducedBlogThread.Body = reproducedBlogThread.Body.Replace(oldAttach, newAttach);

                        //替换标题图
                        if (blogThread.FeaturedImageAttachmentId > 0 && blogThread.FeaturedImageAttachmentId == attachment.AttachmentId)
                        {
                            reproducedBlogThread.FeaturedImage             = newAttachment.GetRelativePath() + "\\" + newAttachment.FileName;
                            reproducedBlogThread.FeaturedImageAttachmentId = newAttachment.AttachmentId;
                        }
                    }
                }
            }

            bool isCreated = blogService.Create(reproducedBlogThread, model.PrivacyStatus1, model.PrivacyStatus2);

            if (!isCreated)
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "发布失败",
                    Body = "发布失败,请稍后再试!",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            ////设置隐私状态
            //UpdatePrivacySettings(reproducedBlogThread, model.PrivacyStatus1, model.PrivacyStatus2);

            //设置用户分类
            if (!string.IsNullOrEmpty(model.OwnerCategoryIds))
            {
                string[] ownerCategoryIds = model.OwnerCategoryIds.TrimEnd(',').Split(',');
                categoryService.AddCategoriesToItem(ownerCategoryIds.Select(n => long.Parse(n)), reproducedBlogThread.ThreadId);
            }

            //设置标签(如此处理是因为标签选择器会输出两个同名的hidden input)
            if (model.TagNames != null && model.TagNames.Count() == 2 && !string.IsNullOrEmpty(model.TagNames.ElementAt(1)))
            {
                tagService.AddTagsToItem(model.TagNames.ElementAt(1), reproducedBlogThread.UserId, reproducedBlogThread.ThreadId);
            }
            // return Redirect(SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId));
            return(Redirect(SiteUrls.Instance().BlogDetail(spaceKey, reproducedBlogThread.ThreadId)));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// 文章列表
        /// </summary>
        public ActionResult List(string spaceKey, ListType listType, string tag = null, int year = 0, int month = 0, long categoryId = 0, int pageIndex = 1)
        {
            PagingDataSet <BlogThread> blogs = null;
            IUser  currentUser = UserContext.CurrentUser;
            string title       = string.Empty;

            switch (listType)
            {
            case ListType.Archive:
                ArchivePeriod archivePeriod = ArchivePeriod.Year;
                if (month > 0)
                {
                    archivePeriod = ArchivePeriod.Month;
                }

                ArchiveItem archiveItem = new ArchiveItem();
                archiveItem.Year  = year;
                archiveItem.Month = month;

                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, archivePeriod, archiveItem, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetsForArchive(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, archivePeriod, archiveItem, 20, pageIndex);
                }

                title = "归档:" + year + "年";
                if (month > 0)
                {
                    title += month + "月";
                }

                break;

            case ListType.Category:
                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, categoryId, null, false, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, categoryId, null, false, 20, pageIndex);
                }

                Category category = categoryService.Get(categoryId);
                title = "分类:" + category.CategoryName;

                break;

            case ListType.Tag:
                if (currentUser != null && currentUser.UserName == spaceKey)
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), currentUser.UserId, true, false, null, tag, false, 20, pageIndex);
                }
                else
                {
                    blogs = blogService.GetOwnerThreads(TenantTypeIds.Instance().User(), UserIdToUserNameDictionary.GetUserId(spaceKey), false, true, null, tag, false, 20, pageIndex);
                }

                title = "标签:" + tag;

                break;

            default:
                break;
            }

            ViewData["title"] = title;
            pageResourceManager.InsertTitlePart(title);

            return(View(blogs));
        }
Ejemplo n.º 4
0
        /// <summary>
        /// 日志管理
        /// </summary>
        /// <param name="auditStatus">审批状态</param>
        /// <param name="categoryId">日志类别id</param>
        /// <param name="subjectKeywords">标题关键字</param>
        /// <param name="isEssential">是否加精</param>
        /// <param name="userId">作者id</param>
        /// <param name="pageSize">分页大小</param>
        /// <param name="pageIndex">页码</param>
        public ActionResult ManageBlogs(AuditStatus?auditStatus = null, long?categoryId = null, string subjectKeywords = null, bool?isEssential = null, string userId = null, string tenantTypeId = null, int pageSize = 20, int pageIndex = 1)
        {
            long?blogUserId = null;

            if (!string.IsNullOrEmpty(userId))
            {
                userId = userId.Trim(',');
                if (!string.IsNullOrEmpty(userId))
                {
                    blogUserId = long.Parse(userId);
                }
            }

            //获取类别
            IEnumerable <Category> categorys    = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread());
            SelectList             categoryList = new SelectList(categorys.Select(n => new { text = n.CategoryName, value = n.CategoryId }), "value", "text", categoryId);

            ViewData["categoryList"] = categoryList;

            //组装是否加精
            List <SelectListItem> selectListIsEssential = new List <SelectListItem> {
                new SelectListItem {
                    Text = "是", Value = true.ToString()
                }, new SelectListItem {
                    Text = "否", Value = false.ToString()
                }
            };

            ViewData["isEssential"] = new SelectList(selectListIsEssential, "Value", "Text", isEssential);
            ViewData["userId"]      = blogUserId;

            //获取租户类型
            IEnumerable <TenantType> tenantTypes = tenantTypeService.Gets(ApplicationKeys.Instance().Blog());
            SelectList tenants = null;

            tenants                  = new SelectList(tenantTypes.Select(n => new { text = n.Name, value = n.TenantTypeId }), "value", "text", tenantTypeId);
            ViewData["tenants"]      = tenants;
            ViewData["tenantscount"] = tenantTypes.Count();

            PagingDataSet <BlogThread> blogs = blogService.GetsForAdmin(null, auditStatus, categoryId, isEssential, blogUserId, subjectKeywords, pageSize, pageIndex);

            pageResourceManager.InsertTitlePart("日志管理");

            return(View(blogs));
        }
Ejemplo n.º 5
0
        public ActionResult Edit(string spaceKey, BlogThreadEditModel model)
        {
            string errorMessage = string.Empty;

            if (ModelState.HasBannedWord(out errorMessage))
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "发布失败",
                    Body = errorMessage,
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            BlogThread blogThread = model.AsBlogThread();

            //写文章
            if (model.ThreadId == 0)
            {
                if (!authorizer.BlogThread_Create(spaceKey, out errorMessage))
                {
                    if (model.IsDraft)
                    {
                        return(Json(new StatusMessageData(StatusMessageType.Error, "没有权限创建新的文章!")));
                    }
                    else
                    {
                        return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                        {
                            Title = "没有权限",
                            Body = errorMessage,
                            StatusMessageType = StatusMessageType.Hint
                        })));
                    }
                }


                //  blogThread = model.AsBlogThread();
                bool isCreated = blogService.Create(blogThread, model.PrivacyStatus1, model.PrivacyStatus2);

                if (!isCreated)
                {
                    if (model.IsDraft)
                    {
                        return(Json(new StatusMessageData(StatusMessageType.Error, "发布失败,请稍后再试!")));
                    }
                    else
                    {
                        return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                        {
                            Title = "发布失败",
                            Body = "发布失败,请稍后再试!",
                            StatusMessageType = StatusMessageType.Hint
                        })));
                    }
                }
            }
            //编辑文章
            else
            {
                //   blogThread = model.AsBlogThread();

                if (!authorizer.BlogThread_Edit(blogThread))
                {
                    if (model.IsDraft)
                    {
                        return(Json(new StatusMessageData(StatusMessageType.Error, "没有权限编辑" + blogThread.Subject + "!")));
                    }
                    else
                    {
                        return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                        {
                            Title = "没有权限",
                            Body = "没有权限编辑" + blogThread.Subject + "!",
                            StatusMessageType = StatusMessageType.Hint
                        })));
                    }
                }

                //如果之前是草稿,现在正式发布,那么需要先删除草稿,然后创建新的文章
                if (blogThread.IsDraft && !model.IsDraft)
                {
                    blogThread.IsDraft = false;
                    blogThread         = blogThread.Clone();
                    blogService.Delete(blogThread.ThreadId);
                    bool isCreated = blogService.Create(blogThread, model.PrivacyStatus1, model.PrivacyStatus2);
                }
                else
                {
                    blogService.Update(blogThread, privacyStatus1: model.PrivacyStatus1, privacyStatus2: model.PrivacyStatus2);

                    //清除用户分类
                    categoryService.ClearCategoriesFromItem(blogThread.ThreadId, blogThread.OwnerId, TenantTypeIds.Instance().BlogThread());

                    if (blogSettings.AllowSetSiteCategory)
                    {
                        //清除站点分类(投稿到)
                        categoryService.ClearCategoriesFromItem(blogThread.ThreadId, 0, TenantTypeIds.Instance().BlogThread());
                    }

                    //清除标签
                    tagService.ClearTagsFromItem(blogThread.ThreadId, blogThread.UserId);
                }
            }

            ////设置隐私状态
            //UpdatePrivacySettings(blogThread, model.PrivacyStatus1, model.PrivacyStatus2);

            //设置用户分类
            if (!string.IsNullOrEmpty(model.OwnerCategoryIds))
            {
                string[] ownerCategoryIds = model.OwnerCategoryIds.TrimEnd(',').Split(',');
                categoryService.AddCategoriesToItem(ownerCategoryIds.Select(n => long.Parse(n)), blogThread.ThreadId);
            }

            if (blogSettings.AllowSetSiteCategory)
            {
                //设置站点分类(投稿到)
                if (model.SiteCategoryId.HasValue)
                {
                    categoryService.AddCategoriesToItem(new List <long> {
                        model.SiteCategoryId.Value
                    }, blogThread.ThreadId);
                }
            }

            string tags = string.Join(",", model.TagNames);

            if (!string.IsNullOrEmpty(tags))
            {
                tagService.AddTagsToItem(tags, blogThread.UserId, blogThread.ThreadId);
            }

            //如果是保存草稿,则返回Json
            if (blogThread.IsDraft)
            {
                return(Json(new { MessageType = StatusMessageType.Success, MessageContent = "保存成功!", ThreadId = blogThread.ThreadId }));
            }
            else
            {
                return(Redirect(SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId)));
                //return Json(new { MessageType = StatusMessageType.Success, MessageContent = SiteUrls.Instance().BlogDetail(spaceKey, blogThread.ThreadId), ThreadId = blogThread.ThreadId });
            }
        }
Ejemplo n.º 6
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、@用户(看到了)
        }
Ejemplo n.º 7
0
 /// <summary>
 /// 判断是否为租户普通成员
 /// </summary>
 /// <param name="currentUser">当前用户</param>
 /// <param name="tenantOwnerId">租户拥有者Id</param>
 /// <returns>true-是;false-不是</returns>
 public bool IsTenantMember(IUser currentUser, long tenantOwnerId)
 {
     return(new SubscribeService(TenantTypeIds.Instance().BarSection()).IsSubscribed(tenantOwnerId, currentUser.UserId));
 }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据排序条件分页显示用户
        /// </summary>
        /// <param name="sortBy">排序条件</param>
        /// <param name="pageIndex">当前页码</param>
        /// <param name="pageSize">每页记录</param>
        /// <returns>根据排序条件倒排序分页显示用户</returns>
        public PagingDataSet <User> GetPagingUsers(SortBy_User?sortBy, int pageIndex, int pageSize)
        {
            PagingDataSet <User> users =
                GetPagingEntities(pageSize, pageIndex, Tunynet.Caching.CachingExpirationType.ObjectCollection,
                                  () =>
            {
                StringBuilder cacheKey = new StringBuilder("PagingTopUsers:");
                cacheKey.AppendFormat("SortBy-{0}", sortBy);

                return(cacheKey.ToString());
            },
                                  () =>
            {
                var sql      = PetaPoco.Sql.Builder;
                var whereSql = Sql.Builder;
                var orderSql = Sql.Builder;
                whereSql.Where("IsActivated =1 and IsBanned = 0");

                CountService countService = new CountService(TenantTypeIds.Instance().User());
                StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().User());
                string countTableName = countService.GetTableName_Counts();
                int stageCountDays;
                string stageCountType;

                if (sortBy.HasValue)
                {
                    switch (sortBy)
                    {
                    case SortBy_User.FollowerCount:
                        orderSql.OrderBy("FollowerCount desc");
                        break;

                    case SortBy_User.Rank:
                        orderSql.OrderBy("Rank desc");
                        break;

                    case SortBy_User.ReputationPoints:
                        orderSql.OrderBy("ReputationPoints desc");
                        break;

                    case SortBy_User.TradePoints:
                        orderSql.OrderBy("TradePoints desc");
                        break;

                    case SortBy_User.DateCreated:
                        orderSql.OrderBy("UserId desc");
                        break;

                    case SortBy_User.PreWeekHitTimes:
                        stageCountDays = 7;
                        stageCountType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().HitTimes(), stageCountDays);
                        sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, stageCountType))
                        .On("UserId = c.ObjectId");
                        orderSql.OrderBy("c.StatisticsCount desc");
                        break;

                    case SortBy_User.HitTimes:
                        sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, CountTypes.Instance().HitTimes()))
                        .On("UserId = c.ObjectId");
                        orderSql.OrderBy("c.StatisticsCount desc");
                        break;

                    case SortBy_User.PreWeekReputationPoints:
                        stageCountDays = 7;
                        stageCountType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().ReputationPointsCounts(), stageCountDays);
                        sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, stageCountType))
                        .On("UserId = c.ObjectId");
                        orderSql.OrderBy("c.StatisticsCount desc");
                        break;

                    default:
                        orderSql.OrderBy("UserId desc");
                        break;
                    }
                }
                return(sql.Append(whereSql).Append(orderSql));
            });

            return(users);
        }
Ejemplo n.º 9
0
        public override void ProcessRequest(HttpContext context)
        {
            long attachmentId = context.Request.QueryString.Get <long>("attachmentId", 0);

            if (attachmentId <= 0)
            {
                WebUtility.Return404(context);
                return;
            }

            string tenantTypeId = context.Request.QueryString.Get <string>("tenantTypeId", null);

            if (string.IsNullOrEmpty(tenantTypeId))
            {
                WebUtility.Return404(context);
                return;
            }
            AttachmentService <Attachment> attachmentService = new AttachmentService <Attachment>(tenantTypeId);
            Attachment attachment = attachmentService.Get(attachmentId);

            if (attachment == null)
            {
                WebUtility.Return404(context);
                return;
            }

            IUser currentUser = UserContext.CurrentUser;

            //判断是否有附件的购买权限或下载权限,有下载权限肯定有购买权限,目前只有未登录或积分不够时才判定为没有权限
            if (!new Authorizer().Attachment_Buy(attachment))
            {
                WebUtility.Return403(context);
                return;
            }

            //如果还没有下载权限,则说明积分可以支付附件售价,但是还未购买,则先进行积分交易
            if (!new Authorizer().Attachment_Download(attachment))
            {
                //积分交易
                PointService pointService = new PointService();
                pointService.Trade(currentUser.UserId, attachment.UserId, attachment.Price, string.Format("购买附件{0}", attachment.FriendlyFileName), true);
            }

            //创建下载记录
            AttachmentDownloadService attachmentDownloadService = new AttachmentDownloadService();

            attachmentDownloadService.Create(currentUser == null ? 0 : currentUser.UserId, attachment.AttachmentId);

            //下载计数
            CountService countService = new CountService(TenantTypeIds.Instance().Attachment());

            countService.ChangeCount(CountTypes.Instance().DownloadCount(), attachment.AttachmentId, attachment.UserId, 1, false);

            bool enableCaching = context.Request.QueryString.GetBool("enableCaching", true);

            context.Response.Status     = "302 Object Moved";
            context.Response.StatusCode = 302;

            LinktimelinessSettings linktimelinessSettings = DIContainer.Resolve <ILinktimelinessSettingsManager>().Get();
            string token = Utility.EncryptTokenForAttachmentDownload(linktimelinessSettings.Highlinktimeliness, attachmentId);

            context.Response.Headers.Add("Location", SiteUrls.Instance().AttachmentTempUrl(attachment.AttachmentId, tenantTypeId, token, enableCaching));

            context.Response.Flush();
            context.Response.End();
        }
Ejemplo n.º 10
0
        /// <summary>
        /// 动态处理程序
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="eventArgs"></param>
        private void BarPostActivityModule_After(BarPost sender, AuditEventArgs eventArgs)
        {
            ActivityService activityService = new ActivityService();
            AuditService    auditService    = new AuditService();
            bool?           auditDirection  = auditService.ResolveAuditDirection(eventArgs.OldAuditStatus, eventArgs.NewAuditStatus);

            if (auditDirection == true) //生成动态
            {
                BarThreadService barThreadService = new BarThreadService();
                BarThread        barThread        = barThreadService.Get(sender.ThreadId);
                if (barThread == null)
                {
                    return;
                }
                if (sender.UserId == barThread.UserId)
                {
                    return;
                }
                var barUrlGetter = BarUrlGetterFactory.Get(barThread.TenantTypeId);
                if (barUrlGetter == null)
                {
                    return;
                }
                if (sender.ParentId > 0)
                {
                    BarPost parentPost = new BarPostService().Get(sender.ParentId);
                    if (parentPost == null)
                    {
                        return;
                    }
                    if (parentPost.UserId == sender.UserId)
                    {
                        return;
                    }
                }
                Activity actvity = Activity.New();
                actvity.ActivityItemKey = ActivityItemKeys.Instance().CreateBarPost();
                actvity.ApplicationId   = BarConfig.Instance().ApplicationId;
                //仅一级回复可以上传附件
                if (sender.ParentId == 0)
                {
                    AttachmentService        attachmentService = new AttachmentService(TenantTypeIds.Instance().BarPost());
                    IEnumerable <Attachment> attachments       = attachmentService.GetsByAssociateId(sender.PostId);
                    if (attachments != null && attachments.Any(n => n.MediaType == MediaType.Image))
                    {
                        actvity.HasImage = true;
                    }
                    //actvity.HasMusic = barThread.HasMusic;
                    //actvity.HasVideo = barThread.HasVideo;
                }

                actvity.IsOriginalThread      = true;
                actvity.IsPrivate             = barUrlGetter.IsPrivate(barThread.SectionId);
                actvity.OwnerId               = barThread.SectionId;
                actvity.OwnerName             = barThread.BarSection.Name;
                actvity.OwnerType             = barUrlGetter.ActivityOwnerType;
                actvity.ReferenceId           = barThread.ThreadId;
                actvity.ReferenceTenantTypeId = TenantTypeIds.Instance().BarThread();
                actvity.SourceId              = sender.PostId;
                actvity.TenantTypeId          = TenantTypeIds.Instance().BarPost();
                actvity.UserId = sender.UserId;

                //创建从属内容,不向自己的动态收件箱推送动态
                activityService.Generate(actvity, false);
            }
            else if (auditDirection == false) //删除动态
            {
                activityService.DeleteSource(TenantTypeIds.Instance().BarPost(), sender.PostId);
            }
        }
Ejemplo n.º 11
0
        /// <summary>
        /// 获取前N个用户
        /// </summary>
        /// <param name="topNumber">获取用户数</param>
        /// <param name="sortBy">排序字段</param>
        /// <returns></returns>
        public IEnumerable <User> GetTopUsers(int topNumber, SortBy_User sortBy)
        {
            IEnumerable <User> topUsers = null;

            topUsers = GetTopEntities(topNumber, CachingExpirationType.ObjectCollection,
                                      () =>
            {
                //获取缓存
                StringBuilder cacheKey = new StringBuilder("TopUsers:");
                cacheKey.AppendFormat("SortBy-{0}", (int)sortBy);

                return(cacheKey.ToString());
            },
                                      () =>
            {
                var sql      = PetaPoco.Sql.Builder;
                var whereSql = Sql.Builder;
                var orderSql = Sql.Builder;
                whereSql.Where("IsActivated =1 and IsBanned = 0");

                CountService countService = new CountService(TenantTypeIds.Instance().User());
                StageCountTypeManager stageCountTypeManager = StageCountTypeManager.Instance(TenantTypeIds.Instance().User());
                string countTableName = countService.GetTableName_Counts();
                int stageCountDays;
                string stageCountType;

                switch (sortBy)
                {
                case SortBy_User.FollowerCount:
                    orderSql.OrderBy("FollowerCount desc");
                    break;

                case SortBy_User.ReputationPoints:
                    orderSql.OrderBy("ReputationPoints desc");
                    break;

                case SortBy_User.DateCreated:
                    orderSql.OrderBy("UserId desc");
                    break;

                case SortBy_User.PreWeekHitTimes:
                    stageCountDays = 7;
                    stageCountType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().HitTimes(), stageCountDays);
                    sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, stageCountType))
                    .On("UserId = c.ObjectId");
                    orderSql.OrderBy("c.StatisticsCount desc");
                    break;

                case SortBy_User.HitTimes:
                    sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, CountTypes.Instance().HitTimes()))
                    .On("UserId = c.ObjectId");
                    orderSql.OrderBy("c.StatisticsCount desc");
                    break;

                case SortBy_User.PreWeekReputationPoints:
                    stageCountDays = 7;
                    stageCountType = stageCountTypeManager.GetStageCountType(CountTypes.Instance().ReputationPointsCounts(), stageCountDays);
                    sql.LeftJoin(string.Format("(select * from {0} WHERE ({0}.CountType = '{1}')) c", countTableName, stageCountType))
                    .On("UserId = c.ObjectId");
                    orderSql.OrderBy("c.StatisticsCount desc");
                    break;

                default:
                    orderSql.OrderBy("FollowerCount desc");
                    break;
                }
                return(sql.Append(whereSql).Append(orderSql));
            });
            return(topUsers);
        }
Ejemplo n.º 12
0
        public ActionResult EditRole(RoleEditModel model)
        {
            Stream             stream    = null;
            HttpPostedFileBase roleImage = Request.Files["RoleImage"];
            Role role = roleService.Get(model.RoleName);

            if (roleImage != null && !string.IsNullOrEmpty(roleImage.FileName))
            {
                TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Role());
                if (!tenantLogoSettings.ValidateFileLength(roleImage.ContentLength))
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}", Formatter.FormatFriendlyFileSize(tenantLogoSettings.MaxLogoLength * 1024)));
                    return(View(model));
                }

                LogoSettings logoSettings = DIContainer.Resolve <ISettingsManager <LogoSettings> >().Get();
                if (!logoSettings.ValidateFileExtensions(roleImage.FileName))
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "不支持的文件类型,仅支持" + logoSettings.AllowedFileExtensions);
                    return(View(model));
                }

                stream          = roleImage.InputStream;
                model.RoleImage = roleImage.FileName;
            }
            else        //当取不到上传的图片文件名时RoleImage值保持不变
            {
                model.RoleImage = role != null ? role.RoleImage : string.Empty;
            }
            if (model != null && !string.IsNullOrEmpty(model.RoleName))
            {
                if (role != null)
                {
                    role = model.AsRole();
                    roleService.Update(role, stream);
                }
            }

            return(RedirectToAction("ManageUsers"));
        }
Ejemplo n.º 13
0
        public ActionResult _EditIdentificationType(IdentificationTypeEditModel editModel)
        {
            string fileName = string.Empty;
            Stream stream   = null;

            //获取上传图片
            HttpPostedFileBase logo = Request.Files["IdentificationTypeLogo"];

            //如果上传图片不为空则校验其扩展名和大小
            if (logo != null && logo.ContentLength > 0)
            {
                fileName = logo.FileName;

                //校验附件的扩展名
                ISettingsManager <LogoSettings> logoSettingsManager = DIContainer.Resolve <ISettingsManager <LogoSettings> >();
                LogoSettings logoSettings = logoSettingsManager.Get();
                if (!logoSettings.ValidateFileExtensions(fileName))
                {
                    return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Error, "只允许上传后缀名为 " + logoSettings.AllowedFileExtensions.TrimEnd(',') + " 的文件"))));
                }

                //校验附件的大小
                TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Identification());
                if (!tenantLogoSettings.ValidateFileLength(logo.ContentLength))
                {
                    return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}KB", tenantLogoSettings.MaxLogoLength)))));
                }

                stream = logo.InputStream;
            }

            //如果IdentificationTypeId大于0则为编辑标识
            if (editModel.IdentificationTypeId > 0)
            {
                IdentificationType identificationType = editModel.AsIdentificationType();
                identificationService.UpdateIdentificationType(identificationType, stream);
            }
            //否则为创建标识
            else
            {
                if (logo == null || logo.ContentLength == 0)
                {
                    return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Error, "图片不能为空!"))));
                }
                IdentificationType identificationType = editModel.AsIdentificationType();
                identificationService.CreateIdentificationType(identificationType, stream);
            }
            return(Content(WarpJsonMessage(new StatusMessageData(StatusMessageType.Success, "操作成功!"))));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// 应用初始化
        /// </summary>
        /// <param name="containerBuilder">容器构建器</param>
        public override void Initialize(ContainerBuilder containerBuilder)
        {
            //注册ResourceAccessor的应用资源
            ResourceAccessor.RegisterApplicationResourceManager(ApplicationId, "Spacebuilder.CMS.Resources.Resource", typeof(Spacebuilder.CMS.Resources.Resource).Assembly);

            //注册EventModule
            containerBuilder.RegisterAssemblyTypes(Assembly.Load("Spacebuilder.CMS")).Where(t => typeof(IEventMoudle).IsAssignableFrom(t)).As <IEventMoudle>().SingleInstance();

            //注册全文检索搜索器
            containerBuilder.Register(c => new CmsSearcher("资讯", "~/App_Data/IndexFiles/Cms", true, 4)).As <ISearcher>().Named <ISearcher>(CmsSearcher.CODE).SingleInstance();

            //资讯应用数据统计
            containerBuilder.Register(c => new CmsApplicationStatisticDataGetter()).Named <IApplicationStatisticDataGetter>(this.ApplicationKey).SingleInstance();

            //注册资讯解析器
            containerBuilder.Register(c => new CmsBodyProcessor()).Named <IBodyProcessor>(TenantTypeIds.Instance().ContentItem()).SingleInstance();

            //注册附件设置
            TenantAttachmentSettings.RegisterSettings(tenantAttachmentSettingsElement);

            //评论设置的注册
            TenantCommentSettings.RegisterSettings(tenantCommentSettingsElement);
        }
Ejemplo n.º 15
0
        public ActionResult EditSection(BarSectionEditModel model)
        {
            HttpPostedFileBase logoImage         = Request.Files["LogoImage"];
            string             logoImageFileName = string.Empty;
            Stream             stream            = null;

            if (logoImage != null && !string.IsNullOrEmpty(logoImage.FileName))
            {
                TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().BarSection());
                if (!tenantLogoSettings.ValidateFileLength(logoImage.ContentLength))
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("Logo文件大小不允许超过{0}", Formatter.FormatFriendlyFileSize(tenantLogoSettings.MaxLogoLength * 1024)));
                    return(View(model));
                }

                LogoSettings logoSettings = DIContainer.Resolve <ILogoSettingsManager>().Get();
                if (!logoSettings.ValidateFileExtensions(logoImage.FileName))
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "Logo文件是不支持的文件类型,仅支持" + logoSettings.AllowedFileExtensions);
                    return(View(model));
                }
                stream            = logoImage.InputStream;
                logoImageFileName = logoImage.FileName;
            }


            IEnumerable <long> managerUserIds = Request.Form.Gets <long>("ManagerUserIds");

            if (model.SectionId == 0)
            {
                BarSection section = model.AsBarSection();

                //long userId = Request.QueryString.Gets<long>(model.UserId, new List<long>()).FirstOrDefault();


                section.UserId = Request.Form.Gets <long>("UserId", new List <long>()).FirstOrDefault();
                if (section.UserId == 0)
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "请输入吧主信息");
                    return(View(model));
                }
                section.LogoImage    = logoImageFileName;
                section.DisplayOrder = model.DisplayOrder ?? 100;
                if (managerUserIds != null && managerUserIds.Count() > 0)
                {
                    managerUserIds = managerUserIds.Where(n => n != section.UserId);
                }

                bool isCreated = barSectionService.Create(section, UserContext.CurrentUser.UserId, managerUserIds, stream);

                categoryService.AddItemsToCategory(new List <long> {
                    section.SectionId
                }, model.CategoryId, 0);

                if (isCreated)
                {
                    TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, "创建成功");
                    return(Redirect(SiteUrls.Instance().EditSection(section.SectionId)));
                }
                ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "创建失败");
                return(View(model));
            }
            else
            {
                BarSection section = model.AsBarSection();



                long userId = Request.Form.Gets <long>("UserId", new List <long>()).FirstOrDefault();
                if (userId == 0)
                {
                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "必须输入吧主信息");
                    ViewData["ManagerUserIds"]    = barSectionService.GetSectionManagers(section.SectionId).Select(n => n.UserId);
                    IBarSettingsManager manager  = DIContainer.Resolve <IBarSettingsManager>();
                    BarSettings         settings = manager.Get();
                    ViewData["SectionManagerMaxCount"] = settings.SectionManagerMaxCount;
                    return(View(model));
                }
                section.UserId = userId;
                if (!string.IsNullOrEmpty(logoImageFileName))
                {
                    section.LogoImage = logoImageFileName;
                }
                section.DisplayOrder = model.DisplayOrder ?? 100;
                barSectionService.Update(section, UserContext.CurrentUser.UserId, managerUserIds, stream);
                categoryService.ClearCategoriesFromItem(section.SectionId, 0, TenantTypeIds.Instance().BarSection());
                categoryService.AddItemsToCategory(new List <long> {
                    section.SectionId
                }, model.CategoryId, 0);

                TempData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Success, "更新成功");
                return(Redirect(SiteUrls.Instance().EditSection(model.SectionId)));
            }
        }
Ejemplo n.º 16
0
        public override void RegisterArea(AreaRegistrationContext context)
        {
            //广场首页是否以瀑布流显示
            string isWaterfall = MicroblogConfig.GetConfig(1001).ApplicationElement.Element("microblogSquare").Attribute("isWaterfall").Value;
            string actionName  = isWaterfall == "true" ? "Waterfall" : "Microblog";

            //对于IIS6.0默认配置不支持无扩展名的url
            string extensionForOldIIS = ".aspx";
            int    iisVersion         = 0;

            if (!int.TryParse(ConfigurationManager.AppSettings["IISVersion"], out iisVersion))
            {
                iisVersion = 7;
            }
            if (iisVersion >= 7)
            {
                extensionForOldIIS = string.Empty;
            }
            #region Channel

            context.MapRoute(
                "Channel_Microblog_Square",                                    // Route name
                "microblog/s-{sortBy}-{tagGroupId}" + extensionForOldIIS,      // URL with parameters
                new { controller = "ChannelMicroblog", action = "Microblog" }, // Parameter defaults
                new { sortBy = @"(\w+)|(\{\w+\})", tagGroupId = @"(\d+)|(\{\d+\})" } // Parameter defaults
                );

            context.MapRoute(
                "Channel_Microblog",              // Route name
                "microblog" + extensionForOldIIS, // URL with parameters
                new { controller = "ChannelMicroblog", action = actionName } // Parameter defaults
                );

            context.MapRoute(
                "Channel_Microblog_Topic",                                 // Route name
                "microblog/t-{topic}" + extensionForOldIIS,                // URL with parameters
                new { controller = "ChannelMicroblog", action = "Topic" }, // Parameter defaults
                new { topic = @"(\S+)|(\{\S+\})" } // Parameter defaults
                );

            context.MapRoute(
                "Channel_Microblog_Common",                // Route name
                "microblog/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "ChannelMicroblog", action = "Home" } // Parameter defaults
                );

            #endregion

            #region UserSpace

            context.MapRoute(
                "UserSpace_Microblog_Home",                        // Route name
                "u/{SpaceKey}/microbloghome" + extensionForOldIIS, // URL with parameters
                new { controller = "Microblog", action = "Mine", CurrentNavigationId = "11100102" } // Parameter defaults
                );

            context.MapRoute(
                "ApplicationCount_Microblog",                      // Route name
                "u/{SpaceKey}/microbloghome" + extensionForOldIIS, // URL with parameters
                new { controller = "Microblog", action = "Mine", CurrentNavigationId = "11100102" } // Parameter defaults
                );

            context.MapRoute(
                "UserSpace_Microblog_AtMe",                        // Route name
                "u/{SpaceKey}/microblogatme" + extensionForOldIIS, // URL with parameters
                new { controller = "Microblog", action = "ListReferred", CurrentNavigationId = "11100103" } // Parameter defaults
                );

            context.MapRoute(
                "UserSpace_Microblog_Favorites",                        // Route name
                "u/{SpaceKey}/microblogFavorites" + extensionForOldIIS, // URL with parameters
                new { controller = "Microblog", action = "ListFavorites", CurrentNavigationId = "11100104" } // Parameter defaults
                );

            context.MapRoute(
                "UserSpace_Microblog_Detail",                        // Route name
                "u/{SpaceKey}/m-{microblogId}" + extensionForOldIIS, // URL with parameters
                new { controller = "Microblog", action = "Detail" }, // Parameter defaults
                new { microblogId = @"(\d+)|(\{\d+\})" } // Parameter defaults
                );

            context.MapRoute(
                "UserSpace_Microblog_Common",                           // Route name
                "u/{SpaceKey}/microblog/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "Microblog", action = "ListMy" } // Parameter defaults

                );

            #region 动态列表控件路由

            context.MapRoute(
                string.Format("ActivityDetail_{0}_CreateMicroblog", TenantTypeIds.Instance().Microblog()), // Route name
                "microblog/activity/{ActivityId}" + extensionForOldIIS,                                    // URL with parameters
                new { controller = "MicroblogActivity", action = "_Microblog_Activity" } // Parameter defaults
                );

            context.MapRoute(
                string.Format("MicroblogActivity_Common", TenantTypeIds.Instance().Microblog()), // Route name
                "microblogactivity/{action}" + extensionForOldIIS,                               // URL with parameters
                new { controller = "MicroblogActivity" } // Parameter defaults
                );

            #endregion

            context.MapRoute(
                "Microblog_Common",                               // Route name
                "microblog/common/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "Microblog" } // Parameter defaults
                );

            #endregion UserSpace

            #region GroupSpace

            context.MapRoute(
                "Group_Microblog_Tag",                                              // Route name
                "g/{SpaceKey}/microblog/t-{tagName}" + extensionForOldIIS,          // URL with parameters
                new { controller = "GroupSpaceMicroblog", action = "TopicDetail" }, // Parameter defaults
                new { tagName = @"(\S+)|(\{\S+\})" } // Parameter defaults
                );

            context.MapRoute(
                "Group_Microblog_Detail",                                      // Route name
                "g/{SpaceKey}/microblog/m-{microblogId}" + extensionForOldIIS, // URL with parameters
                new { controller = "GroupSpaceMicroblog", action = "Detail" }, // Parameter defaults
                new { microblogId = @"(\d+)|(\{\d+\})" } // Parameter defaults
                );

            context.MapRoute(
                "Group_Microblog_Common",                               // Route name
                "g/{SpaceKey}/microblog/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "GroupSpaceMicroblog" } // Parameter defaults
                );
            #endregion

            #region ControlPanel

            context.MapRoute(
                "ControlPanel_Microblog_Home",                 // Route name
                "controlpanelmicroblogs" + extensionForOldIIS, // URL with parameters
                new { controller = "ControlPanelMicroblog", action = "ManageMicroblogs", CurrentNavigationId = "20100101" } // Parameter defaults
                );

            context.MapRoute(
                "ControlPanel_Microblog_Common",                       // Route name
                "controlpanelmicroblog/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "ControlPanelMicroblog", CurrentNavigationId = "20000010" } // Parameter defaults
                );

            //群组微博中管理发言
            context.MapRoute(
                "ControlPanel_GroupMicroblog_Common",                                // Route name
                "ControlPanelGroupMicroblogs/ManageMicroblogs" + extensionForOldIIS, // URL with parameters
                new { controller = "ControlPanelMicroblog", action = "ManageMicroblogs", CurrentNavigationId = "20101101", tenantTypeId = TenantTypeIds.Instance().Group() } // Parameter defaults
                );
            #endregion
        }
Ejemplo n.º 17
0
        public ActionResult ManageBars(ManageBarEditModel model, int pageIndex = 1)
        {
            pageResourceManager.InsertTitlePart("帖吧管理");

            //long userId = Request.QueryString.Gets<long>(model.UserId, new List<long>()).FirstOrDefault();

            BarSectionQuery query  = model.GetQuery();
            long            userId = Request.QueryString.Gets <long>("UserId", new List <long>()).FirstOrDefault();

            if (userId > 0)
            {
                query.UserId = userId;
            }
            ViewData["UserId"] = query.UserId;

            PagingDataSet <BarSection> sections = barSectionService.Gets(TenantTypeIds.Instance().Bar(), query, model.PageSize ?? 20, pageIndex);

            //为提升性能,批量获取吧主用户
            userService.GetFullUsers(sections.Select(n => n.UserId));
            ViewData["BarSections"] = sections;
            //foreach (var item in sections)
            //{
            //


            //    ViewData["BarSections-Category-" + item.SectionId] = categoryService.GetOwnerCategories(item.SectionId, TenantTypeIds.Instance().BarSection());
            //}



            PagingDataSet <Category> categories = categoryService.GetCategories(PubliclyAuditStatus.Success, TenantTypeIds.Instance().BarSection(), null, 1);



            ViewData["CategoryId"] = new SelectList(categories, "CategoryId", "CategoryName", model.CategoryId);


            //Dictionary<bool, string> enabledValues = new Dictionary<bool, string> { { true, "是" }, { false, "否" } };
            //ViewData["Enabled"] = new SelectList(enabledValues.Select(n => new { text = n.Value, value = n.Key.ToString().ToLower() }), "value", "text", model.Enabled);



            List <SelectListItem> enabledSelectLists = new List <SelectListItem> {
                new SelectListItem {
                    Text = "是", Value = true.ToString()
                },
                new SelectListItem {
                    Text = "否", Value = false.ToString()
                }
            };

            ViewData["Enabled"] = new SelectList(enabledSelectLists, "Value", "Text", model.Enabled);
            return(View(model));
        }
Ejemplo n.º 18
0
        public ActionResult EditTopic(TagEditModel tagEditModel)
        {
            System.IO.Stream stream = null;

            //是否创建
            bool isCreate = tagEditModel.TagId == 0;

            if (isCreate)
            {
                ViewData["editTopicTitle"] = "创建话题";
            }
            else
            {
                ViewData["editTopicTitle"] = "编辑话题";
            }

            TagService         tagService = new TagService(tagEditModel.TenantTypeId);
            IEnumerable <long> userIds    = Request.Form.Gets <long>("RelatedObjectIds");

            //是特色标签
            if (tagEditModel.IsFeatured)
            {
                HttpPostedFileBase tagLogo  = Request.Files["tagLogo"];
                string             fileName = tagLogo == null ? "" : tagLogo.FileName;
                if (string.IsNullOrEmpty(fileName) && string.IsNullOrEmpty(tagEditModel.FeaturedImage))
                {
                    //标签分组下拉框
                    SelectList topicGroups = GetTagGroupSelectList(tagEditModel.TopicGroupId, tagEditModel.TenantTypeId);
                    ViewData["topicGroups"] = topicGroups;

                    //取到用户设置的相关标签
                    ViewData["seletedUserIds"] = userIds;

                    ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "图片不能为空");

                    return(View(tagEditModel));
                }
                else if (!string.IsNullOrEmpty(fileName))
                {
                    //校验附件的扩展名
                    LogoSettings logoSettings = DIContainer.Resolve <ISettingsManager <LogoSettings> >().Get();
                    if (!logoSettings.ValidateFileExtensions(fileName))
                    {
                        //标签分组下拉框
                        SelectList topicGroups = GetTagGroupSelectList(tagEditModel.TopicGroupId, tagEditModel.TenantTypeId);
                        ViewData["topicGroups"] = topicGroups;

                        //取到用户设置的相关标签
                        ViewData["seletedUserIds"] = userIds;

                        ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, "只允许上传后缀名为 .gif .jpg .jpeg .png 的文件");

                        return(View(tagEditModel));
                    }

                    //校验附件的大小
                    TenantLogoSettings tenantLogoSettings = TenantLogoSettings.GetRegisteredSettings(TenantTypeIds.Instance().Tag());
                    if (!tenantLogoSettings.ValidateFileLength(tagLogo.ContentLength))
                    {
                        //标签分组下拉框
                        SelectList topicGroups = GetTagGroupSelectList(tagEditModel.TopicGroupId, tagEditModel.TenantTypeId);
                        ViewData["topicGroups"] = topicGroups;

                        //取到用户设置的相关标签
                        ViewData["seletedUserIds"] = userIds;

                        ViewData["StatusMessageData"] = new StatusMessageData(StatusMessageType.Error, string.Format("文件大小不允许超过{0}KB", tenantLogoSettings.MaxLogoLength));

                        return(View(tagEditModel));
                    }

                    stream = tagLogo.InputStream;
                    tagEditModel.FeaturedImage = fileName;
                }
            }

            //获取相关微博
            IEnumerable <long> seletedUserIds = userIds;

            //创建
            if (isCreate)
            {
                Tag tag = tagEditModel.AsTag();
                tagService.Create(tag, stream);

                //添加到分组
                if (tagEditModel.TopicGroupId > 0)
                {
                    tagService.BatchAddGroupsToTag(new List <long>()
                    {
                        tagEditModel.TopicGroupId
                    }, tagEditModel.TagName);
                }
            }//更新
            else
            {
                Tag tag = tagEditModel.AsTag();
                tagService.Update(tag, stream);

                //添加到分组
                if (tagEditModel.TopicGroupId > 0)
                {
                    tagService.BatchAddGroupsToTag(new List <long>()
                    {
                        tagEditModel.TopicGroupId
                    }, tagEditModel.TagName);
                }
            }

            return(RedirectToAction("ManageMicroblogTopics"));
        }
Ejemplo n.º 19
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);
        }
Ejemplo n.º 20
0
        public override void RegisterArea(AreaRegistrationContext context)
        {
            //对于IIS6.0默认配置不支持无扩展名的url
            string extensionForOldIIS = ".html";
            int    iisVersion         = 0;

            if (!int.TryParse(ConfigurationManager.AppSettings["IISVersion"], out iisVersion))
            {
                iisVersion = 7;
            }
            if (iisVersion >= 7)
            {
                extensionForOldIIS = string.Empty;
            }

            #region Channel
            //日志频道首页
            context.MapRoute(
                "Channel_Blog_Home",         // Route name
                "Blog" + extensionForOldIIS, // URL with parameters
                new { controller = "ChannelBlog", action = "Home", CurrentNavigationId = "10100202" } // Parameter defaults
                );

            //站点分类
            context.MapRoute(
                "Channel_Blog_SiteCategory",                                                  // Route name
                "Blog/c-{categoryId}-{pageIndex}" + extensionForOldIIS,                       // URL with parameters
                new { controller = "ChannelBlog", action = "ListByCategory", pageIndex = 1 }, // Parameter defaults
                new { categoryId = @"(\d+)|(\{\d+\})", pageIndex = @"(\d+)|(\{\d+\})" }
                );

            //标签
            context.MapRoute(
                "Channel_Blog_Tag",                                                                         // Route name
                "Blog/t-{tagName}" + extensionForOldIIS,                                                    // URL with parameters
                new { controller = "ChannelBlog", action = "ListByTag", CurrentNavigationId = "10100201" }, // Parameter defaults
                new { tagName = @"(\S+)|(\{\S+\})" }
                );

            context.MapRoute(
                "Channel_Blog_Rank",                                                                                        // Route name
                "Blog/Rank-{rank}-{pageIndex}" + extensionForOldIIS,                                                        // URL with parameters
                new { controller = "ChannelBlog", action = "ListByRank", CurrentNavigationId = "10100201", pageIndex = 1 }, // Parameter defaults
                new { pageIndex = @"(\d+)|(\{\d+\})" }
                );

            context.MapRoute(
                "Channel_Blog_Common",                // Route name
                "Blog/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "ChannelBlog", action = "Home" } // Parameter defaults
                );

            #endregion

            #region UserSpace

            //日志首页
            context.MapRoute(
                "UserSpace_Blog_Home",                        // Route name
                "u/{SpaceKey}/BlogHome" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Home", CurrentNavigationId = "11100202" } // Parameter defaults
                );


            //日志首页
            context.MapRoute(
                "UserSpace_Blog_Subscribed",                        // Route name
                "u/{SpaceKey}/BlogSubscribed" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Subscribed", CurrentNavigationId = "11100204" } // Parameter defaults
                );

            //我的日志/他的日志
            context.MapRoute(
                "UserSpace_Blog_Blog",                    // Route name
                "u/{SpaceKey}/Blog" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Blog", CurrentNavigationId = "11100203" } // Parameter defaults
                );

            //我的日志/他的日志
            context.MapRoute(
                "ApplicationCount_Blog",                  // Route name
                "u/{SpaceKey}/Blog" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Blog", CurrentNavigationId = "11100203" } // Parameter defaults
                );

            //日志详细页
            context.MapRoute(
                "UserSpace_Blog_Detail",                          // Route name
                "u/{SpaceKey}/B-{threadId}" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Detail" },   // Parameter defaults
                new { threadId = @"(\d+)|(\{\d+\})" }
                );

            //创建日志
            context.MapRoute(
                "UserSpace_Blog_Create",                         // Route name
                "u/{SpaceKey}/Blog/Create" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Edit" } // Parameter defaults
                );

            //编辑日志
            context.MapRoute(
                "UserSpace_Blog_Edit",                                    // Route name
                "u/{SpaceKey}/Blog/Edit-{threadId}" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Edit" },             // Parameter defaults
                new { threadId = @"(\d+)|(\{\d+\})" }
                );

            //日志列表页-存档
            context.MapRoute(
                "UserSpace_Blog_List_Archive",                                      // Route name
                "u/{SpaceKey}/Blog-{listType}-{year}-{month}" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "List", month = 0 },            // Parameter defaults
                new { year = @"(\d+)|(\{\d+\})", month = @"(\d+)|(\{\d+\})" }
                );

            //日志列表页-分类
            context.MapRoute(
                "UserSpace_Blog_List_Category",                                   // Route name
                "u/{SpaceKey}/Blog-{listType}-{categoryId}" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "List" },                     // Parameter defaults
                new { categoryId = @"(\d+)|(\{\d+\})" }
                );

            //日志列表页-标签
            context.MapRoute(
                "UserSpace_Blog_List_Tag",                                 // Route name
                "u/{SpaceKey}/Blog-{listType}-{tag}" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "List" },              // Parameter defaults
                new { tag = @"(\S+)|(\{\S+\})" }
                );

            context.MapRoute(
                "UserSpace_Blog_Common",                           // Route name
                "u/{SpaceKey}/Blog/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "Blog", action = "Home" } // Parameter defaults
                );

            #endregion UserSpace

            #region 动态列表控件路由

            context.MapRoute(
                string.Format("ActivityDetail_{0}_CreateBlogThread", TenantTypeIds.Instance().BlogThread()), // Route name
                "BlogActivity/CreateThread/{ActivityId}" + extensionForOldIIS,                               // URL with parameters
                new { controller = "BlogActivity", action = "_CreateBlogThread" } // Parameter defaults
                );

            context.MapRoute(
                string.Format("ActivityDetail_{0}_CreateBlogComment", TenantTypeIds.Instance().Comment()), // Route name
                "BlogActivity/CreateComment/{ActivityId}" + extensionForOldIIS,                            // URL with parameters
                new { controller = "BlogActivity", action = "_CreateBlogComment" } // Parameter defaults
                );

            #endregion

            #region ControlPanel
            context.MapRoute(
                "ControlPanel_Blog_Home",                                     // Route name
                "ControlPanel/Content/Blog/ManageBlogs" + extensionForOldIIS, // URL with parameters
                new { controller = "ControlPanelBlog", action = "ManageBlogs", CurrentNavigationId = "20100201" } // Parameter defaults
                );

            context.MapRoute(
                "ControlPanel_Blog_Common",                                // Route name
                "ControlPanel/Content/Blog/{action}" + extensionForOldIIS, // URL with parameters
                new { controller = "ControlPanelBlog", CurrentNavigationId = "20000010" } // Parameter defaults
                );

            #endregion
        }
Ejemplo n.º 21
0
        public ActionResult _SetCategory(string threadIds)
        {
            IEnumerable <Category> categorys    = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread());
            SelectList             categoryList = new SelectList(categorys.Select(n => new { text = n.CategoryName, value = n.CategoryId }), "value", "text", categorys.First().CategoryId);

            ViewData["categoryList"] = categoryList;
            return(View());
        }
Ejemplo 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());
        }
Ejemplo n.º 23
0
        public ActionResult _SetCategories(string spaceKey, IEnumerable <long> threadIds, IEnumerable <long> categoryIds)
        {
            IUser currentUser = UserContext.CurrentUser;

            if (categoryIds != null && categoryIds.Count() > 0)
            {
                foreach (long threadId in threadIds)
                {
                    BlogThread blogThread = blogService.Get(threadId);
                    if (authorizer.BlogThread_Edit(blogThread))
                    {
                        //清除用户分类
                        categoryService.ClearCategoriesFromItem(threadId, currentUser.UserId, TenantTypeIds.Instance().BlogThread());

                        //设置用户分类
                        categoryService.AddCategoriesToItem(categoryIds, threadId);
                    }
                    else
                    {
                        return(Json(new StatusMessageData(StatusMessageType.Error, "无权操作!")));
                    }
                }
            }

            return(Json(new StatusMessageData(StatusMessageType.Success, "设置分类成功!")));
        }
Ejemplo n.º 24
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);
        }
Ejemplo n.º 25
0
        public ActionResult _Reproduce(string spaceKey, long threadId)
        {
            BlogThread blogThread = blogService.Get(threadId);

            if (blogThread == null)
            {
                return(HttpNotFound());
            }

            if (UserContext.CurrentUser.UserId == blogThread.UserId)
            {
                return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                {
                    Title = "无效操作",
                    Body = "不能转载自己的文章",
                    StatusMessageType = StatusMessageType.Hint
                })));
            }

            BlogThreadEditModel model = new BlogThreadEditModel()
            {
                PrivacyStatus = PrivacyStatus.Public
            };

            model.ThreadId = threadId;

            //文章用户分类下拉列表
            IEnumerable <Category> ownerCategories = categoryService.GetOwnerCategories(UserContext.CurrentUser.UserId, TenantTypeIds.Instance().BlogThread());

            ViewData["ownerCategories"] = new SelectList(ownerCategories, "CategoryId", "CategoryName", null);

            return(View(model));
        }
Ejemplo n.º 26
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()));
        }
Ejemplo n.º 27
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));
            }

            ViewData["User"] = blogThread.User;
            return(View(blogThread));
        }
Ejemplo n.º 28
0
        public ActionResult EditSection(long?sectionId = null)
        {
            pageResourceManager.InsertTitlePart("帖吧设置");
            if (sectionId.HasValue)
            {
                BarSection section = barSectionService.Get(sectionId ?? 0);
                if (section == null)
                {
                    return(HttpNotFound());
                }
                ViewData["UserId"]         = section.UserId;
                ViewData["ManagerUserIds"] = barSectionService.GetSectionManagers(sectionId ?? 0).Select(n => n.UserId);
                IBarSettingsManager manager  = DIContainer.Resolve <IBarSettingsManager>();
                BarSettings         settings = manager.Get();
                ViewData["SectionManagerMaxCount"] = settings.SectionManagerMaxCount;

                BarSectionEditModel    model      = section.AsEditModel();
                IEnumerable <Category> categories = categoryService.GetCategoriesOfItem(section.SectionId, 0, TenantTypeIds.Instance().BarSection());
                if (categories != null && categories.Count() > 0)
                {
                    model.CategoryId = categories.ElementAt(0).CategoryId;
                }

                return(View(model));
            }
            else
            {
                ViewData["UserId"] = UserContext.CurrentUser.UserId;
            }
            return(View(new BarSectionEditModel()));
        }
Ejemplo n.º 29
0
        public ActionResult Edit(string spaceKey, long?threadId, long?ownerId)
        {
            BlogThreadEditModel model      = null;
            BlogThread          blogThread = null;

            //文章用户分类下拉列表
            IEnumerable <Category> ownerCategories = null;

            //写文章
            if (!threadId.HasValue)
            {
                string errorMessage = string.Empty;
                if (!authorizer.BlogThread_Create(spaceKey, out errorMessage))
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Title = "没有权限",
                        Body = errorMessage,
                        StatusMessageType = StatusMessageType.Hint
                    })));
                }

                model = new BlogThreadEditModel()
                {
                    PrivacyStatus = PrivacyStatus.Public
                };
                if (ownerId.HasValue)
                {
                    model.OwnerId = ownerId;
                }

                //获取所有者分类
                if (ownerId.HasValue)
                {
                    ownerCategories = categoryService.GetOwnerCategories(ownerId.Value, TenantTypeIds.Instance().BlogThread());
                }
                else
                {
                    ownerCategories = categoryService.GetOwnerCategories(UserContext.CurrentUser.UserId, TenantTypeIds.Instance().BlogThread());
                }

                pageResourceManager.InsertTitlePart("写文章");
            }

            //编辑文章
            else
            {
                blogThread = blogService.Get(threadId.Value);
                if (blogThread == null)
                {
                    return(HttpNotFound());
                }

                if (!authorizer.BlogThread_Edit(blogThread))
                {
                    return(Redirect(SiteUrls.Instance().SystemMessage(TempData, new SystemMessageViewModel
                    {
                        Title = "没有权限",
                        Body = "没有权限编辑" + blogThread.Subject + "!",
                        StatusMessageType = StatusMessageType.Hint
                    })));
                }

                Dictionary <int, IEnumerable <ContentPrivacySpecifyObject> > privacySpecifyObjects = contentPrivacyService.GetPrivacySpecifyObjects(TenantTypeIds.Instance().BlogThread(), blogThread.ThreadId);
                if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().User()))
                {
                    IEnumerable <ContentPrivacySpecifyObject> userPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().User()];
                    ViewData["userPrivacySpecifyObjects"] = string.Join(",", userPrivacySpecifyObjects.Select(n => n.SpecifyObjectId));
                }
                if (privacySpecifyObjects.ContainsKey(SpecifyObjectTypeIds.Instance().UserGroup()))
                {
                    IEnumerable <ContentPrivacySpecifyObject> userGroupPrivacySpecifyObjects = privacySpecifyObjects[SpecifyObjectTypeIds.Instance().UserGroup()];
                    ViewData["userGroupPrivacySpecifyObjects"] = string.Join(",", userGroupPrivacySpecifyObjects.Select(n => n.SpecifyObjectId));
                }

                model = blogThread.AsEditModel();

                //获取所有者分类
                ownerCategories = categoryService.GetOwnerCategories(blogThread.OwnerId, TenantTypeIds.Instance().BlogThread());

                IEnumerable <Category>      selectedOwnerCategories = blogThread.OwnerCategories;
                Dictionary <long, Category> ownerCategoryDic        = new Dictionary <long, Category>();
                if (selectedOwnerCategories != null && selectedOwnerCategories.Count() > 0)
                {
                    ownerCategoryDic = selectedOwnerCategories.ToDictionary(n => n.CategoryId, n => n);
                }
                ViewData["ownerCategoryDic"] = ownerCategoryDic;

                pageResourceManager.InsertTitlePart("编辑文章");
            }

            ViewData["ownerCategories"] = ownerCategories;

            //文章站点分类下拉列表(投稿到)
            if (blogSettings.AllowSetSiteCategory)
            {
                IEnumerable <Category> siteCategories = categoryService.GetOwnerCategories(0, TenantTypeIds.Instance().BlogThread());
                ViewData["siteCategories"] = new SelectList(siteCategories, "CategoryId", "CategoryName", blogThread == null ? null : blogThread.SiteCategoryId);
            }

            return(View(model));
        }
Ejemplo n.º 30
0
        /// <summary>
        /// 照片搜索
        /// </summary>
        /// <param name="query">条件</param>
        /// <returns></returns>
        public ActionResult Search(PhotoFullTextQuery query)
        {
            query.Keyword      = WebUtility.UrlDecode(query.Keyword);
            query.TenantTypeId = TenantTypeIds.Instance().User();
            query.PageSize     = 20;
            IUser currentUser = UserContext.CurrentUser;

            if (currentUser != null)
            {
                if (currentUser.UserId == query.UserId)
                {
                    query.IgnoreAuditAndPrivacy = true;
                }
            }


            ViewData["keyword"] = query.Keyword;
            ViewData["filter"]  = query.Filter;
            ViewData["userId"]  = query.UserId;

            //调用搜索器进行搜索
            PhotoSearcher         photoSearcher = (PhotoSearcher)SearcherFactory.GetSearcher(PhotoSearcher.CODE);
            PagingDataSet <Photo> photos        = photoSearcher.Search(query);

            int minus = 0;

            foreach (var photo in photos)
            {
                bool isCurrentUser = true;
                if (currentUser != null)
                {
                    isCurrentUser = query.UserId == currentUser.UserId ? true : photo.AuditStatus == AuditStatus.Success;
                }
                if (!(authorizer.Photo_Search(photo.Album) && isCurrentUser))
                {
                    minus++;
                }
            }
            ViewData["minus"] = minus;

            //添加到用户搜索历史记录

            if (currentUser != null)
            {
                if (!string.IsNullOrWhiteSpace(query.Keyword))
                {
                    searchHistoryService.SearchTerm(currentUser.UserId, PhotoSearcher.CODE, query.Keyword);
                }
            }

            //添加到热词
            if (!string.IsNullOrWhiteSpace(query.Keyword))
            {
                searchedTermService.SearchTerm(PhotoSearcher.CODE, query.Keyword);
            }

            //设置页面Meta
            if (string.IsNullOrWhiteSpace(query.Keyword))
            {
                pageResourceManager.InsertTitlePart("照片搜索");
            }
            else
            {
                pageResourceManager.InsertTitlePart(query.Keyword + "的相关照片");
            }

            return(View(photos));
        }