Ejemplo n.º 1
0
 public void PrintError(Exception err)
 {
     if (string.IsNullOrEmpty(err.HelpLink)) { err.HelpLink = SiteCfg.WebSite; }
     FileTemplate tpl = new FileTemplate();
     tpl.LoadFile(Path.Combine(SiteCfg.Router, "Common/Theme/Error.htm"));
     tpl.SetTag("HelpLink", Pre(err.HelpLink));
     tpl.SetTag("Message", Pre(err.Message));
     tpl.SetTag("Source", Pre(err.Source));
     tpl.SetTag("StackTrace", Pre(err.StackTrace));
     tpl.Print();
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 取得菜单
 /// </summary>
 public string MenuCode(string xmlContent, string bigClassCode, string classCode)
 {
     StringBuilder sr = new StringBuilder();
     //取得循环元素
     string parentMenu = bigClassCode;
     string menuItem = classCode;
     //开始处理
     XmlDocument menuXml = new XmlDocument();
     menuXml.LoadXml(xmlContent);
     XmlNodeList parents = menuXml.SelectNodes("/root/parent");
     foreach (XmlNode node in parents)
     {
         string itemsCode = string.Empty;
         XmlNodeList items = node.SelectNodes("item");
         foreach (XmlNode itemNode in items)
         {
             FileTemplate ift = new FileTemplate();
             ift.LoadCode(menuItem);
             ift.SetTag("Caption", itemNode.Attributes["name"].Value);
             ift.SetTag("Link", itemNode.Attributes["link"].Value);
             if (string.IsNullOrEmpty(itemNode.Attributes["icon"].Value)) { ift.SetTag("Icon", string.Empty); }
             else { ift.SetTag("Icon", string.Format("<img src=\"Common/Images/Icons/{0}\" width=\"16\" height=\"16\"/>", itemNode.Attributes["icon"].Value)); }
             itemsCode += ift.Code;
         }
         //全局处理
         FileTemplate ft = new FileTemplate();
         ft.LoadCode(parentMenu);
         ft.SetTag("Caption", node.Attributes["name"].Value);
         ft.SetTag("Rel", node.Attributes["rel"].Value);
         ft.SetTag("ID", node.Attributes["id"].Value);
         ft.SetTag("ItemList", itemsCode);
         sr.Append(ft.Code);
     }
     return sr.ToString();
 }