示例#1
0
        private string GetPdwXslPath(string bizName, bool isIf, List <string> selectedTables,
                                     Relations relations, XmlNode startNode = null)
        {
            string        xslPath      = string.Empty;
            List <string> path         = new List <string>();
            List <string> parentPath   = new List <string>();
            bool          isForeachTag = false;

            if (relations.MapInfos.ContainsKey(bizName))
            {
                string tableName = relations.MapInfos[bizName].TableName;
                if (tableName.StartsWith("[") && tableName.EndsWith("]"))
                {
                    tableName = tableName.Substring(1, tableName.Length - 2);
                }
                path    = GetPath(selectedTables, tableName);
                bizName = "@" + MarkupUtilities.XmlEncode(bizName);
                if (isIf)
                {
                    bizName = bizName + "= 1";
                }
                if (_foreach.Count > 0) // has foreach parent
                {
                    parentPath = _foreach[_foreach.Count - 1].Path;
                }
            }
            else
            {
                if (bizName == ProntoDoc.Framework.CoreObject.FrameworkConstants.PdwWatermark)
                {
                    xslPath = GetSectionPath() + "/";
                    bizName = "@" + Pdw.Core.MarkupUtilities.XmlEncode(bizName);
                }
                else
                {
                    if (_foreach.Count > 0)
                    {
                        isForeachTag = true;
                        path         = _foreach[_foreach.Count - 1].Path;
                        if (_foreach.Count > 1) // has foreach parent
                        {
                            parentPath = _foreach[_foreach.Count - 2].Path;
                        }
                    }
                }
            }

            // build virtual path
            for (int i = 0; i < parentPath.Count - path.Count; i++)
            {
                if (MarkupUtilities.IsExistOnList(selectedTables, parentPath[i]))
                {
                    xslPath = "../" + xslPath;
                }
            }

            // build path
            for (int i = parentPath.Count; i < path.Count; i++)
            {
                if (MarkupUtilities.IsExistOnList(selectedTables, path[i]))
                {
                    xslPath = xslPath + MarkupUtilities.XmlEncode(path[i]) + "/"; // ngocbv: add encode
                }
            }
            xslPath = xslPath + bizName;
            if (xslPath.EndsWith("/"))
            {
                xslPath = xslPath.Remove(xslPath.Length - 1);
            }

            if (string.IsNullOrEmpty(xslPath) && path.Count > 0)
            {
                xslPath = "../" + MarkupUtilities.XmlEncode(path[path.Count - 1]);
            }

            // process add section (put virutal path at the root table)
            if (_isAddSection)
            {
                if ((_foreach.Count == 1 && isForeachTag) ||           // root for-each tag (add virtual path in the first)
                    (_foreach.Count == 0 && selectedTables.Count > 0)) // root select (remove the first path)
                {
                    string sectionPath = GetSectionPath();
                    int    index       = IndexOfSecondChar(xslPath, '/', false); // second because the first is DomainName
                    if (index > 0)
                    {
                        xslPath = xslPath.Substring(index + 1);
                        if (string.IsNullOrEmpty(xslPath) && selectedTables.Count > 0) // using for for-each of root after for-each multi section
                        {
                            xslPath = "../../" + sectionPath;
                        }
                    }
                    else
                    {
                        if (selectedTables.Count > 0 && xslPath == sectionPath) // in case user tag for-each root node
                        {
                            xslPath = "../../" + sectionPath;
                        }
                    }
                }
            }

            // process when tag in header or footer
            if (startNode != null)
            {
                if (selectedTables.Count > 0)
                {
                    bool isInFooterOrHeader = IsInFooterOrHeader(startNode);
                    if (isInFooterOrHeader)
                    {
                        string sectionPath = GetSectionPath();
                        if (!xslPath.StartsWith(sectionPath))
                        {
                            xslPath = sectionPath + "/" + xslPath;
                        }
                    }
                }
            }

            return(xslPath);
        }
示例#2
0
        private string GetPdeXslPath(string bizName, List <string> selectedTables)
        {
            string        xslPath      = string.Empty;
            List <string> path         = selectedTables;
            List <string> parentPath   = new List <string>();
            bool          isForeachTag = false;

            if (!string.IsNullOrWhiteSpace(bizName)) // data tag
            {
                if (_foreach.Count > 0)
                {
                    string colKey = _foreach[_foreach.Count - 1].Path[0];
                    parentPath = GetPdeSelectedTables(colKey, false);
                }
            }
            else // for-each
            {
                if (_foreach.Count > 0)
                {
                    string colKey = _foreach[_foreach.Count - 1].Path[0];
                    path = selectedTables = GetPdeSelectedTables(colKey, false);

                    if (_foreach.Count > 1) // has foreach parent
                    {
                        colKey     = _foreach[_foreach.Count - 2].Path[0];
                        parentPath = GetPdeSelectedTables(colKey, false);
                    }
                }
            }

            // build virtual path
            for (int i = 0; i < parentPath.Count - path.Count; i++)
            {
                if (MarkupUtilities.IsExistOnList(selectedTables, parentPath[i]))
                {
                    xslPath = "../" + xslPath;
                }
            }

            // build path
            for (int i = parentPath.Count; i < path.Count; i++)
            {
                if (MarkupUtilities.IsExistOnList(selectedTables, path[i]))
                {
                    xslPath = xslPath + path[i] + "/";
                }
            }

            if (xslPath.EndsWith("/"))
            {
                xslPath = xslPath.Remove(xslPath.Length - 1);
            }

            if (string.IsNullOrEmpty(xslPath) && path.Count > 0)
            {
                xslPath = "../" + MarkupUtilities.XmlEncode(path[path.Count - 1]);
            }

            // process add section (put virutal path at the root table)
            if (_isAddSection)
            {
                if ((_foreach.Count == 1 && isForeachTag) ||           // root for-each tag (add virtual path in the first)
                    (_foreach.Count == 0 && selectedTables.Count > 0)) // root select (remove the first path)
                {
                    string sectionPath = GetSectionPath();
                    int    index       = IndexOfSecondChar(xslPath, '/', false); // second because the first is DomainName
                    if (index > 0)
                    {
                        xslPath = xslPath.Substring(index + 1);
                        if (string.IsNullOrEmpty(xslPath) && selectedTables.Count > 0) // using for for-each of root after for-each multi section
                        {
                            xslPath = "../../" + sectionPath;
                        }
                    }
                    else
                    {
                        if (selectedTables.Count > 0 && xslPath == sectionPath) // in case user tag for-each root node
                        {
                            xslPath = "../../" + sectionPath;
                        }
                    }
                }
            }

            return(xslPath);
        }