Пример #1
0
        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    = ErrorCode == 0 ? axAPI.GetFutureCodeByIndex(e.nErrCode) : axAPI.GetFutureCodeByIndex(ErrorCode);

                if (Account == null)
                {
                    Box.Show("This Account is not Registered.", "Caution", waiting);

                    SendExit?.Invoke(this, new ForceQuit(end));
                }
                if (!axAPI.GetLoginInfo("GetServerGubun").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));
        }
Пример #2
0
        private void KHOpenAPI_OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (e.nErrCode == 0)
            {
                string   accountCnt   = axKHOpenAPI1.GetLoginInfo("ACCOUNT_CNT");
                string[] accountArray = axKHOpenAPI1.GetLoginInfo("ACCLIST").Split(';');
                string   userId       = axKHOpenAPI1.GetLoginInfo("USER_ID");
                string   userName     = axKHOpenAPI1.GetLoginInfo("USER_NAME");
                string   keySeq       = axKHOpenAPI1.GetLoginInfo("KEY_BSECGB");
                string   firewall     = axKHOpenAPI1.GetLoginInfo("FIREW_SECGB");
                string   serverType   = axKHOpenAPI1.GetLoginInfo("GetServerGubun");

                List <string> accountList = accountArray.ToList();
                accountList.Remove("");
                accountListbox.DataSource = accountList;
                uidLabel.Text             = userId;
                unLabel.Text = userName;
                ksLabel.Text = (keySeq == "0") ? "정상" : "해지";
                fwLabel.Text = (firewall == "0")? "미설정" : (firewall == "1")? "설정" : "해지";
                stLabel.Text = (serverType == "1")? "모의투자" : "실서버";

                axKHOpenAPI1.KOA_Functions(("ShowAccountWindow"), (""));
                Presenter.RequestTotalAsset(accountList[0], "");
                Presenter.RequestAsset(accountList[0], "");
            }
            else
            {
                System.Windows.Forms.MessageBox.Show("로그인 실패");
                Application.Exit();
            }
        }
Пример #3
0
        private void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            int           i;
            string        exclusion, date = GetDistinctDate(CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday) - CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now.AddDays(1 - DateTime.Now.Day), CalendarWeekRule.FirstDay, DayOfWeek.Sunday) + 1);
            List <string> code = new List <string>
            {
                axAPI.GetFutureCodeByIndex(e.nErrCode)
            };

            for (i = 2; i < 4; i++)
            {
                foreach (var om in axAPI.GetActPriceList().Split(';'))
                {
                    exclusion = axAPI.GetOptionCode(om.Insert(3, "."), i, date);

                    if (code.Exists(o => o.Equals(exclusion)))
                    {
                        continue;
                    }

                    code.Add(exclusion);
                }
            }
            if (TimerBox.Show("Are You using Automatic Login??\n\nIf You aren't using It,\nClick No.\n\nAfter 5 Seconds,\nIt's Regarded as an Automatic Mode and Proceeds.", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1, 5617).Equals((DialogResult)7))
            {
                axAPI.KOA_Functions("ShowAccountWindow", "");
            }

            SendAccount?.Invoke(this, new Account(axAPI.GetLoginInfo("ACCLIST"), axAPI.GetLoginInfo("USER_ID"), axAPI.GetLoginInfo("USER_NAME"), axAPI.GetLoginInfo("GetServerGubun")));
            code.RemoveAt(1);
            var absence = Sql.GetSchema("Tables");

            Delay.delay = 615;

            foreach (KeyValuePair <string, string> kv in table)
            {
                if (absence.AsEnumerable().Where(o => o.ItemArray.Contains(kv.Key)).Any() == false)
                {
                    var sql = Sql.CreateCommand();
                    sql.CommandText    = kv.Value;
                    sql.CommandTimeout = 0;
                    sql.CommandType    = CommandType.Text;
                    sql.BeginExecuteNonQuery();
                }
            }
            foreach (string output in code)
            {
                RemainingDay(output);
            }

            if (TimerBox.Show("Do You Want to Retrieve Recent Data?\n\nPress 'YES' after 35 Seconds to Receive Data.\n\nDo Not Receive while the Market is Operating.\n\nWarning\n\nReceiving Information for Trading.\n\nIf You have Access to Trading,\nPlease don't Click.\n\nWhen Reception is Complete,\nProceed to the Next Step.", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button2, (uint)code.Count * 743).Equals((DialogResult)6))
            {
                Delay.delay = 4150;
                Request(code[0]);

                return;
            }
            SendConfirm?.Invoke(this, new Identify("It is valid until ", DateTime.ParseExact(Code[0].Substring(18, 8), "yyyyMMdd", null)));
            Delay.delay = 205;
        }
Пример #4
0
        private static void AxKHOpenAPI1_OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (e.nErrCode != 0)
            {
                Application.Exit();
            }

            _loginSucceed = true;

            string acclist = _api.GetLoginInfo("ACCLIST");

            string[] accounts = acclist.Trim().Split(';').Where(x => x.Length > 0).ToArray();

            var userId = _api.GetLoginInfo("USER_ID");
            var server = _api.GetLoginInfo("GetServerGubun") == "0" ? "모의" : "실제";

            // fill etfs
            FillStocks("8", _etfs);

            // fill stocks
            FillStocks("0", _stocks);

            if (Connected != null)
            {
                Connected(accounts, userId, server);
            }
        }
