public void LogOn() { if (HttpContext.Current == null) { return; } var identity = (FormsIdentity)HttpContext.Current.User.Identity; var id = _cookieParser.GetUserId(identity); var role = _cookieParser.GetUserRoleName(identity); var connection = Context.ConnectionId; var userInfo = new UserInfo { Id = id, Role = role, Connection = connection }; IdDictionary[id] = userInfo; ConnectionDictionary[connection] = userInfo; if (role == PrompterRoleName) { PrompterStatus.ChangeStatus(id, On); } }
private void SaveLog(WebContexts webContexts) { if (webContexts == null) { throw new ArgumentNullException("webContexts"); } if (!_userActivityLoggingState.IsUserActivityActivated) { return; } if (_desctiption == null) { _desctiption = _descriptionGetter.GetDefaultDescription(webContexts); } var identity = (FormsIdentity)webContexts.CurrentHttpContext.User.Identity; var userId = _coockieParser.GetUserId(identity); var userRoleName = _coockieParser.GetUserRoleName(identity); var userLogin = _coockieParser.GetUserLogin(identity); _logService.SaveActivityAsync(new UserActivity { Date = DateTime.Now, Description = _desctiption, EntityState = EntityState.Added, UserId = userId, UserName = userLogin, UserRoleName = userRoleName }); }