Ejemplo n.º 1
0
        /// <summary>
        /// 查询数据
        /// </summary>
        protected DataTable get_search_list(int _pagesize, out int _totalcount, int _site_id)
        {
            //创建一个DataTable
            string    link_url = null;
            DataTable dt       = null;
            DataTable oldData  = new BLL.article().GetSearch(this.channel, _pagesize, page, "(title like '%" + keyword + "%' or zhaiyao like '%" + keyword + "%')", "add_time desc,id desc", out _totalcount).Tables[0];

            //复制结构
            dt = oldData.Clone();
            dt.Columns.Add("link_url", Type.GetType("System.String"));
            if (oldData.Rows.Count > 0)
            {
                foreach (DataRow dr in oldData.Rows)
                {
                    link_url = get_url_rewrite(Utils.StrToInt(dr["channel_id"].ToString(), 0), dr["call_index"].ToString(), Utils.StrToInt(dr["id"].ToString(), 0));
                    if (!string.IsNullOrEmpty(link_url))
                    {
                        DataRow row = dt.NewRow();
                        row["id"]          = dr["id"];
                        row["site_id"]     = dr["site_id"];
                        row["channel_id"]  = dr["channel_id"];
                        row["category_id"] = dr["category_id"];
                        row["title"]       = dr["title"];
                        row["call_index"]  = dr["call_index"];
                        row["remark"]      = dr["remark"];
                        row["img_url"]     = dr["img_url"];
                        row["link_url"]    = link_url;
                        row["add_time"]    = dr["add_time"];
                        row["update_time"] = dr["update_time"];
                        row["tags"]        = dr["tags"];
                        dt.Rows.Add(row);
                    }
                }
            }
            return(dt);
        }