Dev2.ServerLifecycleManager.ProcessWorkflowGroup C# (CSharp) Method

ProcessWorkflowGroup() private method

Transforms WorkflowGroup nodes into WorkflowEntry objects.
private ProcessWorkflowGroup ( XmlNode section ) : bool
section System.Xml.XmlNode
return bool
        bool ProcessWorkflowGroup(XmlNode section)
        {
            XmlNodeList allWorkflows = section.HasChildNodes ? section.ChildNodes : null;

            if(allWorkflows != null)
            {
                XmlAttributeCollection allAttribs = section.Attributes;
                string groupName = null;

                if(allAttribs != null)
                {
                    foreach(XmlAttribute currentAttrib in allAttribs)
                    {
                        if(String.Equals(currentAttrib.Name, "Name", StringComparison.OrdinalIgnoreCase))
                        {
                            groupName = currentAttrib.Value;
                        }
                    }
                }

                if(groupName == null)
                {
                    Fail("Configuration error, WorkflowGroup has no Name attribute.");
                    return false;
                }

                List<WorkflowEntry> group = new List<WorkflowEntry>();

                foreach(XmlNode current in allWorkflows)
                {
                    if(String.Equals(current.Name, "Workflow", StringComparison.OrdinalIgnoreCase))
                    {
                        allAttribs = current.Attributes;
                        string name = null;

                        if(allAttribs != null)
                        {
                            foreach(XmlAttribute currentAttrib in allAttribs)
                            {
                                if(String.Equals(currentAttrib.Name, "Name", StringComparison.OrdinalIgnoreCase))
                                {
                                    name = currentAttrib.Value;
                                }
                            }
                        }

                        if(name == null)
                        {
                            Fail("Configuration error, Workflow has no Name attribute.");
                            return false;
                        }

                        Dictionary<string, string> arguments = new Dictionary<string, string>(StringComparer.Ordinal);

                        if(current.HasChildNodes)
                        {
                            XmlNodeList allArguments = current.ChildNodes;

                            foreach(XmlNode currentArg in allArguments)
                            {
                                if(String.Equals(currentArg.Name, "Argument", StringComparison.OrdinalIgnoreCase))
                                {
                                    allAttribs = currentArg.Attributes;

                                    if(allAttribs != null)
                                    {
                                        string key = null;

                                        foreach(XmlAttribute argAttrib in allAttribs)
                                        {
                                            if(String.Equals(argAttrib.Name, "Key", StringComparison.OrdinalIgnoreCase))
                                            {
                                                key = argAttrib.Value;
                                            }
                                        }

                                        if(key == null)
                                        {
                                            Fail("Configuration error, Argument has no Key attribute.");
                                            return false;
                                        }

                                        string value = currentArg.InnerText;

                                        if(arguments.ContainsKey(key))
                                        {
                                            arguments[key] = value;
                                        }
                                        else
                                        {
                                            arguments.Add(key, value);
                                        }
                                    }
                                }
                            }
                        }

                        group.Add(new WorkflowEntry(name));
                    }
                }

                if(group.Count > 0)
                {
                    if(_workflowGroups.ContainsKey(groupName))
                    {
                        group.InsertRange(0, _workflowGroups[groupName]);
                        _workflowGroups[groupName] = group.ToArray();
                    }
                    else
                    {
                        _workflowGroups.Add(groupName, group.ToArray());
                    }
                }
            }

            return true;
        }