/// <summary> /// 按用户名登录 /// </summary> /// <param name="userInfo">用户</param> /// <param name="userName">用户名</param> /// <param name="returnStatusCode">返回状态码</param> /// <param name="returnStatusMessage">返回状消息</param> /// <returns>用户实体</returns> public BaseUserInfo LogOnByUserName(BaseUserInfo userInfo, string userName, out string returnStatusCode, out string returnStatusMessage) { // 写入调试信息 #if (DEBUG) int milliStart = BaseBusinessLogic.StartDebug(userInfo, MethodBase.GetCurrentMethod()); #endif // 加强安全验证防止未授权匿名调用 #if (!DEBUG) BaseSystemInfo.IsAuthorized(userInfo); #endif BaseUserInfo returnUserInfo = null; returnStatusCode = string.Empty; returnStatusMessage = string.Empty; using (IDbHelper dbHelper = DbHelperFactory.GetHelper(BaseSystemInfo.UserCenterDbType)) { try { dbHelper.Open(UserCenterDbConnection); BaseUserManager userManager = new BaseUserManager(dbHelper, userInfo); // 先侦测是否在线 userManager.CheckOnLine(); // 再进行登录 returnUserInfo = userManager.LogOnByUserName(userName, userInfo.IPAddress, userInfo.MACAddress); returnStatusCode = userManager.ReturnStatusCode; returnStatusMessage = userManager.GetStateMessage(); // 登录时会自动记录进行日志记录,所以不需要进行重复日志记录 // BaseLogManager.Instance.Add(dbHelper, userInfo, this.serviceName, MethodBase.GetCurrentMethod()); } catch (Exception ex) { BaseExceptionManager.LogException(dbHelper, userInfo, ex); throw ex; } finally { dbHelper.Close(); } } // 写入调试信息 #if (DEBUG) BaseBusinessLogic.EndDebug(MethodBase.GetCurrentMethod(), milliStart); #endif return returnUserInfo; }