Пример #1
0
        public __tuple <ErrorCode_, Account> _loginAccount(string nAccountName, string nPassward, uint nDeviceType)
        {
            ErrorCode_ errorCode_ = this._checkDevice(nDeviceType);

            if (ErrorCode_.mSucess_ == errorCode_)
            {
                __tuple <SqlStatus_, AccountB> accountDB_ = this._LoginAccountB(nAccountName);
                errorCode_ = this._getErrorCode(accountDB_._get_0());
                if (ErrorCode_.mSucess_ == errorCode_)
                {
                    AccountB accountB_ = accountDB_._get_1();
                    errorCode_ = accountB_._checkPassward(nPassward);
                }
            }
            Account account_ = null;

            if (ErrorCode_.mSucess_ == errorCode_)
            {
                uint accountId_ = AccountB._accountId(nAccountName);
                account_ = this._getAccount(accountId_);
                if (null == account_)
                {
                    account_ = new Account();
                    account_._setAccountId(accountId_);
                    account_._addDeviceType(nDeviceType);
                    mAccounts[accountId_] = account_;
                }
                account_._setTicks(DateTime.Now.Ticks);
            }
            return(new __tuple <ErrorCode_, Account>(errorCode_, account_));
        }
Пример #2
0
        ErrorCode_ _getErrorCode(SqlStatus_ nSqlStatus)
        {
            ErrorCode_ result_ = ErrorCode_.mSucess_;

            if (SqlStatus_.mFail_ == nSqlStatus)
            {
                result_ = ErrorCode_.mFail_;
            }
            return(result_);
        }
Пример #3
0
        ErrorCode_ _checkDevice(uint nDeviceType)
        {
            ErrorCode_    result_    = ErrorCode_.mSucess_;
            DeviceService deviceMgr_ = __singleton <DeviceService> ._instance();

            if (!deviceMgr_._contain(nDeviceType))
            {
                result_ = ErrorCode_.mDevice_;
            }
            return(result_);
        }
Пример #4
0
        public ErrorCode_ _checkPassward(string nPassward)
        {
            ErrorCode_ result_        = ErrorCode_.mSucess_;
            uint       loginPassward_ = HashString._runPasswardId(nPassward);
            uint       hashPassward_  = HashString._runPasswardId(mPassward);

            if (loginPassward_ != hashPassward_)
            {
                result_ = ErrorCode_.mPassward_;
            }
            return(result_);
        }
Пример #5
0
        public ErrorCode_ _logoutAccount(string nAccountName, uint nDeviceId, uint nDeviceType)
        {
            ErrorCode_ result_  = ErrorCode_.mSucess_;
            Account    account_ = this._getAccount(nAccountName);

            if (null == account_)
            {
                result_ = ErrorCode_.mFail_;
            }
            if (ErrorCode_.mSucess_ == result_)
            {
                result_ = account_._logout(nDeviceId, nDeviceType);
                if (!account_._isOnline())
                {
                    mAccounts.Remove(account_._getAccountId());
                }
            }
            return(result_);
        }
Пример #6
0
        public ErrorCode_ _logout(uint nDeviceId, uint nDeviceType)
        {
            ErrorCode_   result_       = ErrorCode_.mSucess_;
            DeviceStatus deviceStatus_ = this._getDeviceStatus(nDeviceType);

            if (null == deviceStatus_)
            {
                result_ = ErrorCode_.mDeviceType_;
            }
            if ((null != deviceStatus_) && (deviceStatus_._getId() != nDeviceId))
            {
                result_ = ErrorCode_.mDeviceId_;
            }
            if (ErrorCode_.mSucess_ == result_)
            {
                mDeviceStatus.Remove(nDeviceType);
            }
            return(result_);
        }