Esempio n. 1
0
        public ActionResult Edit(int?id)
        {
            var userinfo = BLLSession.UserInfoSessioin;
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("blogTag", GetDataHelper.GetAllTag(BLLSession.UserInfoSessioin.Id).ToList());
            dic.Add("blogType", CacheData.GetAllType().Where(t => t.UsersId == BLLSession.UserInfoSessioin.Id).ToList());
            List <BlogsDTO> blogs = new List <BlogsDTO>();

            if (null != id)
            {
                int          ttt;
                BLL.BlogsBLL blogbll = new BlogsBLL();
                if (id == 0)//代表 未分类
                {
                    blogs = blogbll.GetList(1, 50, out ttt, t => t.BlogTypes.Count() == 0 && (t.UsersId == userinfo.Id), false, t => t.BlogCreateTime, false)
                            .ToList().Select(t => new BlogsDTO()
                    {
                        Id        = t.Id,
                        BlogTitle = t.BlogTitle
                    }).ToList();
                }
                else
                {
                    blogs = blogbll.GetList(1, 50, out ttt, t => t.BlogTypes.Where(v => v.Id == id).Count() > 0 && (t.UsersId == userinfo.Id), false, t => t.BlogCreateTime, false)
                            .ToList().Select(t => new BlogsDTO()
                    {
                        Id        = t.Id,
                        BlogTitle = t.BlogTitle
                    }).ToList();
                }
            }
            dic.Add("blogs", blogs);
            return(View(dic));
        }
Esempio n. 2
0
        public ActionResult Release(int?id)
        {
            if (BLLSession.UserInfoSessioin == null)
            {
                Response.Redirect("/Account/Login?href=/ManageBlog/Release");
                return(null);
            }
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("blogTag", GetDataHelper.GetAllTag(BLLSession.UserInfoSessioin.UserId).ToList());
            dic.Add("blogType", DataCache.GetAllType().Where(t => t.UserId == BLLSession.UserInfoSessioin.UserId).ToList());
            Blogs blog = null;

            if (null != id)
            {
                blog = new Blogs();
                BlogsBLL blogbll = new BlogsBLL();
                blog = blogbll.GetList(t => t.BlogId == id && (t.UserId == BLLSession.UserInfoSessioin.UserId || BLLSession.UserInfoSessioin.UserName == admin)).FirstOrDefault();
                if (blog == null)
                {
                    return(View("Error"));
                }
            }
            dic.Add("blog", blog);
            return(View(dic));
        }
Esempio n. 3
0
        /// <summary>
        /// 检查 这个 url地址 是否被添加过
        /// </summary>
        /// <param name="url"></param>
        /// <returns></returns>
        private bool IsAreBlog(string url)
        {
            //BLL.BlogsBLL blog = new BLL.BlogsBLL();
            //var blogs = blog.GetList(t => t.BlogUrl == url);
            //return blogs.Count() >= 1;
            BlogsBLL blog  = new BlogsBLL();
            var      blogs = blog.GetList(t => t.BlogUrl == url);

            return(blogs.Count() >= 1);
        }
Esempio n. 4
0
        //
        // GET: /Home/

        public ActionResult Index(int?page, int?sorttype)
        {
            BlogsBLL     blogBll   = new BlogsBLL();
            int          total     = 0;
            int          pageIndex = page ?? 1;
            int          sortType  = sorttype ?? 1;
            List <Blogs> bloglist  = null;

            if (sortType == 2)
            {
                bloglist = blogBll.GetList(pageIndex, pageSize, out total, t => t.IsShowHome == true, t => t.CreateTime, false).ToList();
            }
            else if (sortType == 4)
            {
                bloglist = blogBll.GetList(pageIndex, pageSize, out total, t => t.IsShowHome == true, t => t.CreateTime, false).ToList();
            }
            else if (sortType == 3)
            {
                bloglist = blogBll.GetList(pageIndex, pageSize, out total, t => t.IsShowHome == true, t => t.BlogReadNum, false).ToList();
            }
            else
            {
                bloglist = blogBll.GetList(pageIndex, pageSize, out total, t => t.IsShowHome == true, t => t.UpTime, false).ToList();
            }
            bloglist.ForEach(t =>
            {
                t.BlogRemarks = Blog.Helper.MyHtmlHelper.GetHtmlText(t.Content);
            });
            Dictionary <string, Object> dic = new Dictionary <string, object>();

            dic.Add("blog", bloglist);
            dic.Add("users", BLL.DataCache.GetUsersInfo());
            dic.Add("userSession", BLL.Common.BLLSession.UserInfoSessioin);
            dic.Add("total", total);
            return(View(dic));
        }
