Пример #1
0
 /// <summary>
 /// 显示内容
 /// </summary>
 /// <param name="sender">基类对象</param>
 /// <param name="e">事件对象</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     using (_DbHelper conn = new _DbHelper(SiteCfg.Conn))
     {
         conn.Open();
         conn.BeginTransaction();
         try
         {
             XsltTemplate tpl = new XsltTemplate(conn);
             //初始化全局页面类库
             _WebBase wb = new _WebBase();
             wb.InitConn();
             //开始执行
             switch (SiteFun.Query("act"))
             {
                 case "page":
                     {
                         int id = SiteFun.ToInt(SiteFun.Query("id"));
                         string local = SiteFun.Query("local");
                         WebPage webPg = new WebPage(conn);
                         tpl.LoadXslt(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webPg.OutTheme, "Page.View")));
                         tpl.BindXml(webPg.OutWrite(id, local));
                         break;
                     }
                 case "tags":
                     {
                         WebTags webTags = new WebTags(conn);
                         tpl.LoadXslt(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webTags.OutTheme, "Tag.List")));
                         tpl.BindXml(webTags.OutWrite());
                         break;
                     }
                 case "fellows":
                     {
                         WebFellows webFlw = new WebFellows(conn);
                         tpl.LoadXslt(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webFlw.OutTheme, "Fellow.List")));
                         tpl.BindXml(webFlw.OutWrite());
                         break;
                     }
                 case "expand":
                     {
                         foreach (object type in new SiteExpand().GetTypes(typeof(IWebExpand).FullName))
                         {
                             IWebExpand iae = ((IWebExpand)type);
                             if (iae.Key == SiteFun.Query("key"))
                             {
                                 StringBuilder xml = new StringBuilder();
                                 xml.Append("\t\t<expand>\n");
                                 xml.AppendFormat("\t\t\t<css>{0}</css>\n", SiteFun.CDATA(iae.Css));
                                 xml.AppendFormat("\t\t\t<html>{0}</html>\n", SiteFun.CDATA(iae.OutHtml()));
                                 xml.Append("\t\t</expand>\n");
                                 tpl.LoadXslt(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, iae.OutTheme, "Expand.View")));
                                 tpl.BindXml(new _WebBaseXml(conn).OutBaseXml(iae.Name, xml.ToString()));
                                 break;
                             }
                         }
                         break;
                     }
                 default:
                     {
                         WebArticle webArt = new WebArticle(conn);
                         switch (SiteFun.Query("mode"))
                         {
                             case "view":
                                 {
                                     int id = SiteFun.ToInt(SiteFun.Query("id"));
                                     string local = SiteFun.Query("local");
                                     string pwd = SiteFun.Post("pwd");
                                     int page = SiteFun.ToInt(SiteFun.Query("page"));
                                     int pageSize = webArt.OutSetting.Parameter.CommentNum;
                                     string tplFile = "Article.View";
                                     PostItem postItem = new PostData(conn).GetPost(id);
                                     ColumnItem columnItem = new ColumnData(conn).GetColumn(postItem.ColumnID);
                                     if (postItem.ID == 0) { postItem = new PostData(conn).GetPost(local); }
                                     if (!string.IsNullOrEmpty(columnItem.ViewTemplate) && File.Exists(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webArt.OutTheme, columnItem.ViewTemplate)))) { tplFile = columnItem.ViewTemplate; }
                                     tpl.LoadXslt(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webArt.OutTheme, tplFile)));
                                     tpl.BindXml(webArt.OutWriteView(id, local, pwd, page, pageSize));
                                     break;
                                 }
                             default:
                                 {
                                     int cid = SiteFun.ToInt(SiteFun.Query("cid"));
                                     string clocal = SiteFun.Query("clocal");
                                     string tag = SiteFun.Query("tag");
                                     string key = SiteFun.Query("key");
                                     int page = SiteFun.ToInt(SiteFun.Query("page"));
                                     int pageSize = webArt.OutSetting.Parameter.ArticleNum;
                                     string tplFile = "Article.List";
                                     //开始处理
                                     ColumnItem column = new ColumnData(conn).GetColumn(cid);
                                     if (column.ID == 0) { column = new ColumnData(conn).GetColumn(clocal); }
                                     if (column.ID == 0 && string.IsNullOrEmpty(tag) && string.IsNullOrEmpty(key) && page == 0 && File.Exists(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webArt.OutTheme, "Index")))) { tplFile = "Index"; }
                                     else
                                     {
                                         if (column.ID > 0)
                                         {
                                             if (!string.IsNullOrEmpty(column.ListTemplate) && File.Exists(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webArt.OutTheme, column.ListTemplate)))) { tplFile = column.ListTemplate; }
                                             if (column.PageSize > 0) { pageSize = column.PageSize; }
                                         }
                                     }
                                     tpl.LoadXslt(Path.Combine(SiteCfg.Router, string.Format(SitePath.ThemePathFormat, webArt.OutTheme, tplFile)));
                                     tpl.BindXml(webArt.OutWriteList(cid, clocal, tag, key, page, pageSize));
                                     break;
                                 }
                         }
                         break;
                     }
             }
             if (conn.ExecuteCount > 0) { conn.Commit(); }
             tpl.Print();
         }
         catch (Exception err)
         {
             if (conn.ExecuteCount > 0) { conn.Rollback(); }
             IMyError exeError = new MyError();
             foreach (IMyError myError in new SiteExpand().GetTypes(typeof(IMyError).FullName))
             {
                 exeError = myError;
                 break;
             }
             exeError.PrintError(err);
         }
         conn.Close();
     }
 }
