コード例 #1
0
        HtmlGenericControl BindArticleList()
        {
            List <Article> artilesTemp = ArticleManager.GetAllArticles();
            List <Article> articles    = artilesTemp.GetRange(0, Math.Min(_Num, artilesTemp.Count));

            if (articles.Count == 0)
            {
                HtmlGenericControl p = new HtmlGenericControl("P");
                p.InnerText = "没有资讯信息!";
                return(p);
            }

            HtmlGenericControl ul = new HtmlGenericControl("ul");

            ul.ID = "ulArticleList";

            HtmlGenericControl li     = null;
            HtmlAnchor         anchor = null;

            foreach (var b in articles)
            {
                li               = new HtmlGenericControl("LI");
                anchor           = new HtmlAnchor();
                anchor.HRef      = GlobalSettings.RelativeWebRoot + "pages/view.aspx?news-newsdetail&ID=" + GlobalSettings.Encrypt(b.ID.ToString());
                anchor.InnerText = GlobalSettings.SubString(b.Title, 30);
                anchor.Title     = b.Title;
                anchor.Target    = "_blank";
                li.Controls.Add(anchor);

                ul.Controls.Add(li);
            }
            return(ul);
        }
コード例 #2
0
        public async Task <ActionResult> ArticleList(int pageIndex = 1, int pageSize = 2)
        {
            //总页码,当前页码,可显示页码数
            var articleManager = new ArticleManager();
            var userId         = Guid.Parse(Session["userId"].ToString());                             //获取用户id
            var articles       = await articleManager.GetAllArticles(userId, pageIndex - 1, pageSize); //获取分页数据

            var dataCount = await articleManager.GetDataCount(userId);                                 //获取数据条数

            return(View(new PagedList <ArticleDto>(articles, pageIndex, pageSize, dataCount)));        //返回分页list
        }
コード例 #3
0
    private void DataBinds()
    {
        PagedDataSource pdsList = new PagedDataSource();

        //对PagedDataSource 对象的相关属性赋值
        pdsList.DataSource       = ArticleManager.GetAllArticles();
        pdsList.AllowPaging      = true;
        pdsList.PageSize         = anpPager.PageSize;
        pdsList.CurrentPageIndex = anpPager.CurrentPageIndex - 1;
        rpArticle.DataSource     = pdsList;
        rpArticle.DataBind();
    }
コード例 #4
0
    private void bind()
    {
        //Label1.Text=ArticleManager.GetArticleById(2).Contents;
        PagedDataSource pdsList = new PagedDataSource();

        //对PagedDataSource 对象的相关属性赋值
        pdsList.DataSource       = ArticleManager.GetAllArticles();
        pdsList.AllowPaging      = true;
        pdsList.PageSize         = anpPager.PageSize;
        pdsList.CurrentPageIndex = anpPager.CurrentPageIndex - 1;
        rpArticle.DataSource     = pdsList;
        rpArticle.DataBind();
    }
コード例 #5
0
        public async Task <ActionResult> GetArticles(int returnCount)
        {
            IArticleManager articleManager = new ArticleManager();
            //获取所有文章的数量
            int allArticleCount = await articleManager.GetAllArticleDataCount();

            //random( 0 - 所有的数量/数量 )
            int    maxCount = allArticleCount / returnCount;//最大值(不加1,最后一页可能不够数量)
            Random rd       = new Random();
            int    index    = rd.Next(0, maxCount);
            //获取所有文章(random,数量)
            List <ArticleDto> data = await articleManager.GetAllArticles(index, returnCount);

            return(Json(data, JsonRequestBehavior.AllowGet));
        }
