コード例 #1
0
        /// <summary>
        /// 编辑列表
        /// </summary>
        /// <param name="CollectionId"></param>
        /// <returns></returns>
        public ActionResult PostList(string CollectionId = "")
        {
            if (Session[ConstHelper.Session_USERID] == null)
            {
                return(Redirect("/Home/Index"));
            }
            string OwnerId        = Session[ConstHelper.Session_USERID].ToString();
            var    collectionlist = Collection.GetCollectionListByOwnerId(OwnerId);

            ViewBag.CollectionId   = CollectionId;
            ViewBag.CollectionList = collectionlist;
            if (collectionlist.Count == 0)
            {
                //如果没有文集,则什么都不显示
                ViewData.Model = new List <ArticleItemBody>();
            }
            else
            {
                //显示第一个或者指定文集
                var CurrentCollectionId = string.IsNullOrEmpty(CollectionId) ? collectionlist[0].Sn : CollectionId;
                //自己的文章,则并非只是发布到首页的
                var ArticleList = Article.GetArticleByColIdAndPublish(CurrentCollectionId, false);
                ViewData.Model       = ArticleListManager.GetArticleItemBodyListByArticleList(ArticleList);
                ViewBag.CollectionId = CurrentCollectionId;
            }
            ViewBag.Title = "列表";
            return(View());
        }
コード例 #2
0
        /// <summary>
        /// 文集内文章列表
        /// </summary>
        /// <param name="CollectionId"></param>
        /// <returns></returns>
        public ActionResult CollectionList(string CollectionId)
        {
            if (string.IsNullOrEmpty(CollectionId))
            {
                return(Redirect("/"));
            }
            //文章展示页面,链接到该文章所属文集,所以是对于大众的,只要是 发布的 ,不论是否在首页
            var ArticleList = Article.GetArticleByColIdAndPublish(CollectionId, true);

            ViewData.Model = ArticleListManager.GetArticleItemBodyListByArticleList(ArticleList);
            var Col = Collection.GetCollectionBySn(CollectionId);

            ViewBag.Title = Col.Title;
            return(View());
        }
コード例 #3
0
        /// <summary>
        /// 检索
        /// </summary>
        /// <returns></returns>
        public ActionResult Search(int PageNo = 1)
        {
            //先从Post里面获得
            string KeyWord = Request.Form["txtKeyword"];

            if (string.IsNullOrEmpty(KeyWord))
            {
                //再从URL中取得
                KeyWord = Request.QueryString["Keyword"];
            }

            if (string.IsNullOrEmpty(KeyWord))
            {
                //两次取得都为空的话,退出
                return(Redirect("/"));
            }
            ViewBag.KeyWord = KeyWord;
            ViewBag.Title   = KeyWord + "的检索结果";
            string SearchMethod   = ConfigurationManager.AppSettings["SearchMethod"];
            var    resultArticles = new List <Article>();

            switch (SearchMethod)
            {
            case ConstHelper.MongoTextSearch:
                //设置Text索引用以检索(ElasticSearch)
                resultArticles = Article.Search(KeyWord);
                break;

            case ConstHelper.ElasticSearch:
                resultArticles = SearchManager.Search(KeyWord, nameof(Article.Title));
                break;
            }
            //公开发布的文章
            resultArticles = resultArticles.Where((x) => { return(!x.IsPrivate && x.PublishStatus == ApproveStatus.Accept); }).ToList();
            var resultArticleItems = ArticleListManager.GetArticleItemBodyListByArticleList(resultArticles);

            //按照评分排序
            resultArticleItems.Sort((x, y) => { return(y.Score.CompareTo(x.Score)); });
            Pages p = new Pages(resultArticles.Count, 20)
            {
                CurrentPageNo = PageNo
            };

            ViewBag.Pages  = p;
            ViewData.Model = p.GetList(resultArticleItems);
            return(View());
        }
コード例 #4
0
        /// <summary>
        /// 标签列表
        /// </summary>
        /// <param name="TagName"></param>
        /// <returns></returns>
        public ActionResult TagList(string TagName, int PageNo = 1)
        {
            var   articles = Article.GetArticleListByTag(TagName);
            Pages p        = new Pages(articles.Count, 50)
            {
                CurrentPageNo = PageNo
            };

            ViewBag.TagArticleCnt = articles.Count;
            ViewBag.Pages         = p;
            var articlebodys = ArticleListManager.GetArticleItemBodyListByArticleList(p.GetList(articles));

            ViewBag.MostAuthorByTag = ASideColumnManager.GetMostAuthorByTag(TagName, 10);
            ViewData.Model          = articlebodys;
            ViewBag.TagStockCnt     = articlebodys.Sum((x) => { return(x.StockCnt); });
            ViewBag.Title           = TagName;
            return(View());
        }
コード例 #5
0
        /// <summary>
        /// 作者页
        /// </summary>
        /// <param name="accountid"></param>
        /// <returns></returns>
        public ActionResult Index(string CollectionId, string accountid)
        {
            if (accountid == null)
            {
                return(Redirect("/"));
            }
            var user = UserInfo.GetUserInfoBySn(accountid);

            if (user == null)
            {
                return(Redirect("/"));
            }

            var collectionlist = Collection.GetCollectionListByOwnerId(accountid);

            if (CollectionId == "0")
            {
                if (collectionlist.Count > 0)
                {
                    CollectionId = collectionlist[0].Sn;
                }
            }

            ViewBag.CollectionId   = CollectionId;
            ViewBag.CollectionList = collectionlist;
            if (collectionlist.Count == 0)
            {
                //如果没有文集,则什么都不显示
                ViewBag.CollectionArticles = new List <Article>();
            }
            else
            {
                //显示第一个或者指定文集
                var CurrentCollectionId = string.IsNullOrEmpty(CollectionId) ? collectionlist[0].Sn : CollectionId;
                ArticleListManager.ArticleQueryFilter aqf = new ArticleListManager.ArticleQueryFilter()
                {
                    collectionid = CurrentCollectionId,
                    isPrivate    = false,
                    statuslist   = new ApproveStatus[] { ApproveStatus.Accept, ApproveStatus.NotNeed }
                };
                if (Session[ConstHelper.Session_USERID] != null && Session[ConstHelper.Session_USERID].ToString().Equals(accountid))
                {
                    //自己看自己
                    aqf.isPrivate  = null;
                    aqf.statuslist = null;
                }
                var ArticleList = ArticleListManager.GetArticleItemBodyListByArticleList(ArticleListManager.GetArticles(aqf));
                ViewBag.CollectionArticles = ArticleList;
            }
            var userbody = UserManager.GetUserBody(accountid);

            ViewData.Model = userbody;
            ViewBag.Title  = user.NickName;
            ArticleListManager.ArticleQueryFilter publicAQF = new ArticleListManager.ArticleQueryFilter()
            {
                ownid      = accountid,
                isPrivate  = false,
                statuslist = new ApproveStatus[] { ApproveStatus.Accept, ApproveStatus.NotNeed }
            };
            var articles    = ArticleListManager.GetArticles(publicAQF);
            var rankContain = TagUtility.Statistics(articles);

            ViewBag.PersonalTagAside   = ASideColumnManager.CreateTagRankAside(rankContain, 10);
            ViewBag.PersonalHobbyAside = ASideColumnManager.TagHobby(accountid, 10);
            ViewBag.RankTagDic         = rankContain.RankKeyDic;
            return(View());
        }