Esempio n. 1
1
 public void Execute()
 {
     List<string> argList =ArgumentsParser.Parse(_Request.Content);
     int appType = argList[3].ToInt();
     LoginParameter loginParameter = new LoginParameter()
     {
         LoginId = argList[0],
         Password=argList[1],
         Version=argList[2],
         AppType=(AppType)argList[3].ToInt(),
         Request=_Request
     };
     LoginManager loginManager = new LoginManager();
     loginManager.StateLoadingCompleted += OnLoginStateLoadingCompleteCallback;
     loginManager.Login(loginParameter);
 }
Esempio n. 2
0
 public void Login(LoginParameter parameter)
 {
     AsyncEnumerator ae = new AsyncEnumerator();
     ae.BeginExecute(_LoginProvider.AsyncLogin(parameter, ae), ae.EndExecute);
 }
Esempio n. 3
0
        public IEnumerator<int> AsyncLogin(LoginParameter parameter,AsyncEnumerator ae)
        {
            string connectionString = SettingManager.Default.ConnectionString;
            LoginInfo loginInfo = new LoginInfo() { Parameter=parameter};
            if (LoginRetryTimeHelper.IsFailedCountExceeded(parameter.LoginId, ParticipantType.Customer, connectionString))
            {
                loginInfo.Status = LoginStatus.ExceedMaxRetryCount;
                OnCompleted(loginInfo);
                yield break;
            }
            if (!parameter.LoginId.HasValue())
            {
                loginInfo.Status = LoginStatus.LoginIdIsEmpty;
                OnCompleted(loginInfo);
                yield break;
            }

            Application.Default.ParticipantService.BeginLogin(parameter.LoginId, parameter.Password,ae.End(), null);
            yield return 1;
            try
            {
                loginInfo.UserID = Application.Default.ParticipantService.EndLogin(ae.DequeueAsyncResult());
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                loginInfo.Status = LoginStatus.ParticipantServiceLoginFailed;
                OnCompleted(loginInfo);
                yield break;
            }

            if (loginInfo.UserID == Guid.Empty)
            {
                loginInfo.Status = LoginStatus.UserIdIsEmpty;
                OnCompleted(loginInfo);
                yield break;
            }

            Guid programID = new Guid(SettingManager.Default.GetJavaTraderSettings("TradingConsole"));
            Guid permissionID = new Guid(SettingManager.Default.GetJavaTraderSettings("Run"));
            Application.Default.SecurityService.BeginCheckPermission(loginInfo.UserID, programID, permissionID, "", "", loginInfo.UserID, ae.End(), null);
            yield return 1;
            bool isAuthrized = false;
            try
            {
                string message;
                isAuthrized = Application.Default.SecurityService.EndCheckPermission(ae.DequeueAsyncResult(), out message);
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                loginInfo.Status = LoginStatus.CheckPermissionFailed;
                OnCompleted(loginInfo);
                yield break;
            }

            if (!isAuthrized)
            {
                loginInfo.Status = LoginStatus.NotAuthrized;
                OnCompleted(loginInfo);
                yield break;
            }

            var token = new Token(Guid.Empty, UserType.Customer, parameter.AppType);
            token.UserID = loginInfo.UserID;
            token.SessionID = parameter.Request.ClientInfo.Session.ToString();
            SessionManager.Default.AddToken(parameter.Request.ClientInfo.Session, token);

            var stateServerCallToken = new Token
            {
                UserID = token.UserID,
                AppType = AppType.TradingConsole,
                SessionID = token.SessionID,
                UserType=token.UserType
            };

            Application.Default.StateServer.BeginLogin(stateServerCallToken, ae.End(), null);
            yield return 1;
            bool isStateServerLogined = false;
            try
            {
                isStateServerLogined = Application.Default.StateServer.EndLogin(ae.DequeueAsyncResult());
            }
            catch (Exception ex)
            {
                _Logger.Error(ex);
                loginInfo.Status = LoginStatus.StateServerLoginFailed;
                OnCompleted(loginInfo);
                yield break;
            }

            if (!isStateServerLogined)
            {
                loginInfo.Status = LoginStatus.StateServerNotLogined;
                OnCompleted(loginInfo);
                yield break;
            }
            loginInfo.Status = LoginStatus.Success;
            OnCompleted(loginInfo);
        }