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(); } }
public void LoadData() { System.Collections.Generic.IEnumerable <CMS.Article> it = ListArticle.Take(Number); if (it.Count() > 0) { CMS.Article article = it.Take(1).Single(); ArticleId = article.Id.ToString(); ArticleName = article.Name; ArticleDescription = article.GetDescription(); rptTabTopic.DataSource = it.Skip(1); rptTabTopic.DataBind(); } }
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)); } }