Esempio n. 5
0
        /// <summary>
        /// 根据类型id获取所属类型文章列表(返回分部视图)
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public PartialViewResult EditBlogsByType(int id)
        {
            var sessionUser = BLLSession.UserInfoSessioin;

            if (sessionUser == null)
            {
                Response.Redirect("/Account/Login?href=/ManageBlog/Release");
                return(null);
            }
            List <Blogs> blogList = new List <Blogs>();
            BlogsBLL     blogBLL  = new BlogsBLL();

            blogList = blogBLL.GetList(t => t.BlogTypes.BlogTypeId == id).ToList();
            return(PartialView(blogList));
        }
Esempio n. 6
0
        public PartialViewResult FlushTypeList(int?blogid)
        {
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("blogType", DataCache.GetAllType().Where(t => t.UserId == BLLSession.UserInfoSessioin.UserId).ToList());
            Blogs blog = null;

            if (null != blogid)
            {
                blog = new Blogs();
                BlogsBLL blogbll = new BlogsBLL();
                blog = blogbll.GetList(t => t.BlogId == blogid && (t.UserId == BLLSession.UserInfoSessioin.UserId || BLLSession.UserInfoSessioin.UserName == admin)).FirstOrDefault();
            }
            dic.Add("blog", blog);
            return(PartialView(dic));
        }
Esempio n. 7
0
        /// <summary>
        /// 重新获取索引
        /// </summary>
        /// <returns></returns>
        public ActionResult getIndex()
        {
            HtmlAgilityPack.HtmlDocument documnet = new HtmlDocument();
            BlogsBLL bloglist = new BlogsBLL();
            var list = new List<SearchResult>();

            list = bloglist.GetList(t => true).ToList().Select(t => new SearchResult()
            {
                blogTag = "",
                url = "/" + t.BlogUsersSet.UserName + "/" + t.Id + ".html",// t.BlogUrl,
                id = t.Id,//DocumentNode
                content = getText(t.BlogContent, documnet),
                clickQuantity = 3,
                title = t.BlogTitle,
                flag = t.UsersId
            }).ToList();

            PanGuLuceneHelper.instance.DeleteAll();
            SafetyWriteHelper<SearchResult>.logWrite(list, PanGuLuceneHelper.instance.CreateIndex);
            return Content("ok");
        }
        /// <summary>
        /// 重新获取索引
        /// </summary>
        /// <returns></returns>
        public ActionResult getIndex()
        {
            HtmlAgilityPack.HtmlDocument documnet = new HtmlDocument();
            BlogsBLL bloglist = new BlogsBLL();
            var      list     = new List <SearchResult>();

            list = bloglist.GetList(t => true).ToList().Select(t => new SearchResult()
            {
                blogTag       = "",
                url           = "/" + t.BlogUsersSet.UserName + "/" + t.Id + ".html", // t.BlogUrl,
                id            = t.Id,                                                 //DocumentNode
                content       = getText(t.BlogContent, documnet),
                clickQuantity = 3,
                title         = t.BlogTitle,
                flag          = t.UsersId
            }).ToList();

            PanGuLuceneHelper.instance.DeleteAll();
            SafetyWriteHelper <SearchResult> .logWrite(list, PanGuLuceneHelper.instance.CreateIndex);

            return(Content("ok"));
        }
