/// <summary>
        /// 进行持仓检查,对已经过期的合约按昨日结算价进行强制平仓
        /// </summary>
        private void CheckHoldTable()
        {
            //LogHelper.WriteDebug("FutureDayChecker.CheckHoldTable开始检查持仓表");

            OrderAccepter          orderAccepter = OrderAccepterService.Service;
            QH_HoldAccountTableDal dal           = new QH_HoldAccountTableDal();

            string where = string.Format("UserAccountDistributeLogo = '{0}'", holdAccount.UserAccountDistributeLogo);
            List <QH_HoldAccountTableInfo> listCheck = dal.GetListArray(where);

            // DataRepository.QhHoldAccountTableProvider.GetByUserAccountDistributeLogo(
            //     holdAccount.UserAccountDistributeLogo);

            if (Utils.IsNullOrEmpty(listCheck))
            {
                return;
            }

            decimal price = 0;
            List <QH_HoldAccountTableInfo> list = new List <QH_HoldAccountTableInfo>();

            //这里是要分开处理,已经是过期的合约前面就已经强行平仓掉就没有后面的持仓限制和最小单位整数倍的判断
            foreach (var holdTable in listCheck)
            {
                //如果不是交易日,不进行强行平仓 add by 董鹏 2010-05-05
                if (!CommonParaProxy.GetInstance().IsTradeDate(holdTable.Contract))
                {
                    continue;
                }
                if (MCService.IsExpireLastedTradeDate(holdTable.Contract))
                {
                    //在最后交易日 进行平仓
                    //string msg = "";
                    //bool canGetPrice = MCService.GetFutureYesterdayPreSettlementPrice(holdTable.Contract, out price,
                    //                                                                  ref msg);
                    //if (!canGetPrice)
                    //{
                    //    string format = "FutureDayChecker.CheckHoldTable无法获取合约{0}的昨日收盘结算价,错误信息:{1}";
                    //    string msg2 = string.Format(format, holdTable.Contract, msg);
                    //    LogHelper.WriteDebug(msg2);
                    //    continue;
                    //}

                    //每天清算后,持仓均价就是结算价
                    price = holdTable.HoldAveragePrice;

                    #region  账户类型进行商品期货、股指期货平仓 add by 董鹏 2010-02-03
                    UA_UserAccountAllocationTableDal accDal = new UA_UserAccountAllocationTableDal();
                    var acc = accDal.GetModel(holdTable.UserAccountDistributeLogo);
                    if (acc.AccountTypeLogo == (int)Types.AccountType.CommodityFuturesHoldCode)
                    {
                        //此处原来只有HistoryHoldAmount,造成未清算成功的持仓平不掉,因此加上TodayHoldAmount;
                        //而TodayFreezeAmount清算是否成功都没有影响 -- update by 董鹏 2010-03-29
                        //CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)(holdTable.HistoryHoldAmount + holdTable.TodayHoldAmount), Types.QHForcedCloseType.Expired);
                        //平历史
                        CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)holdTable.HistoryHoldAmount, Types.QHForcedCloseType.Expired, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                        //平今
                        CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)holdTable.TodayHoldAmount, Types.QHForcedCloseType.Expired, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.CloseTodayPosition);
                    }
                    if (acc.AccountTypeLogo == (int)Types.AccountType.StockFuturesHoldCode)
                    {
                        CloseStockIndexContract(orderAccepter, holdTable, (float)price, true);
                    }
                    #endregion
                    //CloseStockIndexContract(orderAccepter, holdTable, (float)price, true);
                }
                else
                {
                    list.Add(holdTable);
                }
            }


            #region 商品期货进行持仓限制、最小交割单位整数倍检验,并平仓超出量 add by 董鹏 2010-02-04
            if (holdAccount.AccountTypeLogo == (int)Types.AccountType.CommodityFuturesHoldCode)
            {
                LogHelper.WriteDebug("---->商品期货持仓限制、最小小交割单位整数倍验证,UserAccountDistributeLogo=" + holdAccount.UserAccountDistributeLogo);
                List <QH_HoldAccountTableInfo> listCloseContract;

                price = 0;

                //记录超出持仓限制的量:<持仓记录主键,超出量>
                Dictionary <int, decimal> dicAmount;
                // 超过最大持仓限制
                listCloseContract = FindWillClosedContractOverMaxHoldLimit(list, out dicAmount);
                foreach (var holdTable in listCloseContract)
                {
                    CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)dicAmount[holdTable.AccountHoldLogoId], Types.QHForcedCloseType.OverHoldLimit, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                    //进行了持仓限制平仓的不再进行最小交割单位验证,下次持仓检查的时候才进行。
                    list.Remove(holdTable);
                }
                //超出最小交割量整数倍
                listCloseContract = FindWillClosedContractNotModMinUnitLimit(list, out dicAmount);
                foreach (var holdTable in listCloseContract)
                {
                    CloseCommoditiesContract(orderAccepter, holdTable, (float)price, (float)dicAmount[holdTable.AccountHoldLogoId], Types.QHForcedCloseType.NotModMinUnit, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                }
            }
            #endregion
            //LogHelper.WriteDebug("FutureDayChecker.CheckHoldTable结束检查持仓表");
        }
        /// <summary>
        /// 检查资金表,可用资金小于0的走资金强行平仓流程
        /// </summary>
        private void CheckCapitalTable(object state)
        {
            //LogHelper.WriteDebug("FutureDayChecker.CheckFundTable开始检查资金表");
            QH_CapitalAccountTableDal dal = new QH_CapitalAccountTableDal();

            //TList<QhCapitalAccountTable> list =
            //  DataRepository.QhCapitalAccountTableProvider.GetByUserAccountDistributeLogo(
            //      capitalAccount.UserAccountDistributeLogo);
            string where = string.Format("UserAccountDistributeLogo = '{0}' ", capitalAccount.UserAccountDistributeLogo);
            List <QH_CapitalAccountTableInfo> list = dal.GetListArray(where);

            if (Utils.IsNullOrEmpty(list))
            {
                return;
            }

            foreach (QH_CapitalAccountTableInfo accountTable in list)
            {
                //if (accountTable.AvailableCapital<0.00m)
                //    continue;

                List <QH_HoldAccountTableInfo> listCloseContract;
                OrderAccepter orderAccepter = OrderAccepterService.Service;

                if (accountTable.AvailableCapital < 0)
                {
                    if (accountTable.TradeCurrencyType < 0.00m)
                    {
                        continue;
                    }

                    List <QH_HoldAccountTableInfo> list2 = GetHoldAccountTableList(holdAccount.UserAccountDistributeLogo, accountTable.TradeCurrencyType);
                    if (Utils.IsNullOrEmpty(list2))
                    {
                        continue;
                    }

                    listCloseContract = FindWillCLosedContract(list2);

                    foreach (var holdTable in listCloseContract)
                    {
                        //如果不是交易日,不进行强行平仓 add by 董鹏 2010-05-05
                        if (!CommonParaProxy.GetInstance().IsTradeDate(holdTable.Contract))
                        {
                            continue;
                        }

                        //CloseStockIndexContract(orderAccepter, holdTable, 0, false);
                        #region  账户类型进行商品期货、股指期货平仓 add by 董鹏 2010-02-03
                        if (holdAccount.AccountTypeLogo == (int)Types.AccountType.CommodityFuturesHoldCode)
                        {
                            //此处原来只有HistoryHoldAmount,造成未清算成功的持仓平不掉,因此加上TodayHoldAmount;
                            //而TodayFreezeAmount清算是否成功都没有影响 -- update by 董鹏 2010-03-29
                            //平历史
                            CloseCommoditiesContract(orderAccepter, holdTable, 0, (float)holdTable.HistoryHoldAmount, Types.QHForcedCloseType.CapitalCheck, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.ClosePosition);
                            //平今
                            CloseCommoditiesContract(orderAccepter, holdTable, 0, (float)holdTable.TodayHoldAmount, Types.QHForcedCloseType.CapitalCheck, ReckoningCounter.Entity.Contants.Types.FutureOpenCloseType.CloseTodayPosition);
                        }
                        if (holdAccount.AccountTypeLogo == (int)Types.AccountType.StockFuturesHoldCode)
                        {
                            CloseStockIndexContract(orderAccepter, holdTable, (float)holdTable.HoldAveragePrice, false);
                        }
                        #endregion
                    }
                }
            }

            //LogHelper.WriteDebug("FutureDayChecker.CheckFundTable结束检查资金表");
        }