public static string[] PopulateArticleKeywordList(string prefixText)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                    dbContext.Connection.Open();
                string LowerKeywords = @prefixText.ToLower();

                var query = (from x in dbContext.Articles
                            where x.Headline.ToLower().Contains(LowerKeywords)
                            || x.Alias.Replace("-", " ").Contains(LowerKeywords)
                            || x.Authors.Contains(LowerKeywords)
                            || x.Abstract.Contains(LowerKeywords)                          
                            || x.Source.Contains(LowerKeywords)
                            || x.Tags.Contains(LowerKeywords)
                            && x.Status == "2"
                            orderby x.ArticleId descending
                             select x).ToList();

                string[] items = new string[query.Count];
                items = query.Select(o => o.ToString()).ToArray();
                return items;
            }
       
        }
        public static List<Article> SearchByKeywords(string Keywords, string CultureCode, int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                    dbContext.Connection.Open();
                string LowerKeywords = @Keywords.ToLower();

                var query = from x in dbContext.Articles
                            where x.Headline.ToLower().Contains(LowerKeywords)
                            || x.Alias.Replace("-", " ").Contains(LowerKeywords)
                            || x.Authors.Contains(LowerKeywords)
                            || x.Abstract.Contains(LowerKeywords)
                            || x.MainText.Contains(LowerKeywords)
                            || x.Source.Contains(LowerKeywords)
                            || x.Tags.Contains(LowerKeywords)
                            && x.CultureCode.Trim() == CultureCode && x.Status == "2"
                            orderby x.ArticleId descending
                            select x;
                int TotalItemCount = 0;
                if (query.Count() > 0)
                {
                    if (iTotalItemCount <= query.Count())
                        TotalItemCount = iTotalItemCount;
                    else
                        TotalItemCount = query.Count();
                }
                return query.Take(TotalItemCount).ToList();
            }
        }
Пример #3
0
        public static List <Article> GetActiveListByTotalViewsFixedNum(string Code, string CultureCode, int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                {
                    dbContext.Connection.Open();
                }

                var query = from x in dbContext.Articles
                            where x.CategoryCode == Code &&
                            x.CultureCode.Trim() == CultureCode &&
                            x.Status == "2" &&
                            x.TotalViews > 3
                            orderby x.TotalViews descending
                            select x;
                int TotalItemCount = 0;
                if (query.Count() > 0)
                {
                    if (iTotalItemCount <= query.Count())
                    {
                        TotalItemCount = iTotalItemCount;
                    }
                    else
                    {
                        TotalItemCount = query.Count();
                    }
                }
                return(query.Take(TotalItemCount).ToList());
            }
        }
Пример #4
0
        public static string[] PopulateArticleKeywordList(string prefixText)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                {
                    dbContext.Connection.Open();
                }
                string LowerKeywords = @prefixText.ToLower();

                var query = (from x in dbContext.Articles
                             where x.Headline.ToLower().Contains(LowerKeywords) ||
                             x.Alias.Replace("-", " ").Contains(LowerKeywords) ||
                             x.Authors.Contains(LowerKeywords) ||
                             x.Abstract.Contains(LowerKeywords) ||
                             x.Source.Contains(LowerKeywords) ||
                             x.Tags.Contains(LowerKeywords) &&
                             x.Status == "2"
                             orderby x.ArticleId descending
                             select x).ToList();

                string[] items = new string[query.Count];
                items = query.Select(o => o.ToString()).ToArray();
                return(items);
            }
        }
Пример #5
0
        public static List <Article> GetActiveListByFixedRecords(int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                {
                    dbContext.Connection.Open();
                }
                List <Article> lst = (from x in dbContext.Articles
                                      where x.Status == "2"
                                      orderby x.ArticleId descending
                                      select x).ToList();

                int TotalItemCount = 0;
                if (lst.Count() > 0)
                {
                    if (iTotalItemCount <= lst.Count())
                    {
                        TotalItemCount = iTotalItemCount;
                    }
                    else
                    {
                        TotalItemCount = lst.Count();
                    }
                }
                return(lst.Take(TotalItemCount).ToList());
            }
        }
 public List<ArticleComment> GetListByArticleIdStatus(int ArticleId, string status)
 {
     using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
     {
         dbContext.CommandTimeout = Settings.CommandTimeout;
         System.Data.Objects.ObjectResult<ArticleComment> obj_result = dbContext.sp_ArticleComments_GetList();
         IQueryable<ArticleComment> query = obj_result.AsQueryable();
         if (ArticleId>0)
             query = query.Where(x => x.ArticleId == ArticleId);
         if (!string.IsNullOrEmpty(status))
             query = query.Where(x => x.Publish == status);
         return query.ToList();
     }
 }
