private void LoopThroughProcess(string[] args, XmlNode xmlNode, Process process) { if (args[0] != string.Empty) { args[0] = CommonXml.RenameIntegerPath(args[0]); xmlNode = xmlNode.SelectSingleNode(args[0]); if (xmlNode != null) { if (process.CheckGroups(CommonXml.GetAttributeValue(xmlNode, "rights"))) { XmlNodeList contentNodes = xmlNode.SelectNodes("*"); LoopThroughProcessOneByOne(contentNodes, "template", process, args); LoopThroughProcessOneByOne(contentNodes, "handle", process, args); LoopThroughProcessOneByOne(contentNodes, "redirect", process, args); LoopThroughProcessOneByOne(contentNodes, "load", process, args); args = Common.Common.RemoveOne(args); if (args != null) { LoopThroughProcess(args, xmlNode, process); } } else { string redirectUrl = GetRedirectUrl(process.CurrentProcess); process.HttpPage.Response.Redirect(redirectUrl); // ToDo: is this the way to do it } } } }
private void FrontPage() { object[] results = Process.Plugins.InvokeAll("users", "list_groups", Process.CurrentUser); List <string> userGroups = new List <string>(Common.FlattenToStrings(results)); foreach (string group in userGroups) { string xPath = string.Format("groups/item[@name='{0}']", group); XmlNode node; try { node = Process.Settings.GetAsNode(xPath); } catch { node = null; } if (node == null) { continue; } string frontPage = CommonXml.GetAttributeValue(node, "frontpage"); if (string.IsNullOrEmpty(frontPage)) { continue; } Process.HttpPage.Response.Redirect(frontPage + "/"); } }
private void CopyInfoFromTree() { this["name"] = _treeNode.Name; this["menuname"] = CommonXml.GetAttributeValue(_treeNode, "menuname"); this["pageidentifier"] = CommonXml.GetXPath(_treeNode); this["status"] = CommonXml.GetAttributeValue(_treeNode, "status"); }
private void HandlePlugin(XmlNode contentNode, string[] args, Process process) { if (contentNode.Attributes != null) { IPlugin provider = GetProvider(contentNode.Attributes["provider"].Value); if (provider != null) { switch (contentNode.Name) { case "load": ControlList control = process.Content.GetSubControl(CommonXml.GetAttributeValue(contentNode, "place")); string action = CommonXml.GetAttributeValue(contentNode, "action"); string value = GetValue(contentNode, process); string pathTrail = JoinPath(Common.Common.RemoveOne(args)); if (provider is IPlugin2) { ((IPlugin2)provider).Load(control, action, value, pathTrail); } else { provider.Load(control, action, pathTrail); } break; case "handle": string mainEvent = process.QueryEvents["main"]; if (mainEvent != string.Empty) { provider.Handle(mainEvent); } break; } } } }
public string this[string name] { get { string attribute = CommonXml.GetAttributeValue(_xmlNode, name); return(attribute); } set { CommonXml.SetAttributeValue(_xmlNode, name, value); } }
private void HandleLog() { XmlNode messagesNode = CommonXml.GetNode(Process.XmlData, "messages", EmptyNodeHandling.Ignore); if (messagesNode == null) { return; } String logFileName = Process.Settings["errorlog/logpath"]; XmlNodeList items = messagesNode.SelectNodes("item"); if (items != null) { foreach (XmlNode item in items) { bool writtenToLogFile = false; try { if (CommonXml.GetAttributeValue(item, "writtenToLogFile") == "true") { writtenToLogFile = true; } } catch { writtenToLogFile = false; } if (writtenToLogFile) { continue; } if (CommonXml.GetAttributeValue(item, "messagetype") != "Error") { continue; } String errorType = CommonXml.GetAttributeValue(item, "type"); String message = item.InnerText; File.AppendAllText(logFileName, String.Format("{0};{1};{2}\r\n", DateTime.Now.ToUniversalTime(), errorType, message)); CommonXml.SetAttributeValue(item, "writtenToLogFile", "true"); } } }
private static string GetValue(XmlNode contentNode, Process process) { StringBuilder value = new StringBuilder(CommonXml.GetAttributeValue(contentNode, "value")); if (value.ToString() == string.Empty) { // No value is specified. Maybe a variable was requested? string variable = CommonXml.GetAttributeValue(contentNode, "variable"); if (variable != string.Empty) { value = new StringBuilder(process.Variables[variable]); } } else { ReplaceVariables(process.Variables, value); // Replace variables } return(value.ToString()); }
/// <summary> /// Gets the page. /// </summary> /// <param name="pageNode">The page node.</param> /// <returns></returns> private Page GetPage(XmlNode pageNode) { Page page = null; if (pageNode != null) { string path = CommonXml.GetXPath(pageNode); string fileName = Path.Combine(_contentRoot, string.Format(_contentFilenameFormat, path)); if (!File.Exists(fileName)) { PagePath pagePath = new PagePath(path); CreateFile(pagePath.Path, pagePath.Name, CommonXml.GetAttributeValue(pageNode, "menuname")); } XmlDocument document = new XmlDocument(); document.Load(fileName); page = new Page(document.SelectSingleNode("//page"), GetPageNode(path), this); } return(page); }