public string GetQHDesc(CommoditiesDealBackEntity entity)
        {
            string format = "期货成交回报[OrderNo={0},DealPrice={1},DealAmount={2},DealTime={3}, ID={4}, CounterID={5}]";

            return(string.Format(format, entity.OrderNo, entity.DealPrice, entity.DealAmount, entity.DealTime, entity.Id,
                                 CountID));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Desc: 保存商品期货成交回报
        /// Create by: 董鹏
        /// Create Date: 2010-01-25
        /// </summary>
        /// <param name="model">成交回报实体</param>
        public void SaveDealBack(CommoditiesDealBackEntity model)
        {
            #region 通道号或者成交实体不能为空
            //实体判断,成交回报实体不能为空。
            if (model == null || string.IsNullOrEmpty(model.ChannelID))
            {
                return;
            }
            #endregion

            #region  步撮合中心委托回报实体
            lock (((ICollection)MatchCenterManager.Instance.DealCommoditiesBackEntitys).SyncRoot)
            {
                if (MatchCenterManager.Instance.DealCommoditiesBackEntitys.ContainsKey(model.ChannelID))
                {
                    Queue <CommoditiesDealBackEntity> queue = MatchCenterManager.Instance.DealCommoditiesBackEntitys[model.ChannelID];
                    queue.Enqueue(model);
                }
                else
                {
                    //队列实体
                    var queue = new Queue <CommoditiesDealBackEntity>();
                    queue.Enqueue(model);
                    MatchCenterManager.Instance.DealCommoditiesBackEntitys[model.ChannelID] = queue;
                }
            }
            #endregion
        }
        /// <summary>
        /// 保存期货成交回报
        /// </summary>
        /// <param name="entity">成交回报</param>
        public bool InsertQHDealBackEntity(CommoditiesDealBackEntity entity)
        {
            if (HasAddId(entity.Id))
            {
                return(false);
            }

            BD_UnReckonedDealTableInfo table = new BD_UnReckonedDealTableInfo();

            table.id      = entity.Id;
            table.OrderNo = entity.OrderNo;
            table.Price   = entity.DealPrice;
            table.Amount  = (int)entity.DealAmount;
            table.Time    = entity.DealTime;

            table.EntityType = (int)DealBackEntityType.QH;

            string desc = GetQHDesc(entity);

            LogHelper.WriteDebug("$-------$CrashManager.InsertQHDealBackEntity" + desc);

            SaveEntity(table);

            //entity.Id = table.Id.ToString();
            AddID(entity.Id);
            return(true);
        }
Exemplo n.º 4
0
        /// <summary>
        /// 增加一条记录
        /// </summary>
        public static int Add(CommoditiesDealBackEntity model)
        {
            StringBuilder strSql = null;

            strSql = new StringBuilder();
            strSql.Append("insert into CommoditiesDealOrder(");
            strSql.Append("DealOrderNo,OrderNo,ChannelID,");
            strSql.Append("OrderPrice,DealAmount,DealTime");
            strSql.Append("");
            strSql.Append(")");
            strSql.Append(" values (");
            strSql.Append("'" + model.Id + "',");
            strSql.Append("'" + model.OrderNo + "',");
            strSql.Append("'" + model.ChannelID + "',");
            strSql.Append("" + model.DealPrice + ",");
            strSql.Append("" + model.DealAmount + ",");
            strSql.Append("'" + model.DealTime + "'");
            strSql.Append(")");
            try
            {
                Database  db        = DatabaseFactory.CreateDatabase();
                DbCommand dbCommand = db.GetSqlStringCommand(strSql.ToString());
                object    obj       = db.ExecuteNonQuery(dbCommand);
                return(1);
            }
            catch (Exception ex)
            {
                LogHelper.WriteError("CH-111:数据库连接受阻", ex);
                return(0);
            }
        }
        public static string DescInfo(this CommoditiesDealBackEntity entity)
        {
            string format = "CommoditiesDealBackEntity[OrderNo={0},DealPrice={1},DealAmount={2},DealTime={3},ID={4}]";
            string desc   = string.Format(format, entity.OrderNo, entity.DealPrice, entity.DealAmount, entity.DealTime,
                                          entity.Id);

            return(desc);
        }
Exemplo n.º 6
0
        /// <summary>
        /// 商品期货成交实体转换为股指期货成交实体
        /// </summary>
        /// <param name="model"></param>
        /// <returns></returns>
        public static FutureDealBackEntity SPQHDealEntryConversionGZQHDealEntry(CommoditiesDealBackEntity model)
        {
            FutureDealBackEntity dealEntry = new FutureDealBackEntity();

            dealEntry.DealAmount = model.DealAmount;
            dealEntry.DealPrice  = model.DealPrice;
            dealEntry.DealTime   = model.DealTime;
            dealEntry.Id         = model.Id;
            dealEntry.OrderNo    = model.OrderNo;

            return(dealEntry);
        }
        private void ProcessQHTable(BD_UnReckonedDealTableInfo table)
        {
            CommoditiesDealBackEntity entity = new CommoditiesDealBackEntity();

            entity.Id         = table.id;
            entity.OrderNo    = table.OrderNo;
            entity.DealPrice  = table.Price.Value;
            entity.DealAmount = table.Amount.Value;
            entity.DealTime   = table.Time.Value;

            LogHelper.WriteInfo("$-------$CrashManager.ProcessXHTable重新发送期货成交回报" + GetQHDesc(entity));

            ReckonCenter.Instace.AcceptSPQHDealOrder(entity);
        }
Exemplo n.º 8
0
        /// <summary>
        /// 商品期货成交回报接收
        /// </summary>
        /// <param name="model"></param>
        public void ProcessMercantileDealRpt(CommoditiesDealBackEntity model)
        {
            string desc = CrashManager.GetInstance().GetQHDesc(model);

            LogHelper.WriteDebug("<---商品期货成交回报接收DoCallbackProcess.ProcessMercantileDealRpt" + desc);

            if (string.IsNullOrEmpty(model.Id))
            {
                model.Id = Guid.NewGuid().ToString();
            }

            if (CrashManager.GetInstance().InsertQHDealBackEntity(model))
            {
                //即时清算
                ReckonCenter.Instace.AcceptSPQHDealOrder(model);
            }
        }
Exemplo n.º 9
0
        /// <summary>
        /// 绑定数据
        /// </summary>
        /// <param name="reader">IDataReader</param>
        /// <returns></returns>
        public static CommoditiesDealBackEntity ReaderBind(IDataReader reader)
        {
            if (reader == null)
            {
                return(null);
            }
            CommoditiesDealBackEntity model = new CommoditiesDealBackEntity();
            object obj;

            obj = reader["DealOrderNo"];
            if (obj != null && obj != DBNull.Value)
            {
                model.Id = obj.ToString();
            }
            obj = reader["OrderNo"];
            if (obj != null && obj != DBNull.Value)
            {
                model.OrderNo = obj.ToString();
            }
            obj = reader["ChannelID"];
            if (obj != null && obj != DBNull.Value)
            {
                model.ChannelID = obj.ToString();
            }
            obj = reader["OrderPrice"];
            if (obj != null && obj != DBNull.Value)
            {
                model.DealPrice = (decimal)obj;
            }
            obj = reader["DealAmount"];
            if (obj != null && obj != DBNull.Value)
            {
                model.DealAmount = (decimal)obj;
            }
            obj = reader["DealTime"];
            if (obj != null && obj != DBNull.Value)
            {
                model.DealTime = (DateTime)obj;
            }
            return(model);
        }
        /// <summary>
        /// 商品期货成交回报
        /// Create by 董鹏 2010-01-22
        /// </summary>
        /// <param name="model">委托单</param>
        private void ProcessCommoditiesStock(CommoditiesDealBackEntity model)
        {
            //期货成交实体不能为空
            if (model == null)
            {
                return;
            }
            model.DealTime = DateTime.Now;
            OperationContext context = null;

            if (model.ChannelID != null)    //上下文通道不能为空
            {
                if (MatchCenterManager.Instance.OperationContexts.ContainsKey(model.ChannelID))
                {
                    context = MatchCenterManager.Instance.OperationContexts[model.ChannelID];
                }
                else
                {
                    LogHelper.WriteError("商品期货成交回报,在缓存通道号列表中找不到指定的" + model.ChannelID +
                                         "通道号,回报数据以缓存到回推队列中!", new Exception("商品期货成交回报获取回推通道!"));
                }
            }
            //撮合中心上下文不能为空
            if (context == null)
            {
                TradePushBackImpl.Instanse.SaveDealBack(model);
                return;
            }
            var channel = context.Channel;

            //撮合中心通道为空
            if (channel == null)
            {
                TradePushBackImpl.Instanse.SaveDealBack(model);
                return;
            }
            if (channel.State != CommunicationState.Opened)
            {
                TradePushBackImpl.Instanse.SaveDealBack(model);
                return;
            }
            try
            {
                var callback = context.GetCallbackChannel <IDoOrderCallback>();
                if (callback != null)
                {
                    var md = new DoBackCommoditiesStockDealDeletate(callback.ProcessMercantileDealRpt);
                    md.BeginInvoke(model, null, null);
                }
                DeleteBackStock(model.Id);//数据库删除


                //var callback = context.GetCallbackChannel<IDoOrderCallback>();
                //if (callback != null)
                //{
                //    callback.ProcessMercantileDealRpt(model);
                //    DeleteCommodities(model.Id);
                //}
            }
            //成交回报异常处理
            catch (Exception ex)
            {
                TradePushBackImpl.Instanse.SaveDealBack(model);
                LogHelper.WriteError(GenerateInfo.CH_E002, ex);
                return;
            }
        }
Exemplo n.º 11
0
        //void IOrderDealRptCallback.ProcessMercantileDealRpt(CommoditiesDealBackEntity model)
        //{
        //    throw new NotImplementedException();
        //}

        IAsyncResult IOrderDealRptCallback.BeginProcessMercantileDealRpt(CommoditiesDealBackEntity model, AsyncCallback callback, object asyncState)
        {
            throw new NotImplementedException();
        }