예제 #1
0
        private void LoadSidebar()
        {
            radmMenu.Text = "";
            //GetPath();
            cmd      = ConvertUtility.ToString(Request.QueryString["cmd"]);
            portalid = ConvertUtility.ToInt32(Request.QueryString["portalid"]);
            DataTable dtCommands = null;

            if (!CurrentUser.IsSuperAdmin)
            {
                dtCommands = CommandController.GetCommandsForUserByPortalID(CurrentUser.UserID, portalid);
            }
            else
            {
                dtCommands = CommandController.GetCommands();
            }

            DataRow[] drRoots = dtCommands.Select("CommandParentID = 0");
            sb.Append("<ul class=\"nav navbar-nav\">");
            foreach (DataRow row in drRoots)
            {
                string name = "";
                string url  = "";
                name = row["CommandName"].ToString();
                //_item.Value = row["CommandID"].ToString();

                int       curItem      = ConvertUtility.ToInt32(row["CommandID"].ToString());
                DataRow[] _lstCommands = dtCommands.Select("CommandParentID = " + curItem + " AND CommandVisible = 1");

                if (!string.IsNullOrEmpty(row["CommandUrl"].ToString().Trim()))
                {
                    url = row["CommandUrl"].ToString();
                }
                else if (!string.IsNullOrEmpty(row["CommandKey"].ToString().Trim()))
                {
                    url = AppEnv.AdminUrlParams(row["CommandKey"].ToString()) + row["CommandParams"].ToString();
                }
                if (ConvertUtility.ToBoolean(row["CommandVisible"]) == false || ConvertUtility.ToBoolean(row["CommandEnable"]) == false)
                {
                    continue;
                }

                if (_lstCommands.Length > 0)
                {
                    sb.Append("<li>");
                    sb.Append(string.Format(fmAd, url, name));
                    sb.Append("<ul class=\"dropdown-menu\">");
                    LoadSidebarItems(ConvertUtility.ToInt32(row["CommandID"].ToString()), dtCommands);
                    sb.Append("</ul>");
                    sb.Append("</li>");
                }
                else
                {
                    sb.Append(string.Format(fmUi, url, name));
                }
            }
            sb.Append("</ul>");

            radmMenu.Text = sb.ToString();
        }
예제 #2
0
        protected override void OnPreRender(EventArgs e)
        {
            base.OnPreRender(e);
            //Fill commands
            lstCommands.Items.Clear();

            if (!CurrentUser.IsSuperAdmin)
            {
                CommandController.FillToListBox(lstCommands.Items, CommandController.GetCommandsForUserByPortalID(CurrentUser.UserID, ConvertUtility.ToInt32(dropPortal.SelectedValue)), 0, CurrentUser.IsSuperAdmin);
            }
            else
            {
                CommandController.FillToListBox(lstCommands.Items, CommandController.GetCommands(), 0, CurrentUser.IsSuperAdmin);
            }

            DataTable dtUserCommands = CommandController.GetCommandsForUserNotGroup(userId, ConvertUtility.ToInt32(dropPortal.SelectedValue));

            foreach (DataRow row in dtUserCommands.Rows)
            {
                if (lstCommands.Items.FindByValue(row["CommandID"].ToString()) != null)
                {
                    lstCommands.Items.FindByValue(row["CommandID"].ToString()).Selected = true;
                }
            }

            DataTable dtReturnCommand = new DataTable();

            dtReturnCommand.Columns.Add("CommandID", typeof(String));
            dtReturnCommand.Columns.Add("PortalID", typeof(String));
            dtReturnCommand.Columns.Add("UserID", typeof(String));
            dtReturnCommand.Columns.Add("CommandParentID", typeof(String));
            dtReturnCommand.Columns.Add("CommandName", typeof(String));
            dtReturnCommand.Columns.Add("Level", typeof(String));
            dtReturnCommand.Columns.Add("Role_View", typeof(String));
            dtReturnCommand.Columns.Add("Role_Add", typeof(String));
            dtReturnCommand.Columns.Add("Role_Update", typeof(String));
            dtReturnCommand.Columns.Add("Role_Delete", typeof(String));
            dtReturnCommand.Columns.Add("UseForWeb", typeof(String));
            dtReturnCommand.Columns.Add("UseForWap", typeof(String));
            dtReturnCommand.Columns.Add("UseForSMS", typeof(String));
            dtReturnCommand.Columns.Add("UseForXzone", typeof(String));

            dtCommand = dtUserCommands;
            DataTable _dtReturnCommand = UserController.BuildRecursiveUserPermission(dtUserCommands, dtReturnCommand, userId, ConvertUtility.ToInt32(dropPortal.SelectedValue));

            dgrUserRole.DataSource = _dtReturnCommand;
            dgrUserRole.DataBind();
        }