Esempio n. 9
0
        public ActionResult Release(int?id)
        {
            var userinfo = BLLSession.UserInfoSessioin;

            if (null == userinfo)
            {
                Response.Redirect("/UserManage/Login?href=/Admin/Release");
                return(null);
            }
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("blogTag", GetDataHelper.GetAllTag(BLLSession.UserInfoSessioin.Id).ToList());
            dic.Add("blogType", CacheData.GetAllType().Where(t => t.UsersId == BLLSession.UserInfoSessioin.Id).ToList());
            ModelDB.Blogs blog = new ModelDB.Blogs();
            if (null != id)
            {
                BLL.BlogsBLL blogbll = new BlogsBLL();
                blog = blogbll.GetList(t => t.Id == id && (t.UsersId == userinfo.Id || userinfo.UserName == admin)).FirstOrDefault();
            }
            dic.Add("blog", blog);
            return(View(dic));
        }
Esempio n. 10
0
        /// <summary>
        /// 删除 文章
        /// </summary>
        /// <param name="id"></param>
        /// <returns></returns>
        public ActionResult Del(int?id)
        {
            var          userinfo = BLLSession.UserInfoSessioin;
            List <Blogs> blogs    = new List <Blogs>();
            bool         isdelok  = false;

            if (null != id)
            {
                BLL.BlogsBLL    blogbll = new BlogsBLL();
                BLL.BlogTagsBLL tagbll  = new BlogTagsBLL();
                var             delBlog = blogbll.GetList(t => t.BlogId == id, isAsNoTracking: false).FirstOrDefault();
                List <BlogTags> tagList = delBlog.BlogTags.ToList();



                //blogbll.Mod(new Blogs() { BlogId = (int)id,IsDel=true }, "IsDel");
                try
                {
                    foreach (var tag in tagList)
                    {
                        if (tag.Blogs.Count(t => !t.IsDel) <= 1)
                        {
                            isdelok = tagbll.Del(tag, isAsTracking: false);
                        }
                    }

                    blogbll.Del(delBlog, isAsTracking: false);
                    isdelok = blogbll.save() > 0;
                    BLL.DataCache.GetAllType(true);
                }
                catch (Exception ex)
                {
                    isdelok = false;
                    return(Content(ex.ToString()));
                }
            }
            return(Content((isdelok).ToString()));
        }
        /// <summary>
        /// 获取博主首页
        /// </summary>
        /// <param name="name">博主用户名</param>
        /// <param name="id">博主首页博客列表当前页码(为空时为第一页)</param>
        /// <returns></returns>
        public ActionResult UserBlogHome(string name, int?id)
        {
            int      myId = id ?? 1;
            int      totalPage;
            BlogsBLL blogsBLL  = new BlogsBLL();
            var      blogsList = blogsBLL.GetList(myId, pageSize, out totalPage, t => t.BlogUsers.UserName == name, t => t.UpTime, false).ToList() //linq 选择数据时候 不能new 已知的对象,只能匿名的。 但是如果从一个 List 列表 就可以new 已知的类。
                                 .Select(t => new Blog.Domain.Blogs
            {
                BlogId       = t.BlogId,
                Title        = t.Title,
                Content      = Blog.Helper.MyHtmlHelper.GetHtmlText(t.Content),
                UpTime       = t.UpTime,
                CreateTime   = t.CreateTime,
                BlogComments = t.BlogComments,
                BlogReadNum  = t.BlogReadNum
            }).ToList();
            Dictionary <string, object> dic = new Dictionary <string, object>();

            dic.Add("blogslist", blogsList);
            dic.Add("totalpage", totalPage);
            SetDic(dic, name);
            return(View(dic));
        }
