private void LoadGZQHOrderFromDB()
        {
            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
            string format = "OrderStatusId = '{0}'";

            string where = string.Format(format, (int)Entity.Contants.Types.OrderStateType.DOSUnRequired);
            List <QH_TodayEntrustTableInfo> list = null;

            try
            {
                list = dal.GetListArray(where);
                //list = DataRepository.QhTodayEntrustTableProvider.Find(where);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message, ex);
            }

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

            foreach (QH_TodayEntrustTableInfo table in list)
            {
                //不再判断是否是当天
                var order = new QhTodayEntrustTableEx(table);
                CacheStockIndexFuturesOrder(order);
            }
        }
        /// <summary>
        /// Title:根据要更新的委托单列表更新回推的通道
        /// Desc.:本方法逻辑,首先这里要更新现货今日委托表中的通道
        ///       更新之后再根据委托单列表在今日成交和历史成交表获取对应的交易单编号更新回推故障中的通道.
        /// </summary>
        /// <param name="numberList">要更新的委托单列表</param>
        /// <param name="newClientId">列新的通道号</param>
        public void UpdateEntrustPushBackChannelID(List <string> numberList, string newClientId)
        {
            StringBuilder sb = new StringBuilder("");

            foreach (var item in numberList)
            {
                if (item != null && !string.IsNullOrEmpty(item.Trim()))
                {
                    sb.AppendFormat(",  '{0}'", item);
                }
            }
            string updateStr = sb.ToString();

            if (!string.IsNullOrEmpty(updateStr))
            {
                updateStr = updateStr.Substring(updateStr.IndexOf(',') + 1);
            }
            if (string.IsNullOrEmpty(updateStr.Trim()))
            {
                return;
            }
            //根据委托单列表获取今日成交的成交编号并在历史表中获取,
            //因为会在清算时会把当日的移到了历史表中
            string tradeNumberList = GetTodayAndHistroyTradeNumberString(updateStr);

            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();

            DataManager.ExecuteInTransaction((db, trans) =>
            {
                //更新完今日委托表中的通道号
                dal.UpdateChannel(updateStr, newClientId, db, trans);
                //更新回推数据表中的通道
                Update(tradeNumberList, newClientId, db, trans);
            });
        }
        /// <summary>
        /// 根据委托单号,从今日委托和历史委托中查询相关的委托单数据
        /// 这里如果在历史委托表中的数据因为没有可撤标识,这里为了能转换回今日委托,所以直接转为不可撤0
        /// 通道号附为空字符串""
        /// </summary>
        /// <param name="entrustStr">委托单号</param>
        /// <returns></returns>
        public List <QH_TodayEntrustTableInfo> GetEntrustListByEnturstNo(string entrustStr)
        {
            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
            CommonDALOperate <QH_TodayEntrustTableInfo> com = new CommonDALOperate <QH_TodayEntrustTableInfo>();

            return(com.ExecuterReaderDataBind(string.Format(GetEntrustListByEnturstNoSqlScript(), entrustStr.ToString()), dal.ReaderBind));
        }
        /// <summary>
        /// 根据通道号返回要回道的所有委托数据,这里包含历史委托的数据
        /// </summary>
        /// <param name="channleID">通道号</param>
        /// <returns></returns>
        public List <QH_TodayEntrustTableInfo> GetEntrustListByChannleID(string channleID)
        {
            string sql = string.Format(GetDistincEntrustNumberSqlScript(), channleID);
            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
            CommonDALOperate <QH_TodayEntrustTableInfo> com = new CommonDALOperate <QH_TodayEntrustTableInfo>();

            return(com.ExecuterReaderDataBind(string.Format(GetEntrustListByEnturstNoSqlScript(), sql), dal.ReaderBind));
        }
        /// <summary>
        /// 依据期货委托单号获取委托单实体
        /// </summary>
        /// <param name="strEntrustId"></param>
        /// <param name="tm"></param>
        /// <returns></returns>
        public static QH_TodayEntrustTableInfo GetQHEntrustEntity(string strEntrustId, ReckoningTransaction tm)
        {
            QH_TodayEntrustTableInfo result = null;

            QH_TodayEntrustTableDal qhtodayEntrustTabledDal = new QH_TodayEntrustTableDal();

            result = qhtodayEntrustTabledDal.GetModel(strEntrustId);

            return(result);
        }
        /// <summary>
        /// 依据期货委托单号获取委托单实体
        /// </summary>
        /// <param name="strEntrustId"></param>
        /// <returns></returns>
        public static QH_TodayEntrustTableInfo GetQHEntrustEntity(string strEntrustId)
        {
            QH_TodayEntrustTableInfo result = null;

            //var tetp = new SqlQhTodayEntrustTableProvider(TransactionFactory.RC_ConnectionString, true, string.Empty);

            QH_TodayEntrustTableDal qhtodayEntrustTabledDal = new QH_TodayEntrustTableDal();

            result = qhtodayEntrustTabledDal.GetModel(strEntrustId);

            return(result);
        }
