コード例 #1
0
ファイル: BlogPost.cs プロジェクト: LeoLcy/cnblogsbywojilu
 /// <summary>
 /// ��������б�
 /// </summary>
 public List<Maticsoft.Model.BlogPost> DataTableToList(DataTable dt)
 {
     List<Maticsoft.Model.BlogPost> modelList = new List<Maticsoft.Model.BlogPost>();
     int rowsCount = dt.Rows.Count;
     if (rowsCount > 0)
     {
         Maticsoft.Model.BlogPost model;
         for (int n = 0; n < rowsCount; n++)
         {
             model = new Maticsoft.Model.BlogPost();
             if(dt.Rows[n]["Id"].ToString()!="")
             {
                 model.Id=int.Parse(dt.Rows[n]["Id"].ToString());
             }
             if(dt.Rows[n]["OwnerId"].ToString()!="")
             {
                 model.OwnerId=int.Parse(dt.Rows[n]["OwnerId"].ToString());
             }
             model.OwnerType=dt.Rows[n]["OwnerType"].ToString();
             model.OwnerUrl=dt.Rows[n]["OwnerUrl"].ToString();
             if(dt.Rows[n]["AppId"].ToString()!="")
             {
                 model.AppId=int.Parse(dt.Rows[n]["AppId"].ToString());
             }
             if(dt.Rows[n]["SysCategoryId"].ToString()!="")
             {
                 model.SysCategoryId=int.Parse(dt.Rows[n]["SysCategoryId"].ToString());
             }
             if(dt.Rows[n]["CreatorId"].ToString()!="")
             {
                 model.CreatorId=int.Parse(dt.Rows[n]["CreatorId"].ToString());
             }
             model.CreatorUrl=dt.Rows[n]["CreatorUrl"].ToString();
             if(dt.Rows[n]["CategoryId"].ToString()!="")
             {
                 model.CategoryId=int.Parse(dt.Rows[n]["CategoryId"].ToString());
             }
             model.Title=dt.Rows[n]["Title"].ToString();
             model.Content=dt.Rows[n]["Content"].ToString();
             model.Abstract=dt.Rows[n]["Abstract"].ToString();
             model.Pic=dt.Rows[n]["Pic"].ToString();
             if(dt.Rows[n]["CommentCondition"].ToString()!="")
             {
                 model.CommentCondition=int.Parse(dt.Rows[n]["CommentCondition"].ToString());
             }
             if(dt.Rows[n]["Hits"].ToString()!="")
             {
                 model.Hits=int.Parse(dt.Rows[n]["Hits"].ToString());
             }
             if(dt.Rows[n]["IsPic"].ToString()!="")
             {
                 model.IsPic=int.Parse(dt.Rows[n]["IsPic"].ToString());
             }
             if(dt.Rows[n]["IsPick"].ToString()!="")
             {
                 model.IsPick=int.Parse(dt.Rows[n]["IsPick"].ToString());
             }
             if(dt.Rows[n]["IsTop"].ToString()!="")
             {
                 model.IsTop=int.Parse(dt.Rows[n]["IsTop"].ToString());
             }
             if(dt.Rows[n]["Replies"].ToString()!="")
             {
                 model.Replies=int.Parse(dt.Rows[n]["Replies"].ToString());
             }
             if(dt.Rows[n]["SaveStatus"].ToString()!="")
             {
                 model.SaveStatus=int.Parse(dt.Rows[n]["SaveStatus"].ToString());
             }
             if(dt.Rows[n]["AccessStatus"].ToString()!="")
             {
                 model.AccessStatus=int.Parse(dt.Rows[n]["AccessStatus"].ToString());
             }
             model.Ip=dt.Rows[n]["Ip"].ToString();
             if(dt.Rows[n]["Created"].ToString()!="")
             {
                 model.Created=DateTime.Parse(dt.Rows[n]["Created"].ToString());
             }
             modelList.Add(model);
         }
     }
     return modelList;
 }
コード例 #2
0
ファイル: SpiderTool.cs プロジェクト: LeoLcy/cnblogsbywojilu
        private static void savePageDetail( DetailLink lnk, StringBuilder sb )
        {
            SpiderTemplate template = lnk.Template;
            string url = lnk.Url;
            string title = lnk.Title;
            string summary = lnk.Abstract;

            if (isPageExist( url, sb )) return;

            String pageBody = new PagedDetailSpider().GetContent( url, template, sb );

            if (pageBody == null) return;

            SpiderArticle pd = new SpiderArticle();
            pd.Title = title;
            pd.Url = strUtil.SubString( url, 250 );
            pd.Abstract = summary;
            pd.Body = pageBody;
            pd.SpiderTemplate = template;

            MatchCollection matchs = Regex.Matches( pageBody, RegPattern.Img, RegexOptions.Singleline );
            if (matchs.Count > 0) {
                pd.IsPic = 1;
                pd.PicUrl = matchs[0].Groups[1].Value;
            }

            pd.insert();

            sb.AppendLine( "保存成功..." + lnk.Title + "_" + lnk.Url );

            pageBody = Regex.Replace(pageBody, "font-size", "", RegexOptions.IgnoreCase);
            string strArcitleLink = "<div class=\"ArcitleLink\"><a href=" + pd.Url + ">原文链接</a></div>";
            pageBody = pageBody + strArcitleLink;

            Maticsoft.BLL.BlogCategory bllBlogCategory = new Maticsoft.BLL.BlogCategory();
            DataSet ds = bllBlogCategory.GetList("AppId = '" + template.IsDelete.ToString() + "'");
            int nCateID = 1;
            if (ds.Tables[0].Rows.Count > 0)
            {
                nCateID = (int)ds.Tables[0].Rows[0]["Id"];
            }

            BlogPost data = new BlogPost();

            data.CategoryId = nCateID;
            data.Title = title;
            data.Abstract = summary;
            data.Content = pageBody;
            data.AccessStatus = 0;
            data.CommentCondition = 0;
            data.SaveStatus = 1;//草稿
            data.Created = System.DateTime.Now.Date;
            data.IsTop = 0;
            data.IsPick = 0;
            data.IsPic = 0;
            data.Ip = "";
            data.OwnerId = template.IsDelete;
            data.OwnerUrl = template.SiteName;
            data.OwnerType = "wojilu.Members.Users.Domain.User";
            data.CreatorUrl = template.SiteName;
            data.AppId = template.IsDelete; ;
            data.CreatorId = template.IsDelete;
            Maticsoft.BLL.BlogPost bll = new Maticsoft.BLL.BlogPost();
            bll.Add(data);
        }
