internal cAccountId(string pHost, eAccountType pType, string pUserId) { if (string.IsNullOrWhiteSpace(pHost)) { throw new ArgumentOutOfRangeException(nameof(pHost)); } if (pType == eAccountType.userid) { if (string.IsNullOrEmpty(pUserId)) { throw new ArgumentOutOfRangeException(nameof(pUserId)); } } else { if (pUserId != null) { throw new ArgumentOutOfRangeException(nameof(pUserId)); } } Host = pHost; Type = pType; UserId = pUserId; }
private cCredentials(eAccountType pType, cLogin pLogin, bool pTryAllSASLs = false) { Type = pType; UserId = null; Login = pLogin; TryAllSASLs = pTryAllSASLs; }
TeechipControl() : base() { m_isLogined = false; m_oAccountType = eAccountType.Unknown; m_strCurrentAccount = ""; m_strPassword = ""; }
public bool Login(eAccountType oAccountType, string strUser, string strPassword, bool bSavePassword, bool bServiceMode = false) { if (m_isLogined && m_oAccountType == oAccountType && strUser.Trim().Equals(m_strCurrentAccount, StringComparison.InvariantCultureIgnoreCase) && strPassword == m_strPassword) { return(m_isLogined); } try { switch (oAccountType) { case eAccountType.Google: m_isLogined = LoginGoogle(strUser.Trim(), strPassword); break; case eAccountType.Facebook: break; case eAccountType.TCAccount: m_isLogined = LoginTC(strUser.Trim(), strPassword); break; default: break; } if (m_isLogined) { m_oAccountType = oAccountType; m_strCurrentAccount = strUser.Trim(); m_strPassword = strPassword; if (bSavePassword) { Utility.SaveAccount(LoginInforFile2, strUser.Trim(), strPassword, (int)m_oAccountType); } else { File.Delete(LoginInforFile2); } } return(m_isLogined); } catch (Exception ex) { Utility.LogError(ex); } return(false); }
/**<summary></summary>*/ protected cCredentials(string pUserId, cLogin pLogin, bool pTryAllSASLs = false) { if (string.IsNullOrEmpty(pUserId)) { throw new ArgumentOutOfRangeException(nameof(pUserId)); } Type = eAccountType.userid; UserId = pUserId; Login = pLogin; TryAllSASLs = pTryAllSASLs; }
internal cAccountId(string pHost, eAccountType pType) { if (string.IsNullOrWhiteSpace(pHost)) { throw new ArgumentOutOfRangeException(nameof(pHost)); } if (pType == eAccountType.userid) { throw new ArgumentOutOfRangeException(nameof(pType)); } Host = pHost; Type = pType; UserId = null; }
void IMT4ServerConnectorHost.OnResponse( ReturnCode errorcode, string errormessage, eMT4ServerType serverIndex, MT4REQ reqType, eOrderStatus trans_status, int masterLogin, /*int orderOrLogin,*/ Guid server_trans_id, eAccountType accType, MT4REQMODE reqMode, MT4Request request) { try { OnResponseAsync( errorcode, errormessage, serverIndex, reqType, trans_status, masterLogin, /*orderOrLogin,*/ server_trans_id, accType, reqMode, request, CancellationToken.None).Wait(); } catch (Exception exception) { m_ptrLogger.LogException(exception); } }
private static extern int tgcpapi_csharp_set_uid_account(IntPtr handle, eAccountType type, eAccountFormat format, UInt64 uid);
private static extern int tgcpapi_csharp_set_openid_account(IntPtr handle, eAccountType type, [MarshalAs(UnmanagedType.LPStr)] String openid);
public int create_and_init_string(int service_id, byte[] app_id, int len, int buff_len, eAccountType type, string openid, byte[] atk, int atk_len) { return(tgcpapi_csharp_create_and_init_string(ref handle_, service_id, app_id, len, buff_len, type, openid, atk, atk_len)); }
public int create_and_init(int service_id, byte[] app_id, int len, int buff_len, eAccountType type, UInt64 uid, byte[] atk, int atk_len) { return(tgcpapi_csharp_create_and_init(ref handle_, service_id, app_id, len, buff_len, type, uid, atk, atk_len)); }
public int SetOpenUidAccount(eAccountType type, eAccountFormat format, UInt64 uid) { return(tgcpapi_csharp_set_uid_account(handle_, type, format, uid)); }
public int SetOpenIDAccount(eAccountType type, string openid) { return(tgcpapi_csharp_set_openid_account(handle_, type, openid)); }
private static extern int tgcpapi_csharp_create_and_init_string(ref IntPtr handle, int service_id, [MarshalAs(UnmanagedType.LPArray)] byte[] app_id, int app_id_len, int buff_len, eAccountType type, string openid, [MarshalAs(UnmanagedType.LPArray)] byte[] atk, int atk_len);
//连接 private int ConnectInternal() { int ret = 0; int iSerivceID = 123; int iBuffLen = 1024 * 1024; string appid = "appId123456"; eAccountType AccountType = eAccountType.TGCP_ACCOUNT_TYPE_PC_OPENID; eEncryptMethod iEncMethod = eEncryptMethod.TGCP_ENCRYPT_METHOD_AES; eKeyMaking iKeyMode = eKeyMaking.TGCP_KEY_MAKING_INSVR; // if (this.m_loginInfo == null) // { //#if !UNITY_EDITOR // m_loginInfo = MSDK.Instance.getLoginRecord(); // GlobalData.system.SaveLoginRetInfo(m_loginInfo); // appid = (PlatformType.Weixin == m_loginInfo.platform) ? NetConfig.wx_appid : NetConfig.qq_appid; //#endif // } if (null != m_TgcpHandle) { Log.info("有旧的tcp handler", "NetConnector.connectInternal"); } m_TgcpHandle = new TGCPAPI(); #if UNITY_STANDALONE_WIN m_TgcpHandle.WSAStartUp(2, 0); #endif //switch (this.m_loginInfo.platform) //{ // case PlatformType.Weixin: // AccountType = eAccountType.TGCP_ACCOUNT_TYPE_WX_OPENID; // break; // case PlatformType.QQ: // AccountType = eAccountType.TGCP_ACCOUNT_TYPE_QQ_OPENID; // break; // case PlatformType.Guest: // AccountType = eAccountType.TGCP_ACCOUNT_TYPE_IOS_GUEST; // break; // default: // Log.info("AccountType 末赋值"); // break; //} Log.info("appid: " + appid); Log.info("openid: " + m_openid); Log.info("accesstoken: " + ""); Log.info("AccountType: " + AccountType); Log.info("iEncMethod: " + iEncMethod); Log.info("iKeyMode: " + iKeyMode); Log.info("iSerivceID: " + iSerivceID); //if (string.IsNullOrEmpty(m_loginInfo.openid)) //{ // Log.info("openid为空,须重新登录"); // //openid为空操作待补 // OnOpenIdIsEmptyHandler(); // return ret; //} // 发送更新鉴权信息 //EventManager.Send(EventType_DataReport.QQ_REPORT_UPDATE_AUTH_INFO, new object[] { accesstoken, openid }); byte[] byteid = TDRTools.strToByte(appid); byte[] bytetoken = TDRTools.strToByte("access tokey"); ret = m_TgcpHandle.create_and_init_string(iSerivceID, byteid, byteid.Length, iBuffLen, AccountType, m_openid, bytetoken, bytetoken.Length); if (0 != ret) { Log.info("m_TgcpHandle.create_and_init_string failed: " + ret); return(ret); } ret = m_TgcpHandle.set_security_info(iEncMethod, iKeyMode, ""); if (0 != ret) { Log.info("m_TgcpHandle.set_security_info failed: " + ret); return(ret); } ret = m_TgcpHandle.set_refresh_token_expire(0); if (0 != ret) { Log.info("m_TgcpHandle.set_refresh_token_expire failed: " + ret); return(ret); } // #if UNITY_EDITOR // ret = m_TgcpHandle.set_authtype(eAuthType.TGCP_AUTH_NONE); // #endif //暂时都关闭鉴权 ret = m_TgcpHandle.set_authtype(eAuthType.TGCP_AUTH_NONE); Log.info("m_TgcpHandle init success"); try { Log.info("ip: " + m_ipAddress); Log.info("port: " + GlobalData.system.serverData.port); ret = AsynConnectServer(m_ipAddress, m_port); if (0 != ret) { Log.infoWarning("Could not connect!"); NotifyDisconnected((TGCP_ERROR)ret); } Log.info("Net_initConned"); } catch (Exception ex) { Log.info(ex.ToString()); } return(ret); }
public Account(eAccountType accountType) { this.accountType = accountType; this.transactions = new List <Transaction>(); }
/// <summary> /// WitFXMT4ServerBL.onMT4Response /// </summary> private async Task OnResponseAsync( ReturnCode errorcode, string errormessage, eMT4ServerType serverIndex, MT4REQ reqType, eOrderStatus trans_status, int masterLogin, /*int orderOrLogin,*/ Guid server_trans_id, eAccountType accType, MT4REQMODE reqMode, MT4Request request, CancellationToken cancellationToken) { Debug.Assert(masterLogin > 0); //m_ptrMySqlWrapper.insertLog(Utilities.LOG_INFO,masterLogin,orderOrLogin,"X",) if (reqType == MT4REQ.MT4REQ_NEW_ACCOUNT) { var mt4Login = request.User?.login ?? 0; if (trans_status == eOrderStatus.ORD_STAT_EXECUTED) { Debug.Assert(mt4Login > 0); m_ptrLogger.LogInfo($"EXECUTED : MT4 Account {mt4Login}, master Login {masterLogin}, AccountType: {accType}"); MT4Account acc = new MT4Account(); //memset(&acc, 0, sizeof(MT4Account)); acc._accountType = accType; acc._masterLogin = masterLogin; acc._mt4Login = mt4Login; acc._mt4ServerIndex = serverIndex; //if (serverIndex == SRV_TYPE_DEMO) //{ // Demo.insertMT4Account(orderOrLogin); //} //else //{ // Live.insertMT4Account(orderOrLogin); //} lock (_mt4LoginsByServerIndex) AddMt4LoginNoLock(serverIndex, mt4Login); await _mt4AccountService.InsertMT4Account(acc, cancellationToken); //if (!) //{ // m_ptrLogger.LogError("Unable to insert MT4 account for masterlogin: %d MT4 Login: %d in database", masterLogin, orderOrLogin); //} //else //{ #region Rebate //TODO: Claudia: rebate //if (accType == ACC_TYPE_REBATE) //{ // Dictionary<int, int>.iterator it2; // //lock (m_SyncMapMt4Master) // //{ // it2 = m_mapMasterRebateAcc.find(masterLogin); // if (it2 == m_mapMasterRebateAcc.end()) // { // m_mapMasterRebateAcc.insert(new ValueTuple<int, int>(masterLogin, orderOrLogin)); // } // //} //} #endregion ////else //if (accType != ACC_TYPE_REBATE) ////{ //Dictionary<bool, Dictionary<int, int>>.iterator it1; ////Dictionary<int, int>.iterator it2; ////lock (m_SyncMapMt4Master) ////{ //bool isDemoServer = serverIndex == SRV_TYPE_DEMO ? true : false; //it1 = m_mapMT4MasterLogin.find(isDemoServer); //if (it1 == m_mapMT4MasterLogin.end()) //{ // Dictionary<int, int> mp2 = new Dictionary<int, int>(); // m_mapMT4MasterLogin.insert(new ValueTuple<bool, Dictionary<int, int>>(isDemoServer, mp2)); // it1 = m_mapMT4MasterLogin.find(isDemoServer); //} //it1.second.insert(new ValueTuple<int, int>(orderOrLogin, masterLogin)); ////} ////} ////} if (accType == eAccountType.ACC_TYPE_SSP) { await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken); await _signalService.UpdateSSPSignalMT4Login(server_trans_id, mt4Login, cancellationToken); //fetchAllSignal(); //fetchAllSSPSignal(); //fetchAllSMSignal(); //insertDBTransmitData(masterLogin, FDMT_Signal_ID); //insertDBTransmitData(masterLogin, FDMT_SSPSignal_ID); } else if (accType == eAccountType.ACC_TYPE_SM) { await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken); await _signalService.UpdateSMSignalMT4Login(server_trans_id, mt4Login, cancellationToken); //fetchAllSignal(); //fetchAllSSPSignal(); //fetchAllSMSignal(); //insertDBTransmitData(masterLogin, FDMT_Signal_ID); //insertDBTransmitData(masterLogin, FDMT_SMSignal_ID); } var m_masterUserSetting = await _masterSettingsService.GetCachedMasterSettingsAsync(cancellationToken); if (accType == eAccountType.ACC_TYPE_FOLLOWER_DEMO || accType == eAccountType.ACC_TYPE_SSP || accType == eAccountType.ACC_TYPE_SM) { MT4Request ptrMT4Req4 = (MT4Request) new MT4Request(); //memset(ptrMT4Req4, 0, sizeof(MT4Request)); //ptrMT4Req4.newLoginOrOrderID = orderOrLogin; // Alexey ptrMT4Req4.masterLogin = masterLogin; ptrMT4Req4.reqType = MT4REQ.MT4REQ_BALANCE; //ptrMT4Req4.socketID = socketID; ptrMT4Req4.status = eOrderStatus.ORD_STAT_RECVD; ptrMT4Req4.serverTransID = TransactionService.NewTransactionId(); ptrMT4Req4.ptrData = new MT4OrderInfo(); //memset(ptrMT4Req4.ptrData, 0, sizeof(MT4OrderInfo)); MT4OrderInfo ptrOrd = (MT4OrderInfo)ptrMT4Req4.ptrData; ptrOrd._accountType = accType; ptrOrd._masterLogin = masterLogin; ptrOrd._mt4Login = mt4Login; ptrOrd._mt4ServerIndex = serverIndex; ptrOrd._orderTransMode = eMT4OrderTransMode.ORD_TRANS_CLOSE; ptrOrd._orderType = eMT4OrderType.ORD_TYPE_BALANCE; ptrOrd._price = request.deposit; if (ptrOrd._price == 0) { if (accType == eAccountType.ACC_TYPE_FOLLOWER_DEMO) { ptrOrd._price = m_masterUserSetting._deposit_followerDemo; } else if (accType == eAccountType.ACC_TYPE_SSP) { ptrOrd._price = m_masterUserSetting._deposit_SSP; } else if (accType == eAccountType.ACC_TYPE_SM) { ptrOrd._price = m_masterUserSetting._deposit_SM; } } Demo.insertMT4Request(ptrMT4Req4); } else if (accType == eAccountType.ACC_TYPE_FOLLOWER_LIVE) { MT4Request ptrMT4Req4 = (MT4Request) new MT4Request(); //memset(ptrMT4Req4, 0, sizeof(MT4Request)); //ptrMT4Req4.newLoginOrOrderID = orderOrLogin; // Alexey ptrMT4Req4.masterLogin = masterLogin; ptrMT4Req4.reqType = MT4REQ.MT4REQ_BALANCE; //ptrMT4Req4.socketID = socketID; ptrMT4Req4.status = eOrderStatus.ORD_STAT_RECVD; ptrMT4Req4.serverTransID = TransactionService.NewTransactionId(); ptrMT4Req4.ptrData = new MT4OrderInfo(); //memset(ptrMT4Req4.ptrData, 0, sizeof(MT4OrderInfo)); MT4OrderInfo ptrOrd = (MT4OrderInfo)ptrMT4Req4.ptrData; ptrOrd._accountType = accType; ptrOrd._masterLogin = masterLogin; ptrOrd._mt4Login = mt4Login; ptrOrd._mt4ServerIndex = serverIndex; ptrOrd._orderTransMode = eMT4OrderTransMode.ORD_TRANS_CLOSE; ptrOrd._orderType = eMT4OrderType.ORD_TYPE_BALANCE; ptrOrd._price = request.deposit; if (ptrOrd._price == 0) { ptrOrd._price = m_masterUserSetting._deposit_followerLive; } Live.insertMT4Request(ptrMT4Req4); } var ptrResp = new MT4AccountResponse(); //MT_MT4AccountResponse_ID CppHelper.memcpy(ref ptrResp._account, acc); _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_MT4AccountResponse_ID, masterLogin); } else if (trans_status == eOrderStatus.ORD_STAT_PROCESSING) { // Claudia: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request Debug.Assert(masterLogin > 0); m_ptrLogger.LogInfo("PROCESSING : MT4 Account %d master Login %d AccountType: %d", mt4Login, masterLogin, accType); var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID ptrResp._serverTransID = server_trans_id; ptrResp._requestMode = reqMode; ptrResp._retCode = (eReturnCode)trans_status; //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID); _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin); } else if (trans_status == eOrderStatus.ORD_STAT_REJECTED) { // Claudia: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request Debug.Assert(masterLogin > 0); m_ptrLogger.LogInfo("REJECTED : MT4 Account %d master Login %d AccountType: %d", mt4Login, masterLogin, accType); if (accType == eAccountType.ACC_TYPE_SSP) { await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true); await _signalService.UpdateSSPSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true); } if (accType == eAccountType.ACC_TYPE_SM) { await _signalService.UpdateSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true); await _signalService.UpdateSMSignalMT4Login(server_trans_id, mt4Login, cancellationToken, isRemove : true); } var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID ptrResp._serverTransID = server_trans_id; ptrResp._requestMode = reqMode; ptrResp._retCode = (eReturnCode)trans_status; ptrResp._mt4errorcode = errorcode; CppHelper.strcpy(out ptrResp._mt4errormessage, errormessage); //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID); _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin); } //insertDBTransmitData(masterLogin, FDMT_MasterUser_ID); //insertDBTransmitData(masterLogin, FDMT_MT4Account_ID); //insertDBTransmitData(masterLogin, FDMT_SSPSignal_ID); //insertDBTransmitData(masterLogin, FDMT_SSPSignal_ID); } else { var orderId = request.OrderInfo?._orderID ?? 0; if (trans_status == eOrderStatus.ORD_STAT_PROCESSING) { // Alexey: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request Debug.Assert(masterLogin > 0 && server_trans_id != Guid.Empty); m_ptrLogger.LogInfo($"PROCESSING : Order {orderId}, master Login {masterLogin}, UID: {server_trans_id}"); var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID ptrResp._serverTransID = server_trans_id; ptrResp._requestMode = reqMode; ptrResp._retCode = (eReturnCode)trans_status; //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID); _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin); } else if (trans_status == eOrderStatus.ORD_STAT_REJECTED) { // Alexey: it's normal that orderOrLogin parameter is 0, because MT4 is still processing the request Debug.Assert(masterLogin > 0 && server_trans_id != Guid.Empty); m_ptrLogger.LogInfo($"REJECTED : Order {orderId}, master Login {masterLogin}, UID: {server_trans_id}"); var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID ptrResp._serverTransID = server_trans_id; ptrResp._requestMode = reqMode; ptrResp._retCode = (eReturnCode)trans_status; ptrResp._mt4errorcode = errorcode; CppHelper.strcpy(out ptrResp._mt4errormessage, errormessage); //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID); _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin); } else if (trans_status == eOrderStatus.ORD_STAT_EXECUTED) { if (reqMode == MT4REQMODE.OPEN_TRADE) { Debug.Assert(server_trans_id != Guid.Empty && orderId > 0 && request.Order != null && request.Order.OrderId == 0); request.Order.OrderId = orderId; await _orderService.InsertAsync(request.Order, cancellationToken); // updateTransLinking(server_trans_id, orderOrLogin); } //if (reqMode == MT4REQMODE.CLOSE_TRADE || reqMode == MT4REQMODE.DELETE_TRADE) //{ // removeTransLinking(server_trans_id); //} Debug.Assert(masterLogin > 0 && server_trans_id != Guid.Empty); m_ptrLogger.LogInfo($"EXECUTED : Order {orderId}, master Login {masterLogin}, UID: {server_trans_id}"); var ptrResp = new SocialOrderResponse(); //MT_SocialOrderResponse_ID ptrResp._serverTransID = server_trans_id; ptrResp._requestMode = reqMode; ptrResp._retCode = (eReturnCode)trans_status; //SentDataUsingSocketID(ptrResp, MT_SocialOrderResponse_ID, socketID); _connectionMgr.SentDataUsingLoginID(ptrResp, MessageTypeID.MT_SocialOrderResponse_ID, masterLogin); } } }