Esempio n. 7
0
        /// <summary>
        /// 更新委托信息
        /// </summary>
        /// <param name="entrustNubmer">委托单号</param>
        /// <param name="orderMessage">信息</param>
        /// <returns></returns>
        public static bool UpdateEntrustOrderMessage(string entrustNubmer, string orderMessage)
        {
            try
            {
                QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
                dal.UpdateOrderMessage(entrustNubmer, orderMessage);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message, ex);
                return(false);
            }

            return(true);
        }
Esempio n. 8
0
        /// <summary>
        /// 更新委托表
        /// </summary>
        /// <param name="tet">委托表</param>
        /// <param name="rt">事务包装类</param>
        /// <returns>是否成功</returns>
        public static bool UpdateEntrustTable(QH_TodayEntrustTableInfo tet, ReckoningTransaction rt)
        {
            try
            {
                QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
                dal.Update(tet, rt);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message, ex);
                return(false);
            }

            return(true);
        }
Esempio n. 9
0
        /// <summary>
        /// 删除当日委托
        /// </summary>
        /// <param name="entrustNumber">委托单号</param>
        public static bool DeleteTodayEntrust(string entrustNumber)
        {
            try
            {
                QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
                dal.Delete(entrustNumber);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message, ex);
                return(false);
            }

            return(true);
        }
Esempio n. 10
0
 /// <summary>
 /// 更新期货委托单
 /// </summary>
 /// <param name="stockOrder">委托单</param>
 public static void UpdateFutureOrder(QH_TodayEntrustTableInfo stockOrder)
 {
     try
     {
         //var sxtetp = new SqlQhTodayEntrustTableProvider(TransactionFactory.RC_ConnectionString, true,
         //string.Empty);
         // sxtetp.Update(stockOrder);
         QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
         dal.Update(stockOrder);
     }
     catch (Exception ex)
     {
         LogHelper.WriteError(ex.Message, ex);
     }
 }
        /// <summary>
        ///
        /// </summary>
        /// <param name="strMcOrderNo"></param>
        /// <returns></returns>
        protected override OrderCacheItem LoadCacheItemFromDB(string strMcOrderNo)
        {
            OrderCacheItem result = null;

            string where = string.Format("McOrderId = '{0}' ", strMcOrderNo);

            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();
            var tets = dal.GetListArrayWithNoLock(where);

            if (!Utils.IsNullOrEmpty(tets))
            {
                try
                {
                    var tet       = tets[0];
                    var cacheItem = new OrderCacheItem(tet.CapitalAccount, tet.TradeAccount,
                                                       tet.EntrustNumber,
                                                       (
                                                           GTA.VTS.Common.CommonObject.Types.TransactionDirection)
                                                       Enum.Parse(
                                                           typeof(
                                                               GTA.VTS.Common.CommonObject.Types.TransactionDirection),
                                                           tet.BuySellTypeId.ToString
                                                               ()));
                    cacheItem.EntrustAmount = tet.EntrustAmount;
                    cacheItem.Code          = tet.ContractCode;
                    var user = AccountManager.Instance.GetUserByAccount(tet.CapitalAccount);
                    if (user != null)
                    {
                        cacheItem.TraderId = user.UserID;
                    }
                    //else
                    //{
                    //    cacheItem.TraderId = GetTraderIdByFundAccount(tet.CapitalAccount); //TODO:需要根据资金账户获取用户ID
                    //}

                    AddOrderMappingInfo(tet.McOrderId, cacheItem);
                    result = cacheItem;
                }
                catch (Exception ex)
                {
                    LogHelper.WriteError(ex.Message, ex);
                }
            }

            return(result);
        }
