private DbDataReader GetOrderItems(bool tradeOnly, EMarketType market)
        {
            string sql = null;
            char mt = this.GetMarketType(market);

            if (tradeOnly)
            {
                if (market == EMarketType.ALL)
                {
                    if (this.Date.Date == System.DateTime.Now.Date)
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' AND CjNum > 0 ORDER BY CrtDate", this.DateName);
                    else
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable_his WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' AND CjNum > 0 ORDER BY CrtDate", this.DateName);
                }
                else
                {
                    if (this.Date.Date == System.DateTime.Now.Date)
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' AND CjNum > 0 AND {1} = '{2}' ORDER BY CrtDate", this.DateName, OrderRow_LH.C_sc, mt);
                    else
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable_his WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' AND CjNum > 0 AND {1} = '{2}' ORDER BY CrtDate", this.DateName, OrderRow_LH.C_sc, mt);
                }
            }
            else
            {
                if (market == EMarketType.ALL)
                {
                    if (this.Date.Date == System.DateTime.Now.Date)
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' ORDER BY CrtDate", this.DateName);
                    else
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable_his WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' ORDER BY CrtDate", this.DateName);
                }
                else
                {
                    if (this.Date.Date == System.DateTime.Now.Date)
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' AND {1} = '{2}' ORDER BY CrtDate", this.DateName, OrderRow_LH.C_sc, mt);
                    else
                        sql = string.Format("SELECT * FROM dbo.tb_OrderTable_his WHERE SUBSTRING(CONVERT(CHAR(10), CrtDate, 112), 1, 8) = '{0}' AND {1} = '{2}' ORDER BY CrtDate", this.DateName, OrderRow_LH.C_sc, mt);
                }
            }

            return this.ExecuteReader(sql);
        }
 private char GetMarketType(EMarketType type)
 {
     switch (type)
     {
         case EMarketType.SH:
             return '1';
         case EMarketType.SZ:
             return '2';
         case EMarketType.JJ:
             return '7';
         default:
             return '\0';
     }
 }
        internal List<TradeInfo_O32> GetTradeItems(string secutityId, EMarketType market)
        {
            List<TradeInfo_O32> dataList = new List<TradeInfo_O32>();
            if (string.IsNullOrEmpty(secutityId))
                return dataList;

            List<TradeInfo_O32> datas = this.GetTradeItems(market);
            dataList = datas.Where(o => o.VC_REPORT_CODE == secutityId).ToList();

            return dataList;
        }
        //internal static EEntrustType GetEntrustType(TradeInfo_O32 o)
        //{
        //    switch (o.C_ENTRUST_DIRECTION)
        //    {
        //        case 'X':
        //            return EEntrustType.卖出开仓;
        //        case 'Y':
        //            return EEntrustType.买入平仓;
        //        case 'V':
        //            return EEntrustType.买入开仓;
        //        case 'W':
        //            return EEntrustType.卖出平仓;
        //        default:
        //            if (o.VC_REPORT_DIRECTION == "B" || o.VC_REPORT_DIRECTION == "0B")
        //                return EEntrustType.买入;
        //            else
        //                return EEntrustType.卖出;
        //    }
        //}

        //public EEntrustType GetEntrustType(TradeInfo_O32 row)
        //{
        //    EEntrustType type = EEntrustType.无;
        //    switch (row.C_ENTRUST_DIRECTION)
        //    {
        //        case '0':
        //            type = EEntrustType.议案投票;
        //            break;
        //        case '1':
        //            type = EEntrustType.买入;
        //            break;
        //        case '2':
        //            type = EEntrustType.卖出;
        //            break;
        //        case '3':
        //            type = EEntrustType.债券买入;
        //            break;
        //        case '4':
        //            type = EEntrustType.债券卖出;
        //            break;
        //        case '5':
        //            type = EEntrustType.融资回购_折入;
        //            break;
        //        case '6':
        //            type = EEntrustType.融券回购_折出;
        //            break;
        //        case '7':
        //            type = EEntrustType.融资购回;
        //            break;
        //        case '8':
        //            type = EEntrustType.融券购回;
        //            break;
        //        case '9':
        //            type = EEntrustType.配股认购;
        //            break;
        //        case 'A':
        //            type = EEntrustType.转股;
        //            break;
        //        case 'B':
        //            type = EEntrustType.回售;
        //            break;
        //        case 'C':
        //            type = EEntrustType.申购;
        //            break;
        //        case 'D':
        //            type = EEntrustType.基金认购;
        //            break;
        //        case 'E':
        //            type = EEntrustType.基金转换;
        //            break;
        //        case 'F':
        //            type = EEntrustType.存款;
        //            break;
        //        case 'G':
        //            type = EEntrustType.转托管;
        //            break;
        //        case 'H':
        //            type = EEntrustType.指定交易;
        //            break;
        //        case 'I':
        //            type = EEntrustType.撤销指定;
        //            break;
        //        case 'J':
        //            type = EEntrustType.承销买入;
        //            break;
        //        case 'K':
        //            type = EEntrustType.分销买入;
        //            break;
        //        case 'L':
        //            type = EEntrustType.分销卖出;
        //            break;
        //        case 'M':
        //            break;
        //        case 'N':
        //            type = EEntrustType.债券投标;
        //            break;
        //        case 'O':
        //            type = EEntrustType.预受要约;
        //            break;
        //        case 'P':
        //            type = EEntrustType.ETF基金申购;
        //            break;
        //        case 'Q':
        //            type = EEntrustType.ETF基金赎回;
        //            break;
        //        case 'R':
        //            type = EEntrustType.行权认购;
        //            break;
        //        case 'S':
        //            type = EEntrustType.行权认沽;
        //            break;
        //        case 'T':
        //            type = EEntrustType.提交质押;
        //            break;
        //        case 'U':
        //            type = EEntrustType.转回质押;
        //            break;
        //        case 'V':
        //            type = EEntrustType.买入开仓;
        //            break;
        //        case 'W':
        //            type = EEntrustType.卖出平仓;
        //            break;
        //        case 'X':
        //            type = EEntrustType.卖出开仓;
        //            break;
        //        case 'Y':
        //            type = EEntrustType.买入平仓;
        //            break;
        //        case 'Z':
        //            type = EEntrustType.盈亏结转;
        //            break;
        //        case 'a':
        //            type = EEntrustType.项目投资;
        //            break;
        //        case 'b':
        //            type = EEntrustType.预受要约撤销;
        //            break;
        //        case 'c':
        //            type = EEntrustType.债券远期买入;
        //            break;
        //        case 'd':
        //            type = EEntrustType.债券远期卖出;
        //            break;
        //        case 'e':
        //            break;
        //        case 'f':
        //            break;
        //        case 'g':
        //            type = EEntrustType.跨市场转托管;
        //            break;
        //        case 'h':
        //            break;
        //        case 'i':
        //            type = EEntrustType.存款支取;
        //            break;
        //        case 'j':
        //            break;
        //        case 'k':
        //            break;
        //        case 'l':
        //            break;
        //        case 'm':
        //            type = EEntrustType.基金分拆;
        //            break;
        //        case 'n':
        //            type = EEntrustType.基金合并;
        //            break;
        //        case 'o':
        //            type = EEntrustType.基金冲账;
        //            break;
        //        case 'p':
        //            type = EEntrustType.开基申购;
        //            break;
        //        case 'q':
        //            type = EEntrustType.开基赎回;
        //            break;
        //        case 'r':
        //            type = EEntrustType.认购;
        //            break;
        //        case 's':
        //            type = EEntrustType.约定购回;
        //            break;
        //        case 't':
        //            break;
        //        case 'u':
        //            break;
        //        case 'v':
        //            break;
        //        case 'w':
        //            break;
        //        case 'x':
        //            break;
        //        case 'y':
        //            break;
        //        case 'z':
        //            type = EEntrustType.分红设置;
        //            break;
        //        case '(':
        //            type = EEntrustType.担保券交存;
        //            break;
        //        case ')':
        //            type = EEntrustType.担保券提取;
        //            break;
        //        case '{':
        //            type = EEntrustType.融资买入;
        //            break;
        //        case '}':
        //            type = EEntrustType.卖券还款;
        //            break;
        //        case '[':
        //            type = EEntrustType.融券卖出;
        //            break;
        //        case ']':
        //            type = EEntrustType.买券还券;
        //            break;
        //        case '!':
        //            type = EEntrustType.无;
        //            break;
        //        case '+':
        //            type = EEntrustType.债券融出到期;
        //            break;
        //        case '-':
        //            type = EEntrustType.债券融出;
        //            break;
        //        case '*':
        //            type = EEntrustType.债券融入到期;
        //            break;
        //        case '~':
        //            type = EEntrustType.直接还券;
        //            break;
        //        case '?':
        //            type = EEntrustType.债券融入;
        //            break;
        //        case '`':
        //            type = EEntrustType.直接还款;
        //            break;
        //        default:
        //            break;
        //    }

        //    return type;
        //}

        #endregion

        /// <summary>
        /// 获取当前表中的所有数据。
        /// </summary>
        internal List<TradeInfo_O32> GetTradeItems(EMarketType type)
        {
            List<TradeInfo_O32> datas = new List<TradeInfo_O32>();
            char mt = this.GetMarketType(type);

            //DateTime startTime = System.DateTime.Now;
            using (DbDataReader reader = this.GetTradeInfos())
            {
                while (reader.Read())
                {
                    TradeInfo_O32 row = this.GetTradeInfo(reader);

                    if (type == EMarketType.ALL)
                    {
                        datas.Add(row);
                    }
                    else
                    {
                        if (row.C_MARKET_NO == mt)
                            datas.Add(row);
                    }
                }
            }

            //TimeSpan span = DateTime.Now - startTime;
            //Trace.WriteLine("");
            //Trace.WriteLine("#### EMarketType = " + type.ToString());
            //Trace.WriteLine("#### 时间间隔    = " + span.ToString());
            //Trace.WriteLine("");

            return datas;
        }
        /// <summary>
        /// 获取当天所有给定证券代码的数据。
        /// </summary>
        public List<OrderRow_LH> GetTradeItems(string securityId, EMarketType type)
        {
            int index = securityId.IndexOf('.');
            if (index > 0)
                securityId = securityId.Substring(0, index);

            if (this.ImportState == EImportStatus.Init)
                this.SyncImportState2Local();

            List<OrderRow_LH> dataList = new List<OrderRow_LH>();
            if (this.ImportState == EImportStatus.NotDetected)
                return dataList;

            using (DbDataReader reader = this.GetOrderItems(true, type))
            {
                while (reader.Read())
                {
                    OrderRow_LH row = this.GetOrderRow_LH(reader);
                    if (row.zqdm == securityId)
                        dataList.Add(this.GetOrderRow_LH(reader));
                }
            }

            return dataList;
        }
        public List<OrderRow_LH> GetTradeItems(EMarketType type)
        {
            List<OrderRow_LH> list = new List<OrderRow_LH>();

            using (DbDataReader reader = this.GetOrderItems(true, type))
            {
                while (reader.Read())
                {
                    list.Add(this.GetOrderRow_LH(reader));
                }
            }
            this.Close();

            return list;
        }