Пример #2
0
 /// <summary>
 /// 后台页面执行过程
 /// </summary>
 /// <param name="sender">系统对象</param>
 /// <param name="e">事件对象</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     if (!IsPostBack) { Page.DataBind(); }
     using (_DbHelper conn = new _DbHelper(SiteCfg.Conn))
     {
         conn.Open();
         conn.BeginTransaction();
         try
         {
             Stopwatch watch = new Stopwatch();
             watch.Start();
             //菜单HTML设置
             StringBuilder parentMenu = new StringBuilder();
             parentMenu.AppendLine("<div class=\"item\" id=\"{$ID}\">");
             parentMenu.AppendLine("\t<div class=\"top\">");
             parentMenu.AppendLine("\t\t<a class=\"menuCap\" rel=\"{$Rel}\">{$Caption}</a><span></span>");
             parentMenu.AppendLine("\t</div>");
             parentMenu.AppendLine("\t<div class=\"content\">");
             parentMenu.AppendLine("\t\t<ul>");
             parentMenu.AppendLine("\t\t{$ItemList}");
             parentMenu.AppendLine("\t\t</ul>");
             parentMenu.AppendLine("\t</div>");
             parentMenu.AppendLine("</div>");
             string menuItem = "<li><a href=\"{$Link}\">{$Caption}</a>{$Icon}</li>";
             //初始化后台基类
             _AdminBase admBase = new _AdminBase(conn);
             //初始化全局数据连接
             admBase.InitConn();
             menuDisplay.Text = new _AdminBase(conn).MenuCode(GetMenuXml(admBase.IsLogin), parentMenu.ToString(), menuItem);
             //是否登录
             if (admBase.IsLogin)
             {
                 //是否是用户控件扩展
                 if (SiteFun.Query("act") == "extend")
                 {
                     try
                     {
                         string folder = SiteFun.Query("folder");
                         string key = SiteFun.Query("key");
                         if (!string.IsNullOrEmpty(folder)) { folder = folder.Replace("..", string.Empty); }
                         XmlDocument extendXml = new XmlDocument();
                         string configXmlPath = Path.Combine(SiteCfg.Router, string.Format("Common/Expand/_Admin/{0}/Config.xml", folder));
                         if (File.Exists(configXmlPath))
                         {
                             extendXml.Load(configXmlPath);
                             //用户控件的文件名
                             string ucFile = string.Empty;
                             foreach (XmlNode node in extendXml.SelectNodes("/root/item"))
                             {
                                 if (node.Attributes["key"].Value == key)
                                 {
                                     ucFile = node.Attributes["file"].Value;
                                     if (!string.IsNullOrEmpty(ucFile)) { ucFile = ucFile.Replace("..", string.Empty); }
                                     break;
                                 }
                             }
                             string ucFilePath = string.Format("Common/Expand/_Admin/{0}/{1}", folder, ucFile);
                             if (File.Exists(Path.Combine(SiteCfg.Router, ucFilePath)))
                             {
                                 Control uc = new UserControl().LoadControl(ucFilePath);
                                 mainDisplay.Controls.Add(uc);
                             }
                             else { mainDisplay.Text = "No " + ucFilePath; }
                         }
                     }
                     catch (Exception er) { mainDisplay.Text = er.Message; }
                 }
                 else { mainDisplay.Text = getMainCode(conn); }
             }
             else { mainDisplay.Text = admBase.LoginWindow(); }
             powered.Text = SiteCfg.Powered;
             if (conn.ExecuteCount > 0) { conn.Commit(); }
             watch.Stop();
             debug.Text = watch.Elapsed.TotalSeconds.ToString("0.0000");
             watch.Reset();
         }
         catch (Exception err)
         {
             if (conn.ExecuteCount > 0) { conn.Rollback(); }
             IMyError exeError = new MyError();
             foreach (IMyError myError in new SiteExpand().GetTypes(typeof(IMyError).FullName))
             {
                 exeError = myError;
                 break;
             }
             exeError.PrintError(err);
         }
         conn.Close();
     }
 }
