Ejemplo n.º 1
0
        /// <summary>
        /// Binds the scripts.
        /// </summary>
        private void BindScripts()
        {
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "ExtBase", ResolveClientUrl("~/Scripts/ext/ext-base.js"));
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "ExtAll", ResolveClientUrl("~/Scripts/ext/ext-all.js"));
            Page.ClientScript.RegisterClientScriptInclude(this.Page.GetType(), "ManagementClientProxy", ResolveClientUrl("~/Scripts/ManagementClientProxy.js"));

            string url  = "~/Apps/Dashboard/Scripts";
            string path = Server.MapPath(url);

            if (Directory.Exists(path))
            {
                foreach (FileInfo file in new DirectoryInfo(path).GetFiles())
                {
                    this.ClientScript.RegisterClientScriptInclude(file.Name, this.ResolveClientUrl(String.Format("{0}/{1}", url, file.Name)));
                }
            }

            Page.ClientScript.RegisterClientScriptBlock(this.Page.GetType(), "ExtBlankInit", "Ext.BLANK_IMAGE_URL = 'images/s.gif';", true);

            // set page title
            string scriptKey = "CSManagementClient.SetPageTitle('" + UtilHelper.GetResFileString("{DashboardStrings:Dashboard_Home}") + "');";

            Page.ClientScript.RegisterStartupScript(this.Page.GetType(), "Dashboard_PageTitleKey", scriptKey, true);

            // register portlet scripts
            //ScriptManager.GetCurrent(this.Page).Scripts.Add(new ScriptReference("~/Apps/Core/Layout/Scripts/Portal.js"));
            //ScriptManager.GetCurrent(this.Page).Scripts.Add(new ScriptReference("~/Apps/Core/Layout/Scripts/PortalColumn.js"));
            //ScriptManager.GetCurrent(this.Page).Scripts.Add(new ScriptReference("~/Apps/Core/Layout/Scripts/Portlet.js"));
            ScriptManager.GetCurrent(this.Page).ScriptMode = ScriptMode.Release;

            ScriptManager.GetCurrent(this.Page).EnablePageMethods = true;
        }
 private void BindPermissionsTree()
 {
     this.PermissionsTree.Nodes.Clear();
     foreach (ModuleConfig moduleConfig in ManagementContext.Current.Configs)
     {
         if (moduleConfig.Acl != null && moduleConfig.Acl.Groups != null)
         {
             foreach (AclGroup aclGroup in (CollectionBase)moduleConfig.Acl.Groups)
             {
                 TreeNode treeNode = new TreeNode();
                 treeNode.Value        = this.GetTreeNodeUniqueId("group_", aclGroup.ID);
                 treeNode.Text         = UtilHelper.GetResFileString("{SharedStrings:" + aclGroup.Name + "}");
                 treeNode.ShowCheckBox = new bool?(false);
                 treeNode.SelectAction = TreeNodeSelectAction.Expand;
                 treeNode.ImageUrl     = this.Page.ResolveUrl("~/Apps/Customer/images/security_folder.png");
                 foreach (AclGroup group in (CollectionBase)aclGroup.Groups)
                 {
                     if (this.AddAclGroup(group, treeNode) == 0)
                     {
                         treeNode.Select();
                     }
                 }
                 this.PermissionsTree.Nodes.Add(treeNode);
             }
         }
     }
 }
