public IHttpActionResult Main() { try { var request = new AuthenticatedRequest(); var dynamicInfo = DynamicInfo.GetDynamicInfo(request, request.UserInfo); var ifInfo = TranslateUtils.JsonDeserialize <DynamicInfo.IfInfo>(dynamicInfo.ElementValues); var isSuccess = false; var html = string.Empty; if (ifInfo != null) { if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsUserLoggin)) { isSuccess = request.IsUserLoggin; } else if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsAdministratorLoggin)) { isSuccess = request.IsAdminLoggin; } else if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsUserOrAdministratorLoggin)) { isSuccess = request.IsUserLoggin || request.IsAdminLoggin; } else if (StringUtils.EqualsIgnoreCase(ifInfo.Type, StlIf.TypeIsUserGroup)) { if (request.IsUserLoggin) { var group = UserGroupManager.GetUserGroupInfo(request.UserInfo.GroupId); if (StringUtils.EqualsIgnoreCase(ifInfo.Op, StlIf.OperateNotEquals)) { isSuccess = !StringUtils.EqualsIgnoreCase(group.GroupName, ifInfo.Value); } else { isSuccess = StringUtils.EqualsIgnoreCase(group.GroupName, ifInfo.Value); } } } var template = isSuccess ? dynamicInfo.SuccessTemplate : dynamicInfo.FailureTemplate; html = StlDynamic.ParseDynamicContent(dynamicInfo, template); } return(Ok(new { Value = isSuccess, Html = html })); } catch (Exception ex) { return(InternalServerError(ex)); } }
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}"" />"; }
public IHttpActionResult Submit([FromBody] UserGroupInfo itemObj) { try { var request = new AuthenticatedRequest(); if (!request.IsAdminLoggin || !request.AdminPermissionsImpl.HasSystemPermissions(ConfigManager.SettingsPermissions.User)) { return(Unauthorized()); } if (itemObj.Id == -1) { if (UserGroupManager.IsExists(itemObj.GroupName)) { return(BadRequest("保存失败,已存在相同名称的用户组!")); } var groupInfo = new UserGroupInfo { GroupName = itemObj.GroupName, AdminName = itemObj.AdminName }; DataProvider.UserGroupDao.Insert(groupInfo); request.AddAdminLog("新增用户组", $"用户组:{groupInfo.GroupName}"); } else if (itemObj.Id == 0) { ConfigManager.SystemConfigInfo.UserDefaultGroupAdminName = itemObj.AdminName; DataProvider.ConfigDao.Update(ConfigManager.Instance); UserGroupManager.ClearCache(); request.AddAdminLog("修改用户组", "用户组:默认用户组"); } else if (itemObj.Id > 0) { var groupInfo = UserGroupManager.GetUserGroupInfo(itemObj.Id); if (groupInfo.GroupName != itemObj.GroupName && UserGroupManager.IsExists(itemObj.GroupName)) { return(BadRequest("保存失败,已存在相同名称的用户组!")); } groupInfo.GroupName = itemObj.GroupName; groupInfo.AdminName = itemObj.AdminName; DataProvider.UserGroupDao.Update(groupInfo); request.AddAdminLog("修改用户组", $"用户组:{groupInfo.GroupName}"); } return(Ok(new { Value = UserGroupManager.GetUserGroupInfoList() })); } catch (Exception ex) { return(InternalServerError(ex)); } }