public 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 ltlEmail = (Literal)e.Item.FindControl("ltlEmail"); var ltlMobile = (Literal)e.Item.FindControl("ltlMobile"); var ltlLastActivityDate = (Literal)e.Item.FindControl("ltlLastActivityDate"); var ltlLoginCount = (Literal)e.Item.FindControl("ltlLoginCount"); var ltlCreationDate = (Literal)e.Item.FindControl("ltlCreationDate"); var ltlWritingCount = (Literal)e.Item.FindControl("ltlWritingCount"); var ltlSelect = (Literal)e.Item.FindControl("ltlSelect"); var hlChangePassword = (HyperLink)e.Item.FindControl("hlChangePassword"); var hlEditLink = (HyperLink)e.Item.FindControl("hlEditLink"); ltlUserName.Text = GetUserNameHtml(userInfo); ltlDisplayName.Text = userInfo.DisplayName; ltlEmail.Text = userInfo.Email; ltlMobile.Text = userInfo.Mobile; ltlLastActivityDate.Text = DateUtils.GetDateAndTimeString(userInfo.LastActivityDate); ltlLoginCount.Text = userInfo.CountOfLogin.ToString(); ltlCreationDate.Text = DateUtils.GetDateAndTimeString(userInfo.CreateDate); hlEditLink.NavigateUrl = PageUserAdd.GetRedirectUrlToEdit(userInfo.Id, GetRedirectUrl()); hlChangePassword.Attributes.Add("onclick", ModalUserPassword.GetOpenWindowString(userInfo.UserName)); ltlSelect.Text = $@"<input type=""checkbox"" name=""UserIDCollection"" value=""{userInfo.Id}"" />"; ltlWritingCount.Text = userInfo.CountOfWriting.ToString(); }
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}"" />"; }