示例#1
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                foreach (var package in _internalList)
                {
                    var packageNode = oDoc.CreateElement("package");
                    package.XmlAppend(packageNode);
                    node.AppendChild(packageNode);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#2
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                foreach (var item in _internalList.OrderBy(x => x.Name))
                {
                    var tableNode = oDoc.CreateElement("t");
                    item.XmlAppend(tableNode);
                    node.AppendChild(tableNode);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                foreach (var customStoredProcedure in _internalList)
                {
                    var customStoredProcedureNode = oDoc.CreateElement("customstoredprocedure");
                    customStoredProcedure.XmlAppend(customStoredProcedureNode);
                    node.AppendChild(customStoredProcedureNode);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#4
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                foreach (TableComponent component in this)
                {
                    var componentNode = oDoc.CreateElement("component");
                    component.XmlAppend(componentNode);
                    node.AppendChild(componentNode);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#5
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                foreach (var Reference in _references)
                {
                    var ReferenceNode = oDoc.CreateElement("f");
                    Reference.XmlAppend(ReferenceNode);
                    node.AppendChild(ReferenceNode);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#6
0
        private void SaveSettings()
        {
            //Save settings
            var cacheFile = new ModelCacheFile(((ModelRoot)_tableCollection.Root).GeneratorProject);
            var document  = new XmlDocument();

            document.LoadXml("<a><z></z></a>");
            var containerNode = document.DocumentElement.ChildNodes[0];

            XmlHelper.AddAttribute(containerNode, "prefixChecked", optPrefix.Checked);
            XmlHelper.AddAttribute(containerNode, "prefix", txtPrefix.Text);
            XmlHelper.AddAttribute(containerNode, "replaceText", chkReplaceText.Checked);
            XmlHelper.AddAttribute(containerNode, "replaceSource", txtReplaceSource.Text);
            XmlHelper.AddAttribute(containerNode, "replaceTarget", txtReplaceTarget.Text);
            XmlHelper.AddAttribute(containerNode, "upcase", optUpcase.Checked);
            XmlHelper.AddAttribute(containerNode, "underscore", optUnderscore.Checked);
            XmlHelper.AddAttribute(containerNode, "TwoCaps", chkSkip2Caps.Checked);
            cacheFile.TableFacadeSettings = document.OuterXml;
            cacheFile.Save();
        }
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                foreach (var item in _internalList)
                {
                    var aggregateNode = oDoc.CreateElement("customaggregate");
                    item.XmlAppend(aggregateNode);
                    node.AppendChild(aggregateNode);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#8
0
        private XmlElement CreateTaskNode(Task t, XmlDocument xd)
        {
            var d = new Document(t.Node.Id);
            var x = d.ToPreviewXml(xd);//  xd.CreateNode(XmlNodeType.Element, "node", "");

            var xTask = xd.CreateElement("task");

            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "Id", t.Id.ToString()));
            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "Date", t.Date.ToString("s")));
            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "NodeId", t.Node.Id.ToString()));
            xTask.SetAttributeNode(XmlHelper.AddAttribute(xd, "TotalWords", cms.businesslogic.translation.Translation.CountWords(d.Id).ToString()));
            xTask.AppendChild(XmlHelper.AddCDataNode(xd, "Comment", t.Comment));
            string protocol = GlobalSettings.UseSSL ? "https" : "http";

            xTask.AppendChild(XmlHelper.AddTextNode(xd, "PreviewUrl", protocol + "://" + Request.ServerVariables["SERVER_NAME"] + SystemDirectories.Umbraco + "/translation/preview.aspx?id=" + t.Id.ToString()));
            //            d.XmlPopulate(xd, ref x, false);
            xTask.AppendChild(x);

            return(xTask);
        }
示例#9
0
        public override void XmlAppend(XmlNode node)
        {
            var oDoc = node.OwnerDocument;

            node.AddAttribute("key", this.Key);

            XmlHelper.AddAttribute((XmlElement)node, "createdByColumnName", CreatedByColumnName);
            XmlHelper.AddAttribute((XmlElement)node, "createdDateColumnName", CreatedDateColumnName);
            XmlHelper.AddAttribute((XmlElement)node, "modifiedByColumnName", ModifiedByColumnName);
            XmlHelper.AddAttribute((XmlElement)node, "modifiedDateColumnName", ModifiedDateColumnName);
            XmlHelper.AddAttribute((XmlElement)node, "timestampColumnName", TimestampColumnName);
            XmlHelper.AddAttribute((XmlElement)node, "fullIndexSearchColumnName", FullIndexSearchColumnName);
            XmlHelper.AddAttribute((XmlElement)node, "grantExecUser", GrantExecUser);

            var columnsNode = oDoc.CreateElement("columns");

            Columns.XmlAppend(columnsNode);
            node.AppendChild(columnsNode);

            var customViewColumnsNode = oDoc.CreateElement("customviewcolumns");

            this.CustomViewColumns.XmlAppend(customViewColumnsNode);
            node.AppendChild(customViewColumnsNode);

            var relationsNode = oDoc.CreateElement("relations");

            this.Relations.XmlAppend(relationsNode);
            node.AppendChild(relationsNode);

            node.AddAttribute("databaseName", this.DatabaseName);

            var tablesNode = oDoc.CreateElement("tables");

            this.Tables.XmlAppend(tablesNode);
            node.AppendChild(tablesNode);

            var customViewsNode = oDoc.CreateElement("customviews");

            this.CustomViews.XmlAppend(customViewsNode);
            node.AppendChild(customViewsNode);
        }