Пример #3
0
 /// <summary>
 /// 显示内容
 /// </summary>
 /// <param name="sender">基类对象</param>
 /// <param name="e">事件对象</param>
 protected void Page_Load(object sender, EventArgs e)
 {
     using (_DbHelper conn = new _DbHelper(SiteCfg.Conn))
     {
         conn.Open();
         conn.BeginTransaction();
         try
         {
             _ServiceBase sb = new _ServiceBase();
             sb.InitConn();
             //开始执行
             switch (SiteFun.Query("act"))
             {
                 case "comment":
                     {
                         new ServiceComment(conn).OutWrite();
                         break;
                     }
                 case "passwordArticle":
                     {
                         new ServicePost(conn).OutWriteOfPasswordArticle();
                         break;
                     }
                 case "rss":
                     {
                         new ServiceRss(conn).OutWrite();
                         break;
                     }
                 case "autoSave":
                     {
                         new ServicePost(conn).OutAutoSavePost();
                         break;
                     }
                 case "rePostContent":
                     {
                         new ServicePost(conn).OutRePostContent();
                         break;
                     }
                 case "artVote":
                     {
                         new ServicePost(conn).OutWriteVote();
                         break;
                     }
                 case "matchTags":
                     {
                         new ServiceTag(conn).GetMatchTags();
                         break;
                     }
                 case "trackback":
                     {
                         new ServiceTrackback(conn).OutWrite();
                         break;
                     }
                 case "verifyCode":
                     {
                         new ServiceVerifyCode().Display();
                         break;
                     }
                 case "getTime":
                     {
                         new ServiceTime().OutWrite();
                         break;
                     }
                 case "expand":
                     {
                         foreach (object type in new SiteExpand().GetTypes(typeof(IServiceExpand).FullName))
                         {
                             IServiceExpand iae = ((IServiceExpand)type);
                             if (iae.Key == SiteFun.Query("key"))
                             {
                                 iae.OutWrite();
                                 break;
                             }
                         }
                         break;
                     }
             }
             if (conn.ExecuteCount > 0) { conn.Commit(); }
         }
         catch (Exception err)
         {
             if (conn.ExecuteCount > 0) { conn.Rollback(); }
             IMyError exeError = new MyError();
             foreach (IMyError myError in new SiteExpand().GetTypes(typeof(IMyError).FullName))
             {
                 exeError = myError;
                 break;
             }
             exeError.PrintError(err);
         }
         conn.Close();
     }
 }