コード例 #6
0
        string GenerateArticle(ref bool result)
        {
            ProductQuery pq = new ProductQuery();

            pq.HasPublished = true;
            pq.PageIndex    = 0;
            pq.PageSize     = int.MaxValue;

            List <Article> arts = ArticleManager.GetAllArticles();
            SiteMapBuilder smb  = new SiteMapBuilder();

            foreach (Article p in arts)
            {
                smb.AddLocalUrl("pages/view.aspx?news-newsdetail&id=" + GlobalSettings.Encrypt(p.ID.ToString()), DateTime.Now);
            }
            smb.Save(GlobalSettings.MapPath("~/sitemap/articles.xml"));
            result = true;
            return("成功生成/更新【资讯】地图!");
        }
コード例 #7
0
        /// <summary>
        /// 初始化索引
        /// </summary>
        /// <param name="indexPath"></param>
        public static void InitializeIndex(string indexPath)
        {
            try
            {
                string[] oldIndexFiles = System.IO.Directory.GetFiles(indexPath, "*.*");
                foreach (var oldIndexFile in oldIndexFiles)
                {
                    System.IO.File.Delete(oldIndexFile);
                }
            }
            catch
            {
            }
            List <Article> articlesForIndex = new List <Article>();
            List <Article> articles         = ArticleManager.GetAllArticles();

            //分多次进行索引
            int indexedCount = 0;

            for (int i = 0; i < articles.Count; i++)
            {
                indexedCount += 1;
                if (articles[i] != null)
                {
                    articlesForIndex.Add(articles[i]);
                }

                if (indexedCount >= 1000)
                {
                    Insert(articlesForIndex, indexPath);
                    articlesForIndex.Clear();
                    indexedCount = 0;
                }
            }
            Insert(articlesForIndex, indexPath);
        }
コード例 #8
0
    private void InitialDataBind()
    {
        SiteSettings ss = HHContext.Current.SiteSettings;

        ltCopyRight.Text = ss.Copyright;

        StringBuilder       sbItems = new StringBuilder();
        List <ProductBrand> brands  = ProductBrands.GetProductBrands();

        foreach (ProductBrand item in brands)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-brand&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.BrandID.ToString()),
                                 GlobalSettings.SubString(item.BrandName, 10),
                                 item.BrandName);
        }
        ltBrand.Text = sbItems.ToString();

        List <ProductIndustry> inds = ProductIndustries.GetProductIndustries();

        sbItems.Remove(0, sbItems.Length);
        foreach (ProductIndustry item in inds)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-industry&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.IndustryID.ToString()),
                                 GlobalSettings.SubString(item.IndustryName, 10),
                                 item.IndustryName);
        }
        ltIndustry.Text = sbItems.ToString();

        ProductQuery q = new ProductQuery();

        q.PageIndex    = 0;
        q.PageSize     = int.MaxValue;
        q.HasPublished = true;
        List <Product> ps = Products.GetProductList(q);

        sbItems.Remove(0, sbItems.Length);
        foreach (Product item in ps)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-product&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.ProductID.ToString()),
                                 GlobalSettings.SubString(item.ProductName, 17),
                                 item.ProductName);
        }
        ltProduct.Text = sbItems.ToString();

        List <ProductCategory> cats = ProductCategories.GetCategories();

        sbItems.Remove(0, sbItems.Length);
        foreach (ProductCategory item in cats)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?product-category&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.CategoryID.ToString()),
                                 GlobalSettings.SubString(item.CategoryName, 10),
                                 item.CategoryName);
        }
        ltCategory.Text = sbItems.ToString();


        List <Article> ars = ArticleManager.GetAllArticles();

        sbItems.Remove(0, sbItems.Length);
        foreach (Article item in ars)
        {
            sbItems.AppendFormat("<li><a href=\"http://www.ehuaho.com/pages/view.aspx?news-newsdetail&ID={0}\" target=\"_blank\" title=\"{2}\">{1}</a></li>",
                                 GlobalSettings.Encrypt(item.ID.ToString()),
                                 GlobalSettings.SubString(item.Title, 10),
                                 item.Title);
        }
        ltNews.Text = sbItems.ToString();
        //ltCategory; ltIndustry; ltNews; ltProduct;
    }