Exemple #1
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="id"></param>
        /// <returns></returns>
        public ActionResult Del(int?id)
        {
            var             userinfo = BLLSession.UserInfoSessioin;
            List <BlogsDTO> blogs    = new List <BlogsDTO>();
            int             isdelok  = -1;

            if (null != id)
            {
                BLL.BlogsBLL blogbll = new BlogsBLL();
                blogbll.Del(new ModelDB.Blogs()
                {
                    Id = (int)id
                }, true);
                isdelok = blogbll.save(false);
                List <SearchResult> list = new List <SearchResult>();
                list.Add(new SearchResult()
                {
                    id = (int)id
                });
                SafetyWriteHelper <SearchResult> .logWrite(list, PanGuLuceneHelper.instance.Delete);
            }
            return(Content((isdelok > 0).ToString()));
        }
Exemple #3
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());
        }
Exemple #4
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");
        }
        /// <summary>
        /// 根据用户导入cnblog数据
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public string Import(string userName, string iszf, string isshowhome, string isshowmyhome)
        {
            userName = userName.Trim();
            int blosNumber           = 0;
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string url = "http://www.cnblogs.com/" + userName + @"/mvc/blog/sidecolumn.aspx";

            HtmlAgilityPack.HtmlWeb      htmlweb  = new HtmlAgilityPack.HtmlWeb();
            HtmlAgilityPack.HtmlDocument document = new HtmlDocument();
            var    docment = htmlweb.Load(url);
            string userid  = GetCnblogUserId(userName);
            var    liS     = docment.DocumentNode.SelectNodes("//*[@id='sidebar_categories']/div[1]/ul/li");

            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("//*[@id='mainContent']/div/div[2]/div[@class='entrylistItem']");
                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;
                    if (IsAreBlog(typeitemhref))
                    {
                        continue;//说明这篇文章已经备份过了的
                    }
                    var bloghtml       = htmlweb.Load(typeitemhref);
                    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']");
                    }
                    try
                    {
                        blogName = blogNameObj.InnerText;
                    }
                    catch (Exception)
                    { }

                    var blogtitle      = bloghtml.DocumentNode.SelectSingleNode("//*[@id='cb_post_title_url']").InnerText;
                    var blogurl        = bloghtml.DocumentNode.SelectSingleNode("//*[@id='cb_post_title_url']").Attributes["href"].Value;
                    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 = Blogs.Common.Helper.MyHtmlHelper.GetRequest(blogtypetagurl);
                    var jsonobj = jss.Deserialize <Dictionary <string, string> >(blogtag);
                    if (null == jsonobj)
                    {
                        continue;//如果没有 则返回  (这里只能去 数字.html  不能取那种自定义的url)
                    }
                    var tagSplit  = jsonobj["Tags"].Split(',');
                    var 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, userName));
                        }
                    }
                    var categoriesSplit = jsonobj["Categories"].Split(',');
                    var 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, userName));
                        }
                    }
                    var blogtimeobj = bloghtml.DocumentNode.SelectSingleNode("//*[@id='post-date']");
                    var blogtime    = "";
                    if (null != blogtimeobj)
                    {
                        blogtime = blogtimeobj.InnerText;
                    }

                    DateTime?createtime    = null;
                    var      Outcreatetime = DateTime.Now;
                    if (DateTime.TryParse(blogtime, out Outcreatetime))
                    {
                        createtime = Outcreatetime;
                    }
                    BlogsBLL blog       = new BlogsBLL();
                    var      myBlogTags = new BlogTagsBLL().GetList(t => blogtagid.Contains(t.Id), isAsNoTracking: false).ToList();   //.ToList();

                    var myBlogTypes = new BLL.BlogTypesBLL().GetList(t => blogtypeid.Contains(t.Id), isAsNoTracking: false).ToList(); //.ToList();
                    try
                    {
                        var modelMyBlogs = new ModelDB.Blogs()
                        {
                            BlogContent    = blogcontext,
                            BlogCreateTime = createtime,
                            BlogTitle      = blogtitle,
                            BlogUrl        = blogurl,
                            IsDel          = false,
                            BlogTags       = myBlogTags,
                            BlogTypes      = myBlogTypes,
                            UsersId        = GetUserId(userName),
                            BlogForUrl     = blogurl,
                            IsForwarding   = iszf == "true",
                            IsShowMyHome   = isshowmyhome == "true",
                            IsShowHome     = isshowhome == "true"
                        };
                        blog.Add(modelMyBlogs);
                        blog.save();
                        var newtag = string.Empty;
                        try
                        {
                            modelMyBlogs.BlogTags.Where(t => true).ToList().ForEach(t => newtag += t.TagName + " ");
                            var          newblogurl = "/" + modelMyBlogs.BlogUsersSet.UserName + "/" + modelMyBlogs.Id + ".html";
                            SearchResult search     = new SearchResult()
                            {
                                flag          = modelMyBlogs.UsersId,
                                id            = modelMyBlogs.Id,
                                title         = blogtitle,
                                clickQuantity = 0,
                                blogTag       = newtag,
                                content       = getText(blogcontext, document),
                                url           = newblogurl
                            };

                            SafetyWriteHelper <SearchResult> .logWrite(search, PanGuLuceneHelper.instance.CreateIndex);
                        }
                        catch (Exception)
                        {
                        }

                        var postid = blogurl.Substring(blogurl.LastIndexOf('/') + 1);
                        postid = postid.Substring(0, postid.LastIndexOf('.'));
                        testJumonyParser(modelMyBlogs.Id, postid, userName);

                        blosNumber++;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            if (blosNumber > 0)
            {
                Blogs.BLL.Common.GetDataHelper.GetAllTag();
                Blogs.BLL.Common.CacheData.GetAllType(true);
                Blogs.BLL.Common.CacheData.GetAllUserInfo(true);
                return("成功导入" + blosNumber + "篇Blog");
            }
            return("ok");
        }
