Esempio n. 1
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var userId       = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.Id));
            var userName     = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.UserName));
            var displayName  = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.DisplayName));
            var mobile       = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.Mobile));
            var avatarUrl    = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.AvatarUrl));
            var departmentId = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.DepartmentId));
            var areaId       = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.AreaId));

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = userName;
            }
            var countOfFailedLogin = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.CountOfFailedLogin));
            var countOfLogin       = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.CountOfLogin));
            var isLockedOut        = SqlUtils.EvalBool(e.Item.DataItem, nameof(AdministratorInfo.IsLockedOut));
            var lastActivityDate   = SqlUtils.EvalDateTime(e.Item.DataItem, nameof(AdministratorInfo.LastActivityDate));

            var ltlAvatar           = (Literal)e.Item.FindControl("ltlAvatar");
            var ltlUserName         = (Literal)e.Item.FindControl("ltlUserName");
            var ltlDisplayName      = (Literal)e.Item.FindControl("ltlDisplayName");
            var ltlMobile           = (Literal)e.Item.FindControl("ltlMobile");
            var ltlDepartment       = (Literal)e.Item.FindControl("ltlDepartment");
            var ltlArea             = (Literal)e.Item.FindControl("ltlArea");
            var ltlLastActivityDate = (Literal)e.Item.FindControl("ltlLastActivityDate");
            var ltlCountOfLogin     = (Literal)e.Item.FindControl("ltlCountOfLogin");
            var ltlRoles            = (Literal)e.Item.FindControl("ltlRoles");
            var ltlActions          = (Literal)e.Item.FindControl("ltlActions");
            var ltlSelect           = (Literal)e.Item.FindControl("ltlSelect");

            ltlAvatar.Text      = $@"<img src=""{(!string.IsNullOrEmpty(avatarUrl) ? avatarUrl : "../assets/images/default_avatar.png")}"" class=""rounded-circle"" style=""height: 36px; width: 36px;""/>";
            ltlUserName.Text    = GetUserNameHtml(userId, userName, countOfFailedLogin, isLockedOut, lastActivityDate);
            ltlDisplayName.Text = displayName;
            ltlMobile.Text      = mobile;
            ltlDepartment.Text  = DepartmentManager.GetDepartmentName(departmentId);
            ltlArea.Text        = AreaManager.GetAreaName(areaId);

            ltlLastActivityDate.Text = GetDateTime(lastActivityDate);
            ltlCountOfLogin.Text     = countOfLogin.ToString();
            ltlRoles.Text            = AdminManager.GetRolesHtml(userName);

            if (AuthRequest.AdminName != userName)
            {
                ltlActions.Text = ConfigHelper.GetConfigBool("IsSso") ? $@"
<a class=""m-r-5"" href=""javascript:;"" onclick=""{ModalPermissionsSet.GetOpenWindowString(userName)}"">权限设置</a>
" : $@"
<a class=""m-r-5"" href=""adminProfile.cshtml?pageType=admin&userId={userId}"">修改资料</a>
<a class=""m-r-5"" href=""adminPassword.cshtml?pageType=admin&userId={userId}"">更改密码</a>
<a class=""m-r-5"" href=""javascript:;"" onclick=""{ModalPermissionsSet.GetOpenWindowString(userName)}"">权限设置</a>
";

                ltlSelect.Text = $@"<input type=""checkbox"" name=""UserNameCollection"" value=""{userName}"" />";
            }
        }
Esempio n. 2
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var userName     = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.UserName));
            var displayName  = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.DisplayName));
            var mobile       = SqlUtils.EvalString(e.Item.DataItem, nameof(AdministratorInfo.Mobile));
            var departmentId = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.DepartmentId));
            var areaId       = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.AreaId));

            if (string.IsNullOrEmpty(displayName))
            {
                displayName = userName;
            }
            var countOfFailedLogin = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.CountOfFailedLogin));
            var countOfLogin       = SqlUtils.EvalInt(e.Item.DataItem, nameof(AdministratorInfo.CountOfLogin));
            var isLockedOut        = SqlUtils.EvalBool(e.Item.DataItem, nameof(AdministratorInfo.IsLockedOut));
            var lastActivityDate   = SqlUtils.EvalDateTime(e.Item.DataItem, nameof(AdministratorInfo.LastActivityDate));

            var ltlUserName         = (Literal)e.Item.FindControl("ltlUserName");
            var ltlDisplayName      = (Literal)e.Item.FindControl("ltlDisplayName");
            var ltlMobile           = (Literal)e.Item.FindControl("ltlMobile");
            var ltlDepartment       = (Literal)e.Item.FindControl("ltlDepartment");
            var ltlArea             = (Literal)e.Item.FindControl("ltlArea");
            var ltlLastActivityDate = (Literal)e.Item.FindControl("ltlLastActivityDate");
            var ltlCountOfLogin     = (Literal)e.Item.FindControl("ltlCountOfLogin");
            var ltlRoles            = (Literal)e.Item.FindControl("ltlRoles");
            var ltlEdit             = (Literal)e.Item.FindControl("ltlEdit");
            var hlChangePassword    = (HyperLink)e.Item.FindControl("hlChangePassword");
            var ltlRole             = (Literal)e.Item.FindControl("ltlRole");
            var ltlSelect           = (Literal)e.Item.FindControl("ltlSelect");

            ltlUserName.Text    = GetUserNameHtml(userName, countOfFailedLogin, isLockedOut, lastActivityDate);
            ltlDisplayName.Text = displayName;
            ltlMobile.Text      = mobile;
            ltlDepartment.Text  = DepartmentManager.GetDepartmentName(departmentId);
            ltlArea.Text        = AreaManager.GetAreaName(areaId);

            ltlLastActivityDate.Text = GetDateTime(lastActivityDate);
            ltlCountOfLogin.Text     = countOfLogin.ToString();
            ltlRoles.Text            = AdminManager.GetRolesHtml(userName);

            var urlEdit = PageAdministratorAdd.GetRedirectUrlToEdit(departmentId, userName);

            ltlEdit.Text = $@"<a href=""{urlEdit}"">修改属性</a>";
            hlChangePassword.Attributes.Add("onclick", ModalAdminPassword.GetOpenWindowString(userName));

            if (AuthRequest.AdminName != userName)
            {
                var openWindowString = ModalPermissionsSet.GetOpenWindowString(userName);
                ltlRole.Text   = $@"<a href=""javascript:;"" onclick=""{openWindowString}"">权限设置</a>";
                ltlSelect.Text = $@"<input type=""checkbox"" name=""UserNameCollection"" value=""{userName}"" />";
            }
        }