private int BindRecursive(List <JsonTreeNode> nodes, XPathNavigator linkItem) { int num = 0; foreach (XPathNavigator linkItem1 in linkItem.SelectChildren(string.Empty, string.Empty)) { string attribute1 = linkItem1.GetAttribute("permissions", string.Empty); JsonTreeNode jsonTreeNode = new JsonTreeNode(); string resFileString = UtilHelper.GetResFileString(linkItem1.GetAttribute("text", string.Empty)); string attribute2 = linkItem1.GetAttribute("id", string.Empty); jsonTreeNode.text = resFileString; jsonTreeNode.id = attribute2; jsonTreeNode.cls = "nodeCls"; jsonTreeNode.iconCls = "iconNodeCls"; string attribute3 = linkItem1.GetAttribute("iconUrl", string.Empty); if (!string.IsNullOrEmpty(attribute3)) { jsonTreeNode.icon = this.ResolveUrl(attribute3); } string attribute4 = linkItem1.GetAttribute("iconCss", string.Empty); if (!string.IsNullOrEmpty(attribute4)) { jsonTreeNode.iconCls = attribute4; } string attribute5 = linkItem1.GetAttribute("command", string.Empty); if (string.IsNullOrEmpty(attribute5)) { if (!string.IsNullOrEmpty(attribute1) && !SecurityContext.Current.CheckPermissionForCurentUser(attribute1, false)) { continue; } } else { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("permissions", attribute1); if (TreeSource.IsEnableCommand("", "", "", attribute5, parameters)) { string str = CommandManager.GetCommandString(attribute5, (Dictionary <string, string>)null).Replace("\"", """); jsonTreeNode.href = string.Format("javascript:{0}", (object)str); } else { continue; } } string attribute6 = linkItem1.GetAttribute("expanded", string.Empty); if (!string.IsNullOrEmpty(attribute6) && attribute6.ToLower().Equals("true")) { jsonTreeNode.expanded = true; } string attribute7 = linkItem1.GetAttribute("type", string.Empty); if (!string.IsNullOrEmpty(attribute7)) { jsonTreeNode.type = attribute7; } bool flag = false; string attribute8 = linkItem1.GetAttribute("treeLoader", string.Empty); string attribute9 = linkItem1.GetAttribute("treeLoaderPath", string.Empty); if (!string.IsNullOrEmpty(attribute8)) { flag = true; } if (!string.IsNullOrEmpty(attribute9)) { flag = true; jsonTreeNode.treeLoader = this.ResolveClientUrl(attribute9); } if (!flag) { jsonTreeNode.children = new List <JsonTreeNode>(); if (this.BindRecursive(jsonTreeNode.children, linkItem1) == 0) { jsonTreeNode.leaf = true; jsonTreeNode.children = (List <JsonTreeNode>)null; } } nodes.Add(jsonTreeNode); ++num; } return(num); }
private int BindRecursive(List <JsonTreeNode> nodes, Link[] linkItem) { int num1 = 0; foreach (Link link in linkItem) { if (link.id.Equals("Order_PurchaseOrdersSunstore") || link.id.Equals("Order_PurchaseOrdersAmavita") || link.id.Equals("Order_PurchaseOrdersCoop") || link.id.Equals("ShippingReceivingSunstore") || link.id.Equals("ShippingReceivingAmavita") || link.id.Equals("ShippingReceivingCoop") ) { if (CheckifUserHasRoleOnMarket(link.id)) { string permissions = link.permissions; JsonTreeNode jsonTreeNode = new JsonTreeNode(); string resFileString = UtilHelper.GetResFileString(link.text); jsonTreeNode.text = resFileString; jsonTreeNode.id = link.id; jsonTreeNode.cls = "nodeCls"; jsonTreeNode.iconCls = "iconNodeCls"; if (!string.IsNullOrEmpty(link.iconUrl)) { jsonTreeNode.icon = this.ResolveUrl(link.iconUrl); } if (!string.IsNullOrEmpty(link.iconCss)) { jsonTreeNode.iconCls = link.iconCss; } if (string.IsNullOrEmpty(link.command)) { if (!string.IsNullOrEmpty(permissions) && !SecurityContext.Current.CheckPermissionForCurentUser(permissions, false)) { continue; } } else { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("permissions", permissions); if (TreeSource.IsEnableCommand("", "LeftMenu", "", link.command, parameters)) { string str = CommandManager.GetCommandString(link.command, (Dictionary <string, string>)null).Replace("\"", """); jsonTreeNode.href = string.Format("javascript:{0}", (object)str); XmlCommand.GetCommandByName("", "LeftMenu", "", link.command); } else { continue; } } if (link.expanded) { jsonTreeNode.expanded = true; } if (!string.IsNullOrEmpty(link.type)) { jsonTreeNode.type = link.type; } bool flag = false; string treeLoader = link.treeLoader; string treeLoaderPath = link.treeLoaderPath; if (!string.IsNullOrEmpty(treeLoader)) { flag = true; } if (!string.IsNullOrEmpty(treeLoaderPath)) { flag = true; jsonTreeNode.treeLoader = this.ResolveClientUrl(treeLoaderPath); } if (!flag) { jsonTreeNode.children = new List <JsonTreeNode>(); int num2 = 0; if (link.Items != null) { num2 = this.BindRecursive(jsonTreeNode.children, link.Items); } if (num2 == 0) { jsonTreeNode.leaf = true; jsonTreeNode.children = (List <JsonTreeNode>)null; } } nodes.Add(jsonTreeNode); ++num1; } } else { string permissions = link.permissions; JsonTreeNode jsonTreeNode = new JsonTreeNode(); string resFileString = UtilHelper.GetResFileString(link.text); jsonTreeNode.text = resFileString; jsonTreeNode.id = link.id; jsonTreeNode.cls = "nodeCls"; jsonTreeNode.iconCls = "iconNodeCls"; if (!string.IsNullOrEmpty(link.iconUrl)) { jsonTreeNode.icon = this.ResolveUrl(link.iconUrl); } if (!string.IsNullOrEmpty(link.iconCss)) { jsonTreeNode.iconCls = link.iconCss; } if (string.IsNullOrEmpty(link.command)) { if (!string.IsNullOrEmpty(permissions) && !SecurityContext.Current.CheckPermissionForCurentUser(permissions, false)) { continue; } } else { Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters.Add("permissions", permissions); if (TreeSource.IsEnableCommand("", "LeftMenu", "", link.command, parameters)) { string str = CommandManager.GetCommandString(link.command, (Dictionary <string, string>)null).Replace("\"", """); jsonTreeNode.href = string.Format("javascript:{0}", (object)str); XmlCommand.GetCommandByName("", "LeftMenu", "", link.command); } else { continue; } } if (link.expanded) { jsonTreeNode.expanded = true; } if (!string.IsNullOrEmpty(link.type)) { jsonTreeNode.type = link.type; } bool flag = false; string treeLoader = link.treeLoader; string treeLoaderPath = link.treeLoaderPath; if (!string.IsNullOrEmpty(treeLoader)) { flag = true; } if (!string.IsNullOrEmpty(treeLoaderPath)) { flag = true; jsonTreeNode.treeLoader = this.ResolveClientUrl(treeLoaderPath); } if (!flag) { jsonTreeNode.children = new List <JsonTreeNode>(); int num2 = 0; if (link.Items != null) { num2 = this.BindRecursive(jsonTreeNode.children, link.Items); } if (num2 == 0) { jsonTreeNode.leaf = true; jsonTreeNode.children = (List <JsonTreeNode>)null; } } nodes.Add(jsonTreeNode); ++num1; } } return(num1); }