Exemplo n.º 1
0
        private void AsyncLoginCompletedCallback(ILoginProvider provider, LoginInfo loginInfo)
        {
            provider.Completed -= AsyncLoginCompletedCallback;
            bool success = false;

            switch (loginInfo.Status)
            {
            case LoginStatus.None:
                break;

            case LoginStatus.ExceedMaxRetryCount:
                var loginId  = loginInfo.Parameter.LoginId;
                var password = loginInfo.Parameter.Password;
                var ip       = loginInfo.Parameter.Request.ClientInfo.RemoteIp;
                _Logger.WarnFormat("{0} login failed: exceed max login retry times", loginId);
                AuditHelper.AddIllegalLogin(AppType.TradingConsole, loginId, password, ip);
                Application.Default.TradingConsoleServer.SaveLoginFail(loginId, password, ip);
                break;

            case LoginStatus.LoginIdIsEmpty:
                _Logger.Warn("LoginId is empty");
                break;

            case LoginStatus.ParticipantServiceLoginFailed:
                break;

            case LoginStatus.UserIdIsEmpty:
                _Logger.WarnFormat("{0} is not a valid user", loginInfo.Parameter.LoginId);
                break;

            case LoginStatus.CheckPermissionFailed:
                break;

            case LoginStatus.NotAuthrized:
                _Logger.WarnFormat("{0} doesn't have the right to login trader", loginInfo.Parameter.LoginId);
                break;

            case LoginStatus.StateServerLoginFailed:
                break;

            case LoginStatus.StateServerNotLogined:
                break;

            case LoginStatus.Success:
                success = true;
                break;
            }
            if (!success)
            {
                LoginRetryTimeHelper.IncreaseFailedCount(loginInfo.Parameter.LoginId, ParticipantType.Customer, SettingManager.Default.ConnectionString);
                OnError(loginInfo.Parameter.Request, loginInfo.Parameter.AppType);
            }
            else
            {
                LoginRetryTimeHelper.ClearFailedCount(loginInfo.UserID, ParticipantType.Customer, SettingManager.Default.ConnectionString);
                ProcessPostAsyncLoginSuccess(loginInfo);
            }
        }