Пример #1
0
        public string GetArticleByTopic(string DetailTopic, string articleid, string isPreview)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            PSCPortal.CMS.Article article = isPreview != null?PSCPortal.CMS.Article.GetArticleUnPublish(articleid) : PSCPortal.CMS.Article.GetArticleByDescription(articleid, DetailTopic);

            //if (articleid == null)
            //    return;
            //if (article.Id == Guid.Empty)
            //    return;
            PSCPortal.CMS.ArticleCollection articleCollection;
            PSCPortal.CMS.Topic             topic = PSCPortal.CMS.Topic.GetTopicPrimary(article.Id.ToString());

            if (topic != null)
            {
                string chuoi = "";
                chuoi = chuoi + " <a style='color:#666;' href=/?TopicId=" + topic.Id.ToString() + ">" + topic.Name + " </a> ";
                dic.Add("TopicId", topic.Id.ToString());
                dic.Add("TopicName", topic.Name);
                dic.Add("ListTopic", chuoi);
                dic.Add("ArticleCreatedDate", article.CreatedDate);
                dic.Add("ArticleTitle", article.Title);
                dic.Add("ArticleId", article.Id.ToString());
                dic.Add("ArticleDescription", PSCPortal.CMS.Article.GetDescription(article.Id));
                dic.Add("ArticleContent", PSCPortal.CMS.Article.GetContent(article.Id));
                articleCollection = PSCPortal.CMS.ArticleCollection.GetArticleCollectionPublish(topic);
                int index = 0;
                for (; index < articleCollection.Count; index++)
                {
                    if (articleCollection[index].Id.ToString() == articleid)
                    {
                        break;
                    }
                }

                IEnumerable <PSCPortal.CMS.Article> it = articleCollection.Skip(index + 1).Take(10);
                dic.Add("oldListArticle", it);

                ///////////Commnet//////////////

                PSCPortal.CMS.ArticleCommentCollection commentList = PSCPortal.CMS.ArticleCommentCollection.GetArticleCommentPublicCollection(article.Id);
                //if (commentList.Count == 0)
                //    pnCommnet.Visible = false;

                IEnumerable <PSCPortal.CMS.ArticleComment> commentDB = commentList.Take(5);
                dic.Add("commentList", commentDB);
                //RadListView1.DataSource = commentDB;
                //RadListView1.DataBind();
                //if (articleCollection.Count == 1)
                //    pnCactinkhac.Visible = false;
            }
            System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
            return(js.Serialize(dic));
        }
Пример #2
0
        public string GetOrtherArticles(string articleId)
        {
            List <Article> articleCollection;

            PSCPortal.CMS.Topic   topic   = PSCPortal.CMS.Topic.GetTopicPrimary(articleId);
            PSCPortal.CMS.Article article = PSCPortal.CMS.Article.GetArticle(articleId);
            int OrtherArticleNumber       = int.Parse(System.Configuration.ConfigurationManager.AppSettings["OrtherArticleNumber"]);

            if (topic != null)
            {
                articleCollection = PSCPortal.CMS.ArticleCollection.GetArticleCollectionPublish(topic).ToList();
                int index = 0;
                for (; index < articleCollection.Count; index++)
                {
                    if (articleCollection[index].Id.ToString() == articleId)
                    {
                        break;
                    }
                }

                articleCollection = articleCollection.Skip(index + 1).Take(OrtherArticleNumber).ToList();
            }
            else
            {
                PSCPortal.CMS.TopicCollection TopicCollection = PSCPortal.CMS.TopicCollection.GetTopicCollectionByArticleId(articleId);

                List <string> listobj = new List <string>();
                foreach (PSCPortal.CMS.Topic item in TopicCollection)
                {
                    if (item.Id != Guid.Empty)
                    {
                        listobj.Add(item.Id.ToString());
                    }
                }
                articleCollection = PSCPortal.CMS.ArticleCollection.GetListArticleOld(article.CreatedDate, listobj).Take(OrtherArticleNumber).ToList();
            }
            //List<Article> resultList = GetArticleCollectionList(topicId, startIndex, size);
            JavaScriptSerializer js = new JavaScriptSerializer();

            return(js.Serialize(articleCollection));
        }