Exemple #6
0
 /// <summary>
 /// 删除 文章
 /// </summary>
 /// <param name="id"></param>
 /// <returns></returns>
 public ActionResult Del(int? id)
 {
     var userinfo = BLLSession.UserInfoSessioin;
     List<BlogsDTO> blogs = new List<BlogsDTO>();
     int isdelok = -1;
     if (null != id)
     {
         BLL.BlogsBLL blogbll = new BlogsBLL();
         blogbll.Del(new ModelDB.Blogs() { Id = (int)id }, true);
         isdelok = blogbll.save(false);
         List<SearchResult> list = new List<SearchResult>();
         list.Add(new SearchResult() { id = (int)id });
         SafetyWriteHelper<SearchResult>.logWrite(list, PanGuLuceneHelper.instance.Delete);
     }
     return Content((isdelok > 0).ToString());
 }
        /// <summary>
        /// 根据用户导入cnblog数据
        /// </summary>
        /// <param name="userName"></param>
        /// <returns></returns>
        public string Import(string userName, string iszf, string isshowhome, string isshowmyhome)
        {
            userName = userName.Trim();
            int blosNumber = 0;
            JavaScriptSerializer jss = new JavaScriptSerializer();
            string url = "http://www.cnblogs.com/" + userName + @"/mvc/blog/sidecolumn.aspx";
            HtmlAgilityPack.HtmlWeb htmlweb = new HtmlAgilityPack.HtmlWeb();
            HtmlAgilityPack.HtmlDocument document = new HtmlDocument();
            var docment = htmlweb.Load(url);
            string userid = GetCnblogUserId(userName);
            var liS = docment.DocumentNode.SelectNodes("//*[@id='sidebar_categories']/div[1]/ul/li");
            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("//*[@id='mainContent']/div/div[2]/div[@class='entrylistItem']");
                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;
                    if (IsAreBlog(typeitemhref))
                        continue;//说明这篇文章已经备份过了的
                    var bloghtml = htmlweb.Load(typeitemhref);
                    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']");
                    try
                    {
                        blogName = blogNameObj.InnerText;
                    }
                    catch (Exception)
                    { }

                    var blogtitle = bloghtml.DocumentNode.SelectSingleNode("//*[@id='cb_post_title_url']").InnerText;
                    var blogurl = bloghtml.DocumentNode.SelectSingleNode("//*[@id='cb_post_title_url']").Attributes["href"].Value;
                    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 = Blogs.Common.Helper.MyHtmlHelper.GetRequest(blogtypetagurl);
                    var jsonobj = jss.Deserialize<Dictionary<string, string>>(blogtag);
                    if (null == jsonobj)
                        continue;//如果没有 则返回  (这里只能去 数字.html  不能取那种自定义的url)
                    var tagSplit = jsonobj["Tags"].Split(',');
                    var 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, userName));
                        }
                    }
                    var categoriesSplit = jsonobj["Categories"].Split(',');
                    var 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, userName));
                        }
                    }
                    var blogtimeobj = bloghtml.DocumentNode.SelectSingleNode("//*[@id='post-date']");
                    var blogtime = "";
                    if (null != blogtimeobj)
                        blogtime = blogtimeobj.InnerText;

                    DateTime? createtime = null;
                    var Outcreatetime = DateTime.Now;
                    if (DateTime.TryParse(blogtime, out Outcreatetime))
                        createtime = Outcreatetime;
                    BlogsBLL blog = new BlogsBLL();
                    var myBlogTags = new BlogTagsBLL().GetList(t => blogtagid.Contains(t.Id), isAsNoTracking: false).ToList();//.ToList();

                    var myBlogTypes = new BLL.BlogTypesBLL().GetList(t => blogtypeid.Contains(t.Id), isAsNoTracking: false).ToList();//.ToList();
                    try
                    {
                        var modelMyBlogs = new ModelDB.Blogs()
                        {
                            BlogContent = blogcontext,
                            BlogCreateTime = createtime,
                            BlogTitle = blogtitle,
                            BlogUrl = blogurl,
                            IsDel = false,
                            BlogTags = myBlogTags,
                            BlogTypes = myBlogTypes,
                            UsersId = GetUserId(userName),
                            BlogForUrl = blogurl,
                            IsForwarding = iszf == "true",
                            IsShowMyHome = isshowmyhome == "true",
                            IsShowHome = isshowhome == "true"
                        };
                        blog.Add(modelMyBlogs);
                        blog.save();
                        var newtag = string.Empty;
                        try
                        {
                            modelMyBlogs.BlogTags.Where(t => true).ToList().ForEach(t => newtag += t.TagName + " ");
                            var newblogurl = "/" + modelMyBlogs.BlogUsersSet.UserName + "/" + modelMyBlogs.Id + ".html";
                            SearchResult search = new SearchResult()
                            {
                                flag = modelMyBlogs.UsersId,
                                id = modelMyBlogs.Id,
                                title = blogtitle,
                                clickQuantity = 0,
                                blogTag = newtag,
                                content = getText(blogcontext, document),
                                url = newblogurl
                            };

                            SafetyWriteHelper<SearchResult>.logWrite(search, PanGuLuceneHelper.instance.CreateIndex);
                        }
                        catch (Exception)
                        {
                        }

                        var postid = blogurl.Substring(blogurl.LastIndexOf('/') + 1);
                        postid = postid.Substring(0, postid.LastIndexOf('.'));
                        testJumonyParser(modelMyBlogs.Id, postid, userName);

                        blosNumber++;
                    }
                    catch (Exception)
                    {
                        throw;
                    }
                }
            }
            if (blosNumber > 0)
            {
                Blogs.BLL.Common.GetDataHelper.GetAllTag();
                Blogs.BLL.Common.CacheData.GetAllType(true);
                Blogs.BLL.Common.CacheData.GetAllUserInfo(true);
                return "成功导入" + blosNumber + "篇Blog";
            }
            return "ok";
        }