Ejemplo n.º 3
0
        private string GetPageTitle()
        {
            string title = String.Empty;

            string classType = ClassType;

            if (String.Compare(classType, "PurchaseOrder", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                if (!String.IsNullOrEmpty(Status))
                {
                    title = UtilHelper.GetResFileString("{OrderStrings:Order_By_Status}");
                }
                else
                {
                    title = UtilHelper.GetResFileString("{OrderStrings:Order_List}");
                }
            }
            else if (String.Compare(classType, "ShoppingCart", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                title = UtilHelper.GetResFileString("{OrderStrings:Cart_List}");
            }
            else if (String.Compare(classType, "PaymentPlan", StringComparison.InvariantCultureIgnoreCase) == 0)
            {
                title = UtilHelper.GetResFileString("{OrderStrings:PaymentPlan_List}");
            }

            return(title);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Binds the permissions tree.
        /// </summary>
        private void BindPermissionsTree()
        {
            PermissionsTree.Nodes.Clear();
            foreach (ModuleConfig config in ManagementContext.Current.Configs)
            {
                // If there no acl defined, do not show items
                if (config.Acl == null)
                {
                    continue;
                }

                foreach (AclGroup group in config.Acl.Groups)
                {
                    TreeNode treeNode = new TreeNode();
                    treeNode.Value        = GetTreeNodeUniqueId(_groupNodePrefix, group.ID);
                    treeNode.Text         = UtilHelper.GetResFileString(group.Name);
                    treeNode.ShowCheckBox = false;
                    treeNode.SelectAction = TreeNodeSelectAction.Expand;
                    treeNode.ImageUrl     = Page.ResolveUrl("~/Apps/Profile/images/security_folder.png");
                    foreach (AclGroup childGroup in group.Groups)
                    {
                        if (AddAclGroup(childGroup, treeNode) == 0)
                        {
                            treeNode.Select();
                        }
                    }

                    PermissionsTree.Nodes.Add(treeNode);
                }
                //PermissionsTree.CollapseAll();
            }
        }
Ejemplo n.º 5
0
        private void ProcessChildren(DataTable dt, XPathNavigator linkItem, string path, bool hiddenParent, int level, bool odd)
        {
            level++;

            foreach (XPathNavigator subItem in linkItem.SelectChildren(string.Empty, string.Empty))
            {
                bool hidden;
                bool.TryParse(subItem.GetAttribute("hidden", string.Empty), out hidden);

                // don't show items, hidden at the above layer
                string hiddenLayer = subItem.GetAttribute("hiddenLayer", string.Empty);
                if (hidden && ProfileId.HasValue && hiddenLayer == NavigationManager.CustomizationLayerGlobal)
                {
                    continue;
                }
                if (hidden && UserId.HasValue && (hiddenLayer == NavigationManager.CustomizationLayerGlobal || hiddenLayer == NavigationManager.CustomizationLayerProfile))
                {
                    continue;
                }

                string id     = subItem.GetAttribute("id", string.Empty);
                string fullId = String.Concat(path, "/", id);

                DataRow dr = dt.NewRow();
                dr["Id"]     = id;
                dr["FullId"] = fullId;
                dr["Title"]  = String.Format(CultureInfo.InvariantCulture,
                                             "<span style=\"padding-left:{0}px;\">{1}</span>",
                                             level * 20,
                                             UtilHelper.GetResFileString(subItem.GetAttribute("text", string.Empty)));

                dr["Order"]        = subItem.GetAttribute("order", string.Empty);
                dr["Hidden"]       = hidden;
                dr["HiddenParent"] = hiddenParent;

                bool changed;
                bool.TryParse(subItem.GetAttribute("changed", string.Empty), out changed);
                dr["Changed"] = changed;
                dr["Odd"]     = odd;

                string addedString = subItem.GetAttribute("added", string.Empty);
                if (String.IsNullOrEmpty(addedString))
                {
                    dr["Added"] = false;
                }
                else
                {
                    dr["Added"] = bool.Parse(addedString);
                }

                dr["HiddenLayer"]  = subItem.GetAttribute("hiddenLayer", string.Empty);
                dr["ChangedLayer"] = subItem.GetAttribute("changedLayer", string.Empty);
                dr["AddedLayer"]   = subItem.GetAttribute("addedLayer", string.Empty);

                dt.Rows.Add(dr);

//				if (!hidden && !hiddenParent)
                ProcessChildren(dt, subItem, fullId, hidden || hiddenParent, level, odd);
            }
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Creates the tabs.
        /// </summary>
        private void CreateTabs()
        {
            AdminView view = ManagementContext.Current.FindView(this.AppId, this.ViewId);

            // Check view permissions
            if (view.Attributes.Contains("permissions"))
            {
                if (!ProfileContext.Current.CheckPermission(view.Attributes["permissions"].ToString()))
                {
                    throw new UnauthorizedAccessException("Current user does not have enough rights to access the requested operation.");
                }
            }

            if (view == null)
            {
                return;
            }

            DefaultTabContainer.Tabs.Clear();

            foreach (ViewTab node in view.Tabs)
            {
                // Check if the node is visible
                if (!IsVisible(node))
                {
                    continue;
                }

                TabPanel tabPanel = new TabPanel();
                if (node.Attributes["Name"] != null)
                {
                    tabPanel.HeaderText = UtilHelper.GetResFileString(node.Attributes["Name"].ToString());
                }

                // Load custom control
                string controlUrl = String.Format("~/Apps/{0}", node.ControlUrl);
                if (File.Exists(Server.MapPath(controlUrl)))
                {
                    Control ctrl = this.LoadControl(controlUrl);
                    tabPanel.Controls.Add(ctrl);
                }
                else
                {
                    throw new FileNotFoundException(Server.MapPath(controlUrl));
                }

                // Add tabs
                DefaultTabContainer.Tabs.Add(tabPanel);
            }

            if (DefaultTabContainer.Tabs.Count > 0)
            {
                DefaultTabContainer.ActiveTabIndex = 0;
            }
        }
Ejemplo n.º 7
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!String.IsNullOrEmpty(_nodeId))
            {
                IXPathNavigable navigable;
                // Selector: ClassName.ViewName.PlaceName.ProfileId.UserId
                Selector selector = new Selector(string.Empty, string.Empty, string.Empty, ProfileManager.GetProfileIdByUser().ToString(), Mediachase.IBN.Business.Security.UserID.ToString());

                // don't hide items for administrator
                if (Mediachase.IBN.Business.Security.IsUserInGroup(Mediachase.IBN.Business.InternalSecureGroups.Administrator))
                {
                    navigable = Mediachase.Ibn.XmlTools.XmlBuilder.GetCustomizationXml(null, StructureType.Navigation, selector);
                }
                else
                {
                    navigable = Mediachase.Ibn.XmlTools.XmlBuilder.GetXml(StructureType.Navigation, selector);
                }

                XPathNavigator link = navigable.CreateNavigator().SelectSingleNode(String.Format("//Link[@id='{0}']", _nodeId));
                if (link != null)
                {
                    string mainTitle = UtilHelper.GetResFileString(link.GetAttribute("text", string.Empty));
                    lblParentName.Text = mainTitle;

                    foreach (XPathNavigator subItem in link.SelectChildren(string.Empty, string.Empty))
                    {
                        string title   = UtilHelper.GetResFileString(subItem.GetAttribute("text", string.Empty));
                        string command = subItem.GetAttribute("command", string.Empty);
                        string cmd     = String.Empty;
                        if (!String.IsNullOrEmpty(command))
                        {
                            if (!CommandManager.IsEnableCommand("", "", "", "", "", command))
                            {
                                continue;
                            }
                            cmd = CommandManager.GetCurrent(this.Page).AddCommand("", "", "", command, null);
                            cmd = cmd.Replace("\"", "&quot;");
                            //node.href = String.Format("javascript:{0}", cmd);
                        }
                        HtmlTableRow  tr = new HtmlTableRow();
                        HtmlTableCell tc = new HtmlTableCell();
                        tc.InnerHtml = String.Format("<img alt='' src='{0}' /> <a href=\"{1}\">{2}</a>",
                                                     Page.ResolveUrl("~/layouts/images/rect.gif"),
                                                     String.Format("javascript:{{{0}}}", cmd), title);
                        tr.Cells.Add(tc);
                        mainTable.Rows.Add(tr);
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public static string FormatAgoDateTime(DateTime date)
        {
            DateTime userUtcNow = GetUserDateTime(DateTime.UtcNow);
            DateTime userDate   = GetUserDateTime(date);

            // make Today and Yesterday bold
            if ((userDate.DayOfYear == userUtcNow.DayOfYear) && (userDate.Year == userUtcNow.Year))
            {
                int minutes = (userUtcNow - userDate).Minutes;
                int hours   = (userUtcNow - userDate).Hours;
                if (userDate > userUtcNow.AddHours(-1))
                {
                    if (minutes > 2)
                    {
                        return(UtilHelper.GetResFileString("{SharedStrings:Minute_Ago}"));
                    }

                    return(String.Format(UtilHelper.GetResFileString("{SharedStrings:Minutes_Ago}"), minutes));
                }
                else
                {
                    if (hours < 2)
                    {
                        return(String.Format(UtilHelper.GetResFileString("{SharedStrings:Hour_Ago}"), hours, minutes));
                    }

                    return(String.Format(UtilHelper.GetResFileString("{SharedStrings:Hours_Ago}"), hours, minutes));
                }
            }
            else if ((userDate.DayOfYear == (userUtcNow.DayOfYear - 1)) && (userDate.Year == userUtcNow.Year))
            {
                int days  = (userUtcNow - userDate).Days;
                int hours = (userUtcNow - userDate).Hours;
                return(String.Format(UtilHelper.GetResFileString("{SharedStrings:Day_Ago}"), days, hours));
            }
            else
            {
                int days = (userUtcNow - userDate).Days;

                if (days < 5)
                {
                    int hours = (userUtcNow - userDate).Hours;
                    return(String.Format(UtilHelper.GetResFileString("{SharedStrings:Days_Ago}"), days, hours));
                }

                return(String.Empty);
            }
        }
        private void BindJsTree()
        {
            string str = string.Empty;

            if (this.Request["tab"] != null)
            {
                str = this.Request["tab"];
            }
            if (string.IsNullOrEmpty(str))
            {
                return;
            }
            List <JsonTreeNode> nodes      = new List <JsonTreeNode>();
            Navigation          navigation = XmlModelHelper.GetNavigation("LeftMenu", string.Empty);

            if (navigation == null || navigation.Tabs == null)
            {
                return;
            }
            foreach (Tab tab in navigation.Tabs.Tab)
            {
                if (!string.IsNullOrEmpty(str) && str == tab.id || string.IsNullOrEmpty(str))
                {
                    JsonTreeNode jsonTreeNode = new JsonTreeNode();
                    jsonTreeNode.id   = tab.id;
                    jsonTreeNode.text = UtilHelper.GetResFileString(tab.text);
                    jsonTreeNode.cls  = "nodeCls";
                    if (!string.IsNullOrEmpty(tab.imageUrl))
                    {
                        jsonTreeNode.icon = this.ResolveUrl(tab.imageUrl);
                    }
                    jsonTreeNode.children = new List <JsonTreeNode>();
                    jsonTreeNode.expanded = true;
                    int num = 0;
                    if (tab.Items != null)
                    {
                        num = this.BindRecursive(jsonTreeNode.children, tab.Items);
                    }
                    if (num == 0)
                    {
                        jsonTreeNode.leaf     = true;
                        jsonTreeNode.children = (List <JsonTreeNode>)null;
                    }
                    nodes.Add(jsonTreeNode);
                }
            }
            this.WriteArray(nodes);
        }
        private void BindFullTree()
        {
            List <JsonTreeNode> nodes = new List <JsonTreeNode>();

            XmlBuilder.GetCustomizableXml2(StructureType.View, 1 != 0, new Selector(new string[1]
            {
                "LeftMenu"
            }));
            Navigation navigation = XmlModelHelper.GetNavigation("LeftMenu", string.Empty);

            if (navigation == null || navigation.Tabs == null)
            {
                return;
            }
            if (navigation.Commands.Command != null)
            {
                foreach (Mediachase.BusinessFoundation.XmlObjectModel.Command command in navigation.Commands.Command)
                {
                    XmlCommand.GetCommandByName("", "LeftMenu", "", command.id);
                }
            }
            foreach (Tab tab in navigation.Tabs.Tab)
            {
                JsonTreeNode jsonTreeNode = new JsonTreeNode();
                jsonTreeNode.id   = tab.id;
                jsonTreeNode.text = UtilHelper.GetResFileString(tab.text);
                jsonTreeNode.cls  = "nodeCls";
                if (!string.IsNullOrEmpty(tab.imageUrl))
                {
                    jsonTreeNode.icon = this.ResolveUrl(tab.imageUrl);
                }
                jsonTreeNode.children = new List <JsonTreeNode>();
                int num = 0;
                if (tab.Items != null)
                {
                    num = this.BindRecursiveNoAsync(jsonTreeNode.children, tab.Items);
                }
                if (num == 0)
                {
                    jsonTreeNode.leaf     = true;
                    jsonTreeNode.children = (List <JsonTreeNode>)null;
                }
                nodes.Add(jsonTreeNode);
            }
            this.WriteArray(nodes);
        }
Ejemplo n.º 11
0
        private int BindRecursiveNoAsync(List <JsonTreeNode> nodes, XPathNavigator linkItem)
        {
            int retVal = 0;

            foreach (XPathNavigator subItem in linkItem.SelectChildren(string.Empty, string.Empty))
            {
                JsonTreeNode node = new JsonTreeNode();

                node.id = subItem.GetAttribute("id", string.Empty);

                node.text = UtilHelper.GetResFileString(subItem.GetAttribute("text", string.Empty));

                string order = subItem.GetAttribute("order", string.Empty);
                if (!string.IsNullOrEmpty(order))
                {
                    node.text = String.Concat("<span class=\"rightColumn\">", order, "</span><span class=\"leftColumn\">", node.text, "</span>");
                }

                node.cls     = "nodeCls";
                node.iconCls = "iconNodeCls";

                string iconUrl = subItem.GetAttribute("iconUrl", string.Empty);
                if (!String.IsNullOrEmpty(iconUrl))
                {
                    node.icon = ResolveClientUrl(iconUrl);
                }

                string iconCss = subItem.GetAttribute("iconCss", string.Empty);
                if (!String.IsNullOrEmpty(iconCss))
                {
                    node.iconCls = iconCss;
                }

                node.children = new List <JsonTreeNode>();
                int count = BindRecursiveNoAsync(node.children, subItem);
                if (count == 0)
                {
                    node.leaf     = true;
                    node.children = null;
                }

                nodes.Add(node);
                retVal++;
            }
            return(retVal);
        }
Ejemplo n.º 12
0
        /// <summary>
        /// Binds the sale types list.
        /// </summary>
        private void BindSaleTypesList()
        {
            SaleTypeFilter.Items.Clear();

            foreach (SalePriceTypeDefinition element in CatalogConfiguration.Instance.SalePriceTypes)
            {
                ListItem li = new ListItem(UtilHelper.GetResFileString(element.Description), element.Value.ToString());
                SaleTypeFilter.Items.Add(li);
            }

            /*
             *          foreach (int key in SaleType.SaleTypes.Keys)
             *          {
             *                  ListItem li = new ListItem(SaleType.SaleTypes[key], key.ToString());
             *                  SaleTypeFilter.Items.Add(li);
             *          }
             * */
        }
Ejemplo n.º 13
0
        private void BindFullTree()
        {
            IXPathNavigable navigable = Mediachase.Ibn.XmlTools.XmlBuilder.GetXml(StructureType.Navigation);

            XPathNavigator      tabsNode = navigable.CreateNavigator().SelectSingleNode("Navigation/Tabs");
            List <JsonTreeNode> nodes    = new List <JsonTreeNode>();

            foreach (XPathNavigator subItem in tabsNode.SelectChildren("Tab", string.Empty))
            {
                JsonTreeNode node = new JsonTreeNode();

                node.id   = subItem.GetAttribute("id", string.Empty);
                node.text = UtilHelper.GetResFileString(subItem.GetAttribute("text", string.Empty));

                string order = subItem.GetAttribute("order", string.Empty);
                if (!string.IsNullOrEmpty(order))
                {
                    node.text += String.Concat("<span class=\"rightColumn\">", order, "</span><span class=\"clearColumn\"></span>");
                }

                node.cls = "nodeCls";

                string iconUrl = subItem.GetAttribute("imageUrl", string.Empty);
                if (!String.IsNullOrEmpty(iconUrl))
                {
                    node.icon = ResolveClientUrl(iconUrl);
                }

                node.children = new List <JsonTreeNode>();
                int count = BindRecursiveNoAsync(node.children, subItem);
                if (count == 0)
                {
                    node.leaf     = true;
                    node.children = null;
                }

                nodes.Add(node);
            }

            WriteArray(nodes);
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Generates the source.
        /// </summary>
        /// <returns></returns>
        private DataTable GenerateSource()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Id", typeof(string)));
            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Description", typeof(string)));

            foreach (DynamicControlInfo dci in DynamicControlFactory.GetControlInfos())
            {
                DataRow row = dt.NewRow();

                row["Id"]          = dci.Uid;
                row["Title"]       = UtilHelper.GetResFileString(dci.Title);
                row["Description"] = UtilHelper.GetResFileString(dci.Description);

                dt.Rows.Add(row);
            }

            return(dt);
        }
        private int BindRecursiveNoAsync(List <JsonTreeNode> nodes, Link[] linkItems)
        {
            int num1 = 0;

            foreach (Link link in linkItems)
            {
                JsonTreeNode jsonTreeNode = new JsonTreeNode();
                jsonTreeNode.id   = link.id;
                jsonTreeNode.text = UtilHelper.GetResFileString(link.text);
                string str = link.order.ToString();
                if (!string.IsNullOrEmpty(str))
                {
                    jsonTreeNode.text = "<span class=\"rightColumn\">" + str + "</span><span class=\"leftColumn\">" + jsonTreeNode.text + "</span>";
                }
                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;
                }
                jsonTreeNode.children = new List <JsonTreeNode>();
                int num2 = 0;
                if (link.Items != null)
                {
                    num2 = this.BindRecursiveNoAsync(jsonTreeNode.children, link.Items);
                }
                if (num2 == 0)
                {
                    jsonTreeNode.leaf     = true;
                    jsonTreeNode.children = (List <JsonTreeNode>)null;
                }
                nodes.Add(jsonTreeNode);
                ++num1;
            }
            return(num1);
        }
Ejemplo n.º 16
0
        private DataTable GenerateTemplatesDataSource()
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Id", typeof(string)));
            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Description", typeof(string)));
            dt.Columns.Add(new DataColumn("ImageUrl", typeof(string)));

            foreach (WorkspaceTemplateInfo wti in WorkspaceTemplateFactory.GetTemplateInfos())
            {
                DataRow row = dt.NewRow();
                row["Id"]          = wti.Uid;
                row["Title"]       = UtilHelper.GetResFileString(wti.Title);
                row["Description"] = UtilHelper.GetResFileString(wti.Description);
                row["ImageUrl"]    = CommerceHelper.GetAbsolutePath(wti.ImageUrl);

                dt.Rows.Add(row);
            }

            return(dt);
        }
        private int BindRecursiveNoAsync(List <JsonTreeNode> nodes, XPathNavigator linkItem)
        {
            int num = 0;

            foreach (XPathNavigator linkItem1 in linkItem.SelectChildren(string.Empty, string.Empty))
            {
                JsonTreeNode jsonTreeNode = new JsonTreeNode();
                jsonTreeNode.id   = linkItem1.GetAttribute("id", string.Empty);
                jsonTreeNode.text = UtilHelper.GetResFileString(linkItem1.GetAttribute("text", string.Empty));
                string attribute1 = linkItem1.GetAttribute("order", string.Empty);
                if (!string.IsNullOrEmpty(attribute1))
                {
                    jsonTreeNode.text = "<span class=\"rightColumn\">" + attribute1 + "</span><span class=\"leftColumn\">" + jsonTreeNode.text + "</span>";
                }
                jsonTreeNode.cls     = "nodeCls";
                jsonTreeNode.iconCls = "iconNodeCls";
                string attribute2 = linkItem1.GetAttribute("iconUrl", string.Empty);
                if (!string.IsNullOrEmpty(attribute2))
                {
                    jsonTreeNode.icon = this.ResolveUrl(attribute2);
                }
                string attribute3 = linkItem1.GetAttribute("iconCss", string.Empty);
                if (!string.IsNullOrEmpty(attribute3))
                {
                    jsonTreeNode.iconCls = attribute3;
                }
                jsonTreeNode.children = new List <JsonTreeNode>();
                if (this.BindRecursiveNoAsync(jsonTreeNode.children, linkItem1) == 0)
                {
                    jsonTreeNode.leaf     = true;
                    jsonTreeNode.children = (List <JsonTreeNode>)null;
                }
                nodes.Add(jsonTreeNode);
                ++num;
            }
            return(num);
        }
Ejemplo n.º 18
0
        /// <summary>
        /// Returns formatted string back
        /// </summary>
        /// <param name="date"></param>
        /// <returns></returns>
        public static string FormatDateTime(DateTime date)
        {
            string   formatted  = "";
            DateTime userUtcNow = GetUserDateTimeNow();
            DateTime userDate   = GetUserDateTime(date);

            // make Today and Yesterday bold
            if ((userDate.DayOfYear == userUtcNow.DayOfYear) && (userDate.Year == userUtcNow.Year))
            {
                formatted  = "<b>" + UtilHelper.GetResFileString("{SharedStrings:Today}") + "</b>, ";
                formatted += userDate.ToString("t");
            }
            else if ((userDate.DayOfYear == (userUtcNow.DayOfYear - 1)) && (userDate.Year == userUtcNow.Year))
            {
                formatted  = "<b>" + UtilHelper.GetResFileString("{SharedStrings:Yesterday}") + "</b>, ";
                formatted += userDate.ToString("t");
            }
            else
            {
                formatted = userDate.ToString();
            }

            return(formatted);
        }
Ejemplo n.º 19
0
 private void BindFromObject(ToolBarItem[] itemCollection, List <McToolbarItem> toolbarItemsCollection)
 {
     if (itemCollection == null)
     {
         return;
     }
     foreach (ToolBarItem toolBarItem in itemCollection)
     {
         McToolbarItem mcToolbarItem1 = new McToolbarItem();
         if (toolBarItem is Menu)
         {
             mcToolbarItem1.ItemType = McToolbarItemType.Menu;
         }
         else if (toolBarItem is Button)
         {
             mcToolbarItem1.ItemType = McToolbarItemType.Button;
         }
         else if (toolBarItem is SplitButton)
         {
             mcToolbarItem1.ItemType = McToolbarItemType.SplitButton;
         }
         else if (toolBarItem is Text)
         {
             mcToolbarItem1.ItemType = McToolbarItemType.Text;
         }
         else if (toolBarItem is Splitter)
         {
             mcToolbarItem1.ItemType = McToolbarItemType.Splitter;
         }
         McToolbarItemAlign    toolbarItemAlign    = McToolbarItemAlign.Left;
         McToolbarItemSplitter toolbarItemSplitter = McToolbarItemSplitter.None;
         if (!string.IsNullOrEmpty(toolBarItem.align))
         {
             try
             {
                 toolbarItemAlign = (McToolbarItemAlign)Enum.Parse(typeof(McToolbarItemAlign), toolBarItem.align);
             }
             catch
             {
                 throw;
             }
         }
         if (!string.IsNullOrEmpty(toolBarItem.itemSplitter))
         {
             try
             {
                 toolbarItemSplitter = (McToolbarItemSplitter)Enum.Parse(typeof(McToolbarItemSplitter), toolBarItem.itemSplitter);
             }
             catch
             {
                 throw;
             }
         }
         if (toolBarItem.imageUrl != string.Empty && (mcToolbarItem1.ItemType == McToolbarItemType.Button || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton || mcToolbarItem1.ItemType == McToolbarItemType.Menu))
         {
             mcToolbarItem1.CssClass += "x-btn-wrap x-btn x-btn-text-icon ";
         }
         mcToolbarItem1.Id        = toolBarItem.id;
         mcToolbarItem1.Text      = this.IsTopMenuWelcomeText(toolBarItem.text) ? this.GetTopMenuWelcomeText(toolBarItem.text) : UtilHelper.GetResFileString(toolBarItem.text);
         mcToolbarItem1.ImageUrl  = this.ResolveClientUrl(toolBarItem.imageUrl);
         mcToolbarItem1.CssClass += toolBarItem.cssClass;
         mcToolbarItem1.ItemAlign = toolbarItemAlign;
         mcToolbarItem1.Handler   = toolBarItem.handler;
         mcToolbarItem1.Tooltip   = UtilHelper.GetResFileString(toolBarItem.tooltip);
         bool isEnabled = true;
         if (!string.IsNullOrEmpty(toolBarItem.commandName))
         {
             CommandParameters           cp         = new CommandParameters(toolBarItem.commandName);
             Dictionary <string, string> dictionary = new Dictionary <string, string>();
             dictionary.Add("GridId", this.GridId);
             dictionary.Add("GridClientId", this.GridClientId);
             dictionary.Add("permissions", toolBarItem.permissions);
             if (!string.IsNullOrEmpty(this.ContainerId))
             {
                 dictionary.Add("ContainerId", this.ContainerId);
             }
             cp.CommandArguments = dictionary;
             string str = CommandManager.GetCurrent(this.Page).AddCommand(this.ClassName, this.ViewName, this.PlaceName, cp, out isEnabled);
             dictionary.Add("CommandManagerScript", str);
             cp.CommandArguments    = dictionary;
             mcToolbarItem1.Params  = cp.ToString();
             mcToolbarItem1.Handler = "defaultToolbarOnClick";
         }
         if (mcToolbarItem1.ItemType == McToolbarItemType.Menu || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton)
         {
             if (toolBarItem is Menu)
             {
                 this.BindFromObject((toolBarItem as Menu).Items, mcToolbarItem1.Items);
             }
             else if (toolBarItem is SplitButton)
             {
                 this.BindFromObject((toolBarItem as SplitButton).Items, mcToolbarItem1.Items);
             }
         }
         if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Left))
         {
             McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter);
             mcToolbarItem2.ItemAlign = toolbarItemAlign;
             toolbarItemsCollection.Add(mcToolbarItem2);
         }
         if (isEnabled)
         {
             toolbarItemsCollection.Add(mcToolbarItem1);
         }
         if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Right))
         {
             McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter);
             mcToolbarItem2.ItemAlign = toolbarItemAlign;
             toolbarItemsCollection.Add(mcToolbarItem2);
         }
     }
 }
