コード例 #1
0
ファイル: PageUser.cs プロジェクト: zxbe/cms
        private string GetUserNameHtml(UserInfo userInfo)
        {
            var showPopWinString = ModalUserView.GetOpenWindowString(userInfo.UserName);
            var state            = string.Empty;

            if (userInfo.IsLockedOut)
            {
                state = @"<span style=""color:red;"">[已被锁定]</span>";
            }
            else if (ConfigManager.SystemConfigInfo.IsUserLockLogin &&
                     ConfigManager.SystemConfigInfo.UserLockLoginCount <= userInfo.CountOfFailedLogin)
            {
                if (_lockType == EUserLockType.Forever)
                {
                    state = @"<span style=""color:red;"">[已被锁定]</span>";
                }
                else
                {
                    var ts    = new TimeSpan(DateTime.Now.Ticks - userInfo.LastActivityDate.Ticks);
                    var hours = Convert.ToInt32(ConfigManager.SystemConfigInfo.UserLockLoginHours - ts.TotalHours);
                    if (hours > 0)
                    {
                        state = $@"<span style=""color:red;"">[错误登录次数过多,已被锁定{hours}小时]</span>";
                    }
                }
            }
            return($@"<a href=""javascript:;"" onclick=""{showPopWinString}"">{userInfo.UserName}</a> {state}");
        }
コード例 #2
0
        private void RptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            var userInfo = new UserInfo(e.Item.DataItem);

            var ltlUserName    = (Literal)e.Item.FindControl("ltlUserName");
            var ltlDisplayName = (Literal)e.Item.FindControl("ltlDisplayName");
            var ltlCreateDate  = (Literal)e.Item.FindControl("ltlCreateDate");
            var ltlSelect      = (Literal)e.Item.FindControl("ltlSelect");
            var hlEditLink     = (HyperLink)e.Item.FindControl("hlEditLink");

            var state = string.Empty;

            if (userInfo.IsLockedOut)
            {
                state = @"<span style=""color:red;"">[已被锁定]</span>";
            }
            ltlUserName.Text = $@"<a href=""javascript:;"" onclick=""{ModalUserView.GetOpenWindowString(userInfo.UserName)}"">{userInfo.UserName}</a>{state}";

            ltlDisplayName.Text = userInfo.DisplayName;

            ltlCreateDate.Text = DateUtils.GetDateAndTimeString(userInfo.CreateDate);

            var userAddUrl = PageUserAdd.GetRedirectUrlToEdit(userInfo.Id, GetRedirectUrl());

            hlEditLink.NavigateUrl = userAddUrl;

            ltlSelect.Text = $@"<input type=""checkbox"" name=""UserIDCollection"" value=""{userInfo.Id}"" />";
        }
コード例 #3
0
        private void rptContents_ItemDataBound(object sender, RepeaterItemEventArgs e)
        {
            if (e.Item.ItemType != ListItemType.Item && e.Item.ItemType != ListItemType.AlternatingItem)
            {
                return;
            }

            if (e.Item.DataItem == null)
            {
                return;
            }

            var id                 = SqlUtils.EvalInt(e.Item.DataItem, nameof(UserInfo.Id));
            var userName           = SqlUtils.EvalString(e.Item.DataItem, nameof(UserInfo.UserName));
            var createDate         = SqlUtils.EvalDateTime(e.Item.DataItem, nameof(UserInfo.CreateDate));
            var lastActivityDate   = SqlUtils.EvalDateTime(e.Item.DataItem, nameof(UserInfo.LastActivityDate));
            var countOfLogin       = SqlUtils.EvalInt(e.Item.DataItem, nameof(UserInfo.CountOfLogin));
            var countOfFailedLogin = SqlUtils.EvalInt(e.Item.DataItem, nameof(UserInfo.CountOfFailedLogin));
            var groupId            = SqlUtils.EvalInt(e.Item.DataItem, nameof(UserInfo.GroupId));
            var isChecked          = SqlUtils.EvalBool(e.Item.DataItem, nameof(UserInfo.IsChecked));
            var isLockedOut        = SqlUtils.EvalBool(e.Item.DataItem, nameof(UserInfo.IsLockedOut));
            var displayName        = SqlUtils.EvalString(e.Item.DataItem, nameof(UserInfo.DisplayName));
            var email              = SqlUtils.EvalString(e.Item.DataItem, nameof(UserInfo.Email));
            var mobile             = SqlUtils.EvalString(e.Item.DataItem, nameof(UserInfo.Mobile));

            var ltlUserName      = (Literal)e.Item.FindControl("ltlUserName");
            var ltlEmail         = (Literal)e.Item.FindControl("ltlEmail");
            var ltlMobile        = (Literal)e.Item.FindControl("ltlMobile");
            var ltlGroupName     = (Literal)e.Item.FindControl("ltlGroupName");
            var ltlLoginCount    = (Literal)e.Item.FindControl("ltlLoginCount");
            var ltlCreationDate  = (Literal)e.Item.FindControl("ltlCreationDate");
            var ltlSelect        = (Literal)e.Item.FindControl("ltlSelect");
            var hlChangePassword = (HyperLink)e.Item.FindControl("hlChangePassword");
            var hlEditLink       = (HyperLink)e.Item.FindControl("hlEditLink");

            var showPopWinString = ModalUserView.GetOpenWindowString(userName);
            var state            = isChecked ? string.Empty : @"<span style=""color:red;"">[待审核]</span>";

            if (isLockedOut)
            {
                state += @"<span style=""color:red;"">[已锁定]</span>";
            }
            else if (ConfigManager.SystemConfigInfo.IsUserLockLogin &&
                     ConfigManager.SystemConfigInfo.UserLockLoginCount <= countOfFailedLogin)
            {
                if (_lockType == EUserLockType.Forever)
                {
                    state += @"<span style=""color:red;"">[已锁定]</span>";
                }
                else
                {
                    var ts    = new TimeSpan(DateTime.Now.Ticks - lastActivityDate.Ticks);
                    var hours = Convert.ToInt32(ConfigManager.SystemConfigInfo.UserLockLoginHours - ts.TotalHours);
                    if (hours > 0)
                    {
                        state += $@"<span style=""color:red;"">[已锁定{hours}小时]</span>";
                    }
                }
            }

            ltlUserName.Text = $@"<a href=""javascript:;"" onclick=""{showPopWinString}"">{userName}</a> {state}";

            if (!string.IsNullOrEmpty(displayName))
            {
                ltlUserName.Text += $"({displayName})";
            }
            ltlEmail.Text        = email;
            ltlMobile.Text       = mobile;
            ltlGroupName.Text    = UserGroupManager.GetUserGroupInfo(groupId).GroupName;
            ltlLoginCount.Text   = countOfLogin.ToString();
            ltlCreationDate.Text = DateUtils.GetDateAndTimeString(createDate);

            hlEditLink.NavigateUrl = PageUserAdd.GetRedirectUrlToEdit(id, GetRedirectUrl());
            hlChangePassword.Attributes.Add("onclick", ModalUserPassword.GetOpenWindowString(userName));
            ltlSelect.Text = $@"<input type=""checkbox"" name=""UserIDCollection"" value=""{id}"" />";
        }