Esempio n. 12
0
        /// <summary>
        /// 根据委托单号获取今日委托
        /// </summary>
        /// <param name="entrustNumber">委托单号</param>
        /// <returns>今日委托</returns>
        public static QH_TodayEntrustTableInfo GetEntrustTable(string entrustNumber)
        {
            QH_TodayEntrustTableInfo tet = null;

            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();

            try
            {
                tet = dal.GetModel(entrustNumber);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError(ex.Message, ex);
            }

            return(tet);
        }
Esempio n. 13
0
        /// <summary>
        /// 检查是否存在对应的委托单号
        /// </summary>
        /// <param name="errMsg">错误信息</param>
        /// <returns>校验结果</returns>
        private bool CheckDelegateExist(ref string errMsg)
        {
            bool result = false;

            errMsg = "";
            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();

            //qhTodayEntrustTable = DataRepository.QhTodayEntrustTableProvider.GetByEntrustNumber(this.orderNo);
            qhTodayEntrustTable = dal.GetModel(this.orderNo);
            if (qhTodayEntrustTable != null)
            {
                result = true;
            }
            else
            {
                string errCode = "GT-1600";
                errMsg = "委托不存在。";
                errMsg = errCode + ":" + errMsg;
                LogHelper.WriteInfo(errMsg);
            }

            return(result);
        }
Esempio n. 14
0
        /// <summary>
        /// 构造股指期货委托单
        /// </summary>
        public static string BuildGZQHOrder(ref QH_TodayEntrustTableInfo order,
                                            StockIndexFuturesOrderRequest originalOrder,
                                            string strHoldingAccount, string strCapitalAccount,
                                            int iCurType, ref string strMessage)
        {
            //bool result = false;
            order = new QH_TodayEntrustTableInfo();

            order.EntrustNumber = BuildQHOrderNo();
            order.EntrustAmount = Convert.ToInt32(originalOrder.OrderAmount);
            order.EntrustPrice  = Convert.ToDecimal(originalOrder.OrderPrice);
            order.EntrustTime   = DateTime.Now;
            order.OfferTime     = DateTime.Now;
            order.IsMarketValue = originalOrder.OrderWay == Types.OrderPriceType.OPTMarketPrice
                                      ? true
                                      : false;
            order.BuySellTypeId = (int)originalOrder.BuySell;
            order.OrderStatusId = (int)Types.OrderStateType.DOSUnRequired;
            if (strHoldingAccount == null)
            {
                strHoldingAccount = "";
            }
            order.TradeAccount = strHoldingAccount;
            if (strCapitalAccount == null)
            {
                strCapitalAccount = "";
            }
            order.CapitalAccount = strCapitalAccount;
            if (originalOrder.PortfoliosId == null)
            {
                originalOrder.PortfoliosId = "";
            }
            order.PortfolioLogo = originalOrder.PortfoliosId;
            if (originalOrder.Code == null)
            {
                originalOrder.Code = "";
            }
            order.ContractCode      = originalOrder.Code;
            order.TradeAmount       = 0;
            order.TradeAveragePrice = 0;
            order.CancelAmount      = 0;
            order.CancelLogo        = true;
            if (originalOrder.ChannelID == null)
            {
                originalOrder.ChannelID = "";
            }
            order.CallbackChannelId = originalOrder.ChannelID;
            order.IsMarketValue     = originalOrder.OrderWay == Types.OrderPriceType.OPTMarketPrice
                                      ? true
                                      : false;
            order.OpenCloseTypeId = (int)originalOrder.OpenCloseType;
            order.TradeUnitId     = (int)originalOrder.OrderUnitType;
            order.CurrencyTypeId  = iCurType;

            order.OrderMessage = "";
            order.McOrderId    = "";

            CheckEntrustLength(order);

            QH_TodayEntrustTableDal dal = new QH_TodayEntrustTableDal();

            dal.Add(order);

            return(order.EntrustNumber);
        }