示例#1
0
 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();
 }
示例#2
0
        /// <summary>
        /// [1]설명 로그인 윈도우를 실행한다.
        ///입력값 없음
        ///반환값 0 - 성공, 음수값은 실패
        ///비고
        ///로그인이 성공하거나 실패하는 경우 OnEventConnect 이벤트가 발생하고 이벤트의 인자값으로 로그인 성공 여부를 알 수 있다.
        ///웹서비스로는 실제 실행할일이 없음.. 엑티브엑스로 화면창이 뜨게 되어있음.
        /// </summary>
        public int CommConnect()
        {
            int ret = axKHOpenAPI.CommConnect();

            FileLog.PrintF("CommConnect():" + ret);
            return(ret);
        }
示例#3
0
        internal static Connect GetInstance(AxKHOpenAPI axAPI, StreamWriter writer)
        {
            if (API == null && axAPI.CommConnect() == 0)
            {
                API = new Connect(axAPI, writer);
            }

            return(API);
        }
示例#4
0
 public void LoginClick(object sender, EventArgs e)
 {
     if (axKHOpenAPI1.CommConnect() != 0)
     {
         control.Print("로그인 실패");
     }
     else
     {
         control.Print("로그인 시작");
     }
 }
示例#5
0
 public void Start()
 {
     if (axKHOpenAPI != null)
     {
         axKHOpenAPI.CommConnect();
     }
     else
     {
         string message = " axKHOpenAPI를 등록해주세요.";
         SendLogMessage(message);
     }
 }
示例#6
0
        //----------------------------------------------------------- Event  -----------------------------------------------------------

        //---------------------------------------------------------- Function ----------------------------------------------------------
        public bool openLoginDialog()
        {
            if (openApi.CommConnect() == 0)
            {
                Console.WriteLine("로그인창 열림");

                return(true);
            }

            Console.WriteLine("로그인창 안열림");

            return(false);
        }
示例#7
0
        public static void Init(AxKHOpenAPI api)
        {
            _api = api;

            _api.OnEventConnect      += AxKHOpenAPI1_OnEventConnect;
            _api.OnReceiveTrData     += AxKHOpenAPI1_OnReceiveTrData;
            _api.OnReceiveRealData   += AxKHOpenAPI1_OnReceiveRealData;
            _api.OnReceiveMsg        += AxKHOpenAPI1_OnReceiveMsg;
            _api.OnReceiveChejanData += AxKHOpenAPI1_OnReceiveChejanData;
            _api.CommConnect();

            _timer.Tick    += Timer_Tick;
            _timer.Interval = 200;
            _timer.Start();
            _beginTime = Time();
        }
示例#8
0
        public void StartProgress()
        {
            if (axAPI != null)
            {
                Error_code = axAPI.CommConnect();

                if (Error_code != 0)
                {
                    SendError?.Invoke(this, new Error(Error_code));

                    Box.Show("Connection Failed!!", "Caution", waiting);

                    SendExit?.Invoke(this, new ForceQuit(end));
                }
                return;
            }
            Box.Show("API Not Found!!", "Caution", waiting);

            SendExit?.Invoke(this, new ForceQuit(end));
        }
示例#9
0
 internal static Connect GetInstance(AxKHOpenAPI axAPI)
 {
     if (API == null && axAPI.CommConnect() == 0)
     {
         API          = new Connect(axAPI);
         HoldingStock = new Dictionary <string, Holding>();
         TR           = new HashSet <TR>()
         {
             new KOA_CREATE_FO_ORD {
                 API = axAPI
             },
             new KOA_NORMAL_FO_CANCEL {
                 API = axAPI
             },
             new KOA_NORMAL_FO_MOD {
                 API = axAPI
             },
             new KOA_NORMAL_SELL_KP_ORD {
                 API = axAPI
             },
             new KOA_NORMAL_SELL_KQ_ORD {
                 API = axAPI
             },
             new KOA_NORMAL_BUY_KP_ORD {
                 API = axAPI
             },
             new KOA_NORMAL_BUY_KQ_ORD {
                 API = axAPI
             }
         };
         Real = new HashSet <Real>()
         {
             new 주식체결 {
                 API = axAPI
             },
             new 주식호가잔량 {
                 API = axAPI
             },
             new 주식시세 {
                 API = axAPI
             },
             new 주식우선호가 {
                 API = axAPI
             },
             Chapter,
             new  물시세
             {
                 API = axAPI
             },
             new  물옵션우선호가
             {
                 API = axAPI
             },
             new  물호가잔량
             {
                 API = axAPI
             },
             new 옵션시세
             {
                 API = axAPI
             },
             new 옵션호가잔량
             {
                 API = axAPI
             }
         };
         Chejan = new Dictionary <string, Chejan>()
         {
             {
                 ((int)ChejanType.주문체결).ToString(),
                 new 주문체결 {
                     API = axAPI
                 }
             },
             {
                 ((int)ChejanType.잔고).ToString(),
                 new 잔고 {
                     API = axAPI
                 }
             },
             {
                 ((int)ChejanType.생잔고).ToString(),
                 new  생잔고 {
                     API = axAPI
                 }
             }
         };
     }
     return(API);
 }