Example #1
0
        protected void ProcessNewOrder(object param)
        {
            try
            {
                lock (tLock)
                {
                    Wrapper wrapper = (Wrapper)param;
                    Order   order   = OrderConverter.ConvertNewOrder(wrapper);
                    string  sender  = (string)wrapper.GetField(OrderFields.SENDER);

                    if (!string.IsNullOrEmpty(sender) && TestingModules.ContainsKey(sender))
                    {
                        SentOrders.Add(order.ClOrdId, sender);

                        QuickFix.Message nos = FIXMessageCreator.CreateNewOrderSingle(order.ClOrdId, order.Security.Symbol, order.Side, order.OrdType, order.SettlType,
                                                                                      order.TimeInForce, order.EffectiveTime, order.OrderQty, order.Price, order.StopPx,
                                                                                      order.Account, order.Exchange);

                        Session.SendToTarget(nos, SessionID);

                        SendersDict.Add(nos.Header.GetInt(QuickFix.Fields.Tags.MsgSeqNum), sender);
                        KeysDict.Add(nos.Header.GetInt(QuickFix.Fields.Tags.MsgSeqNum), order.ClOrdId);
                    }
                    else
                    {
                        throw new Exception("Cannot create an order for unknown sender");
                    }
                }
            }
            catch (Exception ex)
            {
                DoLog(string.Format("Critical error processing new order @{0}:{1}", Configuration.Name, ex.Message), Fwk.Main.Common.Util.Constants.MessageType.Error);
            }
        }
Example #2
0
        private static List <PropertyInfo> GetKeyPropertyInfo <TEntity, TAttribute>(KeysDict datasource) where TAttribute : Attribute
        {
            var type = typeof(TEntity);

            if (datasource.ContainsKey(type))
            {
                return(datasource[type]);
            }
            var props = new List <PropertyInfo>();

            var propertys = GetKeyPropertys <TAttribute>(type);

            if (propertys.Count == 0)
            {
                return(null);
            }

            //查找属性是不是在父类
            foreach (var item in propertys)
            {
                var propertyName = item.Name;

                var propInfo = type.GetTypeInfo().GetDeclaredProperty(propertyName);

                //如果类型有父类。且是定义在父类
                while (propInfo == null && type.GetTypeInfo().BaseType != null)
                {
                    type     = type.GetTypeInfo().BaseType;
                    propInfo = type.GetTypeInfo().GetDeclaredProperty(propertyName);
                }

                if (propInfo != null)
                {
                    props.Add(propInfo);
                }
            }
            datasource.Add(type, props);
            return(props);
        }