Ejemplo n.º 20
0
        /// <summary>
        /// Adds the acl group.
        /// </summary>
        /// <param name="group">The group.</param>
        /// <param name="treeNode">The tree node.</param>
        /// <returns></returns>
        private int AddAclGroup(AclGroup group, TreeNode treeNode)
        {
            int      childrenChecked = -1; // 1 - checked, 2 - unchecked, 0 - some checked, -1 - not set
            TreeNode groupNode       = new TreeNode();

            groupNode.Value        = GetTreeNodeUniqueId(_groupNodePrefix, group.ID);
            groupNode.Text         = UtilHelper.GetResFileString(group.Name);
            groupNode.ShowCheckBox = true;
            groupNode.ImageUrl     = Page.ResolveUrl("~/Apps/Profile/images/security_folder.png");
            groupNode.SelectAction = TreeNodeSelectAction.Expand;
            treeNode.ChildNodes.Add(groupNode);

            // add child groups
            foreach (AclGroup childGroup in group.Groups)
            {
                int result = AddAclGroup(childGroup, groupNode);
                if (result == 2 && childrenChecked == 1)
                {
                    childrenChecked = 0;
                }
                else if (result == 2 && childrenChecked == -1)
                {
                    childrenChecked = 2;
                }
                else if (result == 1 && childrenChecked == -1)
                {
                    childrenChecked = 1;
                }
                else if (result == 1 && childrenChecked == 2)
                {
                    childrenChecked = 0;
                }
                else if (result == 0)
                {
                    childrenChecked = 0;
                }
            }

            // add permissions
            foreach (AclPermission permission in group.Permissions)
            {
                TreeNode permissionNode = new TreeNode();
                permissionNode.Value        = GetTreeNodeUniqueId(_permissionNodePrefix, permission.ToString());
                permissionNode.Text         = UtilHelper.GetResFileString(permission.Name);
                permissionNode.SelectAction = TreeNodeSelectAction.None;
                permissionNode.ImageUrl     = Page.ResolveUrl("~/Apps/Profile/images/security_key.png");

                // check node if permission is set
                if (_Permission != null)
                {
                    PermissionDto.RolePermissionRow[] permissionRows = (PermissionDto.RolePermissionRow[])_Permission.RolePermission.Select(String.Format("Permission='{0}'", permission.ToString()));
                    if (permissionRows != null && permissionRows.Length > 0)
                    {
                        permissionNode.Checked = true;
                        if (childrenChecked == -1)
                        {
                            childrenChecked = 1;
                        }
                    }
                }

                if (!permissionNode.Checked && childrenChecked == 1)
                {
                    childrenChecked = 0;
                }
                if (!permissionNode.Checked && childrenChecked == -1)
                {
                    childrenChecked = 2;
                }

                groupNode.ChildNodes.Add(permissionNode);
            }

            groupNode.Checked = childrenChecked == 1;

            if (childrenChecked == 0)
            {
                groupNode.Select();
                groupNode.Expand();
            }
            else
            {
                groupNode.Collapse();
            }

            return(childrenChecked);
        }
