예제 #1
0
        public static void AxKH_OnReceiveTrData(object sender, AxKHOpenAPILib._DKHOpenAPIEvents_OnReceiveTrDataEvent e)
        {
            //  StopTimer();

            DataTable dt = new DataTable();
            object    handler;
            int       nCnt = 0;

            nCnt = ClsAxKH.AxKH.GetRepeatCnt(e.sTrCode, e.sRQName);

            ClsUtil clsUtil = new ClsUtil();

            //stockCode = clsUtil.Mid(e.sRQName, 1, 6);
            //sRQName = e.sRQName.ToString().Replace(stockCode + "_", "");

            string[] sRQNameArray = e.sRQName.ToString().Trim().Split(',');

            ClsDbLogger.StoreLogger(loggergb: ClsDbLogger.LoggerGb.RecieveLoger, optCallNo: "AxKH_OnReceiveTrData", transText: e.sTrCode.ToString().Trim() + "@" + e.sRQName.ToString().Trim());

            switch (sRQNameArray[0].ToString().Trim())
            {
            case "주식기본정보요청":

                try
                {
                    using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                    {
                        foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column10001Index)))
                        {
                            int j = 0;
                            j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column10001Index), i));
                            dt.Columns.Add(oBasicDataType.GetDataColumn10001((ClsColumnSets.ColumnNameIndex)j));
                        }
                    };

                    handler = AxKH_10001_OnReceived;

                    DataRow dr2th = dt.NewRow();
                    for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                    {
                        var type = dt.Columns[intColumName].DataType;

                        dr2th[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, 0, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                    }

                    dt.Rows.Add(dr2th);

                    if (handler != null)
                    {
                        if (Convert.ToInt32(e.sPrevNext) != 2)
                        {
                            //_OptStatus.InitOptCallingStatus();
                        }
                        //AxKH_10081_OnReceived(e.sTrCode, dt, Convert.ToInt32(e.sPrevNext));
                        AxKH_10001_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                        return;
                    }

                    break;
                }
                catch (Exception)
                {
                    AxKH_10001_OnReceived(e.sRQName.ToString().Trim(), null, Convert.ToInt32(e.sPrevNext));
                    throw;
                }

            case "주식일주월시분요청":
                using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                {
                    foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column10005Index)))
                    {
                        int j = 0;
                        j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column10005Index), i));
                        dt.Columns.Add(oBasicDataType.GetDataColumn10001((ClsColumnSets.ColumnNameIndex)j));
                    }
                };

                handler = AxKH_10005_OnReceived;


                if (nCnt == 0)
                {
                    if (handler != null)
                    {
                        //_OptStatus.InitOptCallingStatus();
                        AxKH_10005_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                        return;
                    }
                }

                for (int i = 0; i < nCnt; i++)
                {
                    DataRow dr = dt.NewRow();
                    for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                    {
                        var type = dt.Columns[intColumName].DataType;
                        dr[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, i, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                    }

                    dt.Rows.Add(dr);
                }

                if (handler != null)
                {
                    if (Convert.ToInt32(e.sPrevNext) != 2)
                    {
                        //_OptStatus.InitOptCallingStatus();
                    }

                    AxKH_10005_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                    return;
                }


                break;

            case "일별거래상세요청":
                using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                {
                    foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column10015Index)))
                    {
                        int j = 0;
                        j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column10015Index), i));
                        dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)j));
                    }
                };

                handler = AxKH_10015_OnReceived;

                if (nCnt == 0)
                {
                    if (handler != null)
                    {
                        //_OptStatus.InitOptCallingStatus();
                        AxKH_10015_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                        return;
                    }
                }

                for (int i = 0; i < nCnt; i++)
                {
                    DataRow dr = dt.NewRow();
                    for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                    {
                        var type = dt.Columns[intColumName].DataType;
                        dr[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, i, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                    }

                    dt.Rows.Add(dr);
                }

                if (handler != null)
                {
                    if (Convert.ToInt32(e.sPrevNext) != 2)
                    {
                        //_OptStatus.InitOptCallingStatus();
                    }
                    //AxKH_10015_OnReceived(e.sTrCode, dt, Convert.ToInt32(e.sPrevNext));
                    AxKH_10015_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                    return;
                }

                break;


            case "공매도추이요청 ":
                using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                {
                    foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column10014Index)))
                    {
                        int j = 0;
                        j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column10014Index), i));
                        dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)j));
                    }
                };
                handler = AxKH_10014_OnReceived;

                if (nCnt == 0)
                {
                    if (handler != null)
                    {
                        //_OptStatus.InitOptCallingStatus();
                        AxKH_10014_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                        return;
                    }
                }

                for (int i = 0; i < nCnt; i++)
                {
                    DataRow dr = dt.NewRow();
                    for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                    {
                        var type = dt.Columns[intColumName].DataType;
                        dr[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, i, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                    }

                    dt.Rows.Add(dr);
                }

                if (handler != null)
                {
                    if (Convert.ToInt32(e.sPrevNext) != 2)
                    {
                        //_OptStatus.InitOptCallingStatus();
                    }

                    AxKH_10014_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                    return;
                }

                break;

            case "주식일봉차트조회":
                using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                {
                    foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column10081Index)))
                    {
                        int j = 0;
                        j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column10081Index), i));
                        dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)j));
                    }
                };

                handler = AxKH_10081_OnReceived;

                if (nCnt == 0)
                {
                    if (handler != null)
                    {
                        //_OptStatus.InitOptCallingStatus();
                        AxKH_10081_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                        return;
                    }
                }

                for (int i = 0; i < nCnt; i++)
                {
                    DataRow dr = dt.NewRow();
                    for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                    {
                        var type = dt.Columns[intColumName].DataType;
                        dr[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, i, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                    }

                    dt.Rows.Add(dr);
                }

                if (handler != null)
                {
                    if (Convert.ToInt32(e.sPrevNext) != 2)
                    {
                        //_OptStatus.InitOptCallingStatus();
                    }
                    //AxKH_10081_OnReceived(e.sTrCode, dt, Convert.ToInt32(e.sPrevNext));
                    AxKH_10081_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                    return;
                }

                break;

            case "종목별투자자기관별차트요청":
                try
                {
                    using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                    {
                        foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column10060Index)))
                        {
                            int j = 0;
                            j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column10060Index), i));
                            // _dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)i));
                            dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)j));
                        }
                    };

                    handler = AxKH_10060_OnReceived;

                    if (nCnt == 0)
                    {
                        if (handler != null)
                        {
                            //_OptStatus.InitOptCallingStatus();
                            AxKH_10060_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                            return;
                        }
                    }

                    for (int i = 0; i < nCnt; i++)
                    {
                        DataRow dr = dt.NewRow();
                        for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                        {
                            var type = dt.Columns[intColumName].DataType;
                            dr[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, i, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                        }

                        dt.Rows.Add(dr);
                    }

                    if (handler != null)
                    {
                        if (Convert.ToInt32(e.sPrevNext) != 2)
                        {
                            //_OptStatus.InitOptCallingStatus();
                        }

                        AxKH_10060_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                        return;
                    }
                    else
                    {
                        AxKH_10060_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                        return;
                    }
                }
                catch (Exception)
                {
                    AxKH_10060_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                    break;
                    throw;
                }



            case "대차거래추이요청(종목별)":
                using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                {
                    foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column20068Index)))
                    {
                        int j = 0;
                        j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column20068Index), i));
                        // _dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)i));
                        dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)j));
                    }
                };
                handler = AxKH_20068_OnReceived;

                if (nCnt == 0)
                {
                    if (handler != null)
                    {
                        //_OptStatus.InitOptCallingStatus();
                        AxKH_20068_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                        return;
                    }
                }

                for (int i = 0; i < nCnt; i++)
                {
                    DataRow dr = dt.NewRow();
                    for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                    {
                        var type = dt.Columns[intColumName].DataType;
                        dr[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, i, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                    }

                    dt.Rows.Add(dr);
                }

                if (handler != null)
                {
                    if (Convert.ToInt32(e.sPrevNext) != 2)
                    {
                        //_OptStatus.InitOptCallingStatus();
                    }

                    AxKH_20068_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                    return;
                }

                break;

            case "테마그룹별요청":
                using (ClsColumnSets oBasicDataType = new ClsColumnSets())
                {
                    foreach (int i in Enum.GetValues(typeof(ClsColumnSets.Column90002Index)))
                    {
                        int j = 0;
                        j = (int)Enum.Parse(typeof(ClsColumnSets.ColumnNameIndex), Enum.GetName(typeof(ClsColumnSets.Column90002Index), i));
                        // _dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)i));
                        dt.Columns.Add(oBasicDataType.GetDataColumn((ClsColumnSets.ColumnNameIndex)j));
                    }
                };
                handler = AxKH_90002_OnReceived;

                if (nCnt == 0)
                {
                    if (handler != null)
                    {
                        //_OptStatus.InitOptCallingStatus();
                        AxKH_90002_OnReceived(e.sRQName.ToString().Trim(), null, 0);
                        return;
                    }
                }

                for (int i = 0; i < nCnt; i++)
                {
                    DataRow dr = dt.NewRow();
                    for (int intColumName = 0; intColumName < dt.Columns.Count; intColumName++)
                    {
                        var type = dt.Columns[intColumName].DataType;
                        dr[dt.Columns[intColumName].ColumnName.ToString()] = Convert.ChangeType(ClsAxKH.AxKH.GetCommData(e.sTrCode, e.sRQName, i, dt.Columns[intColumName].ColumnName.ToString()).ToString().Trim(), type);
                    }

                    dt.Rows.Add(dr);
                }

                if (handler != null)
                {
                    if (Convert.ToInt32(e.sPrevNext) != 2)
                    {
                        //_OptStatus.InitOptCallingStatus();
                    }

                    AxKH_90002_OnReceived(e.sRQName.ToString().Trim(), dt, Convert.ToInt32(e.sPrevNext));
                    return;
                }

                break;

            default:
                return;
            }
        }