Пример #5
0
        void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            SendErrorMessage(e.nErrCode);
            Code = API.GetFutureCodeByIndex(e.nErrCode);
            RemainingDay(Code);
            CodeList = new List <string>
            {
                Code
            };
            if (DateTime.Now.Hour > 4 && (DateTime.Now.Hour < 15 || DateTime.Now.Hour == 15 && DateTime.Now.Minute < 45) && (DateTime.Now.DayOfWeek.Equals(DayOfWeek.Saturday) || DateTime.Now.DayOfWeek.Equals(DayOfWeek.Sunday)) == false)
            {
                if (Temporary == null)
                {
                    PrepareForTrading(API.GetLoginInfo("ACCLIST"));
                }

                DeadLine = DateTime.Now.Hour < 9 ? false : true;
            }
            else if (Temporary != null)
            {
                OnCollectingData(GetInformation());
            }

            SendCount?.Invoke(this, new NotifyIconText((byte)e.nErrCode));
        }
Пример #6
0
 public void OnEventConnectEventHandler(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
 {
     if (OnEventConnectUri != null)
     {
         JObject body = new JObject();
         body["nErrCode"] = e.nErrCode;
         HttpContent content = new StringContent(body.ToString(), Encoding.UTF8, "application/json");
         client.PostAsync(OnEventConnectUri, content);
     }
 }
Пример #7
0
        public void OnEventCon(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (e.nErrCode == 0)
            {
                listBox1.Items.Add(axKHOpenAPI1.GetLoginInfo("USER_ID") + "님 로그인 했읍니다.");
            }

            else if (e.nErrCode == 1)
            {
                listBox1.Items.Add("연결 Fail ...");
            }
        }
Пример #8
0
        void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e) => BeginInvoke(new Action(() =>
        {
            if (e.nErrCode == 0 && (string.IsNullOrEmpty(privacy.SecurityAPI) == false || string.IsNullOrEmpty(axAPI.KOA_Functions(showAccountWindow, string.Empty))))
            {
                Send?.Invoke(this, new SendSecuritiesAPI(FormWindowState.Minimized, securites != null && securites.Length == 0xA ? new Accounts(securites) : new Accounts(axAPI.GetLoginInfo(account))));
            }

            else
            {
                (API as Connect)?.SendErrorMessage(e.nErrCode);
            }
        }));
Пример #9
0
 private void onEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
 {
     if (e.nErrCode == 0)
     {
         string   accountList  = axKHOpenAPI1.GetLoginInfo("ACCNO");
         string[] accountArray = accountList.Split(';');
         for (int i = 0; i < accountArray.Length; i++)
         {
             accountComboBox.Items.Add(accountArray[i]);
         }
     }
 }
Пример #10
0
 public void OnEventCnt(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
 {
     if (e.nErrCode == 0)
     {
         loginIdLab.Text = axKHOpenAPI1.GetLoginInfo("USER_ID");
         string   AccNolist  = axKHOpenAPI1.GetLoginInfo("ACCNO"); //께좌번호
         string[] AccNoArray = AccNolist.Split(';');
         for (int i = 0; i < AccNoArray.Length; ++i)
         {
             comboBox1.Items.Add(AccNoArray[i]);
         }
     }
 }
Пример #11
0
        private void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            int           i;
            string        exclusion, date = GetDistinctDate(CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstDay, DayOfWeek.Sunday) - CultureInfo.CurrentCulture.Calendar.GetWeekOfYear(DateTime.Now.AddDays(1 - DateTime.Now.Day), CalendarWeekRule.FirstDay, DayOfWeek.Sunday) + 1);
            List <string> code = new List <string>
            {
                AxAPI.GetFutureCodeByIndex(e.nErrCode)
            };

            for (i = 2; i < 4; i++)
            {
                foreach (var om in AxAPI.GetActPriceList().Split(';'))
                {
                    exclusion = AxAPI.GetOptionCode(om.Insert(3, "."), i, date);

                    if (code.Exists(o => o.Equals(exclusion)))
                    {
                        continue;
                    }

                    code.Add(exclusion);
                }
            }
            code.RemoveAt(1);
            Sb = new StringBuilder(32);
            var absence = Sql.GetSchema("Columns").Rows;

            for (i = 0; i < code.Count; i++)
            {
                if (absence.Cast <DataRow>().Where(o => o.ItemArray.Contains(code[i])).Any() == false)
                {
                    var sql = Sql.CreateCommand();
                    sql.CommandText    = GetQuery(code[i], date);
                    sql.CommandTimeout = 0;
                    sql.CommandType    = CommandType.Text;
                    sql.BeginExecuteNonQuery();
                }
                Sb.Append(code[i]);

                if (i > 0 && i % 99 == 0 || i == code.Count - 1)
                {
                    AxAPI.CommKwRqData(Sb.ToString(), 0, 100, 3, "OPTFOFID", new Random().Next(1000, 10000).ToString());
                    Sb = new StringBuilder(32);

                    continue;
                }
                Sb.Append(';');
            }
            code.Clear();
        }