Ejemplo n.º 21
0
        /// <summary>
        /// Handles the Load event of the Page control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param>
        protected void Page_Load(object sender, EventArgs e)
        {
            //set application name to page title
            Literal1.Text = String.Format("{0} - {1}", AppContext.Current.ApplicationName, UtilHelper.GetResFileString("{SharedStrings:Mediachase_Commerce_Manager_5_0}"));

            Response.Cache.SetNoStore();
            GetDefaultLink();
            RegisterScripts();

            ManagementHelper.RegisterBrowserStyles(this);
        }
        private int AddAclGroup(AclGroup group, TreeNode treeNode)
        {
            int      num1      = -1;
            TreeNode treeNode1 = new TreeNode();

            treeNode1.Value        = this.GetTreeNodeUniqueId("group_", group.ID);
            treeNode1.Text         = UtilHelper.GetResFileString(group.Name);
            treeNode1.ShowCheckBox = new bool?(true);
            treeNode1.ImageUrl     = this.Page.ResolveUrl("~/Apps/Customer/images/security_folder.png");
            treeNode1.SelectAction = TreeNodeSelectAction.Expand;
            treeNode.ChildNodes.Add(treeNode1);
            foreach (AclGroup group1 in (CollectionBase)group.Groups)
            {
                int num2 = this.AddAclGroup(group1, treeNode1);
                if (num2 == 2 && num1 == 1)
                {
                    num1 = 0;
                }
                else if (num2 == 2 && num1 == -1)
                {
                    num1 = 2;
                }
                else if (num2 == 1 && num1 == -1)
                {
                    num1 = 1;
                }
                else if (num2 == 1 && num1 == 2)
                {
                    num1 = 0;
                }
                else if (num2 == 0)
                {
                    num1 = 0;
                }
            }
            IEnumerator enumerator = group.Permissions.GetEnumerator();

            try
            {
                Func <SecurityPermission, bool>   func           = (Func <SecurityPermission, bool>)null;
                RoleOverviewEditTab.DisplayClass2 cDisplayClass2 = new RoleOverviewEditTab.DisplayClass2();
                while (enumerator.MoveNext())
                {
                    cDisplayClass2.permission = (AclPermission)enumerator.Current;
                    TreeNode child = new TreeNode();
                    child.Value        = this.GetTreeNodeUniqueId("permission_", cDisplayClass2.permission.ToString());
                    child.Text         = UtilHelper.GetResFileString(cDisplayClass2.permission.Name);
                    child.SelectAction = TreeNodeSelectAction.None;
                    child.ImageUrl     = this.Page.ResolveUrl("~/Apps/Customer/images/security_key.png");
                    if (this._Permissions != null)
                    {
                        IEnumerable <SecurityPermission> source = this._Permissions;
                        if (func == null)
                        {
                            // ISSUE: method pointer
                            func = new Func <SecurityPermission, bool>(cDisplayClass2.AddAclGroup);
                        }
                        Func <SecurityPermission, bool> predicate = func;
                        if (Enumerable.Count <SecurityPermission>(source, predicate) > 0)
                        {
                            child.Checked = true;
                            if (num1 == -1)
                            {
                                num1 = 1;
                            }
                        }
                    }
                    if (!child.Checked && num1 == 1)
                    {
                        num1 = 0;
                    }
                    if (!child.Checked && num1 == -1)
                    {
                        num1 = 2;
                    }
                    treeNode1.ChildNodes.Add(child);
                }
            }
            finally
            {
                IDisposable disposable = enumerator as IDisposable;
                if (disposable != null)
                {
                    disposable.Dispose();
                }
            }
            treeNode1.Checked = num1 == 1;
            if (num1 == 0)
            {
                treeNode1.Select();
                treeNode1.Expand();
            }
            else
            {
                treeNode1.Collapse();
            }
            return(num1);
        }
