Exemplo n.º 1
0
        public void OnOrder(Order order)
        {
            // invoke event specific for the transaction
            var correlationId = _typeConverter.ToString(order.TransID);

            #region Totally untested code or handling manual transactions

            if (!_persistentStorage.Contains(correlationId))
            {
                correlationId = "manual:" + order.OrderNum + ":" + correlationId;
                var fakeTrans = new Transaction()
                {
                    Comment  = correlationId,
                    IsManual = true
                               // TODO map order properties back to transaction
                               // ideally, make C# property names consistent (Lua names are set as JSON.NET properties via an attribute)
                };
                _persistentStorage.Set(correlationId, fakeTrans);
            }

            #endregion Totally untested code or handling manual transactions

            var tr = _persistentStorage.Get <Transaction>(correlationId);
            if (tr != null)
            {
                lock (tr)
                {
                    tr.OnOrder(order);
                }
            }

            Trace.Assert(tr != null, "Transaction must exist in persistent storage until it is completed and all order messages are recieved");
        }