Exemple #1
0
        private void Opt10015_OnReceived(string sRQName, DataTable dt, int sPreNext)
        {
            TaskCompletionSource <bool> tcs = null;

            tcs = new TaskCompletionSource <bool>();

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

            string stockCode    = "";
            string stdDate      = "";
            string maxDate      = "";
            string minDate      = "";
            string chainMaxDate = "";

            stockCode = ClsAxKH.RetStockCodeBysRqName(ClsAxKH.OptType.Opt10015, sRQName);
            stdDate   = ClsAxKH.RetStdDateBysRqName(ClsAxKH.OptType.Opt10015, sRQName);

            try
            {
                if (dt != null)
                {
                    maxDate = dt.Compute("max([일자])", string.Empty).ToString().Trim();
                    minDate = dt.Compute("min([일자])", string.Empty).ToString().Trim();

                    ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10015", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "", chainCompGb: "", chainMaxDate: "", chainMinDate: "");

                    var rows = _dtOptCalMagam.AsEnumerable().Where(Row => Row.Field <string>("STOCK_CODE") == stockCode);

                    foreach (DataRow dr2th in rows)
                    {
                        if (dr2th["CHAIN_COMP_GB"].ToString().Trim() == "Y")
                        {
                            chainMaxDate = dr2th["CHAIN_MAX_DATE"].ToString().Trim();
                        }
                    }
                }


                if (tcs == null || tcs.Task.IsCompleted)
                {
                    return;
                }

                if (dt != null)
                {
                    ArrayParam arrParam = new ArrayParam();
                    Sql        oSql     = new Sql(SDataAccess.ClsServerInfo.VADISSEVER, "KIWOOMDB");


                    foreach (DataRow dr in dt.Rows)
                    {
                        WriteTextSafe(stockCode + "(" + dr["일자"] + ")");

                        arrParam.Clear();
                        arrParam.Add("@ACTION_GB", "A");
                        arrParam.Add("@STOCK_CODE", stockCode);
                        arrParam.Add("@STOCK_DATE", dr["일자"].ToString());
                        arrParam.Add("@LAST_PRICE", dr["종가"]);
                        arrParam.Add("@OAGO_DAEBI_SYMBOL", dr["전일대비기호"]);
                        arrParam.Add("@OAGO_DAEBI", dr["전일대비"]);
                        arrParam.Add("@UPDOWN_RATE", dr["등락율"]);
                        arrParam.Add("@TRADE_QTY", dr["거래량"]);
                        arrParam.Add("@TRADE_DAEGUM", dr["거래대금"]);
                        arrParam.Add("@BETRADE_QTY", dr["장전거래량"]);
                        arrParam.Add("@BETRADE_BIJUNG", dr["장전거래비중"]);
                        arrParam.Add("@INTRADE_QTY", dr["장중거래량"]);
                        arrParam.Add("@INTRADE_BIJUNG", dr["장중거래비중"]);
                        arrParam.Add("@AFTRADE_QTY", dr["장후거래량"]);
                        arrParam.Add("@AFTRADE_BIJUNG", dr["장후거래비중"]);
                        arrParam.Add("@SUM3", dr["합계3"]);
                        arrParam.Add("@GITRADE_QTY", dr["기간중거래량"]);
                        arrParam.Add("@BETRADE_DAEGUM", dr["장전거래대금"]);
                        arrParam.Add("@BETRADE_DBIJUNG", dr["장전거래대금비중"]);
                        arrParam.Add("@INTRADE_DAEGUM", dr["장중거래대금"]);
                        arrParam.Add("@INTRADE_DBIJUNG", dr["장중거래대금비중"]);
                        arrParam.Add("@AFTRADE_DAEGUM", dr["장후거래대금"]);
                        arrParam.Add("@AFTRADE_DBIJUNG", dr["장후거래대금비중"]);
                        arrParam.Add("@DEUNG_DATE", "");
                        arrParam.Add("@DEUNG_TIME", "");
                        arrParam.Add("@R_ERRORCD", -1, SqlDbType.Int, ParameterDirection.InputOutput);

                        oSql.ExecuteNonQuery("p_Opt10015Add", CommandType.StoredProcedure, arrParam);

                        if (chainMaxDate != "")
                        {
                            if (chainMaxDate == dr["일자"].ToString().Trim())
                            {
                                ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10015", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "C", chainCompGb: "", chainMaxDate: "", chainMinDate: "");
                                _opt10015.Dispose();

                                tcs.SetResult(true);

                                WaitTime();

                                OnGetStockCode();

                                return;
                            }
                        }
                    }
                }

                // 최근 거래일 100일을 가져오는걸로 한다면
                if (chk100.Checked == true)
                {
                    ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10015", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "C", chainCompGb: "", chainMaxDate: "", chainMinDate: "");

                    _opt10015.Dispose();

                    tcs.SetResult(true);

                    OnGetStockCode();

                    return;
                }
                else
                {
                    if (sPreNext == 2)
                    {
                        tcs.SetResult(true);

                        ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10015", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "S", chainCompGb: "", chainMaxDate: "", chainMinDate: "");

                        WaitTime();

                        _opt10015.SetInit(_FormId);
                        _opt10015.JustRequest(StockCode: sRQNameArray[1].ToString().Trim(), StartDate: sRQNameArray[2].ToString().Trim(), StockName: "", nPrevNext: 2);

                        OPS10060.Text = ClsAxKH._limitCount.ToString();
                        lblTime.Text  = ClsAxKH._limitTime.ToString();

                        return;
                    }
                    else
                    {
                        if (dt != null)
                        {
                            ClsDbLogger.OptCallMagamStoredData(actionGb: "CE", optCaller: "OPT10015", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "C", chainCompGb: "", chainMaxDate: "", chainMinDate: minDate);
                        }
                        else
                        {
                            ClsDbLogger.OptCallMagamStoredData(actionGb: "EE", optCaller: "OPT10015", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "F", chainCompGb: "", chainMaxDate: "", chainMinDate: minDate);
                        }

                        _opt10015.Dispose();

                        tcs.SetResult(true);

                        OnGetStockCode();

                        return;
                    }
                }
            }

            catch (Exception ex)
            {
                _opt10015.Dispose();

                tcs.SetResult(true);

                OnGetStockCode();

                MessageBox.Show(ex.Message.ToString());
                throw;
            }
        }
        private void Opt10081_OnReceived(string sRQName, DataTable dt, int sPreNext)
        {
            TaskCompletionSource <bool> tcs = null;

            tcs = new TaskCompletionSource <bool>();

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

            string stockCode    = "";
            string stdDate      = "";
            string maxDate      = "";
            string minDate      = "";
            string chainMaxDate = "";

            stockCode = ClsAxKH.RetStockCodeBysRqName(ClsAxKH.OptType.Opt10081, sRQName);
            stdDate   = ClsAxKH.RetStdDateBysRqName(ClsAxKH.OptType.Opt10081, sRQName);

            try
            {
                if (dt != null)
                {
                    maxDate = dt.Compute("max([일자])", string.Empty).ToString().Trim();
                    minDate = dt.Compute("min([일자])", string.Empty).ToString().Trim();

                    ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10081", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "", chainCompGb: "", chainMaxDate: "", chainMinDate: "");

                    var rows = _dtOptCalMagam.AsEnumerable().Where(Row => Row.Field <string>("STOCK_CODE") == stockCode);

                    foreach (DataRow dr2th in rows)
                    {
                        if (dr2th["CHAIN_COMP_GB"].ToString().Trim() == "Y")
                        {
                            chainMaxDate = dr2th["CHAIN_MAX_DATE"].ToString().Trim();
                        }
                    }
                }


                if (tcs == null || tcs.Task.IsCompleted)
                {
                    return;
                }

                if (dt != null)
                {
                    ArrayParam arrParam = new ArrayParam();
                    Sql        oSql     = new Sql(SDataAccess.ClsServerInfo.VADISSEVER, "KIWOOMDB");


                    foreach (DataRow dr in dt.Rows)
                    {
                        WriteTextSafe(stockCode + "(" + dr["일자"] + ")");

                        arrParam.Clear();
                        arrParam.Add("@ACTION_GB", "A");
                        arrParam.Add("@STOCK_CODE", stockCode);
                        arrParam.Add("@STOCK_DATE", dr["일자"]);
                        arrParam.Add("@DATE_SEQNO", 0);
                        arrParam.Add("@NOW_PRICE", dr["현재가"]);
                        arrParam.Add("@TRADE_QTY", dr["거래량"]);
                        arrParam.Add("@TRADE_DAEGUM", dr["거래대금"]);
                        arrParam.Add("@START_PRICE", dr["시가"]);
                        arrParam.Add("@HIGH_PRICE", dr["고가"]);
                        arrParam.Add("@LOW_PRICE", dr["저가"]);
                        arrParam.Add("@CHG_JUGA_GB", dr["수정주가구분"]);
                        arrParam.Add("@CHG_RATE", dr["수정비율"]);
                        arrParam.Add("@CHG_JUGA_EVENT", dr["수정주가이벤트"]);
                        arrParam.Add("@R_ERRORCD", -1, SqlDbType.Int, ParameterDirection.InputOutput);

                        oSql.ExecuteNonQuery("p_Opt10081Add", CommandType.StoredProcedure, arrParam);

                        if (chainMaxDate != "")
                        {
                            if (chainMaxDate == dr["일자"].ToString().Trim())
                            {
                                ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10081", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "C", chainCompGb: "", chainMaxDate: "", chainMinDate: "");
                                _opt10081.Dispose();

                                WaitTime();

                                tcs.SetResult(true);

                                OnGetStockCode();

                                return;
                            }
                        }
                    }
                }
                else
                {
                    ClsDbLogger.OptCallMagamStoredData(actionGb: "EE", optCaller: "OPT10081", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "F", chainCompGb: "", chainMaxDate: "", chainMinDate: minDate);

                    _opt10081.Dispose();

                    WaitTime();

                    tcs.SetResult(true);

                    OnGetStockCode();

                    return;
                }

                // 최근 거래일 100일을 가져오는걸로 한다면
                if (chk100.Checked == true)
                {
                    ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10081", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "C", chainCompGb: "", chainMaxDate: "", chainMinDate: "");

                    _opt10081.Dispose();

                    WaitTime();

                    tcs.SetResult(true);

                    OnGetStockCode();

                    return;
                }
                else
                {
                    if (sPreNext == 2)
                    {
                        tcs.SetResult(true);

                        ClsDbLogger.OptCallMagamStoredData(actionGb: "A", optCaller: "OPT10081", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "S", chainCompGb: "", chainMaxDate: "", chainMinDate: "");

                        //_clsDataAccessUtil.Delay(3600);

                        WaitTime();

                        _opt10081.SetInit(_FormId);
                        _opt10081.JustRequest(StockCode: sRQNameArray[1].ToString().Trim(), StockName: "", StdDate: sRQNameArray[2].ToString().Trim(), ModifyJugaGb: sRQNameArray[3].ToString().Trim(), nPrevNext: 2);
                    }
                    else
                    {
                        if (dt != null)
                        {
                            ClsDbLogger.OptCallMagamStoredData(actionGb: "CE", optCaller: "OPT10081", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "C", chainCompGb: "", chainMaxDate: "", chainMinDate: minDate);
                        }
                        else
                        {
                            ClsDbLogger.OptCallMagamStoredData(actionGb: "EE", optCaller: "OPT10081", stockCode: stockCode, stdDate: stdDate, maxDate: maxDate, minDate: minDate, jobIngGb: "F", chainCompGb: "", chainMaxDate: "", chainMinDate: minDate);
                        }

                        _opt10081.Dispose();

                        WaitTime();

                        tcs.SetResult(true);

                        OnGetStockCode();
                        return;
                    }
                }
            }

            catch (Exception ex)
            {
                _opt10081.Dispose();

                tcs.SetResult(true);

                OnGetStockCode();
                WaitTime();
                MessageBox.Show(ex.Message.ToString());
                throw;
            }
        }