Пример #3
0
        protected void LoadData()
        {
            string articleid = Page.RouteData.Values["Id"] != null ? Page.RouteData.Values["Id"].ToString() : Request.QueryString["ArticleId"];
            int    index1    = articleid.IndexOf("/");
            int    review    = articleid.IndexOf("Preview");

            if (index1 > 0)
            {
                articleid = articleid.Substring(0, index1);
            }
            PSCPortal.CMS.Article article = review > -1 ? PSCPortal.CMS.Article.GetArticleUnPublish(articleid) : PSCPortal.CMS.Article.GetArticle(articleid);
            if (articleid == null)
            {
                return;
            }
            if (article.Id == Guid.Empty)
            {
                return;
            }
            PSCPortal.CMS.ArticleCollection articleCollection;
            PSCPortal.CMS.Topic             topic = PSCPortal.CMS.Topic.GetTopicPrimary(article.Id.ToString());
            if (topic != null)
            {
                string chuoi = "";
                TopicId            = topic.Id.ToString();
                chuoi              = chuoi + " <a style='color:#666;' href=/?TopicId=" + TopicId + ">" + topic.Name + " </a> ";
                ListTopic          = chuoi;
                ArticleCreatedDate = article.CreatedDate;
                ArticleTitle       = article.Title;
                ArticleId          = article.Id.ToString();
                IsVisibleComment   = PSCPortal.CMS.Article.CheckVisibleComment(article.Id);
                articleCollection  = PSCPortal.CMS.ArticleCollection.GetArticleCollectionPublish(topic);
                int index = 0;
                for (; index < articleCollection.Count; index++)
                {
                    if (articleCollection[index].Id.ToString() == articleid)
                    {
                        break;
                    }
                }
                int OrtherArticleNumber = int.Parse(System.Configuration.ConfigurationManager.AppSettings["OrtherArticleNumber"]);
                IEnumerable <PSCPortal.CMS.Article> it = articleCollection.Skip(index + 1).Take(OrtherArticleNumber);
                rptArticleOld.DataSource = it;
                rptArticleOld.DataBind();
                if (articleCollection.Count == 1)
                {
                    pnCactinkhac.Visible = false;
                }
            }
            else
            {
                PSCPortal.CMS.TopicCollection TopicCollection = PSCPortal.CMS.TopicCollection.GetTopicCollectionByArticleId(article.Id.ToString());
                string        chuoi   = "";
                List <string> listobj = new List <string>();
                foreach (PSCPortal.CMS.Topic item in TopicCollection)
                {
                    if (item.Id != Guid.Empty)
                    {
                        chuoi = chuoi + " <a style='color:#666;' href='/?TopicId=" + item.Id + "'> " + item.Name + " </a> ";
                        listobj.Add(item.Id.ToString());
                    }
                }

                ListTopic                = chuoi;
                ArticleCreatedDate       = article.CreatedDate;
                ArticleTitle             = article.Title;
                ArticleId                = article.Id.ToString();
                IsVisibleComment         = article.IsVisibleComment.HasValue ? article.IsVisibleComment : false;
                articleCollection        = PSCPortal.CMS.ArticleCollection.GetListArticleOld(article.CreatedDate, listobj);
                rptArticleOld.DataSource = articleCollection;
                rptArticleOld.DataBind();
                if (articleCollection.Count == 0)
                {
                    pnCactinkhac.Visible = false;
                }
            }
            /////////Commment//////////////
            PSCPortal.CMS.ArticleCommentCollection commentList = PSCPortal.CMS.ArticleCommentCollection.GetArticleCommentPublicCollection(article.Id);
            //if (commentList.Count == 0)
            //   pnCommnet.Visible = false;
            //IEnumerable<PSCPortal.CMS.ArticleComment> commentDB = commentList.Take(5);
            //RadListView1.DataSource = commentDB;
            //RadListView1.DataBind();
            article.IncViewTime();
            UserLogin.ArticleId = article.Id.ToString();
        }