コード例 #1
0
ファイル: HtmlManager.cs プロジェクト: fengpb/CodeNote
        public ReturnValue AddOrEdit(Html html)
        {
            ReturnValue retValue = new ReturnValue();
            if (html == null || html.ArtID < 0)
            {
                retValue.IsExists = false;
                retValue.Message = "html 信息为空";
                return retValue;
            }
            Html old = this.Get(html.ArtID);

            using (HtmlDal dal = new HtmlDal())
            {
                if (old == null)
                {
                    if (dal.Add(html))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "页面信息添加成功";
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "页面信息添加失败";
                    }
                }
                else//修改
                {
                    if (dal.Modify(html))
                    {
                        retValue.IsExists = true;
                        retValue.Message = "页面信息修改成功";
                    }
                    else
                    {
                        retValue.IsExists = false;
                        retValue.Message = "页面信息修改失败";
                    }
                }
            }
            return retValue;
        }
コード例 #2
0
ファイル: HtmlManager.cs プロジェクト: fengpb/CodeNote
 /// <summary>
 /// 用于更新sitemap.xml
 /// </summary>
 /// <returns></returns>
 public ReturnValue RefreshSiteMap()
 {
     ReturnValue retValue = new ReturnValue();
     IList<Html> list = null;
     using (HtmlDal dal = new HtmlDal())
     {
         list = dal.SiteMapList();
     }
     if (list != null)
     {
         StringTemplate st = CodeNote.Common.TemplateWrap.GetSt("sitemap_xml");
         if (st != null)
         {
             st.SetAttribute("list", list);
             st.SetAttribute("date", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:sszd"));
             st.SetAttribute("domain", CodeNote.Common.ConfigWrap.FileUrl("domain"));
             st.SetAttribute("baseurl", CodeNote.Common.ConfigWrap.FileUrl(STATIC_HTML_DIR, true));
             if (CodeNote.Common.IoWrap.WriteFile(CodeNote.Common.ConfigWrap.FiePath(SITE_MAP_FILE), st.ToString()))
             {
                 retValue.IsExists = true;
                 retValue.Message = "Refresh stiemap suuuessful!";
             }
             else
             {
                 retValue.IsExists = false;
                 retValue.Message = "Refresh stiemap error!";
             }
         }
         else
         {
             log.Warn("Not find 'sitemap_xml.st' template !");
         }
     }
     else
     {
         retValue.IsExists = false;
         retValue.Message = "无数据";
     }
     return retValue;
 }
コード例 #3
0
ファイル: HtmlManager.cs プロジェクト: fengpb/CodeNote
 public Html Get(int artID)
 {
     Html html = null;
     using (HtmlDal dal = new HtmlDal())
     {
         html = dal.Get(artID);
     }
     return html;
 }