예제 #2
0
        public static void SendCommRqData(OptType optType, ArrayList optCall, string sRQName, string sTrCode, int nPrevNext, string sScreenNo)
        {
            lock (lockObject)
            {
                string stockCode = "";

                ArrayList arrlist = new ArrayList();
                arrlist.Add(sRQName);
                arrlist.Add(sTrCode);
                arrlist.Add(nPrevNext);
                arrlist.Add(sScreenNo);

                AxKHQueueList.Enqueue(arrlist);

                ArrayList item;

                AxKHQueueList.TryDequeue(out item);

                string sRQNameSet = "";

                switch (optType)
                {
                case OptType.Opt10001:
                    //_stockCode10001 = "";

                    //_stockCode10001 = optCall[0].ToString();
                    stockCode = optCall[0].ToString();
                    Opt10001(stockCode: optCall[0].ToString());

                    break;

                case OptType.Opt10005:
                    //_stockCode10005 = "";

                    //_stockCode10005 = optCall[0].ToString();

                    stockCode = optCall[0].ToString();
                    Opt10005(stockCode: optCall[0].ToString());
                    break;

                case OptType.Opt10015:
                    //_stockCode10015 = "";

                    //_stockCode10015 = optCall[0].ToString();
                    stockCode = optCall[0].ToString();
                    Opt10015(stockCode: optCall[0].ToString(), startDate: optCall[1].ToString());
                    break;

                case OptType.Opt10081:
                    //_stockCode10081 = "";

                    //_stockCode10081 = optCall[0].ToString();
                    stockCode = optCall[0].ToString();
                    Opt10081(stockCode: optCall[0].ToString(), stdDate: optCall[1].ToString(), modifyJugaGb: optCall[2].ToString());
                    break;

                case OptType.Opt10086:
                    // _stockCode10086 = "";

                    //_stockCode10086 = optCall[0].ToString();
                    stockCode = optCall[0].ToString();
                    Opt10086(stockCode: optCall[0].ToString(), stdDate: optCall[1].ToString(), displayGb: optCall[2].ToString());
                    break;

                case OptType.Opt10060:
                    // _stockCode10060 = "";
                    //_stockCode10060 = optCall[1].ToString();
                    stockCode = optCall[1].ToString();
                    Opt10060(startDate: optCall[0].ToString(), stockCode: optCall[1].ToString(), amountQtyGb: optCall[2].ToString(), maeMaeGb: optCall[3].ToString(), unitGb: optCall[4].ToString());
                    break;

                case OptType.Opt20068:
                    //_stockCode20068 = "";
                    //_stockCode20068 = optCall[3].ToString();
                    stockCode = optCall[3].ToString();
                    Opt20068(startDate: optCall[0].ToString(), endDate: optCall[1].ToString(), allGb: optCall[2].ToString(), stockCode: optCall[3].ToString());
                    break;

                case OptType.Opt90002:
                    //_kthCode90002 = "";
                    //_kthCode90002 = optCall[1].ToString();
                    stockCode = optCall[1].ToString();
                    Opt90002(dateGb: optCall[0].ToString(), kthCode: optCall[1].ToString());
                    break;

                default:
                    return;
                }

                for (int i = 0; i < optCall.Count; i++)
                {
                    if (sRQNameSet == "")
                    {
                        sRQNameSet = optCall[i].ToString();
                    }
                    else
                    {
                        sRQNameSet = sRQNameSet + "," + optCall[i].ToString();
                    }
                }

                ClsDbLogger.StoreLogger(loggergb: ClsDbLogger.LoggerGb.SendLoger, optCallNo: item[0].ToString() + " : " + "SetInputValue", transText: sRQNameSet);

                string sCommRqData = "";

                for (int i = 0; i < item.Count; i++)
                {
                    if (sCommRqData == "")
                    {
                        sCommRqData = item[i].ToString();
                    }
                    else
                    {
                        sCommRqData = sCommRqData + "," + item[i].ToString();
                    }
                }

                if (SPEED_CALL == true)
                {
                    SpeedSpendTime();
                }
                else
                {
                    RegularSpandTime();
                }

                ClsDbLogger.StoreLogger(loggergb: ClsDbLogger.LoggerGb.SendLoger, optCallNo: item[0].ToString() + " : " + "CommRqData", transText: sRQNameSet + "@" + sCommRqData);

                int nRet = AxKH.CommRqData(sRQName: item[0].ToString() + "," + sRQNameSet, sTrCode: item[1].ToString(), nPrevNext: Convert.ToInt32(item[2]), sScreenNo: item[3].ToString());

                //_CallOptTime = DateTime.Now;

                SendsRQName = item[0].ToString() + "," + sRQNameSet;

                //if (aTimer.Enabled == false)
                //{
                //    // StartTimer();
                //}

                if (ClsWoomErrorCode.GetErrorMessage(nRet) == true)
                {
                    //   Logger(Log.일반, "[OPT10081] : " + lsWoomErrorCode.GetErrorMessage());
                }
                else
                {
                    string erroText = ClsWoomErrorCode.GetErrorMessage();
                    ClsDbLogger.StoreLogger(loggergb: ClsDbLogger.LoggerGb.ErrorLoger, optCallNo: item[0].ToString(), transText: erroText);

                    // Logger(Log.에러, "[OPT10081] : " + Error.GetErrorMessage());
                }
            }
        }