Esempio n. 12
0
        /// <summary>
        /// 删除文章类型
        /// </summary>
        /// <param name="id">要删除的类型id</param>
        /// <returns></returns>
        public String DeleteTypeById(int id)
        {
            bool         result        = false;
            BlogsBLL     blogBLL       = new BlogsBLL();
            BlogTypesBLL typeBLL       = new BlogTypesBLL();
            var          theTypeBlogs  = blogBLL.GetList(t => t.BlogTypeId == id, isAsNoTracking: false).ToList();
            var          defaultTypeID = typeBLL.GetList(t => t.TypeName == "未分类").FirstOrDefault().BlogTypeId;

            foreach (Blogs blog in theTypeBlogs)  //将属于要删除类型的博客分到 未分类 中
            {
                blog.BlogTypeId = defaultTypeID;
            }
            try
            {
                blogBLL.save();
                result = typeBLL.Del(t => t.BlogTypeId == id);
                BLL.DataCache.GetAllType(true);
            }
            catch (Exception ex)
            {
                return(ex.ToString());
            }
            return(result.ToString());
        }
Esempio n. 13
0
        public string Import(string userName, string BlogUserName = "******", string iszf = "false")
        {
            int blosNumber           = 0;
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string url = "http://www.cnblogs.com/" + userName + @"/mvc/blog/sidecolumn.aspx";

            HtmlAgilityPack.HtmlWeb htmlweb = new HtmlAgilityPack.HtmlWeb();
            var    docment = htmlweb.Load(url);
            string userid  = GetCnblogUserId(userName);
            var    liS     = docment.DocumentNode.SelectNodes("//*[@id='sidebar_categories']/div[1]/ul/li");
            //if (liS != null)
            //    foreach (var item in liS)
            //    {
            //        var tXPath = item.XPath;
            //        var href = item.SelectSingleNode(tXPath + "/a").Attributes["href"].Value;
            //        var blogtype = htmlweb.Load(href);
            //        var entrylistItem = blogtype.DocumentNode.SelectNodes("//div[@class='entrylistItem']");
            //        if (null == entrylistItem)//做兼容
            //            entrylistItem = blogtype.DocumentNode.SelectNodes("//div[@class='post post-list-item']"); //
            //        if (null == entrylistItem)
            //        {
            //            continue;
            //        }
            //        foreach (var typeitem in entrylistItem)
            //        {
            //            var typeitemXPath = typeitem.XPath;
            //            var typeitemhrefObj = typeitem.SelectSingleNode(typeitemXPath + "/div/a");
            //            if (null == typeitemhrefObj) //做兼容
            //                typeitemhrefObj = typeitem.SelectSingleNode(typeitemXPath + "/h2/a");
            //            ///////////////////////////////////
            //            var typeitemhref = typeitemhrefObj.Attributes["href"].Value;

            //            var bloghtml = htmlweb.Load(typeitemhref);

            //            var blogtimeobj = bloghtml.DocumentNode.SelectSingleNode("//*[@id='post-date']");
            //            DateTime blogtime;
            //            if (null != blogtimeobj)
            //                blogtime = Convert.ToDateTime(blogtimeobj.InnerText);
            //            else
            //                blogtime = DateTime.Now;
            //            if (bloghtml.DocumentNode.SelectSingleNode("//*[@id='cb_post_title_url']") == null) continue;
            //            var blogurl = "/" + BlogUserName + "/" + bloghtml.DocumentNode.SelectSingleNode("//*[@id='cb_post_title_url']").Attributes["href"].Value.Substring(typeitemhref.LastIndexOf('/') + 1, typeitemhref.LastIndexOf('.') - typeitemhref.LastIndexOf('/') - 1);
            //            if (IsAreBlog(blogurl))
            //                continue;
            //            var blogcontextobj = bloghtml.DocumentNode.SelectSingleNode("//*[@id='cnblogs_post_body']");//.InnerHtml;
            //            if (blogcontextobj == null) continue;//有可能是加密文章
            //            var blogcontext = blogcontextobj.InnerHtml;

            //            var blogNameObj = bloghtml.DocumentNode.SelectSingleNode("//*[@id='Header1_HeaderTitle']");
            //            if (null == blogNameObj)
            //                blogNameObj = bloghtml.DocumentNode.SelectSingleNode("//*[@id='lnkBlogTitle']");
            //            string blogName = string.Empty;
            //            try
            //            {
            //                blogName = blogNameObj.InnerText;
            //            }
            //            catch (Exception)
            //            { }

            //            var blogtitle = bloghtml.DocumentNode.SelectSingleNode("//*[@id='cb_post_title_url']").InnerText;
            //            var blogtypetagurl = "http://www.cnblogs.com/mvc/blog/CategoriesTags.aspx?blogApp=" + userName + "&blogId=" + userid + "&postId=" +
            //                typeitemhref.Substring(typeitemhref.LastIndexOf('/') + 1, typeitemhref.LastIndexOf('.') - typeitemhref.LastIndexOf('/') - 1);
            //            var blogtag = Blog.Helper.MyHtmlHelper.GetRequest(blogtypetagurl);
            //            var jsonobj = jss.Deserialize<Dictionary<string, string>>(blogtag);

            //            List<int> blogtagid = null;
            //            List<int> blogtypeid = null;
            //            if (null == jsonobj)
            //            {//如果没有分类及标签信息 则添加到默认分类中
            //                blogtypeid = new List<int>();
            //                blogtypeid.Add(GetTypeId("未分类", BlogUserName));
            //                goto skip_typeidAndtagid;
            //            }
            //            var tagSplit = jsonobj["Tags"].Split(',');
            //            blogtagid = new List<int>();
            //            for (int i = 0; i < tagSplit.Length; i++)
            //            {
            //                if (tagSplit[i].Length >= 1 && tagSplit[i].LastIndexOf('<') >= 1)
            //                {
            //                    var blogtagname = tagSplit[i].Substring(tagSplit[i].IndexOf('>') + 1, tagSplit[i].LastIndexOf('<') - tagSplit[i].IndexOf('>') - 1);
            //                    blogtagid.Add(this.GetTagId(blogtagname, BlogUserName));
            //                }
            //            }

            //            var categoriesSplit = jsonobj["Categories"].Split(',');
            //            blogtypeid = new List<int>();
            //            for (int i = 0; i < categoriesSplit.Length; i++)
            //            {
            //                if (categoriesSplit[i].Length >= 1 && categoriesSplit[i].LastIndexOf('<') >= 1)
            //                {
            //                    var blogtypename = categoriesSplit[i].Substring(categoriesSplit[i].IndexOf('>') + 1, categoriesSplit[i].LastIndexOf('<') - categoriesSplit[i].IndexOf('>') - 1);
            //                    blogtypeid.Add(this.GetTypeId(blogtypename, BlogUserName));


            //                }
            //            }
            //        skip_typeidAndtagid:



            //            BlogsBLL blog = new BlogsBLL();
            //            List<BlogTags> myBlogTags = null;
            //            if (blogtagid != null)
            //                myBlogTags = new BlogTagsBLL().GetList(t => blogtagid.Contains(t.BlogTagId), isAsNoTracking: false).ToList();//.ToList();
            //            var myBlogTypes = new BLL.BlogTypesBLL().GetList(t => blogtypeid.Contains(t.BlogTypeId)).ToList().FirstOrDefault();//.ToList();
            //            var blogUserId = GetUserId(BlogUserName);
            //            try
            //            {
            //                var modelMyBlogs = new Blogs()
            //                {
            //                    Content = blogcontext,
            //                    CreateTime = blogtime,
            //                    Title = blogtitle,
            //                    IsDel = false,
            //                    BlogTags = myBlogTags,
            //                    BlogTypeId = myBlogTypes.BlogTypeId,
            //                    UserId = blogUserId,
            //                    IsForwarding = iszf == "checked",
            //                    IsShowHome = true
            //                };
            //                blog.Add(modelMyBlogs);
            //                blog.save(false);
            //                blosNumber++;
            //            }
            //            catch (Exception ex)
            //            {
            //                return ex.ToString();
            //            }
            //        }
            //    }
            BlogsBLL blogBLL   = new BlogsBLL();
            var      blogsList = blogBLL.GetList(t => true, isAsNoTracking: false, selectDel: true).ToList();

            blogsList.ForEach(t => { t.BlogUrl = "/" + BlogUserName + "/" + t.BlogId + ".html"; t.BlogRemarks = Blog.Helper.MyHtmlHelper.GetHtmlText(t.Content); });
            blogBLL.save(false);
            if (blosNumber > 0)
            {
                return("成功导入" + blosNumber + "篇Blog");
            }
            return("ok");
        }
