Esempio n. 1
0
        private void BindAccount()
        {
            // load user
            UserInfo user = UsersHelper.GetUser(PanelSecurity.SelectedUserId);

            if (user != null)
            {
                imgAdmin.Visible    = (user.Role == UserRole.Administrator);
                imgReseller.Visible = (user.Role == UserRole.Reseller);
                imgUser.Visible     = (user.Role == UserRole.User);

                // bind account details
                litUsername.Text     = user.Username;
                litFullName.Text     = Utils.EllipsisString(user.FirstName + " " + user.LastName, 25);
                litRole.Text         = PanelFormatter.GetUserRoleName(user.RoleId);
                litCreated.Text      = user.Created.ToString();
                litUpdated.Text      = user.Changed.ToString();
                lnkEmail.Text        = Utils.EllipsisString(user.Email, 25);
                lnkEmail.NavigateUrl = "mailto:" + user.Email;

                // load owner account
                //UserInfo owner = UsersHelper.GetUser(user.OwnerId);
                //if(owner != null)
                //{
                //    litReseller.Text = owner.Username;
                //}


                // bind account status
                UserStatus status = user.Status;
                litStatus.Text = PanelFormatter.GetAccountStatusName((int)status);

                cmdActive.Visible  = (status != UserStatus.Active);
                cmdSuspend.Visible = (status == UserStatus.Active);
                cmdCancel.Visible  = (status != UserStatus.Cancelled);

                StatusBlock.Visible = (PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId);



                // links
                lnkSummaryLetter.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "summary_letter");
                lnkSummaryLetter.Visible     = (PanelSecurity.SelectedUser.Role != UserRole.Administrator);

                lnkEditAccountDetails.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "edit_details");

                lnkChangePassword.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "change_password");
                lnkChangePassword.Visible     = !((PanelSecurity.SelectedUserId == PanelSecurity.EffectiveUserId) && PanelSecurity.LoggedUser.IsPeer);

                lnkDelete.NavigateUrl = EditUrl("UserID", PanelSecurity.SelectedUserId.ToString(), "delete");
                lnkDelete.Visible     = (PanelSecurity.SelectedUserId != PanelSecurity.EffectiveUserId);
            }
        }
Esempio n. 2
0
        public static DataSet GetUsers(int ownerId, bool recursive)
        {
            DataSet   dsUsers = ES.Services.Users.GetRawUsers(ownerId, recursive);
            DataTable dtUsers = dsUsers.Tables[0];

            // add "RoleName", "StatusName" columns
            dtUsers.Columns.Add("RoleName", typeof(string));
            dtUsers.Columns.Add("StatusName", typeof(string));
            foreach (DataRow dr in dtUsers.Rows)
            {
                dr["RoleName"]   = PanelFormatter.GetUserRoleName((int)dr["RoleID"]);
                dr["StatusName"] = PanelFormatter.GetAccountStatusName((int)dr["StatusID"]);
            }

            return(dsUsers);
        }