예제 #3
0
        public void BindData()
        {
            int       roleId          = ConvertUtility.ToInt32(dropRole.SelectedValue);
            DataTable dtRoleCommands  = CommandController.GetCommandsForRoleByPortalID(roleId, ConvertUtility.ToInt32(dropPortal.SelectedValue));
            DataTable dtReturnCommand = new DataTable();

            dtReturnCommand.Columns.Add("CommandID", typeof(String));
            dtReturnCommand.Columns.Add("PortalID", typeof(String));
            dtReturnCommand.Columns.Add("RoleID", typeof(String));
            dtReturnCommand.Columns.Add("CommandParentID", typeof(String));
            dtReturnCommand.Columns.Add("CommandName", typeof(String));
            dtReturnCommand.Columns.Add("Level", typeof(String));
            dtReturnCommand.Columns.Add("Role_View", typeof(String));
            dtReturnCommand.Columns.Add("Role_Add", typeof(String));
            dtReturnCommand.Columns.Add("Role_Update", typeof(String));
            dtReturnCommand.Columns.Add("Role_Delete", typeof(String));
            //dtReturnCommand.Columns.Add("UseForWeb", typeof(String));
            //dtReturnCommand.Columns.Add("UseForWap", typeof(String));
            //dtReturnCommand.Columns.Add("UseForSMS", typeof(String));
            //dtReturnCommand.Columns.Add("UseForXzone", typeof(String));

            dtCommand = dtRoleCommands;
            DataTable _dtReturnCommand = RoleController.BuildRecursiveRolePermission(dtRoleCommands, dtReturnCommand, roleId, ConvertUtility.ToInt32(dropPortal.SelectedValue));

            dgrRolePermission.DataSource = _dtReturnCommand;
            dgrRolePermission.DataBind();

            //Fill commands
            lstCommands.Items.Clear();
            if (!CurrentUser.IsSuperAdmin)
            {
                CommandController.FillToListBox(lstCommands.Items, CommandController.GetCommandsForUserByPortalID(CurrentUser.UserID, ConvertUtility.ToInt32(dropPortal.SelectedValue)), 0, CurrentUser.IsSuperAdmin);
            }
            else
            {
                CommandController.FillToListBox(lstCommands.Items, CommandController.GetCommands(), 0, CurrentUser.IsSuperAdmin);
            }
            CommandSelected();
        }
예제 #4
0
        private void LoadSidebar()
        {
            radmMenu.Text = "";
            //GetPath();
            try
            {
                cmd = ConvertUtility.ToString(Request.QueryString["cmd"]);
            }
            catch
            {
                cmd = "";
            }
            portalid = ConvertUtility.ToInt32(Request.QueryString["portalid"]);
            DataTable dtCommands = null;

            if (!CurrentUser.IsSuperAdmin)
            {
                dtCommands = CommandController.GetCommandsForUserByPortalID(CurrentUser.UserID, portalid);
            }
            else
            {
                dtCommands = CommandController.GetCommands();
            }


            if (cmd != "")
            {
                DataRow[] _lstCommands = dtCommands.Select("CommandKey = '" + cmd + "' AND CommandVisible = 1");
                foreach (DataRow row in _lstCommands)
                {
                    listCmd.Add(row["CommandID"].ToString());
                    if (row["CommandParentID"].ToString() != "0")
                    {
                        LoadParentCommand(ConvertUtility.ToInt32(row["CommandParentID"].ToString()), dtCommands, ref listCmd);
                    }
                    break;
                }
            }

            DataRow[] drRoots = dtCommands.Select("CommandParentID = 0");
            int       _count  = 0;

            if (ConvertUtility.ToString(Request.QueryString["cmd"]) == "")
            {
                sb.Append("<li class=\"start active\"><a href=\"/\"><i class=\"icon-home\"></i><span class=\"title\">Home</span><span class=\"selected\"></span></a></li>");
            }
            else
            {
                sb.Append("<li><a href=\"/\"><i class=\"icon-home\"></i><span class=\"title\">Home</span><span class=\"selected\"></span></a></li>");
            }

            foreach (DataRow row in drRoots)
            {
                string name = "";
                string url  = "";
                name = row["CommandName"].ToString();
                //_item.Value = row["CommandID"].ToString();

                int       curItem      = ConvertUtility.ToInt32(row["CommandID"].ToString());
                DataRow[] _lstCommands = dtCommands.Select("CommandParentID = " + curItem + " AND CommandVisible = 1");

                if (!string.IsNullOrEmpty(row["CommandUrl"].ToString().Trim()))
                {
                    url = row["CommandUrl"].ToString();
                }
                else if (!string.IsNullOrEmpty(row["CommandKey"].ToString().Trim()))
                {
                    url = AppEnv.AdminUrlParams(row["CommandKey"].ToString()) + row["CommandParams"].ToString();
                }
                if (ConvertUtility.ToBoolean(row["CommandVisible"]) == false || ConvertUtility.ToBoolean(row["CommandEnable"]) == false)
                {
                    continue;
                }
                if (listCmd.Contains(row["CommandID"].ToString()))
                {
                    if (_count == 0)
                    {
                        sb.Append("<li class=\"start active\">");
                    }
                    else
                    {
                        sb.Append("<li class=\"active\">");
                    }
                }
                else
                {
                    if (_count == 0)
                    {
                        sb.Append("<li class=\"\">");
                    }
                    else
                    {
                        sb.Append("<li>");
                    }
                }

                if (_lstCommands.Length > 0)
                {
                    if (_count == 0)
                    {
                        sb.Append(string.Format(fmAu, url, name, "icon-gift"));
                    }
                    else
                    {
                        sb.Append(string.Format(fmAu, url, name, "icon-gift"));
                    }
                    sb.Append("<ul class=\"sub-menu\">");
                    LoadSidebarItems(ConvertUtility.ToInt32(row["CommandID"].ToString()), dtCommands);
                    sb.Append("</ul>");
                }
                else
                {
                    if (_count == 0)
                    {
                        sb.Append(string.Format(fmAd, url, name, "icon-home"));
                    }
                    else
                    {
                        sb.Append(string.Format(fmAd, url, name, "icon-gift"));
                    }
                }
                sb.Append("</li>");
                _count++;
            }
            radmMenu.Text = sb.ToString();
        }