/// <summary> /// 命令执行 /// </summary> /// <param name="context"></param> public override void Execute(DataContext context) { int userId = context.UserId; byte[] cmdData = context.CmdData; if (cmdData.Length == 4) { userId = BitConverter.ToInt32(cmdData.Reverse(), 0); } if (Compiled.Debug) { cmdData.Debug("=== User.QueryUserBase 上行数据==="); userId.Debug("=== User.QueryUserBase 上行数据==="); } UserCacheInfo userCache = UserBiz.ReadUserCacheInfo(userId); if (null != userCache) { context.Flush <UserBase>(userCache.ToUserBase()); } else { context.Flush(RespondCode.DataInvalid); } }
/// <summary> /// 提取联系人内容 /// </summary> /// <param name="node"></param> /// <returns></returns> private static ContactContent GetContactContent(this XmlNode node) { ContactContent content = new ContactContent { ShowText = node.InnerText.Trim() }; string user = node.Attributes["User"] == null ? "0" : node.Attributes["User"].Value; int userId = 0; if (int.TryParse(user, out userId) && userId > 0) { UserCacheInfo userCache = UserBiz.ReadUserCacheInfo(userId); if (userCache != null) { content.UserData = userCache.ToUserBase(); } } return(content); }
/// <summary> /// 输出登录结果 /// </summary> /// <param name="context">当前请求上下文应答实例</param> /// <param name="uVaildInfo">用户验证信息</param> internal static void FlushResult(DataContext context, UserVaildInfo uVaildInfo) { UserCacheInfo userCacheInfo = UserBiz.ReadUserCacheInfoFromDb(uVaildInfo.UserId); AuthResult authResult = new AuthResult { UserId = uVaildInfo.UserId, DeviceChanged = context.DeviceId == uVaildInfo.LastLoginDeviceId, SessionId = uVaildInfo.UserId.GetSessionId(), UserBase = userCacheInfo.ToUserBase() }; //缓存用户会话状态 authResult.SessionId.SetSession(uVaildInfo.UserId, ExpiredConfigs.GetSessionExpired()); //缓存用户信息 UserBiz.SetUserCacheInfo(uVaildInfo.UserId, userCacheInfo); //用户登录事件 SignInEvents(authResult, uVaildInfo); //输出请求响应 context.Flush <AuthResult>(authResult); }