Ejemplo n.º 23
0
        protected void Page_Load(object sender, EventArgs e)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("ImageUrl", typeof(string)));
            DataRow         dr;
            IXPathNavigable navigable;
            // Selector: ClassName.ViewName.PlaceName.ProfileId.UserId
            Selector selector = new Selector(string.Empty, string.Empty, string.Empty, ProfileManager.GetProfileIdByUser().ToString(), Mediachase.IBN.Business.Security.UserID.ToString());

            // don't hide items for administrator
            if (Mediachase.IBN.Business.Security.IsUserInGroup(Mediachase.IBN.Business.InternalSecureGroups.Administrator))
            {
                navigable = XmlBuilder.GetCustomizationXml(null, StructureType.Navigation, selector);
            }
            else
            {
                navigable = XmlBuilder.GetXml(StructureType.Navigation, selector);
            }


            XPathNavigator tabs = navigable.CreateNavigator().SelectSingleNode("Navigation/Tabs");

            foreach (XPathNavigator tabItem in tabs.SelectChildren(string.Empty, string.Empty))
            {
                dr = dt.NewRow();
                string title = UtilHelper.GetResFileString(tabItem.GetAttribute("text", string.Empty));
                string id    = tabItem.GetAttribute("id", string.Empty);

                string enableHandler = tabItem.GetAttribute("enableHandler", string.Empty);
                if (!string.IsNullOrEmpty(enableHandler))
                {
                    ICommandEnableHandler enHandler = (ICommandEnableHandler)AssemblyUtil.LoadObject(enableHandler);
                    if (enHandler != null && !enHandler.IsEnable(sender, id))
                    {
                        continue;
                    }
                }

                string imageUrl = tabItem.GetAttribute("imageUrl", string.Empty);
                if (string.IsNullOrEmpty(imageUrl))
                {
                    imageUrl = "~/Images/ext/default/s.gif";
                }

                string type = tabItem.GetAttribute("contentType", string.Empty).ToLower();
                if (string.IsNullOrEmpty(type))
                {
                    type = "default";
                }

                string configUrl = tabItem.GetAttribute("configUrl", string.Empty);
                string checkUrl  = configUrl;
                if (checkUrl.IndexOf("?") >= 0)
                {
                    checkUrl = checkUrl.Substring(0, checkUrl.IndexOf("?"));
                }
                if (type.Equals("default") && string.IsNullOrEmpty(checkUrl))
                {
                    checkUrl  = "~/Apps/Shell/Pages/TreeSource.aspx";
                    configUrl = "~/Apps/Shell/Pages/TreeSource.aspx?tab=" + id;
                }

                if (File.Exists(Server.MapPath(checkUrl)))
                {
                    switch (type)
                    {
                    case "default":
                        ClientScript.RegisterStartupScript(this.Page, this.Page.GetType(), Guid.NewGuid().ToString("N"), string.Format("leftTemplate_AddMenuTab('{0}', '{1}', '{2}');", id, title, ResolveClientUrl(configUrl)), true);
                        break;

                    case "custom":
                        break;

                    default:
                        break;
                    }
                }

                dr["Title"]    = title;
                dr["ImageUrl"] = imageUrl;
                dt.Rows.Add(dr);
            }
            TabItems.DataSource = dt.DefaultView;
            TabItems.DataBind();

            RegisterScripts();

            //Register navigation commands
            string             profileId = ProfileManager.GetProfileIdByUser().ToString();
            string             userId    = Mediachase.IBN.Business.Security.UserID.ToString();
            IList <XmlCommand> list      = XmlCommand.GetListNavigationCommands("", "", "", profileId, userId);
            CommandManager     cm        = CommandManager.GetCurrent(this.Page);

            foreach (XmlCommand cmd in list)
            {
                cm.AddCommand("", "", "", profileId, userId, cmd.CommandName);
            }
        }