示例#10
0
        private static void SaveRelations(string folder, Entity item, List <string> generatedFileList)
        {
            var document = new XmlDocument();

            document.LoadXml(@"<configuration type=""entity.relations"" id=""" + item.Id + @"""></configuration>");

            XmlHelper.AddLineBreak((XmlElement)document.DocumentElement);
            foreach (var relation in item.RelationshipList)
            {
                var relationNode = XmlHelper.AddElement(document.DocumentElement, "relation");

                XmlHelper.AddLineBreak((XmlElement)relationNode);
                XmlHelper.AddCData((XmlElement)relationNode, "summary", relation.Summary);
                XmlHelper.AddLineBreak((XmlElement)relationNode);

                XmlHelper.AddAttribute(relationNode, "id", relation.InternalId);
                XmlHelper.AddAttribute(relationNode, "childid", relation.ChildEntity.Id);
                XmlHelper.AddAttribute(relationNode, "isenforced", relation.IsEnforced);
                XmlHelper.AddAttribute(relationNode, "deleteaction", relation.DeleteAction.ToString());
                XmlHelper.AddAttribute(relationNode, "rolename", relation.RoleName);

                XmlHelper.AddLineBreak((XmlElement)document.DocumentElement);

                //Process the columns
                var relationColumnsNodes = XmlHelper.AddElement((XmlElement)relationNode, "relationfieldset") as XmlElement;
                XmlHelper.AddLineBreak((XmlElement)relationColumnsNodes);
                foreach (var relationField in relation.FieldMapList())
                {
                    var realtionFieldNode = XmlHelper.AddElement(relationColumnsNodes, "field");
                    XmlHelper.AddAttribute(realtionFieldNode, "id", relationField.Id);
                    XmlHelper.AddAttribute(realtionFieldNode, "sourcefieldid", relationField.SourceFieldId);
                    XmlHelper.AddAttribute(realtionFieldNode, "targetfieldid", relationField.TargetFieldId);

                    XmlHelper.AddLineBreak((XmlElement)relationColumnsNodes);
                }
            }

            var f = Path.Combine(folder, item.Name + ".relations.xml");

            WriteFileIfNeedBe(f, document.ToIndentedString(), generatedFileList);
        }
示例#11
0
        public void ToXML(System.Xml.XmlElement node)
        {
            try
            {
                XmlHelper.AddAttribute(node, "type", "combinetable");
                XmlHelper.AddAttribute(node, "entityid1", this.EntityKey1.ToString());
                XmlHelper.AddAttribute(node, "entityid2", this.EntityKey1.ToString());

                var fieldsNode = XmlHelper.AddElement(node, "fields");
                foreach (var k in this.ReMappedFieldIDList.Keys)
                {
                    var n = XmlHelper.AddElement((XmlElement)fieldsNode, "field");
                    XmlHelper.AddAttribute(n, "source", k.ToString());
                    XmlHelper.AddAttribute(n, "target", this.ReMappedFieldIDList[k].ToString());
                }
            }
            catch (Exception ex)
            {
                //Do Nothing
            }
        }
示例#12
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);
                XmlHelper.AddAttribute(node, "name", this.Name);

                if (this.CodeFacade != _def_codeFacade)
                {
                    XmlHelper.AddAttribute(node, "codeFacade", this.CodeFacade);
                }

                var columnsNode = oDoc.CreateElement("columns");
                this.Columns.XmlAppend(columnsNode);
                node.AppendChild(columnsNode);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#13
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);
                XmlHelper.AddAttribute(node, "isUnique", this.IsUnique);
                XmlHelper.AddAttribute(node, "primaryKey", this.PrimaryKey);
                XmlHelper.AddAttribute(node, "clustered", this.Clustered);
                XmlHelper.AddAttribute(node, "description", this.Description);
                XmlHelper.AddAttribute(node, "importedName", this.ImportedName);
                XmlHelper.AddAttribute(node, "id", this.Id);

                var tableIndexColumnListNode = oDoc.CreateElement("ticl");
                _indexColumnList.XmlAppend(tableIndexColumnListNode);
                node.AppendChild(tableIndexColumnListNode);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#14
0
        /// <summary>
        /// Appends the user to the XML document.
        /// </summary>
        /// <param name="xd">The XML document.</param>
        /// <param name="user">The user.</param>
        internal static void AppendUser(XmlDocument xd, User user)
        {
            var node = XmlHelper.AddTextNode(xd, "User", string.Empty);

            node.Attributes.Append(XmlHelper.AddAttribute(xd, "id", user.Id.ToString()));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "name", user.Name));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "loginName", user.LoginName));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "email", user.Email));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "language", user.Language));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "userTypeAlias", user.UserType.Alias));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "isAdmin", user.IsAdmin().ToString()));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "startNodeId", user.StartNodeId.ToString()));
            node.Attributes.Append(XmlHelper.AddAttribute(xd, "startMediaId", user.StartMediaId.ToString()));

            // add the user node to the XmlDocument.
            if (xd.DocumentElement != null)
            {
                xd.DocumentElement.AppendChild(node);
            }
            else
            {
                xd.AppendChild(node);
            }
        }
示例#15
0
        /// <summary>
        /// Saves Stored Procedures to disk
        /// </summary>
        private static void SaveToDisk(nHydrateModel modelRoot, IEnumerable <Entity> list, string rootFolder, nHydrateDiagram diagram, List <string> generatedFileList)
        {
            var folder = Path.Combine(rootFolder, FOLDER_ET);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }

            #region Save other parameter/field information
            foreach (var item in list)
            {
                var document = new XmlDocument();
                document.LoadXml(@"<configuration type=""entity"" name=""" + item.Name + @"""></configuration>");

                XmlHelper.AddLineBreak(document.DocumentElement);
                XmlHelper.AddCData(document.DocumentElement, "summary", item.Summary);
                XmlHelper.AddLineBreak(document.DocumentElement);

                XmlHelper.AddAttribute(document.DocumentElement, "id", item.Id);
                XmlHelper.AddAttribute(document.DocumentElement, "allowcreateaudit", item.AllowCreateAudit);
                XmlHelper.AddAttribute(document.DocumentElement, "allowmodifyaudit", item.AllowModifyAudit);
                XmlHelper.AddAttribute(document.DocumentElement, "allowtimestamp", item.AllowTimestamp);
                XmlHelper.AddAttribute(document.DocumentElement, "codefacade", item.CodeFacade);
                XmlHelper.AddAttribute(document.DocumentElement, "immutable", item.Immutable);
                XmlHelper.AddAttribute(document.DocumentElement, "isassociative", item.IsAssociative);
                XmlHelper.AddAttribute(document.DocumentElement, "typedentity", item.TypedEntity.ToString());
                XmlHelper.AddAttribute(document.DocumentElement, "schema", item.Schema);
                XmlHelper.AddAttribute(document.DocumentElement, "generatesdoublederived", item.GeneratesDoubleDerived);
                XmlHelper.AddAttribute(document.DocumentElement, "isTenant", item.IsTenant);

                #region Fields
                {
                    var fieldsNodes = XmlHelper.AddElement(document.DocumentElement, "fieldset") as XmlElement;
                    XmlHelper.AddLineBreak((XmlElement)fieldsNodes);
                    foreach (var field in item.Fields.OrderBy(x => x.Name))
                    {
                        var fieldNode = XmlHelper.AddElement(fieldsNodes, "field");

                        XmlHelper.AddLineBreak((XmlElement)fieldNode);
                        XmlHelper.AddCData((XmlElement)fieldNode, "summary", field.Summary);
                        XmlHelper.AddLineBreak((XmlElement)fieldNode);

                        XmlHelper.AddAttribute(fieldNode, "id", field.Id);
                        XmlHelper.AddAttribute(fieldNode, "name", field.Name);
                        XmlHelper.AddAttribute(fieldNode, "nullable", field.Nullable);
                        XmlHelper.AddAttribute(fieldNode, "datatype", field.DataType.ToString());
                        XmlHelper.AddAttribute(fieldNode, "identity", field.Identity.ToString());
                        XmlHelper.AddAttribute(fieldNode, "codefacade", field.CodeFacade);
                        XmlHelper.AddAttribute(fieldNode, "dataformatstring", field.DataFormatString);
                        XmlHelper.AddAttribute(fieldNode, "default", field.Default);
                        XmlHelper.AddAttribute(fieldNode, "defaultisfunc", field.DefaultIsFunc);
                        XmlHelper.AddAttribute(fieldNode, "formula", field.Formula);
                        XmlHelper.AddAttribute(fieldNode, "isindexed", field.IsIndexed);
                        XmlHelper.AddAttribute(fieldNode, "isprimarykey", field.IsPrimaryKey);
                        XmlHelper.AddAttribute(fieldNode, "Iscalculated", field.IsCalculated);
                        XmlHelper.AddAttribute(fieldNode, "isunique", field.IsUnique);
                        XmlHelper.AddAttribute(fieldNode, "length", field.Length);
                        XmlHelper.AddAttribute(fieldNode, "scale", field.Scale);
                        XmlHelper.AddAttribute(fieldNode, "sortorder", field.SortOrder);
                        XmlHelper.AddAttribute(fieldNode, "isreadonly", field.IsReadOnly);
                        XmlHelper.AddAttribute(fieldNode, "obsolete", field.Obsolete);

                        XmlHelper.AddLineBreak((XmlElement)fieldsNodes);
                    }
                    XmlHelper.AddLineBreak((XmlElement)document.DocumentElement);
                }
                #endregion

                XmlHelper.AddLineBreak(document.DocumentElement);
                var f = Path.Combine(folder, item.Name + ".configuration.xml");
                WriteFileIfNeedBe(f, document.ToIndentedString(), generatedFileList);

                //Save other files
                SaveEntityIndexes(folder, item, generatedFileList);
                SaveRelations(folder, item, generatedFileList);
                SaveEntityStaticData(folder, item, generatedFileList);
            }
            #endregion

            WriteReadMeFile(folder, generatedFileList);
        }
示例#16
0
        private static void AddEntryToXml(XmlNode parent, NodeSearchElement entry, string dynamoPath)
        {
            var element = XmlHelper.AddNode(parent, entry.GetType().ToString());

            XmlHelper.AddNode(element, "FullCategoryName", entry.FullCategoryName);
            XmlHelper.AddNode(element, "Name", entry.Name);
            XmlHelper.AddNode(element, "Group", entry.Group.ToString());
            XmlHelper.AddNode(element, "Description", entry.Description);

            // Add search tags, joined by ",".
            // E.g. <SearchTags>bounding,bound,bymaxmin,max,min,bypoints</SearchTags>
            XmlHelper.AddNode(element, "SearchTags",
                              String.Join(",", entry.SearchKeywords.Where(word => !String.IsNullOrWhiteSpace(word))));

            var dynamoNode = entry.CreateNode();

            // If entry has input parameters.
            if (dynamoNode.InPorts.Count != 0)
            {
                var inputNode = XmlHelper.AddNode(element, "Inputs");
                for (int i = 0; i < dynamoNode.InPorts.Count; i++)
                {
                    var parameterNode = XmlHelper.AddNode(inputNode, "InputParameter");

                    XmlHelper.AddAttribute(parameterNode, "Name", dynamoNode.InPorts[i].Name);

                    // Case for UI nodes as ColorRange, List.Create etc.
                    // UI nodes  do not have incoming ports in NodeSearchElement, but do have incoming ports in NodeModel.
                    // UI node initializes its incoming ports, when its constructor is called.
                    // So, here we check if NodeModel has input ports and NodeSearchElement also has the same input ports.
                    // UI node node will have several incoming ports on NodeModel,
                    // but 0 incoming ports on NodeSearchElement
                    // (when there is no incoming port, it returns none 1st port by default).
                    if (dynamoNode.InPorts.Count == entry.InputParameters.Count() &&
                        entry.InputParameters.First().Item2 != Properties.Resources.NoneString)
                    {
                        XmlHelper.AddAttribute(parameterNode, "Type", entry.InputParameters.ElementAt(i).Item2);
                    }

                    // Add default value, if it's not null.
                    if (dynamoNode.InPorts[i].DefaultValue != null)
                    {
                        XmlHelper.AddAttribute(parameterNode, "DefaultValue",
                                               dynamoNode.InPorts[i].DefaultValue.ToString());
                    }
                    XmlHelper.AddAttribute(parameterNode, "Tooltip", dynamoNode.InPorts[i].ToolTip);
                }
            }

            // If entry has output parameters.
            if (dynamoNode.OutPorts.Count != 0)
            {
                var outputNode = XmlHelper.AddNode(element, "Outputs");
                for (int i = 0; i < dynamoNode.OutPorts.Count; i++)
                {
                    var parameterNode = XmlHelper.AddNode(outputNode, "OutputParameter");
                    XmlHelper.AddAttribute(parameterNode, "Name", dynamoNode.OutPorts[i].Name);

                    // Case for UI nodes as ColorRange.
                    if (dynamoNode.OutPorts.Count == entry.OutputParameters.Count() &&
                        entry.OutputParameters.First() != Properties.Resources.NoneString)
                    {
                        XmlHelper.AddAttribute(parameterNode, "Type", entry.OutputParameters.ElementAt(i));
                    }

                    XmlHelper.AddAttribute(parameterNode, "Tooltip", dynamoNode.OutPorts[i].ToolTip);
                }
            }

            var          assemblyName  = Path.GetFileNameWithoutExtension(entry.Assembly);
            const string resourcesPath = @"src\Resources\";

            // Get icon paths.
            string pathToSmallIcon = Path.Combine(
                resourcesPath,
                assemblyName,
                "SmallIcons", entry.IconName + ".Small.png");

            string pathToLargeIcon = Path.Combine(
                resourcesPath,
                assemblyName,
                "LargeIcons", entry.IconName + ".Large.png");

            if (!File.Exists(Path.Combine(dynamoPath, @"..\..\..\", pathToSmallIcon)))
            {
                // Try DynamoCore path.
                pathToSmallIcon = Path.Combine(
                    resourcesPath,
                    "DynamoCore",
                    "SmallIcons", entry.IconName + ".Small.png");
            }

            if (!File.Exists(Path.Combine(dynamoPath, @"..\..\..\", pathToLargeIcon)))
            {
                // Try DynamoCore path.
                pathToLargeIcon = Path.Combine(
                    resourcesPath,
                    "DynamoCore",
                    "LargeIcons", entry.IconName + ".Large.png");
            }

            // Dump icons.
            XmlHelper.AddNode(element, "SmallIcon", File.Exists(Path.Combine(dynamoPath, @"..\..\..\", pathToSmallIcon)) ? pathToSmallIcon : "Not found");
            XmlHelper.AddNode(element, "LargeIcon", File.Exists(Path.Combine(dynamoPath, @"..\..\..\", pathToLargeIcon)) ? pathToLargeIcon : "Not found");
        }
示例#17
0
 public virtual void XmlAppend(XmlNode node)
 {
     XmlHelper.AddAttribute(node, "key", this.Key);
     XmlHelper.AddAttribute(node, "value", this.Value);
 }
示例#18
0
        /// <summary>
        /// Append the xmlData node to the web.config file
        /// </summary>
        /// <param name="packageName">Name of the package that we install</param>
        /// <param name="xmlData">The data that must be appended to the web.config file</param>
        /// <returns>True when succeeded</returns>
        public bool Execute(string packageName, XmlNode xmlData)
        {
            //Set result default to false
            bool result = false;

            //Get attribute values of xmlData
            string position, nameSpace, file, xPath;

            position = GetAttributeDefault(xmlData, "position", null);
            if (!GetAttribute(xmlData, "namespace", out nameSpace) || !GetAttribute(xmlData, "file", out file) || !GetAttribute(xmlData, "xpath", out xPath))
            {
                return(result);
            }

            //Create a new xml document
            XmlDocument document = new XmlDocument();

            //Keep current indentions format
            document.PreserveWhitespace = true;

            //Load the web.config file into the xml document
            string configFileName = VirtualPathUtility.ToAbsolute(file);

            document.Load(HttpContext.Current.Server.MapPath(configFileName));

            //Select root node in the web.config file for insert new nodes
            XmlNode rootNode = document.SelectSingleNode(xPath);

            //Check for rootNode exists
            if (rootNode == null)
            {
                return(result);
            }

            //Set modified document default to false
            bool modified = false;

            //Set insert node default true
            bool insertNode = true;

            //Check for namespaces node
            if (rootNode.SelectSingleNode("namespaces") == null)
            {
                //Create namespaces node
                var namespacesNode = document.CreateElement("namespaces");
                rootNode.AppendChild(namespacesNode);

                //Replace root node
                rootNode = namespacesNode;

                //Mark document modified
                modified = true;
            }
            else
            {
                //Replace root node
                rootNode = rootNode.SelectSingleNode("namespaces");
            }

            //Look for existing nodes with same path like the new node
            if (rootNode.HasChildNodes)
            {
                //Look for existing nodeType nodes
                XmlNode node = rootNode.SelectSingleNode(String.Format("//add[@namespace = '{0}']", nameSpace));

                //If path already exists
                if (node != null)
                {
                    //Cancel insert node operation
                    insertNode = false;
                }
            }

            //Check for insert flag
            if (insertNode)
            {
                //Create new node with attributes
                XmlNode newNode = document.CreateElement("add");
                newNode.Attributes.Append(
                    XmlHelper.AddAttribute(document, "namespace", nameSpace));

                //Select for new node insert position
                if (position == null || position == "end")
                {
                    //Append new node at the end of root node
                    rootNode.AppendChild(newNode);

                    //Mark document modified
                    modified = true;
                }
                else if (position == "beginning")
                {
                    //Prepend new node at the beginnig of root node
                    rootNode.PrependChild(newNode);

                    //Mark document modified
                    modified = true;
                }
            }

            //Check for modified document
            if (modified)
            {
                try
                {
                    //Save the Rewrite config file with the new rewerite rule
                    document.Save(HttpContext.Current.Server.MapPath(configFileName));

                    //No errors so the result is true
                    result = true;
                }
                catch (Exception e)
                {
                    //Log error message
                    string message = "Error at execute AddNamespace package action: " + e.Message;
                    LogHelper.Error(typeof(AddNamespace), message, e);
                }
            }
            return(result);
        }
示例#19
0
        public static PackageInstance MakeNew(string Name, string dataSource)
        {
            Reload(dataSource);

            int maxId = 1;

            // Find max id
            foreach (XmlNode n in Source.SelectNodes("packages/package"))
            {
                if (int.Parse(n.Attributes.GetNamedItem("id").Value) >= maxId)
                {
                    maxId = int.Parse(n.Attributes.GetNamedItem("id").Value) + 1;
                }
            }

            XmlElement instance = Source.CreateElement("package");

            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "id", maxId.ToString()));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "version", ""));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "url", ""));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "name", Name));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "folder", Guid.NewGuid().ToString()));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "packagepath", ""));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "repositoryGuid", ""));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "iconUrl", ""));
            //set to current version
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "umbVersion", UmbracoVersion.Current.ToString(3)));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "packageGuid", Guid.NewGuid().ToString()));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "hasUpdate", "false"));

            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "enableSkins", "false"));
            instance.Attributes.Append(XmlHelper.AddAttribute(Source, "skinRepoGuid", ""));

            XmlElement license = Source.CreateElement("license");

            license.InnerText = "MIT License";
            license.Attributes.Append(XmlHelper.AddAttribute(Source, "url", "http://opensource.org/licenses/MIT"));
            instance.AppendChild(license);

            XmlElement author = Source.CreateElement("author");

            author.InnerText = "";
            author.Attributes.Append(XmlHelper.AddAttribute(Source, "url", ""));
            instance.AppendChild(author);

            instance.AppendChild(XmlHelper.AddTextNode(Source, "readme", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "actions", ""));

            instance.AppendChild(XmlHelper.AddTextNode(Source, "datatypes", ""));

            XmlElement content = Source.CreateElement("content");

            content.InnerText = "";
            content.Attributes.Append(XmlHelper.AddAttribute(Source, "nodeId", ""));
            content.Attributes.Append(XmlHelper.AddAttribute(Source, "loadChildNodes", "false"));
            instance.AppendChild(content);

            instance.AppendChild(XmlHelper.AddTextNode(Source, "templates", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "stylesheets", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "documenttypes", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "macros", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "files", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "languages", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "dictionaryitems", ""));
            instance.AppendChild(XmlHelper.AddTextNode(Source, "loadcontrol", ""));

            Source.SelectSingleNode("packages").AppendChild(instance);
            Source.Save(dataSource);
            var retVal = data.Package(maxId, dataSource);

            return(retVal);
        }
示例#20
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);
                XmlHelper.AddAttribute(node, "projectName", this.ProjectName);
                XmlHelper.AddAttribute(node, "transformNames", this.TransformNames);
                XmlHelper.AddAttribute(node, "enableCustomChangeEvents", this.EnableCustomChangeEvents);
                XmlHelper.AddAttribute(node, "supportLegacySearchObject", this.SupportLegacySearchObject);
                XmlHelper.AddAttribute(node, "useUTCTime", this.UseUTCTime.ToString());
                XmlHelper.AddAttribute(node, "version", this.Version);
                XmlHelper.AddAttribute(node, "companyName", this.CompanyName);
                XmlHelper.AddAttribute(node, "emitSafetyScripts", this.EmitSafetyScripts);
                XmlHelper.AddAttribute(node, "tenantColumnName", this.TenantColumnName);
                XmlHelper.AddAttribute(node, "tenantPrefix", this.TenantPrefix);
                XmlHelper.AddAttribute(node, "allowMocks", this.AllowMocks);

                if (!string.IsNullOrEmpty(this.ModuleName))
                {
                    XmlHelper.AddAttribute(node, "moduleName", this.ModuleName);
                }

                XmlHelper.AddAttribute(node, "companyAbbreviation", this.CompanyAbbreviation);
                XmlHelper.AddAttribute(node, "defaultNamespace", this.DefaultNamespace);
                XmlHelper.AddAttribute(node, "storedProcedurePrefix", this.StoredProcedurePrefix);

                //var userInterfaceNode = oDoc.CreateElement("userInterface");
                //this.UserInterface.XmlAppend(userInterfaceNode);
                //node.AppendChild(userInterfaceNode);

                var copyright  = oDoc.CreateNode(XmlNodeType.Element, "copyright", string.Empty);
                var copyright2 = oDoc.CreateCDataSection("copyright");
                copyright2.Value = this.Copyright;
                copyright.AppendChild(copyright2);
                node.AppendChild(copyright);

                var databaseNode = oDoc.CreateElement("database");
                this.Database.XmlAppend(databaseNode);
                node.AppendChild(databaseNode);

                //XmlHelper.AddAttribute(node, "createdDate", _createdDate.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));

                var versionHistoryListNode = oDoc.CreateElement("versionHistoryList");
                node.AppendChild(versionHistoryListNode);
                _versionHistoryList.XmlAppend(versionHistoryListNode);

                XmlHelper.AddAttribute(node, "sqlType", this.SQLServerType.ToString());
                XmlHelper.AddAttribute(node, "efversion", this.EFVersion.ToString());
                XmlHelper.AddAttribute(node, "frameworkVersion", this.FrameworkVersion.ToString());

                if (this.MetaData.Count > 0)
                {
                    var metadataNode = oDoc.CreateElement("metadata");
                    this.MetaData.XmlAppend(metadataNode);
                    node.AppendChild(metadataNode);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            Response.ContentType = "text/xml";
            int pageId;

            XmlNode root = _xd.CreateElement("tasks");

            if (int.TryParse(Request["id"], out pageId))
            {
                var t = new Task(pageId);
                if (t.User.Id == base.getUser().Id || t.ParentUser.Id == base.getUser().Id)
                {
                    XmlNode x = CreateTaskNode(t, _xd);
                    root.AppendChild(x);

                    xmlContents.Text = root.OuterXml;

                    Response.AddHeader("Content-Disposition", "attachment; filename=" + t.Node.Text.Replace(" ", "_") + ".xml");
                }
            }
            else
            {
                var nodes      = new SortedList();
                int totalWords = 0;

                foreach (Task t in Task.GetTasks(base.getUser(), false))
                {
                    if (!nodes.ContainsKey(t.Node.Path))
                    {
                        var xTask = CreateTaskNode(t, _xd);
                        totalWords += int.Parse(xTask.Attributes.GetNamedItem("TotalWords").Value);
                        nodes.Add(t.Node.Path, xTask);
                    }
                }

                // Arrange nodes in tree
                var ide = nodes.GetEnumerator();
                while (ide.MoveNext())
                {
                    var x           = (XmlElement)ide.Value;
                    var parentXpath = UmbracoSettings.UseLegacyXmlSchema ? "//node [@id = '" + x.SelectSingleNode("//node").Attributes.GetNamedItem("parentID").Value + "']" :
                                      "//* [@isDoc and @id = '" + x.SelectSingleNode("//* [@isDoc]").Attributes.GetNamedItem("parentID").Value + "']";
                    var parent = _xd.SelectSingleNode(parentXpath);

                    if (parent == null)
                    {
                        parent = root;
                    }
                    else
                    {
                        parent = parent.ParentNode;
                    }

                    parent.AppendChild((XmlElement)ide.Value);
                }

                root.Attributes.Append(XmlHelper.AddAttribute(_xd, "TotalWords", totalWords.ToString()));
                xmlContents.Text = root.OuterXml;
                Response.AddHeader("Content-Disposition", "attachment; filename=all.xml");
            }
        }
示例#22
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                if (this.Generated != _def_generated)
                {
                    XmlHelper.AddAttribute((XmlElement)node, "generated", this.Generated.ToString());
                }

                if (this.UseSearchObject != _def_useSearchObject)
                {
                    XmlHelper.AddAttribute((XmlElement)node, "useSearchObject", this.UseSearchObject.ToString());
                }

                XmlHelper.AddAttribute(node, "name", this.Name);

                if (this.CodeFacade != _def_codefacade)
                {
                    XmlHelper.AddAttribute(node, "codeFacade", this.CodeFacade);
                }

                if (this.Description != _def_description)
                {
                    XmlHelper.AddAttribute(node, "description", this.Description);
                }

                var sqlNode = oDoc.CreateElement("sql");
                sqlNode.AppendChild(oDoc.CreateCDataSection(this.SQL));
                node.AppendChild(sqlNode);

                var parametersNode = oDoc.CreateElement("parameters");
                this.Parameters.XmlAppend(parametersNode);
                node.AppendChild(parametersNode);

                //if(RelationshipRef != null)
                //{
                //  XmlNode relationshipRefNode = oDoc.CreateElement("relationshipRef");
                //  RelationshipRef.XmlAppend(relationshipRefNode);
                //  node.AppendChild(relationshipRefNode);
                //}

                //XmlAttribute defaultVal = oDoc.CreateAttribute("default");
                //defaultVal.Value = this.Default;
                //node.Attributes.Append(defaultVal);

                //XmlAttribute length = oDoc.CreateAttribute("length");
                //length.Value = this.Length.ToString();
                //node.Attributes.Append(length);

                XmlHelper.AddAttribute(node, "id", this.Id);

                //XmlAttribute dataFieldFriendlyName = oDoc.CreateAttribute("dataFieldFriendlyName");
                //dataFieldFriendlyName.Value = this.FriendlyName;
                //node.Attributes.Append(dataFieldFriendlyName);

                //XmlAttribute dataFieldVisibility = oDoc.CreateAttribute("dataFieldVisibility");
                //dataFieldVisibility.Value = this.UIVisible.ToString();
                //node.Attributes.Append(dataFieldVisibility);

                //XmlAttribute dataFieldSortOrder = oDoc.CreateAttribute("dataFieldSortOrder");
                //dataFieldSortOrder.Value = this.SortOrder.ToString();
                //node.Attributes.Append(dataFieldSortOrder);

                var parentTableRefNode = oDoc.CreateElement("parentTableRef");
                ParentTableRef.XmlAppend(parentTableRefNode);
                node.AppendChild(parentTableRefNode);

                //XmlAttribute type = oDoc.CreateAttribute("type");
                //type.Value = this.Type.ToString("d");
                //node.Attributes.Append(type);

                //XmlAttribute allowNull = oDoc.CreateAttribute("allowNull");
                //allowNull.Value = this.AllowNull.ToString();
                //node.Attributes.Append(allowNull);

                //XmlHelper.AddAttribute(node, "createdDate", _createdDate.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                if (this.Generated != _def_generated)
                {
                    XmlHelper.AddAttribute((XmlElement)node, "generated", this.Generated);
                }

                XmlHelper.AddAttribute(node, "name", this.Name);

                if (this.CodeFacade != _def_codefacade)
                {
                    XmlHelper.AddAttribute(node, "codeFacade", this.CodeFacade);
                }

                if (this.Description != _def_description)
                {
                    XmlHelper.AddAttribute(node, "description", this.Description);
                }

                if (this.FriendlyName != _def_friendlyName)
                {
                    XmlHelper.AddAttribute(node, "dataFieldFriendlyName", this.FriendlyName);
                }

                if (this.UIVisible != _def_UIVisible)
                {
                    XmlHelper.AddAttribute(node, "dataFieldVisibility", this.UIVisible);
                }

                if (this.SortOrder != _def_sortOrder)
                {
                    XmlHelper.AddAttribute(node, "dataFieldSortOrder", this.SortOrder);
                }

                if (this.Default != _def_default)
                {
                    XmlHelper.AddAttribute(node, "default", this.Default);
                }

                if (this.Length != _def_length)
                {
                    XmlHelper.AddAttribute(node, "length", this.Length);
                }

                XmlHelper.AddAttribute(node, "scale", this.Scale);
                XmlHelper.AddAttribute(node, "id", this.Id);

                if (this.SortOrder != _def_sortOrder)
                {
                    XmlHelper.AddAttribute(node, "sortOrder", this.SortOrder);
                }

                XmlHelper.AddAttribute(node, "type", (int)this.DataType);

                if (this.AllowNull != _def_allowNull)
                {
                    XmlHelper.AddAttribute(node, "allowNull", this.AllowNull);
                }

                if (this.IsBrowsable != _def_isBrowsable)
                {
                    XmlHelper.AddAttribute(node, "isBrowsable", this.IsBrowsable);
                }

                if (RelationshipRef != null)
                {
                    var relationshipRefNode = oDoc.CreateElement("relationshipRef");
                    RelationshipRef.XmlAppend(relationshipRefNode);
                    node.AppendChild(relationshipRefNode);
                }

                var parentRefNode = oDoc.CreateElement("parentTableRef");
                ParentRef.XmlAppend(parentRefNode);
                node.AppendChild(parentRefNode);
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#24
0
        /// <summary>
        /// Appends the type of the document.
        /// </summary>
        /// <param name="xd">The XML document.</param>
        /// <param name="docType">The document type.</param>
        /// <param name="includeTabs">if set to <c>true</c> [include tabs].</param>
        /// <param name="includePropertyTypes">if set to <c>true</c> [include property types].</param>
        /// <param name="includeAllowedTemplates">if set to <c>true</c> [include allowed templates].</param>
        internal static void AppendDocumentType(XmlDocument xd, DocumentType docType, bool includeTabs, bool includePropertyTypes, bool includeAllowedTemplates)
        {
            var nodeDocType = XmlHelper.AddTextNode(xd, "DocumentType", string.Empty);

            nodeDocType.AppendChild(XmlHelper.AddCDataNode(xd, "description", docType.Description));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", docType.Id.ToString()));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", docType.Text));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", docType.Alias));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "image", docType.Image));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "thumbnail", docType.Thumbnail));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "master", docType.MasterContentType.ToString()));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "hasChildren", docType.HasChildren.ToString()));
            nodeDocType.Attributes.Append(XmlHelper.AddAttribute(xd, "defaultTemplate", docType.DefaultTemplate.ToString()));

            if (includeTabs)
            {
                var tabs = docType.getVirtualTabs;
                if (tabs != null && tabs.Length > 0)
                {
                    var nodeTabs = XmlHelper.AddTextNode(xd, "tabs", string.Empty);

                    foreach (var tab in tabs)
                    {
                        var nodeTab = XmlHelper.AddTextNode(xd, "tab", string.Empty);
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "id", tab.Id.ToString()));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "caption", tab.Caption));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", tab.SortOrder.ToString()));

                        nodeTabs.AppendChild(nodeTab);
                    }

                    nodeDocType.AppendChild(nodeTabs);
                }
            }

            if (includePropertyTypes)
            {
                var propertyTypes = docType.PropertyTypes;
                if (propertyTypes != null && propertyTypes.Count > 0)
                {
                    var nodePropertyTypes = XmlHelper.AddTextNode(xd, "propertyTypes", string.Empty);

                    foreach (var propertyType in propertyTypes)
                    {
                        var nodePropertyType = XmlHelper.AddTextNode(xd, "propertyType", string.Empty);
                        nodePropertyType.AppendChild(XmlHelper.AddCDataNode(xd, "description", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", propertyType.Id.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Name));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", propertyType.Alias));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "contentTypeId", propertyType.ContentTypeId.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "mandatory", propertyType.Mandatory.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", propertyType.SortOrder.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "tabId", propertyType.TabId.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "regEx", propertyType.ValidationRegExp));

                        nodePropertyTypes.AppendChild(nodePropertyType);
                    }

                    nodeDocType.AppendChild(nodePropertyTypes);
                }
            }

            if (includeAllowedTemplates)
            {
                var templates = docType.allowedTemplates;
                if (templates != null && templates.Length > 0)
                {
                    var nodeTemplates = XmlHelper.AddTextNode(xd, "allowedTemplates", string.Empty);

                    foreach (var template in templates)
                    {
                        var nodeTemplate = XmlHelper.AddTextNode(xd, "template", string.Empty);
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "id", template.Id.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "name", template.Text));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", template.Alias));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "masterPageFile", template.TemplateFilePath));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "masterTemplate", template.MasterTemplate.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "hasChildren", template.HasChildren.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", template.sortOrder.ToString()));
                        nodeTemplate.Attributes.Append(XmlHelper.AddAttribute(xd, "isDefaultTemplate", (template.Id == docType.DefaultTemplate).ToString()));

                        nodeTemplates.AppendChild(nodeTemplate);
                    }

                    nodeDocType.AppendChild(nodeTemplates);
                }
            }

            if (xd.DocumentElement != null)
            {
                xd.DocumentElement.AppendChild(nodeDocType);
            }
            else
            {
                xd.AppendChild(nodeDocType);
            }
        }
示例#25
0
        /// <summary>
        /// Saves Views to disk
        /// </summary>
        private static void SaveToDisk(nHydrateModel modelRoot, IEnumerable <View> list, string rootFolder, nHydrateDiagram diagram, List <string> generatedFileList)
        {
            var folder = Path.Combine(rootFolder, FOLDER_VW);

            if (!Directory.Exists(folder))
            {
                Directory.CreateDirectory(folder);
            }
            foreach (var item in list)
            {
                var f = Path.Combine(folder, item.Name + ".sql");
                WriteFileIfNeedBe(f, item.SQL, generatedFileList);
            }

            #region Save other parameter/field information
            foreach (var item in list)
            {
                var document = new XmlDocument();
                document.LoadXml(@"<configuration type=""view"" name=""" + item.Name + @"""></configuration>");

                XmlHelper.AddLineBreak(document.DocumentElement);
                XmlHelper.AddCData(document.DocumentElement, "summary", item.Summary);
                XmlHelper.AddLineBreak(document.DocumentElement);

                XmlHelper.AddAttribute(document.DocumentElement, "id", item.Id);
                XmlHelper.AddAttribute(document.DocumentElement, "codefacade", item.CodeFacade);
                XmlHelper.AddAttribute(document.DocumentElement, "schema", item.Schema);
                XmlHelper.AddAttribute(document.DocumentElement, "generatesdoublederived", item.GeneratesDoubleDerived);

                var fieldsNodes = XmlHelper.AddElement(document.DocumentElement, "fieldset") as XmlElement;
                XmlHelper.AddLineBreak((XmlElement)fieldsNodes);

                foreach (var field in item.Fields.OrderBy(x => x.Name))
                {
                    var fieldNode = XmlHelper.AddElement(fieldsNodes, "field");

                    XmlHelper.AddLineBreak((XmlElement)fieldNode);
                    XmlHelper.AddCData((XmlElement)fieldNode, "summary", field.Summary);
                    XmlHelper.AddLineBreak((XmlElement)fieldNode);

                    XmlHelper.AddAttribute(fieldNode, "id", field.Id);
                    XmlHelper.AddAttribute(fieldNode, "name", field.Name);
                    XmlHelper.AddAttribute(fieldNode, "nullable", field.Nullable);
                    XmlHelper.AddAttribute(fieldNode, "datatype", field.DataType.ToString());
                    XmlHelper.AddAttribute(fieldNode, "codefacade", field.CodeFacade);
                    XmlHelper.AddAttribute(fieldNode, "default", field.Default);
                    XmlHelper.AddAttribute(fieldNode, "length", field.Length);
                    XmlHelper.AddAttribute(fieldNode, "scale", field.Scale);
                    XmlHelper.AddAttribute(fieldNode, "isprimarykey", field.IsPrimaryKey);

                    XmlHelper.AddLineBreak((XmlElement)fieldsNodes);
                }

                XmlHelper.AddLineBreak(document.DocumentElement);
                var f = Path.Combine(folder, item.Name + ".configuration.xml");
                WriteFileIfNeedBe(f, document.ToIndentedString(), generatedFileList);
            }
            #endregion

            WriteReadMeFile(folder, generatedFileList);
        }
示例#26
0
        /// <summary>
        /// Executes the specified package name.
        /// </summary>
        /// <param name="packageName">Name of the package.</param>
        /// <param name="xmlData">The XML data.</param>
        /// <returns></returns>
        public bool Execute(string packageName, XmlNode xmlData)
        {
            // get attribute values of xmlData
            var requiredFields = new[] { "area", "key", "value" };

            foreach (var field in requiredFields)
            {
                if (xmlData.Attributes[field] == null)
                {
                    return(false);
                }
            }

            var area     = xmlData.Attributes["area"].Value;
            var key      = xmlData.Attributes["key"].Value;
            var value    = xmlData.Attributes["value"].Value;
            var language = xmlData.Attributes["language"] != null ? xmlData.Attributes["language"].Value : "en";
            var position = xmlData.Attributes["position"] != null ? xmlData.Attributes["position"].Value : null;

            // create a new xml document
            var document = new XmlDocument()
            {
                PreserveWhitespace = true
            };

            document.Load(IOHelper.MapPath(string.Format(UmbracoLangPath, language)));

            // select root node in the web.config file to insert new node
            var rootNode = EnsureAreaRootNode(area, document);

            var modified   = false;
            var insertNode = true;

            // look for existing nodes with same path like the new node
            if (rootNode.HasChildNodes)
            {
                var node = rootNode.SelectSingleNode(string.Format("//key[@alias = '{0}']", key));
                if (node != null)
                {
                    insertNode = false;
                }
            }

            // check for insert flag
            if (insertNode)
            {
                // create new node with attributes
                var newNode = document.CreateElement("key");
                newNode.Attributes.Append(XmlHelper.AddAttribute(document, "alias", key));
                newNode.InnerText = value;

                // select for new node insert position
                if (position == null || position == "end")
                {
                    // append new node at the end of root node
                    rootNode.AppendChild(newNode);

                    // mark document modified
                    modified = true;
                }
                else if (position == "beginning")
                {
                    // prepend new node at the beginning of root node
                    rootNode.PrependChild(newNode);

                    // mark document modified
                    modified = true;
                }
            }

            // check for modified document
            if (modified)
            {
                try
                {
                    document.Save(IOHelper.MapPath(string.Format(UmbracoLangPath, language)));
                    return(true);
                }
                catch (Exception ex)
                {
                    var message = string.Concat("Error at install ", this.Alias(), " package action: ", ex);
                    LogHelper.Error(typeof(AddLanguageFileKey), message, ex);
                }
            }

            return(false);
        }
示例#27
0
        /// <summary>
        /// Appends the type of the content.
        /// </summary>
        /// <param name="xd">The XML document.</param>
        /// <param name="elementName">Name of the element.</param>
        /// <param name="contentType">The content type.</param>
        /// <param name="includeTabs">if set to <c>true</c> [include tabs].</param>
        /// <param name="includePropertyTypes">if set to <c>true</c> [include property types].</param>
        internal static void AppendContentType(XmlDocument xd, string elementName, ContentType contentType, bool includeTabs, bool includePropertyTypes)
        {
            var nodeContentType = XmlHelper.AddTextNode(xd, elementName, string.Empty);

            nodeContentType.AppendChild(XmlHelper.AddCDataNode(xd, "description", contentType.Description));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", contentType.Id.ToString()));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", contentType.Text));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", contentType.Alias));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "image", contentType.Image));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "thumbnail", contentType.Thumbnail));
            //// nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "master", contentType.MasterContentType.ToString()));
            nodeContentType.Attributes.Append(XmlHelper.AddAttribute(xd, "hasChildren", contentType.HasChildren.ToString()));

            if (includeTabs)
            {
                var tabs = contentType.getVirtualTabs;
                if (tabs != null && tabs.Length > 0)
                {
                    var nodeTabs = XmlHelper.AddTextNode(xd, "tabs", string.Empty);

                    foreach (var tab in tabs)
                    {
                        var nodeTab = XmlHelper.AddTextNode(xd, "tab", string.Empty);
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "id", tab.Id.ToString()));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "caption", tab.Caption));
                        nodeTab.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", tab.SortOrder.ToString()));

                        nodeTabs.AppendChild(nodeTab);
                    }

                    nodeContentType.AppendChild(nodeTabs);
                }
            }

            if (includePropertyTypes)
            {
                var propertyTypes = contentType.PropertyTypes;
                if (propertyTypes != null && propertyTypes.Count > 0)
                {
                    var nodePropertyTypes = XmlHelper.AddTextNode(xd, "propertyTypes", string.Empty);

                    foreach (PropertyType propertyType in propertyTypes)
                    {
                        var nodePropertyType = XmlHelper.AddTextNode(xd, "propertyType", string.Empty);
                        nodePropertyType.AppendChild(XmlHelper.AddCDataNode(xd, "description", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "id", propertyType.Id.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Name));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "alias", propertyType.Alias));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "contentTypeId", propertyType.ContentTypeId.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "name", propertyType.Description));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "mandatory", propertyType.Mandatory.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "sortOrder", propertyType.SortOrder.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "tabId", propertyType.PropertyTypeGroup.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "regEx", propertyType.ValidationRegExp));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "dataTypeId", propertyType.DataTypeDefinition.Id.ToString()));
                        nodePropertyType.Attributes.Append(XmlHelper.AddAttribute(xd, "dataTypeGuid", propertyType.DataTypeDefinition.UniqueId.ToString()));

                        nodePropertyTypes.AppendChild(nodePropertyType);
                    }

                    nodeContentType.AppendChild(nodePropertyTypes);
                }
            }

            // add the content-type node to the XmlDocument.
            if (xd.DocumentElement != null)
            {
                xd.DocumentElement.AppendChild(nodeContentType);
            }
            else
            {
                xd.AppendChild(nodeContentType);
            }
        }
        /// <summary>
        /// Append the xmlData node to the web.config file
        /// </summary>
        /// <param name="packageName">Name of the package that we install</param>
        /// <param name="xmlData">The data that must be appended to the web.config file</param>
        /// <returns>True when succeeded</returns>
        public bool Execute(string packageName, XmlNode xmlData)
        {
            //Set result default to false
            bool result = false;

            //Get attribute values of xmlData
            string position, segment;

            position = GetAttributeDefault(xmlData, "position", null);
            if (!GetAttribute(xmlData, "segment", out segment))
            {
                return(result);
            }

            //Create a new xml document
            XmlDocument document = new XmlDocument();

            //Keep current indentions format
            document.PreserveWhitespace = true;

            //Load the web.config file into the xml document
            document.Load(HttpContext.Current.Server.MapPath(FULL_PATH));
            //Select root node in the web.config file for insert new nodes
            XmlNode rootNode = document.SelectSingleNode("//configuration/system.webServer");

            //Check for rootNode exists
            if (rootNode == null)
            {
                return(result);
            }

            //Set modified document default to false
            bool modified = false;

            //Set insert node default true
            bool insertNode = true;

            //Check for security node
            if (rootNode.SelectSingleNode("security") == null)
            {
                //Create security node
                var securityNode = document.CreateElement("security");
                rootNode.AppendChild(securityNode);

                //Replace root node
                rootNode = securityNode;

                //Mark document modified
                modified = true;
            }
            else
            {
                //Replace root node
                rootNode = rootNode.SelectSingleNode("security");
            }

            //Check for requestFiltering node
            if (rootNode.SelectSingleNode("requestFiltering") == null)
            {
                //Create security node
                var requestFilteringNode = document.CreateElement("requestFiltering");
                rootNode.AppendChild(requestFilteringNode);

                //Replace root node
                rootNode = requestFilteringNode;

                //Mark document requestFilteringNode
                modified = true;
            }
            else
            {
                //Replace root node
                rootNode = rootNode.SelectSingleNode("requestFiltering");
            }

            //Check for hiddenSegments node
            if (rootNode.SelectSingleNode("hiddenSegments") == null)
            {
                //Create security node
                var hiddenSegmentsNode = document.CreateElement("hiddenSegments");
                rootNode.AppendChild(hiddenSegmentsNode);

                //Replace root node
                rootNode = hiddenSegmentsNode;

                //Mark document requestFilteringNode
                modified = true;
            }
            else
            {
                //Replace root node
                rootNode = rootNode.SelectSingleNode("hiddenSegments");
            }

            //Look for existing nodes with same path like the new node
            if (rootNode.HasChildNodes)
            {
                //Look for existing nodeType nodes
                XmlNode node = rootNode.SelectSingleNode(String.Format("//add[@segment = '{0}']", segment));

                //If path already exists
                if (node != null)
                {
                    //Cancel insert node operation
                    insertNode = false;
                }
            }

            //Check for insert flag
            if (insertNode)
            {
                //Create new node with attributes
                XmlNode newNode = document.CreateElement("add");
                newNode.Attributes.Append(
                    XmlHelper.AddAttribute(document, "segment", segment));

                //Select for new node insert position
                if (position == null || position == "end")
                {
                    //Append new node at the end of root node
                    rootNode.AppendChild(newNode);

                    //Mark document modified
                    modified = true;
                }
                else if (position == "beginning")
                {
                    //Prepend new node at the beginnig of root node
                    rootNode.PrependChild(newNode);

                    //Mark document modified
                    modified = true;
                }
            }

            //Check for modified document
            if (modified)
            {
                try
                {
                    //Save the Rewrite config file with the new rewerite rule
                    document.Save(HttpContext.Current.Server.MapPath(FULL_PATH));

                    //No errors so the result is true
                    result = true;
                }
                catch (Exception e)
                {
                    //Log error message
                    string message = "Error at execute AddHiddenSegment package action: " + e.Message;
                    LogHelper.Error(typeof(AddHiddenSegment), message, e);
                }
            }
            return(result);
        }
示例#29
0
        public override void XmlAppend(XmlNode node)
        {
            try
            {
                var oDoc = node.OwnerDocument;

                XmlHelper.AddAttribute(node, "key", this.Key);

                XmlHelper.AddAttribute((XmlElement)node, "createdByColumnName", CreatedByColumnName);
                XmlHelper.AddAttribute((XmlElement)node, "createdDateColumnName", CreatedDateColumnName);
                XmlHelper.AddAttribute((XmlElement)node, "modifiedByColumnName", ModifiedByColumnName);
                XmlHelper.AddAttribute((XmlElement)node, "modifiedDateColumnName", ModifiedDateColumnName);
                XmlHelper.AddAttribute((XmlElement)node, "timestampColumnName", TimestampColumnName);
                XmlHelper.AddAttribute((XmlElement)node, "fullIndexSearchColumnName", FullIndexSearchColumnName);
                XmlHelper.AddAttribute((XmlElement)node, "grantExecUser", GrantExecUser);
                XmlHelper.AddAttribute((XmlElement)node, "useGeneratedCRUD", UseGeneratedCRUD.ToString());
                XmlHelper.AddAttribute((XmlElement)node, "tablePrefix", TablePrefix);
                XmlHelper.AddAttribute((XmlElement)node, "collate", Collate);

                var columnsNode = oDoc.CreateElement("columns");
                Columns.XmlAppend(columnsNode);
                node.AppendChild(columnsNode);

                var customViewColumnsNode = oDoc.CreateElement("customviewcolumns");
                this.CustomViewColumns.XmlAppend(customViewColumnsNode);
                node.AppendChild(customViewColumnsNode);

                var customAggregateColumnsNode = oDoc.CreateElement("customaggregatecolumns");
                this.CustomAggregateColumns.XmlAppend(customAggregateColumnsNode);
                node.AppendChild(customAggregateColumnsNode);

                var customStoredProcedureColumnsNode = oDoc.CreateElement("customstoredprocedurecolumns");
                this.CustomStoredProcedureColumns.XmlAppend(customStoredProcedureColumnsNode);
                node.AppendChild(customStoredProcedureColumnsNode);

                var functionColumnsNode = oDoc.CreateElement("functioncolumns");
                this.FunctionColumns.XmlAppend(functionColumnsNode);
                node.AppendChild(functionColumnsNode);

                var customRetrieveRulesNode = oDoc.CreateElement("customretrieverules");
                this.CustomRetrieveRules.XmlAppend(customRetrieveRulesNode);
                node.AppendChild(customRetrieveRulesNode);

                var customRetrieveRuleParameterNode = oDoc.CreateElement("customretrieveruleparameters");
                this.CustomRetrieveRuleParameters.XmlAppend(customRetrieveRuleParameterNode);
                node.AppendChild(customRetrieveRuleParameterNode);

                var functionParameterNode = oDoc.CreateElement("functionparameters");
                this.FunctionParameters.XmlAppend(functionParameterNode);
                node.AppendChild(functionParameterNode);

                var relationsNode = oDoc.CreateElement("relations");
                this.Relations.XmlAppend(relationsNode);
                node.AppendChild(relationsNode);

                var relationsNode2 = oDoc.CreateElement("viewrelations");
                this.ViewRelations.XmlAppend(relationsNode2);
                node.AppendChild(relationsNode2);

                XmlHelper.AddAttribute(node, "databaseName", this.DatabaseName);

                var tablesNode = oDoc.CreateElement("tables");
                this.Tables.XmlAppend(tablesNode);
                node.AppendChild(tablesNode);

                var functionsNode = oDoc.CreateElement("functions");
                this.Functions.XmlAppend(functionsNode);
                node.AppendChild(functionsNode);

                var customViewsNode = oDoc.CreateElement("customviews");
                this.CustomViews.XmlAppend(customViewsNode);
                node.AppendChild(customViewsNode);

                var customAggregatesNode = oDoc.CreateElement("customaggregates");
                this.CustomAggregates.XmlAppend(customAggregatesNode);
                node.AppendChild(customAggregatesNode);

                var customStoredProceduresNode = oDoc.CreateElement("customstoredprocedures");
                this.CustomStoredProcedures.XmlAppend(customStoredProceduresNode);
                node.AppendChild(customStoredProceduresNode);

                //XmlHelper.AddAttribute(node, "createdDate", _createdDate.ToString("yyyy-MM-dd HH:mm:ss", System.Globalization.CultureInfo.InvariantCulture));
            }
            catch (Exception ex)
            {
                throw;
            }
        }
示例#30
0
 public void ToXML(System.Xml.XmlElement node)
 {
     XmlHelper.AddAttribute(node, "type", "idtogid");
     XmlHelper.AddAttribute(node, "fieldid", this.FieldID.ToString());
 }