Esempio n. 14
0
 public ActionResult Release(int? id)
 {
     var userinfo = BLLSession.UserInfoSessioin;
     if (null == userinfo)
     {
         Response.Redirect("/UserManage/Login?href=/Admin/Release");
         return null;
     }
     Dictionary<string, object> dic = new Dictionary<string, object>();
     dic.Add("blogTag", GetDataHelper.GetAllTag(BLLSession.UserInfoSessioin.Id).ToList());
     dic.Add("blogType", CacheData.GetAllType().Where(t => t.UsersId == BLLSession.UserInfoSessioin.Id).ToList());
     ModelDB.Blogs blog = new ModelDB.Blogs();
     if (null != id)
     {
         BLL.BlogsBLL blogbll = new BlogsBLL();
         blog = blogbll.GetList(t => t.Id == id && (t.UsersId == userinfo.Id || userinfo.UserName == admin)).FirstOrDefault();
     }
     dic.Add("blog", blog);
     return View(dic);
 }
Esempio n. 15
0
        public ActionResult Edit(int? id)
        {
            var userinfo = BLLSession.UserInfoSessioin;
            Dictionary<string, object> dic = new Dictionary<string, object>();
            dic.Add("blogTag", GetDataHelper.GetAllTag(BLLSession.UserInfoSessioin.Id).ToList());
            dic.Add("blogType", CacheData.GetAllType().Where(t => t.UsersId == BLLSession.UserInfoSessioin.Id).ToList());
            List<BlogsDTO> blogs = new List<BlogsDTO>();
            if (null != id)
            {
                int ttt;
                BLL.BlogsBLL blogbll = new BlogsBLL();
                if (id == 0)//代表 未分类
                {
                    blogs = blogbll.GetList(1, 50, out ttt, t => t.BlogTypes.Count() == 0 && (t.UsersId == userinfo.Id), false, t => t.BlogCreateTime, false)
                      .ToList().Select(t => new BlogsDTO()
                      {
                          Id = t.Id,
                          BlogTitle = t.BlogTitle
                      }).ToList();
                }
                else
                {

                    blogs = blogbll.GetList(1, 50, out ttt, t => t.BlogTypes.Where(v => v.Id == id).Count() > 0 && (t.UsersId == userinfo.Id), false, t => t.BlogCreateTime, false)
                       .ToList().Select(t => new BlogsDTO()
                       {
                           Id = t.Id,
                           BlogTitle = t.BlogTitle
                       }).ToList();
                }
            }
            dic.Add("blogs", blogs);
            return View(dic);
        }