Ejemplo n.º 24
0
 public string GetLocalizedName()
 {
     return(UtilHelper.GetResFileString(this.Name));
 }
Ejemplo n.º 25
0
 public string GetLocalizedHeadingString()
 {
     return(UtilHelper.GetResFileString(this.HeadingText));
 }
Ejemplo n.º 26
0
        private void BindDataGrid(bool dataBind)
        {
            DataTable dt = new DataTable();

            dt.Columns.Add(new DataColumn("Id", typeof(string)));
            dt.Columns.Add(new DataColumn("FullId", typeof(string)));
            dt.Columns.Add(new DataColumn("Title", typeof(string)));
            dt.Columns.Add(new DataColumn("Order", typeof(string)));
            dt.Columns.Add(new DataColumn("Hidden", typeof(bool)));
            dt.Columns.Add(new DataColumn("HiddenParent", typeof(bool)));
            dt.Columns.Add(new DataColumn("HiddenLayer", typeof(string)));
            dt.Columns.Add(new DataColumn("Added", typeof(bool)));
            dt.Columns.Add(new DataColumn("AddedLayer", typeof(string)));
            dt.Columns.Add(new DataColumn("Changed", typeof(bool)));
            dt.Columns.Add(new DataColumn("ChangedLayer", typeof(string)));
            dt.Columns.Add(new DataColumn("Odd", typeof(bool)));

            bool odd = true;

            string profileString   = ProfileId.HasValue ? ProfileId.Value.ToString() : String.Empty;
            string principalString = UserId.HasValue ? UserId.Value.ToString() : String.Empty;

            if (UserId.HasValue)
            {
                profileString = ProfileManager.GetProfileIdByUser(UserId.Value).ToString();
            }

            IXPathNavigable navigable;
            Selector        selector = new Selector(string.Empty, string.Empty, string.Empty, profileString, principalString);

            using (DisableDataCacheScope scope = new DisableDataCacheScope())
            {
                navigable = Mediachase.Ibn.XmlTools.XmlBuilder.GetCustomizationXml(null,
                                                                                   Mediachase.Ibn.XmlTools.StructureType.Navigation, selector);
            }
            XPathNavigator tabsNode = navigable.CreateNavigator().SelectSingleNode("Navigation/Tabs");

            foreach (XPathNavigator subItem in tabsNode.SelectChildren("Tab", string.Empty))
            {
                bool hidden;
                bool.TryParse(subItem.GetAttribute("hidden", string.Empty), out hidden);

                // don't show items, hidden at the above layer
                string hiddenLayer = subItem.GetAttribute("hiddenLayer", string.Empty);
                if (hidden && ProfileId.HasValue && hiddenLayer == NavigationManager.CustomizationLayerGlobal)
                {
                    continue;
                }
                if (hidden && UserId.HasValue && (hiddenLayer == NavigationManager.CustomizationLayerGlobal || hiddenLayer == NavigationManager.CustomizationLayerProfile))
                {
                    continue;
                }

                string id = subItem.GetAttribute("id", string.Empty);

                DataRow dr = dt.NewRow();
                dr["Id"]     = subItem.GetAttribute("id", string.Empty);
                dr["FullId"] = id;
                dr["Title"]  = UtilHelper.GetResFileString(subItem.GetAttribute("text", string.Empty));
                dr["Order"]  = subItem.GetAttribute("order", string.Empty);

                dr["Hidden"]       = hidden;
                dr["HiddenParent"] = false;

                bool changed;
                bool.TryParse(subItem.GetAttribute("changed", string.Empty), out changed);
                dr["Changed"] = changed;
                dr["Odd"]     = odd;

                string addedString = subItem.GetAttribute("added", string.Empty);
                if (String.IsNullOrEmpty(addedString))
                {
                    dr["Added"] = false;
                }
                else
                {
                    dr["Added"] = bool.Parse(addedString);
                }

                dr["HiddenLayer"]  = subItem.GetAttribute("hiddenLayer", string.Empty);
                dr["ChangedLayer"] = subItem.GetAttribute("changedLayer", string.Empty);
                dr["AddedLayer"]   = subItem.GetAttribute("addedLayer", string.Empty);

                dt.Rows.Add(dr);

//				if (!hidden)
                ProcessChildren(dt, subItem, id, hidden, 0, odd);

                odd = !odd;
            }

            grdMain.DataSource = dt.DefaultView;

            if (dataBind)
            {
                grdMain.DataBind();
            }
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Binds the recursive.
        /// </summary>
        /// <param name="nodes">The nodes.</param>
        /// <param name="linkItem">The link item.</param>
        /// <returns></returns>
        private int BindRecursive(List <JsonTreeNode> nodes, XPathNavigator linkItem)
        {
            int retVal = 0;

            foreach (XPathNavigator subItem in linkItem.SelectChildren(string.Empty, string.Empty))
            {
                JsonTreeNode node = new JsonTreeNode();

                string text = UtilHelper.GetResFileString(subItem.GetAttribute("text", string.Empty));
                string id   = subItem.GetAttribute("id", string.Empty);

                node.text = text;
                node.id   = id;

                node.cls = "nodeCls";

                node.iconCls = "iconNodeCls";

                string iconUrl = subItem.GetAttribute("iconUrl", string.Empty);
                if (!String.IsNullOrEmpty(iconUrl))
                {
                    node.icon = ResolveClientUrl(iconUrl);
                }

                string iconCss = subItem.GetAttribute("iconCss", string.Empty);
                if (!String.IsNullOrEmpty(iconCss))
                {
                    node.iconCls = iconCss;
                }

                string command = subItem.GetAttribute("command", string.Empty);
                if (!String.IsNullOrEmpty(command))
                {
                    Dictionary <string, string> parameters = new Dictionary <string, string>();
                    parameters.Add("permissions", subItem.GetAttribute("permissions", string.Empty));

                    if (!IsEnableCommand("", "", "", command, parameters))
                    {
                        continue;
                    }

                    string cmd = CommandManager.GetCommandString(command, null);
                    cmd       = cmd.Replace("\"", "&quot;");
                    node.href = String.Format("javascript:{0}", cmd);
                }

                string expanded = subItem.GetAttribute("expanded", string.Empty);
                if (!String.IsNullOrEmpty(expanded) && expanded.ToLower().Equals("true"))
                {
                    node.expanded = true;
                }

                string type = subItem.GetAttribute("type", string.Empty);
                if (!String.IsNullOrEmpty(type))
                {
                    node.type = type;
                }

                bool   isAsyncLoad    = false;
                string treeLoader     = subItem.GetAttribute("treeLoader", string.Empty);
                string treeLoaderPath = subItem.GetAttribute("treeLoaderPath", string.Empty);
                if (!String.IsNullOrEmpty(treeLoader))
                {
                    isAsyncLoad = true;
                }
                if (!String.IsNullOrEmpty(treeLoaderPath))
                {
                    isAsyncLoad     = true;
                    node.treeLoader = ResolveClientUrl(treeLoaderPath);
                }

                if (!isAsyncLoad)
                {
                    node.children = new List <JsonTreeNode>();
                    int count = BindRecursive(node.children, subItem);
                    if (count == 0)
                    {
                        node.leaf     = true;
                        node.children = null;
                    }
                }

                nodes.Add(node);
                retVal++;
            }
            return(retVal);
        }
Ejemplo n.º 28
0
        private string GetTopMenuWelcomeText(string resourceString)
        {
            string fullName = CustomerContext.Current.CurrentContact.FullName;

            return(string.Format("{0}, {1}", (object)UtilHelper.GetResFileString(resourceString), string.IsNullOrEmpty(fullName) ? (object)SecurityContext.Current.CurrentUserName : (object)fullName));
        }
Ejemplo n.º 29
0
        private void GetToolbarItemsFromXml(XPathNavigator node, List <McToolbarItem> itemsCollection)
        {
            foreach (XPathNavigator node1 in node.SelectChildren(string.Empty, string.Empty))
            {
                McToolbarItem mcToolbarItem1 = new McToolbarItem();
                switch (node1.Name)
                {
                case "Text":
                    mcToolbarItem1.ItemType = McToolbarItemType.Text;
                    break;

                case "Splitter":
                    mcToolbarItem1.ItemType = McToolbarItemType.Splitter;
                    break;

                case "Button":
                    mcToolbarItem1.ItemType = McToolbarItemType.Button;
                    break;

                case "Menu":
                    mcToolbarItem1.ItemType = McToolbarItemType.Menu;
                    break;

                case "SplitButton":
                    mcToolbarItem1.ItemType = McToolbarItemType.SplitButton;
                    break;

                default:
                    throw new NotSupportedException(string.Format("Unknown nodeType: {0}", (object)node.Name));
                }
                string                attribute1          = node1.GetAttribute("id", string.Empty);
                string                attribute2          = node1.GetAttribute("text", string.Empty);
                string                attribute3          = node1.GetAttribute("imageUrl", string.Empty);
                string                attribute4          = node1.GetAttribute("cssClass", string.Empty);
                string                attribute5          = node1.GetAttribute("align", string.Empty);
                string                attribute6          = node1.GetAttribute("handler", string.Empty);
                string                attribute7          = node1.GetAttribute("commandName", string.Empty);
                string                attribute8          = node1.GetAttribute("itemSplitter", string.Empty);
                string                attribute9          = node1.GetAttribute("tooltip", string.Empty);
                string                attribute10         = node1.GetAttribute("permissions", string.Empty);
                McToolbarItemAlign    toolbarItemAlign    = McToolbarItemAlign.Left;
                McToolbarItemSplitter toolbarItemSplitter = McToolbarItemSplitter.None;
                if (attribute5 != string.Empty)
                {
                    try
                    {
                        toolbarItemAlign = (McToolbarItemAlign)Enum.Parse(typeof(McToolbarItemAlign), attribute5);
                    }
                    catch
                    {
                        throw;
                    }
                }
                if (attribute8 != string.Empty)
                {
                    try
                    {
                        toolbarItemSplitter = (McToolbarItemSplitter)Enum.Parse(typeof(McToolbarItemSplitter), attribute8);
                    }
                    catch
                    {
                        throw;
                    }
                }
                mcToolbarItem1.Id   = attribute1;
                mcToolbarItem1.Text = UtilHelper.GetResFileString(attribute2);
                if (attribute3 != string.Empty && (mcToolbarItem1.ItemType == McToolbarItemType.Button || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton || mcToolbarItem1.ItemType == McToolbarItemType.Menu))
                {
                    mcToolbarItem1.CssClass += "x-btn-wrap x-btn x-btn-text-icon ";
                }
                mcToolbarItem1.ImageUrl  = this.ResolveClientUrl(attribute3);
                mcToolbarItem1.CssClass += attribute4;
                mcToolbarItem1.ItemAlign = toolbarItemAlign;
                mcToolbarItem1.Handler   = attribute6;
                mcToolbarItem1.Tooltip   = UtilHelper.GetResFileString(attribute9);
                CommandParameters           cp         = new CommandParameters(attribute7);
                Dictionary <string, string> dictionary = new Dictionary <string, string>();
                dictionary.Add("GridId", this.GridId);
                dictionary.Add("GridClientId", this.GridClientId);
                dictionary.Add("permissions", attribute10);
                if (!string.IsNullOrEmpty(this.ContainerId))
                {
                    dictionary.Add("ContainerId", this.ContainerId);
                }
                cp.CommandArguments = dictionary;
                bool isEnabled = true;
                if (attribute7 != string.Empty)
                {
                    string str = CommandManager.GetCurrent(this.Page).AddCommand(this.ClassName, this.ViewName, this.PlaceName, cp, out isEnabled);
                    dictionary.Add("CommandManagerScript", str);
                    cp.CommandArguments    = dictionary;
                    mcToolbarItem1.Params  = cp.ToString();
                    mcToolbarItem1.Handler = "defaultToolbarOnClick";
                }
                if (mcToolbarItem1.ItemType == McToolbarItemType.Menu || mcToolbarItem1.ItemType == McToolbarItemType.SplitButton)
                {
                    if (node1.SelectChildren(string.Empty, string.Empty).Count > 0)
                    {
                        this.GetToolbarItemsFromXml(node1, mcToolbarItem1.Items);
                        if (mcToolbarItem1.Items.Count == 0)
                        {
                            continue;
                        }
                    }
                    else
                    {
                        continue;
                    }
                }
                if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Left))
                {
                    McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter);
                    mcToolbarItem2.ItemAlign = toolbarItemAlign;
                    itemsCollection.Add(mcToolbarItem2);
                }
                if (isEnabled)
                {
                    itemsCollection.Add(mcToolbarItem1);
                }
                if (isEnabled && (toolbarItemSplitter == McToolbarItemSplitter.Both || toolbarItemSplitter == McToolbarItemSplitter.Right))
                {
                    McToolbarItem mcToolbarItem2 = new McToolbarItem(McToolbarItemType.Splitter);
                    mcToolbarItem2.ItemAlign = toolbarItemAlign;
                    itemsCollection.Add(mcToolbarItem2);
                }
            }
        }
