public static void StartSession(AxKHOpenAPI API = null, _DKHOpenAPIEvents_OnEventConnectEventHandler connect_event = null) { if (API != null) { api = API; } else { api = new AxKHOpenAPI(); api.BeginInit(); api.Enabled = true; byte[] bytes = Convert.FromBase64String(@"AAEAAAD/////AQAAAAAAAAAMAgAAAFdTeXN0ZW0uV2luZG93cy5Gb3JtcywgVmVyc2lvbj00LjAuMC4wLCBDdWx0dXJlPW5ldXRyYWwsIFB1YmxpY0tleVRva2VuPWI3N2E1YzU2MTkzNGUwODkFAQAAACFTeXN0ZW0uV2luZG93cy5Gb3Jtcy5BeEhvc3QrU3RhdGUBAAAABERhdGEHAgIAAAAJAwAAAA8DAAAAJQAAAAIBAAAAAQAAAAAAAAAAAAAAABAAAAACAAEAVgoAACsFAAAAAAAACw=="); using (MemoryStream ms = new MemoryStream(bytes, 0, bytes.Length)) { ms.Write(bytes, 0, bytes.Length); ms.Position = 0; api.OcxState = (AxHost.State)(new BinaryFormatter().Deserialize(ms)); } api.OnEventConnect += new _DKHOpenAPIEvents_OnEventConnectEventHandler((s, e) => { Initialized = true; UserId = api.GetLoginInfo("USER_ID"); UserName = api.GetLoginInfo("USER_NAME"); ServerGubun = api.GetLoginInfo("GetServerGubun"); Account.AccountList = api.GetLoginInfo("ACCLIST").Split(';'); Stock.StockInfo = api.GetCodeListByMarket(null).Split(';').Select(x => (x, api.GetMasterCodeName(x))).ToList(); }); if (connect_event != null) { api.OnEventConnect += connect_event; } dummy.Controls.Add(api); api.EndInit(); } api.CommConnect(); }
public void GetUserInfo() { string userName = axKHOpenAPI.GetLoginInfo("USER_NAME"); string userId = axKHOpenAPI.GetLoginInfo("USER_ID"); string accountList = axKHOpenAPI.GetLoginInfo("ACCLIST"); string server = string.Empty; if (axKHOpenAPI.GetLoginInfo("GetServerGubun").Equals("1")) { server = "모의서버"; } else { server = "실서버"; } string[] accounts = accountList.Split(';'); this.userInfo = new UserInfo() { LogIn = true, UserName = userName, UserId = userId, Accounts = accounts, ConnectedServer = server }; OnReceivedUserInfo?.Invoke(this, new OnReceivedUserInfoEventArgs(userInfo)); }
private void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e) { if (e.nErrCode == 0 && Identify(axAPI.GetLoginInfo("USER_ID"), axAPI.GetLoginInfo("USER_NAME")) == true) { Account = axAPI.GetLoginInfo("ACCLIST"); Code = axAPI.GetFutureCodeByIndex(e.nErrCode); if (Account == null) { Box.Show("This Account is not Registered.", "Caution", waiting); SendExit?.Invoke(this, new ForceQuit(end)); } string login = axAPI.GetLoginInfo("GetServerGubun"); if (!login.Equals("1")) { Box.Show("It's a Real Investment.", "Caution", waiting); } axAPI.KOA_Functions("ShowAccountWindow", ""); RemainingDay(); return; } Box.Show("등록되지 않은 사용자이거나\n로그인이 원활하지 않습니다.\n프로그램을 종료합니다.", "오류", waiting); SendExit?.Invoke(this, new ForceQuit(end)); }
public string[] initAccountList() { int cnt = int.Parse(openApi.GetLoginInfo("ACCOUNT_CNT")); if (cnt > 0) { return(openApi.GetLoginInfo("ACCLIST").Split(new string[] { ";" }, StringSplitOptions.RemoveEmptyEntries)); } return(null); }
private void RefreshAccountInfo() { control.Print("LOGIN USER ID : " + axKHOpenAPI1.GetLoginInfo("USER_ID")); control.Print("LOGIN USER NAME : " + axKHOpenAPI1.GetLoginInfo("USER_NAME")); string[] accountArray = axKHOpenAPI1.GetLoginInfo("ACCNO").Split(';'); control.accountComboBox.Items.AddRange(accountArray); control.accountComboBox.SelectedIndex = 0; if (control.accountComboBox.SelectedItem.ToString().Length > 0) { currentAccount = control.accountComboBox.SelectedItem.ToString(); SendRequestAccountInfo(); SendRequestProfitInfo(); } }
/// <summary> /// [4]로그인한 사용자 정보를 반환한다. /// ACCOUNT_CNT – 전체 계좌 개수를 반환한다. ///ACCNO – 전체 계좌를 반환한다.계좌별 구분은 ‘;’이다. ///USER_ID - 사용자 ID를 반환한다. ///USER_NAME – 사용자명을 반환한다. ///KEY_BSECGB – 키보드보안 해지여부. 0:정상, 1:해지 ///FIREW_SECGB – 방화벽 설정 여부. 0:미설정, 1:설정, 2:해지 ///Ex) openApi.GetLoginInfo(“ACCOUNT_CNT”); /// </summary> public string GetLoginInfo(String sTag = "ACCOUNT_CNT") { String ret = axKHOpenAPI.GetLoginInfo(sTag); FileLog.PrintF("GetLoginInfo(" + sTag + ")" + ret); return(ret); }