Beispiel #1
0
        public static Dictionary <string, XPathNavigator> GetDimensionsFromPackage(VulcanConfig vulcanConfig, XPathNavigator patternNavigator)
        {
            Dictionary <string, XPathNavigator> dimDict = new Dictionary <string, XPathNavigator>();

            foreach (XPathNavigator nav in patternNavigator.Select("rc:Dimension", vulcanConfig.NamespaceManager))
            {
                string dimensionName = nav.SelectSingleNode("@Name", vulcanConfig.NamespaceManager).Value;
                dimDict.Add(dimensionName, nav);
                Message.Trace(Severity.Debug, "Found Dimension " + dimensionName);
            }
            return(dimDict);
        }
Beispiel #2
0
        public VulcanPackage(string packageName, string packageType, VulcanConfig vulcanConfig, TemplateManager templateManager, XPathNavigator packageNavigator)
        {
            this._packageName    = packageName;
            this._projectSubpath = GetSubpathFromPackageType(packageType);

            this._vulcanConfig    = vulcanConfig;
            this._templateManager = templateManager;
            this._projectManager  = new ProjectManager(packageName);

            _DTSApplication = new DTS.Application();
            _package        = new DTS.Package();

            this._package.Name     = this._packageName;
            this._packageNavigator = packageNavigator;

            this.UnSave();
        }
Beispiel #3
0
        public DimensionHelper(string dimensionPath, TemplateManager templateManager)
        {
            Message.Trace(Severity.Debug, "Dimension Helper: Parsing Directory {0}", dimensionPath);

            foreach (string file in Directory.GetFiles(dimensionPath))
            {
                Message.Trace(Severity.Debug, "Parsing Dimensions in: {0}", file);
                VulcanConfig vulcanConfig = new VulcanConfig(file);
                foreach (XPathNavigator nav in vulcanConfig.Navigator.Select("//rc:Package", vulcanConfig.NamespaceManager))
                {
                    Message.Trace(Severity.Debug, "Found Dimensions Package {0}", nav.SelectSingleNode("@Name").Value);
                    XPathNavigator patternNavigator = nav.SelectSingleNode("rc:Patterns", vulcanConfig.NamespaceManager);
                    foreach (XPathNavigator dimNav in patternNavigator.Select("rc:Dimensions", vulcanConfig.NamespaceManager))
                    {
                        Dictionary <string, XPathNavigator> dimList = DimensionsPattern.GetDimensionsFromPackage(vulcanConfig, dimNav);
                        foreach (string s in dimList.Keys)
                        {
                            _dimDictionary.Add(s, vulcanConfig);
                            _dimNavDictionary.Add(s, dimList[s]);
                        }
                    }
                }
            }
        }
Beispiel #4
0
        public VulcanConfig XmlTemplateReplacement(VulcanConfig vulcanConfig)
        {
            List<XPathNavigator> nodeList = new List<XPathNavigator>();
            VulcanConfig vc = vulcanConfig;

            foreach (XPathNavigator node in vc.Navigator.SelectDescendants(XPathNodeType.Element, true))
            {
                if (node.XmlType != null && node.XmlType.Name != null)
                {
                    if (node.XmlType.Name.ToUpperInvariant().Contains("TEMPLATEXML"))
                    {
                        nodeList.Add(node);
                    }
                }
            }

            foreach (XPathNavigator node in nodeList)
            {
                XPathNavigator nameNode = node.SelectSingleNode("@Name");
                string templateName = nameNode.Value;
                nameNode.DeleteSelf();
                Message.Trace(Severity.Debug,"Replacing Template {0}", node.OuterXml);
                if (this.templateDictionary.ContainsKey(templateName))
                {
                    Template t = this[templateName];
                    TemplateEmitter te = new TemplateEmitter(t);

                    int parameterCount = 0;
                    if (node.MoveToFirstAttribute())
                    {
                        do
                        {
                            parameterCount++;
                            Message.Trace(Severity.Debug, "Mapping Parameter {0}={1}", node.Name, node.Value);
                            te.SetNamedParameter(node.Name, node.Value);
                        } while (node.MoveToNextAttribute());
                    }
                    if (parameterCount == t.MapDictionary.Keys.Count)
                    {
                        string newXml;
                        te.Emit(out newXml);
                        if (parameterCount > 0)
                        {
                            node.MoveToParent();
                        }
                        Message.Trace(Severity.Debug, "Old Node: {0}", node.OuterXml);
                        node.OuterXml = newXml;
                        Message.Trace(Severity.Debug, "New Node: {0}", node.OuterXml);
                    }
                    else
                    {
                        Message.Trace(Severity.Error, "Template parameters do not match up.  Contains {0} but the template requires {1}", parameterCount, t.MapDictionary.Keys.Count);
                    }
                }
                else
                {
                    Message.Trace(Severity.Error, "Invalid template {0}", templateName);
                }

            }
            string savePath = vc.Save();
            Message.Trace(Severity.Notification,"Saved new VulcanConfig to {0}", savePath);
            vc = new VulcanConfig(savePath);
            return vc;
        }
Beispiel #5
0
        public VulcanConfig XmlTemplateReplacement(VulcanConfig vulcanConfig)
        {
            List <XPathNavigator> nodeList = new List <XPathNavigator>();
            VulcanConfig          vc       = vulcanConfig;

            foreach (XPathNavigator node in vc.Navigator.SelectDescendants(XPathNodeType.Element, true))
            {
                if (node.XmlType != null && node.XmlType.Name != null)
                {
                    if (node.XmlType.Name.ToUpperInvariant().Contains("TEMPLATEXML"))
                    {
                        nodeList.Add(node);
                    }
                }
            }

            foreach (XPathNavigator node in nodeList)
            {
                XPathNavigator nameNode     = node.SelectSingleNode("@Name");
                string         templateName = nameNode.Value;
                nameNode.DeleteSelf();
                Message.Trace(Severity.Debug, "Replacing Template {0}", node.OuterXml);
                if (this.templateDictionary.ContainsKey(templateName))
                {
                    Template        t  = this[templateName];
                    TemplateEmitter te = new TemplateEmitter(t);

                    int parameterCount = 0;
                    if (node.MoveToFirstAttribute())
                    {
                        do
                        {
                            parameterCount++;
                            Message.Trace(Severity.Debug, "Mapping Parameter {0}={1}", node.Name, node.Value);
                            te.SetNamedParameter(node.Name, node.Value);
                        } while (node.MoveToNextAttribute());
                    }
                    if (parameterCount == t.MapDictionary.Keys.Count)
                    {
                        string newXml;
                        te.Emit(out newXml);
                        if (parameterCount > 0)
                        {
                            node.MoveToParent();
                        }
                        Message.Trace(Severity.Debug, "Old Node: {0}", node.OuterXml);
                        node.OuterXml = newXml;
                        Message.Trace(Severity.Debug, "New Node: {0}", node.OuterXml);
                    }
                    else
                    {
                        Message.Trace(Severity.Error, "Template parameters do not match up.  Contains {0} but the template requires {1}", parameterCount, t.MapDictionary.Keys.Count);
                    }
                }
                else
                {
                    Message.Trace(Severity.Error, "Invalid template {0}", templateName);
                }
            }
            string savePath = vc.Save();

            Message.Trace(Severity.Notification, "Saved new VulcanConfig to {0}", savePath);
            vc = new VulcanConfig(savePath);
            return(vc);
        }