Beispiel #1
0
        protected void LoadNewsinBrief()
        {
            using (
                SqlConnection con =
                    new SqlConnection(
                        System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"]
                        .ConnectionString))
            {
                SqlCommand com = new SqlCommand {
                    Connection = con
                };
                con.Open();
                com.CommandType = System.Data.CommandType.Text;
                com.Parameters.AddWithValue("@dataId", Portlet.PortletInstance.Id);
                com.CommandText = "select TopicId From PortletNewsInBrief Where DataId=@dataId";

                Object topicGuid = com.ExecuteScalar();
                if (topicGuid != null)
                {
                    CMS.Topic topic = CMS.Topic.GetTopic(topicGuid.ToString());
                    if (topic != null)
                    {
                        TopicName = topic.Name;
                        CMS.ArticleCollection artCol = CMS.ArticleCollection.GetArticleCollectionPublish(topic);
                        RPDisplay.DataSource = artCol;
                        RPDisplay.DataBind();
                    }
                }
            }
        }
Beispiel #2
0
        private void LoadData()
        {
            Object topicGuid = null;
            int    numberOfArticlesDisplay = 0;

            using (
                SqlConnection con =
                    new SqlConnection(
                        System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"]
                        .ConnectionString))
            {
                SqlCommand com = new SqlCommand();
                com.Connection = con;
                con.Open();
                com.CommandType = System.Data.CommandType.Text;
                com.Parameters.AddWithValue("@dataId", Portlet.PortletInstance.Id);
                com.CommandText = "select TopicId,NumberOfArticlesDisplay From PortletTopicDisplay Where DataId=@dataId";

                SqlDataReader reader = com.ExecuteReader();
                if (reader.Read())
                {
                    topicGuid = (Guid)reader["TopicId"];
                    numberOfArticlesDisplay = int.Parse(reader["NumberOfArticlesDisplay"].ToString());
                }
            }
            if (topicGuid == null)
            {
                return;
            }

            CMS.Topic topicDisplay = CMS.Topic.GetTopic(topicGuid.ToString());
            if (topicDisplay != null)
            {
                //thay đổi ngày 6/5/2014
                TopicName = topicDisplay.Name;
                TopicId   = topicDisplay.Id.ToString();
                CMS.ArticleCollection     arList     = CMS.ArticleCollection.GetArticleCollectionPublish(topicDisplay);
                CMS.ArticleCollection     arListHang = CMS.ArticleCollection.GetArticleCollectionPublishHang(topicDisplay);
                IEnumerable <CMS.Article> iArt1      = arList.Where(a => !arListHang.Contains(a)).Take(numberOfArticlesDisplay - arListHang.Count());
                foreach (var item in iArt1)
                {
                    arListHang.Add(item);
                }
                if (arListHang.Count() == 0)
                {
                    return;
                }
                CMS.Article article = arListHang.Take(1).Single();
                ArticleId    = article.Id.ToString();
                ArticleTitle = article.Title;
                CMS.Article article2 = arListHang.Skip(1).Take(1).Single();
                ArticleId2    = article2.Id.ToString();
                ArticleTitle2 = article2.Title;
                rptArticleRelation.DataSource = arListHang.Skip(2);
                rptArticleRelation.DataBind();
            }
        }