Esempio n. 16
0
        public PartialViewResult SearchBlogResult()
        {
            if (!Request.QueryString.AllKeys.Contains("keyword"))
            {
                return(null);
            }
            string keyword = Request.QueryString["keyword"].Trim();

            if (String.IsNullOrEmpty(keyword))
            {
                return(null);
            }
            int type = int.Parse(Request.QueryString["type"]);

            if (type == 1)
            {
                BlogsBLL blogBLL   = new BlogsBLL();
                string   pIndex    = Request.QueryString.AllKeys.Contains("page") ? Request.QueryString["page"] : "";
                int      PageIndex = 1;
                int.TryParse(pIndex, out PageIndex);
                int totalPage  = 1;
                int totalCount = blogBLL.GetList(t => t.Title.Contains(keyword)).Count();
                var searchlist = blogBLL.GetList(PageIndex, pageSize, out totalPage, t => t.Title.Contains(keyword), t => t.CreateTime).ToList().Select(t => new Blogs
                {
                    Title      = t.Title,
                    Content    = Helper.MyHtmlHelper.GetHtmlText(t.Content).Count() > 300 ? Helper.MyHtmlHelper.GetHtmlText(t.Content).Substring(0, 300) : Helper.MyHtmlHelper.GetHtmlText(t.Content),
                    CreateTime = t.CreateTime,
                    BlogUrl    = t.BlogUrl,
                    BlogUsers  = t.BlogUsers
                }).ToList();
                CompareInfo compareInfo = CultureInfo.CurrentCulture.CompareInfo;
                searchlist.ForEach(t =>
                {
                    t.Title = t.Title.Insert(compareInfo.IndexOf(t.Title, keyword, CompareOptions.IgnoreCase), "<strong>");
                    t.Title = t.Title.Insert(compareInfo.IndexOf(t.Title, keyword, CompareOptions.IgnoreCase) + keyword.Count(), "</strong>");
                });
                Dictionary <string, object> dicResult = new Dictionary <string, object>();
                dicResult.Add("blogslist", searchlist);
                dicResult.Add("totalpage", totalPage);
                dicResult.Add("count", totalCount);
                return(PartialView(dicResult));
            }
            else if (type == 2)
            {
                BlogsBLL    blogBLL     = new BlogsBLL();
                CompareInfo compareInfo = CultureInfo.CurrentCulture.CompareInfo;
                string      pIndex      = Request.QueryString.AllKeys.Contains("page") ? Request.QueryString["page"] : "";
                int         PageIndex   = 1;
                int.TryParse(pIndex, out PageIndex);
                int totalPage  = 1;
                int totalCount = blogBLL.GetList(t => t.BlogRemarks.Contains(keyword)).Count();
                var searchlist = blogBLL.GetList(PageIndex, pageSize, out totalPage, t => (t.BlogRemarks).Contains(keyword), t => t.CreateTime, isAsc: false).ToList().Select(t => new Blogs
                {
                    Title   = t.Title,
                    Content = t.BlogRemarks.Substring(compareInfo.IndexOf(t.BlogRemarks, keyword, CompareOptions.IgnoreCase) >= 10 ? compareInfo.IndexOf(t.BlogRemarks, keyword, CompareOptions.IgnoreCase) - 10 : compareInfo.IndexOf(t.BlogRemarks, keyword, CompareOptions.IgnoreCase)
                                                      , t.BlogRemarks.Length - compareInfo.IndexOf(t.BlogRemarks, keyword, CompareOptions.IgnoreCase) > 300 ? 300 : t.BlogRemarks.Length - compareInfo.IndexOf(t.BlogRemarks, keyword, CompareOptions.IgnoreCase)),
                    CreateTime = t.CreateTime,
                    BlogUrl    = t.BlogUrl,
                    BlogUsers  = t.BlogUsers
                }).ToList();
                searchlist.ForEach(t =>
                {
                    t.Content = t.Content.Insert(compareInfo.IndexOf(t.Content, keyword, CompareOptions.IgnoreCase), "<strong>");
                    t.Content = t.Content.Insert(compareInfo.IndexOf(t.Content, keyword, CompareOptions.IgnoreCase) + keyword.Count(), "</strong>");
                });
                Dictionary <string, object> dicResult = new Dictionary <string, object>();
                dicResult.Add("blogslist", searchlist);
                dicResult.Add("totalpage", totalPage);
                dicResult.Add("count", totalCount);
                return(PartialView(dicResult));
            }
            else
            {
                return(null);
            }
        }