Ejemplo n.º 30
0
        /// <summary>
        /// Gets the toolbar items from XML.
        /// </summary>
        /// <param name="node">The node.</param>
        /// <param name="itemsCollection">The items collection.</param>
        private void GetToolbarItemsFromXml(XPathNavigator node, List <McToolbarItem> itemsCollection)
        {
            foreach (XPathNavigator toolbarItem in node.SelectChildren(string.Empty, string.Empty))
            {
                McToolbarItem item = new McToolbarItem();

                switch (toolbarItem.Name)
                {
                case "Text":
                {
                    item.ItemType = McToolbarItemType.Text;
                    break;
                }

                case "Splitter":
                {
                    item.ItemType = McToolbarItemType.Splitter;
                    break;
                }

                case "Button":
                {
                    item.ItemType = McToolbarItemType.Button;
                    break;
                }

                case "Menu":
                {
                    item.ItemType = McToolbarItemType.Menu;
                    break;
                }

                case "SplitButton":
                {
                    item.ItemType = McToolbarItemType.SplitButton;
                    break;
                }

                default:
                {
                    throw new NotSupportedException(String.Format("Unknown nodeType: {0}", node.Name));
                }
                }

                string Id           = toolbarItem.GetAttribute("id", string.Empty);
                string Text         = toolbarItem.GetAttribute("text", string.Empty);
                string ImageUrl     = toolbarItem.GetAttribute("imageUrl", string.Empty);
                string CssClass     = toolbarItem.GetAttribute("cssClass", string.Empty);
                string Align        = toolbarItem.GetAttribute("align", string.Empty);
                string Handler      = toolbarItem.GetAttribute("handler", string.Empty);
                string CommandName  = toolbarItem.GetAttribute("commandName", string.Empty);
                string ItemSplitter = toolbarItem.GetAttribute("itemSplitter", string.Empty);
                string Tooltip      = toolbarItem.GetAttribute("tooltip", string.Empty);
                string permissions  = toolbarItem.GetAttribute("permissions", string.Empty);

                McToolbarItemAlign    itemAlign    = McToolbarItemAlign.Left;
                McToolbarItemSplitter itemSplitter = McToolbarItemSplitter.None;

                #region Set enum: McToolbarItemAlign
                if (Align != string.Empty)
                {
                    try
                    {
                        itemAlign = (McToolbarItemAlign)Enum.Parse(typeof(McToolbarItemAlign), Align);
                    }
                    catch
                    {
                        throw;
                    }
                }
                #endregion

                #region Set enum: McToolbarItemSplitter
                if (ItemSplitter != string.Empty)
                {
                    try
                    {
                        itemSplitter = (McToolbarItemSplitter)Enum.Parse(typeof(McToolbarItemSplitter), ItemSplitter);
                    }
                    catch
                    {
                        throw;
                    }
                }
                #endregion

                item.Id   = Id;
                item.Text = UtilHelper.GetResFileString(Text);

                if (ImageUrl != string.Empty && (item.ItemType == McToolbarItemType.Button || item.ItemType == McToolbarItemType.SplitButton || item.ItemType == McToolbarItemType.Menu))
                {
                    item.CssClass += "x-btn-wrap x-btn x-btn-text-icon ";
                }

                item.ImageUrl  = this.ResolveClientUrl(ImageUrl);                // this.ResolveUrl dont work here
                item.CssClass += CssClass;
                item.ItemAlign = itemAlign;
                item.Handler   = Handler;
                item.Tooltip   = UtilHelper.GetResFileString(Tooltip);

                CommandParameters param = new CommandParameters(CommandName);

                Dictionary <string, string> dic = new Dictionary <string, string>();
                dic.Add("GridId", this.GridId);
                dic.Add("GridClientId", this.GridClientId);
                dic.Add("permissions", permissions);
                param.CommandArguments = dic;
                bool isEnable = true;

                if (CommandName != string.Empty)
                {
                    string commandManagerScript = CommandManager.GetCurrent(this.Page).AddCommand(this.ClassName, this.ViewName, this.PlaceName, param, out isEnable);
                    dic.Add("CommandManagerScript", commandManagerScript);

                    item.Params  = param.ToString();
                    item.Handler = defaultClientHandler;
                }

                if (item.ItemType == McToolbarItemType.Menu || item.ItemType == McToolbarItemType.SplitButton)
                {
                    GetToolbarItemsFromXml(toolbarItem, item.Items);
                }

                if (isEnable && (itemSplitter == McToolbarItemSplitter.Both || itemSplitter == McToolbarItemSplitter.Left))
                {
                    McToolbarItem splitItem = new McToolbarItem(McToolbarItemType.Splitter);
                    splitItem.ItemAlign = itemAlign;
                    itemsCollection.Add(splitItem);
                }

                if (isEnable)
                {
                    itemsCollection.Add(item);
                }

                if (isEnable && (itemSplitter == McToolbarItemSplitter.Both || itemSplitter == McToolbarItemSplitter.Right))
                {
                    McToolbarItem splitItem = new McToolbarItem(McToolbarItemType.Splitter);
                    splitItem.ItemAlign = itemAlign;
                    itemsCollection.Add(splitItem);
                }
            }
        }