Beispiel #3
0
        private void LoadData()
        {
            Object topicGuid = null;
            int    numberOfArticlesDisplay = 0;

            using (
                SqlConnection con =
                    new SqlConnection(
                        System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"]
                        .ConnectionString))
            {
                SqlCommand com = new SqlCommand();
                com.Connection = con;
                con.Open();
                com.CommandType = System.Data.CommandType.Text;
                com.Parameters.AddWithValue("@dataId", Portlet.PortletInstance.Id);
                com.CommandText = "select TopicId,NumberOfArticlesDisplay From PortletTopicDisplay Where DataId=@dataId";

                SqlDataReader reader = com.ExecuteReader();
                if (reader.Read())
                {
                    topicGuid = (Guid)reader["TopicId"];
                    numberOfArticlesDisplay = int.Parse(reader["NumberOfArticlesDisplay"].ToString());
                }
            }
            if (topicGuid == null)
            {
                return;
            }

            CMS.Topic   topicDisplay = CMS.Topic.GetTopic(topicGuid.ToString());
            SliderTopic result       = new SliderTopic();

            if (topicDisplay != null)
            {
                //thay đổi ngày 6/5/2014

                CMS.ArticleCollection     arList     = CMS.ArticleCollection.GetArticleCollectionPublish(topicDisplay);
                CMS.ArticleCollection     arListHang = CMS.ArticleCollection.GetArticleCollectionPublishHang(topicDisplay);
                IEnumerable <CMS.Article> iArt1      = arList.Where(a => !arListHang.Contains(a)).Take(numberOfArticlesDisplay - arListHang.Count());
                foreach (var item in iArt1)
                {
                    arListHang.Add(item);
                }
                var js = new JavaScriptSerializer();
                Dictionary <string, object> resultDic = new Dictionary <string, object>();
                resultDic["ResultList"] = arListHang;
                resultDic["TopicId"]    = topicDisplay.Id;
                resultDic["TopicName"]  = topicDisplay.Name;
                ListArticle             = js.Serialize(resultDic);
                //rptArticleRelation.DataSource = arListHang;
                //rptArticleRelation.DataBind();
            }
        }
Beispiel #4
0
      public static List <CMS.Article> GetArticleUnLoginCollection(Topic topic)
      {
          List <Article>     result        = new List <Article>();
          List <CMS.Article> listarticleEx = new List <CMS.Article>();

          CMS.ArticleCollection      arList   = CMS.ArticleCollection.GetArticleCollectionPublish(topic);
          CMS.ArticleLoginCollection ArExList = CMS.ArticleLoginCollection.GetArticleLoginCollection(topic);

          foreach (CMS.ArticleLogin item in ArExList)
          {
              CMS.Article a = arList.SingleOrDefault(ar => ar.Id == item.Id);
              listarticleEx.Add(a);
          }

          result = arList.Except(listarticleEx).ToList();
          return(result);
      }
        private void LoadData()
        {
            Object topicGuid = null;
            int    numberOfArticlesDisplay = 0;

            using (
                SqlConnection con =
                    new SqlConnection(
                        System.Configuration.ConfigurationManager.ConnectionStrings["PSCPortalConnectionString"]
                        .ConnectionString))
            {
                SqlCommand com = new SqlCommand {
                    Connection = con
                };
                con.Open();
                com.CommandType = System.Data.CommandType.Text;
                com.Parameters.AddWithValue("@dataId", Portlet.PortletInstance.Id);
                com.CommandText = "select TopicId,NumberOfArticlesDisplay From PortletTopicDisplay Where DataId=@dataId";

                SqlDataReader reader = com.ExecuteReader();
                if (reader.Read())
                {
                    topicGuid = (Guid)reader["TopicId"];
                    numberOfArticlesDisplay = int.Parse(reader["NumberOfArticlesDisplay"].ToString());
                }
            }
            if (topicGuid == null)
            {
                return;
            }

            CMS.Topic topicDisplay = CMS.Topic.GetTopic(topicGuid.ToString());
            if (topicDisplay != null)
            {
                TopicName = topicDisplay.Name;
                TopicId   = topicDisplay.Id.ToString();
                CMS.ArticleCollection arList = CMS.ArticleCollection.GetArticleCollectionPublish(topicDisplay);
                CMS.Article           af     = arList.Count > 0 ? arList.Take(1).Single() : new CMS.Article();
                System.Web.Script.Serialization.JavaScriptSerializer js = new System.Web.Script.Serialization.JavaScriptSerializer();
                ArticleList = js.Serialize(arList.Take(numberOfArticlesDisplay));
            }
        }