Exemple #1
0
        private void HandlePlugin(XmlNode contentNode, string[] args, Process process)
        {
            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.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 != "")
                    {
                        provider.Handle(mainEvent);
                    }
                    break;
                }
            }
        }
Exemple #2
0
 public string this[string name]
 {
     get
     {
         return(CommonXml.GetAttributeValue(m_XmlNode, name));
     }
     set
     {
         CommonXml.SetAttributeValue(m_XmlNode, name, value);
     }
 }
Exemple #3
0
        private 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
            {
                // Replace variables
                ReplaceVariables(process.Variables, value);
            }
            return(value.ToString());
        }
Exemple #4
0
        public static void CombineSettings(string[] paths, Cache cache)
        {
            string[] fileNames = GetConfigFileNames("Settings.xml", paths);
            if (FilesChanged(fileNames, cache))
            {
                XmlDocument combinedSettings = new XmlDocument();
                combinedSettings.AppendChild(combinedSettings.CreateElement("settings"));

                foreach (string fileName in fileNames)
                {
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(fileName);
                    CommonXml.MergeXml(combinedSettings, xmlDocument, "item");

                    cache["changed_" + fileName] = File.GetLastWriteTime(fileName);
                }

                cache["settings"] = combinedSettings;
            }
        }
Exemple #5
0
        public static void CombineProcessTree(string[] paths, Cache cache)
        {
            string[] fileNames = GetConfigFileNames("Process.xml", paths);
            if (FilesChanged(fileNames, cache))
            {
                XmlDocument combinedProcess = new XmlDocument();
                combinedProcess.AppendChild(combinedProcess.CreateElement("process"));

                foreach (string fileName in fileNames)
                {
                    XmlDocument xmlDocument = new XmlDocument();
                    xmlDocument.Load(fileName);
                    CommonXml.MergeXml(combinedProcess, xmlDocument, "load", "handle");

                    cache["changed_" + fileName] = File.GetLastWriteTime(fileName);
                }

                cache["process"] = combinedProcess;
            }
        }
        private static void doMergeXml(XmlNode baseXmlNode, XmlNode mergeXmlNode, params string[] uniqueIdentifiers)
        {
            foreach (XmlNode xmlNode in mergeXmlNode)
            {
                if (xmlNode.Name != "#text")
                {
                    EmptyNodeHandling emptyNode;
                    if (Common.StringArrayContains(uniqueIdentifiers, xmlNode.Name))
                    {
                        emptyNode = EmptyNodeHandling.ForceCreateNew;
                    }
                    else
                    {
                        emptyNode = EmptyNodeHandling.CreateNew;
                    }

                    XmlNode currentBaseXmlnode = GetNode(baseXmlNode, xmlNode.Name, emptyNode);
                    foreach (XmlAttribute xmlAttribute in xmlNode.Attributes)
                    {
                        CommonXml.SetAttributeValue(currentBaseXmlnode, xmlAttribute.Name, xmlAttribute.Value);
                    }
                    if (xmlNode.HasChildNodes)
                    {
                        doMergeXml(currentBaseXmlnode, xmlNode, uniqueIdentifiers);
                    }
                }
                else
                {
                    XmlNode textNode = baseXmlNode.SelectSingleNode("text()");
                    if (textNode != null)
                    {
                        textNode.InnerText = xmlNode.Value;
                    }
                    else
                    {
                        baseXmlNode.AppendChild(baseXmlNode.OwnerDocument.CreateTextNode(xmlNode.Value));
                    }
                }
            }
        }
Exemple #7
0
        public string this[string path, RelativePathHandling relativePathHandling]
        {
            get
            {
                XmlNode settingsNode = CommonXml.GetNode(m_CombinedSettings.SelectSingleNode("settings"), path, EmptyNodeHandling.CreateNew);

                string value = settingsNode.InnerText;

                if (relativePathHandling == RelativePathHandling.ConvertToAbsolute)
                {
                    return(ConvertPath(value));
                }
                else
                {
                    return(value);
                }
            }
            set
            {
                CommonXml.GetNode(m_CustomSettings.SelectSingleNode("settings"), path, EmptyNodeHandling.CreateNew).InnerText   = value;
                CommonXml.GetNode(m_CombinedSettings.SelectSingleNode("settings"), path, EmptyNodeHandling.CreateNew).InnerText = value;
                Save();
            }
        }
Exemple #8
0
 public XmlNode GetAsNode(string path)
 {
     return(CommonXml.GetNode(m_CombinedSettings.SelectSingleNode("settings"), path));
 }
 protected XmlNode GetNode(string cleanPath, EmptyNodeHandling emptyNode)
 {
     return(CommonXml.GetNode(m_ParentNode, cleanPath, emptyNode));
 }
Exemple #10
0
        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("*");
                        foreach (XmlNode contentNode in contentNodes)
                        {
                            // Not very pretty, I know, but it seems to be the
                            // best way to allow for proper debugging
                            if (process.HttpPage.Request.ServerVariables["REMOTE_ADDR"] == "127.0.0.1")
                            {
                                switch (contentNode.Name)
                                {
                                case "load":
                                    HandlePlugin(contentNode, args, process);
                                    break;

                                case "handle":
                                    HandlePlugin(contentNode, args, process);
                                    break;

                                case "template":
                                    process.mainTemplate = process.Settings["templates/" + contentNode.Attributes["name"].Value];
                                    break;

                                case "redirect":
                                    process.HttpPage.Response.Redirect(process.GetUrl(contentNode.Attributes["href"].Value));
                                    break;
                                }
                            }
                            else
                            {
                                try
                                {
                                    switch (contentNode.Name)
                                    {
                                    case "load":
                                        HandlePlugin(contentNode, args, process);
                                        break;

                                    case "handle":
                                        HandlePlugin(contentNode, args, process);
                                        break;

                                    case "template":
                                        process.mainTemplate = process.Settings["templates/" + contentNode.Attributes["name"].Value];
                                        break;

                                    case "redirect":
                                        process.HttpPage.Response.Redirect(process.GetUrl(contentNode.Attributes["href"].Value));
                                        break;
                                    }
                                }
                                catch (Exception e)
                                {
                                    process.AddMessage(e);
                                }
                            }
                        }
                        args = Common.RemoveOne(args);

                        if (args != null)
                        {
                            LoopThroughProcess(args, xmlNode, process);
                        }
                    }
                    else
                    {
                        string redirectUrl = string.Format("login.aspx?redirect={0}", process.QueryOther["process"]);
                        process.HttpPage.Response.Redirect(redirectUrl); // todo: is this the way to do it
                    }
                }
            }
        }