Пример #12
0
        void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (e.nErrCode == 0)
            {
                foreach (var code in GetInformationOfCode(new List <string> {
                    axAPI.GetFutureCodeByIndex(0)
                }, axAPI.GetCodeListByMarket(string.Empty).Split(';')))
                {
                    Send?.Invoke(this, new SendSecuritiesAPI(code));
                }

                Send?.Invoke(this, new SendSecuritiesAPI(axAPI.GetLoginInfo("ACCLIST").Split(';')));
            }
            else
            {
                Send?.Invoke(this, new SendSecuritiesAPI((short)e.nErrCode));
            }
        }
Пример #13
0
        private static void AxKHOpenAPI1_OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (e.nErrCode != 0)
            {
                Application.Exit();
            }

            _loginSucceed = true;

            string acclist = _api.GetLoginInfo("ACCLIST");

            string[] accounts = acclist.Trim().Split(';').Where(x => x.Length > 0).ToArray();

            var userId = _api.GetLoginInfo("USER_ID");
            var server = _api.GetLoginInfo("GetServerGubun") == "0" ? "모의" : "실제";

            // fill etfs
            var list = _api.GetCodeListByMarket("8").Trim().Split(';');

            foreach (var code in list)
            {
                if (string.IsNullOrEmpty(code))
                {
                    continue;
                }

                _etfs.Add(new Stock
                {
                    Code = code,
                    Name = _api.GetMasterCodeName(code)
                });
            }

            _etfs.Sort(delegate(Stock x, Stock y)
            {
                return(string.Compare(x.Name, y.Name));
            });

            if (Connected != null)
            {
                Connected(accounts, userId, server);
            }
        }
Пример #14
0
 private void AxKHOpenAPI_OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
 {
     if (e.nErrCode == ErrorCode.정상처리)
     {
         GetUserInfo();
         SendLogWarningMessage("로그인 성공");
     }
     else if (e.nErrCode == ErrorCode.사용자정보교환실패)
     {
         SendLogMessage("로그인 실패 : 사용자 정보교환 실패");
     }
     else if (e.nErrCode == ErrorCode.서버접속실패)
     {
         SendLogMessage("로그인 실패 : 서버접속 실패");
     }
     else if (e.nErrCode == ErrorCode.버전처리실패)
     {
         SendLogMessage("로그인 실패 : 버전처리 실패");
     }
 }
Пример #15
0
 private void API_OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
 {
     if (e.nErrCode == 0)
     {
         // 사용자 계좌번호
         string   accList      = axKHOpenAPI1.GetLoginInfo("ACCLIST");
         string[] accountArray = accList.Split(';');
         foreach (string account in accountArray)
         {
             if (account.Length > 0)
             {
                 accountComboBox.Items.Add(account);
             }
         }
         // 사용자 조건식
         axKHOpenAPI1.GetConditionLoad();
     }
     else
     {
         MessageBox.Show("로그인 실패");
     }
 }
Пример #16
0
        private void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (!axAPI.GetLoginInfo("GetServerGubun").Equals("1") && e.nErrCode == 0 && confirm.Identify(axAPI.GetLoginInfo("USER_ID"), axAPI.GetLoginInfo("USER_NAME")) && !ErrorCode.Equals(915))
            {
                if (DialogResult.Yes == MessageBox.Show("Do You Want to Retrieve Recent Data?", "Notice", MessageBoxButtons.YesNo, MessageBoxIcon.Question))
                {
                    Delay.delay = 4150;
                    Request();
                }
                SendConfirm?.Invoke(this, new Identify("The Remaining Validity Period is ", CallBasicInformation(e.nErrCode)));

                return;
            }
            else if (ErrorCode.Equals(915) && e.nErrCode.Equals(0))
            {
                CallBasicInformation(e.nErrCode);

                return;
            }
            Box.Show("등록되지 않은 사용자이거나 모의투자로 접속하셨습니다.\n\n프로그램을 종료합니다.", "오류", waiting);
            SendExit?.Invoke(this, new ForceQuit(end));
        }
Пример #17
0
        void OnEventConnect(object sender, _DKHOpenAPIEvents_OnEventConnectEvent e)
        {
            if (e.nErrCode == 0)
            {
                foreach (var code in GetInformationOfCode(new List <string> {
                    axAPI.GetFutureCodeByIndex(0)
                }, axAPI.GetCodeListByMarket(string.Empty).Split(';')))
                {
                    Send?.Invoke(this, new SendSecuritiesAPI(code));
                }

                if (IsAdministrator && axAPI.GetConditionLoad() == 1)
                {
                    Conditions   = new Dictionary <int, string>();
                    API.IsServer = IsServer;
                }
                Send?.Invoke(this, new SendSecuritiesAPI(axAPI.GetLoginInfo("ACCLIST").Split(';')));
            }
            else
            {
                Send?.Invoke(this, new SendSecuritiesAPI((short)e.nErrCode));
            }
        }