Пример #7
0
 public List <ArticleComment> GetListByArticleIdStatus(int ArticleId, string status)
 {
     using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
     {
         dbContext.CommandTimeout = Settings.CommandTimeout;
         System.Data.Objects.ObjectResult <ArticleComment> obj_result = dbContext.sp_ArticleComments_GetList();
         IQueryable <ArticleComment> query = obj_result.AsQueryable();
         if (ArticleId > 0)
         {
             query = query.Where(x => x.ArticleId == ArticleId);
         }
         if (!string.IsNullOrEmpty(status))
         {
             query = query.Where(x => x.Publish == status);
         }
         return(query.ToList());
     }
 }
Пример #8
0
        public static List <Article> GetActiveListByFixedNumCode(string Code, int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                {
                    dbContext.Connection.Open();
                }
                IQueryable <Article> query = from x in dbContext.Articles
                                             where x.Status == "2"
                                             orderby x.ArticleId descending
                                             select x;

                List <Article> lst = new List <Article>();
                if (string.IsNullOrEmpty(Code))
                {
                    lst = query.ToList();
                }
                else
                {
                    lst = query.Where(x => x.CategoryCode.Trim() == Code).ToList();
                }

                int TotalItemCount = 0;
                if (lst.Count() > 0)
                {
                    if (iTotalItemCount <= lst.Count())
                    {
                        TotalItemCount = iTotalItemCount;
                    }
                    else
                    {
                        TotalItemCount = lst.Count();
                    }
                }
                return(lst.Take(TotalItemCount).ToList());
            }
        }
Пример #9
0
        public static List <Article> SearchByKeywords(string Keywords, string CultureCode, int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                {
                    dbContext.Connection.Open();
                }
                string LowerKeywords = @Keywords.ToLower();

                var query = from x in dbContext.Articles
                            where x.Headline.ToLower().Contains(LowerKeywords) ||
                            x.Alias.Replace("-", " ").Contains(LowerKeywords) ||
                            x.Authors.Contains(LowerKeywords) ||
                            x.Abstract.Contains(LowerKeywords) ||
                            x.MainText.Contains(LowerKeywords) ||
                            x.Source.Contains(LowerKeywords) ||
                            x.Tags.Contains(LowerKeywords) &&
                            x.CultureCode.Trim() == CultureCode && x.Status == "2"
                            orderby x.ArticleId descending
                            select x;
                int TotalItemCount = 0;
                if (query.Count() > 0)
                {
                    if (iTotalItemCount <= query.Count())
                    {
                        TotalItemCount = iTotalItemCount;
                    }
                    else
                    {
                        TotalItemCount = query.Count();
                    }
                }
                return(query.Take(TotalItemCount).ToList());
            }
        }
        public static List<Article> GetActiveListByTotalViewsFixedNum(string Code, string CultureCode, int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                    dbContext.Connection.Open();

                var query = from x in dbContext.Articles
                            where x.CategoryCode == Code
                                && x.CultureCode.Trim() == CultureCode 
                                && x.Status == "2"
                                && x.TotalViews > 3
                            orderby x.TotalViews descending
                            select x;
                int TotalItemCount = 0;
                if (query.Count() > 0)
                {
                    if (iTotalItemCount <= query.Count())
                        TotalItemCount = iTotalItemCount;
                    else
                        TotalItemCount = query.Count();
                }
                return query.Take(TotalItemCount).ToList();
            }
        }
        public static List<Article> GetActiveListByFixedNumCode(string Code, int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                    dbContext.Connection.Open();
                IQueryable<Article> query = from x in dbContext.Articles
                                            where x.Status == "2"
                                            orderby x.ArticleId descending
                                            select x; 

                List<Article> lst = new List<Article>();
                if (string.IsNullOrEmpty(Code))
                    lst = query.ToList();
                else
                    lst = query.Where(x => x.CategoryCode.Trim() == Code).ToList();                            
                
                int TotalItemCount = 0;
                if (lst.Count() > 0)
                {
                    if (iTotalItemCount <= lst.Count())
                        TotalItemCount = iTotalItemCount;
                    else
                        TotalItemCount = lst.Count();
                }
                return lst.Take(TotalItemCount).ToList();
            }
        }
        public static List<Article> GetActiveListByFixedRecords(int iTotalItemCount)
        {
            using (ArticleEntities dbContext = new ArticleLibrary.ArticleEntities())
            {
                if (dbContext.Connection.State != ConnectionState.Closed)
                    dbContext.Connection.Open();
                List<Article> lst = (from x in dbContext.Articles
                                            where x.Status == "2"
                                            orderby x.ArticleId descending
                                            select x).ToList();

                int TotalItemCount = 0;
                if (lst.Count() > 0)
                {
                    if (iTotalItemCount <= lst.Count())
                        TotalItemCount = iTotalItemCount;
                    else
                        TotalItemCount = lst.Count();
                }
                return lst.Take(TotalItemCount).ToList();
            }
        }