コード例 #3
0
ファイル: BlogPost.cs プロジェクト: xia7410/cnblogsbywojilu
 /// <summary>
 /// 增加一条数据
 /// </summary>
 public int  Add(Maticsoft.Model.BlogPost model)
 {
     return(dal.Add(model));
 }
コード例 #4
0
ファイル: BlogPost.cs プロジェクト: xia7410/cnblogsbywojilu
 /// <summary>
 /// 更新一条数据
 /// </summary>
 public void Update(Maticsoft.Model.BlogPost model)
 {
     dal.Update(model);
 }
コード例 #5
0
ファイル: BlogPost.cs プロジェクト: xia7410/cnblogsbywojilu
        /// <summary>
        /// 获得数据列表
        /// </summary>
        public List <Maticsoft.Model.BlogPost> DataTableToList(DataTable dt)
        {
            List <Maticsoft.Model.BlogPost> modelList = new List <Maticsoft.Model.BlogPost>();
            int rowsCount = dt.Rows.Count;

            if (rowsCount > 0)
            {
                Maticsoft.Model.BlogPost model;
                for (int n = 0; n < rowsCount; n++)
                {
                    model = new Maticsoft.Model.BlogPost();
                    if (dt.Rows[n]["Id"].ToString() != "")
                    {
                        model.Id = int.Parse(dt.Rows[n]["Id"].ToString());
                    }
                    if (dt.Rows[n]["OwnerId"].ToString() != "")
                    {
                        model.OwnerId = int.Parse(dt.Rows[n]["OwnerId"].ToString());
                    }
                    model.OwnerType = dt.Rows[n]["OwnerType"].ToString();
                    model.OwnerUrl  = dt.Rows[n]["OwnerUrl"].ToString();
                    if (dt.Rows[n]["AppId"].ToString() != "")
                    {
                        model.AppId = int.Parse(dt.Rows[n]["AppId"].ToString());
                    }
                    if (dt.Rows[n]["SysCategoryId"].ToString() != "")
                    {
                        model.SysCategoryId = int.Parse(dt.Rows[n]["SysCategoryId"].ToString());
                    }
                    if (dt.Rows[n]["CreatorId"].ToString() != "")
                    {
                        model.CreatorId = int.Parse(dt.Rows[n]["CreatorId"].ToString());
                    }
                    model.CreatorUrl = dt.Rows[n]["CreatorUrl"].ToString();
                    if (dt.Rows[n]["CategoryId"].ToString() != "")
                    {
                        model.CategoryId = int.Parse(dt.Rows[n]["CategoryId"].ToString());
                    }
                    model.Title    = dt.Rows[n]["Title"].ToString();
                    model.Content  = dt.Rows[n]["Content"].ToString();
                    model.Abstract = dt.Rows[n]["Abstract"].ToString();
                    model.Pic      = dt.Rows[n]["Pic"].ToString();
                    if (dt.Rows[n]["CommentCondition"].ToString() != "")
                    {
                        model.CommentCondition = int.Parse(dt.Rows[n]["CommentCondition"].ToString());
                    }
                    if (dt.Rows[n]["Hits"].ToString() != "")
                    {
                        model.Hits = int.Parse(dt.Rows[n]["Hits"].ToString());
                    }
                    if (dt.Rows[n]["IsPic"].ToString() != "")
                    {
                        model.IsPic = int.Parse(dt.Rows[n]["IsPic"].ToString());
                    }
                    if (dt.Rows[n]["IsPick"].ToString() != "")
                    {
                        model.IsPick = int.Parse(dt.Rows[n]["IsPick"].ToString());
                    }
                    if (dt.Rows[n]["IsTop"].ToString() != "")
                    {
                        model.IsTop = int.Parse(dt.Rows[n]["IsTop"].ToString());
                    }
                    if (dt.Rows[n]["Replies"].ToString() != "")
                    {
                        model.Replies = int.Parse(dt.Rows[n]["Replies"].ToString());
                    }
                    if (dt.Rows[n]["SaveStatus"].ToString() != "")
                    {
                        model.SaveStatus = int.Parse(dt.Rows[n]["SaveStatus"].ToString());
                    }
                    if (dt.Rows[n]["AccessStatus"].ToString() != "")
                    {
                        model.AccessStatus = int.Parse(dt.Rows[n]["AccessStatus"].ToString());
                    }
                    model.Ip = dt.Rows[n]["Ip"].ToString();
                    if (dt.Rows[n]["Created"].ToString() != "")
                    {
                        model.Created = DateTime.Parse(dt.Rows[n]["Created"].ToString());
                    }
                    modelList.Add(model);
                }
            }
            return(modelList);
        }