예제 #1
0
 internal static Protocal.TradingCommand CreateContentChangedCommand(Guid accountId, string content)
 {
     Protocal.TradingCommand command = new Protocal.TradingCommand();
     command.Content   = content;
     command.AccountId = accountId;
     return(command);
 }
예제 #2
0
 internal ICommandProcessor GetCommandProcessor(Protocal.TradingCommand tradingCommand)
 {
     if (tradingCommand is TradingUpdateBalanceCommand)
     {
         return(new UpdateBalanceCommandProcessor((TradingUpdateBalanceCommand)tradingCommand));
     }
     else if (tradingCommand is TradingTransferCommand)
     {
         return(new TransferCommandProcessor((TradingTransferCommand)tradingCommand));
     }
     else if (tradingCommand is TradingExecuteCommand)
     {
         return(new ExecuteCommandProcessor((TradingExecuteCommand)tradingCommand));
     }
     else if (tradingCommand is TradingAcceptPlaceCommand)
     {
         return(new AcceptPlaceCommandProcessor((TradingAcceptPlaceCommand)tradingCommand));
     }
     else if (tradingCommand is TradingPrePaymentCommand)
     {
         return(new PrePaymentCommandProcessor((TradingPrePaymentCommand)tradingCommand));
     }
     else if (tradingCommand is TradingCancelByManagerCommand)
     {
         return(new CancelCommandProccessor((TradingCancelByManagerCommand)tradingCommand));
     }
     else
     {
         return(null);
     }
 }
예제 #3
0
 internal void Process(Protocal.TradingCommand bookCommand, ICommandBroadcast broadcast)
 {
     try
     {
         if (string.IsNullOrEmpty(bookCommand.Content))
         {
             return;
         }
         XElement accountElement = XElement.Parse(bookCommand.Content);
         Guid     accountId      = accountElement.AttrToGuid("ID");
         var      account        = (Account)AccountRepository.Default.Get(accountId);
         if (account == null)
         {
             return;
         }
         Protocal.Commands.ChangedFund changedFund;
         var changes = account.Update(accountElement, out changedFund);
         var tran    = (Transaction)changes.Single().Tran;
         Protocal.Commands.TransactionMapping.Default.Update(account, changes);
         var affectedOrders = this.CreateAffectedOrders(tran);
         broadcast.BoardcastBookResult(StateServer.Token, tran.ToXml().ToXmlNode(), account.ToXml().ToXmlNode(), affectedOrders);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
예제 #4
0
        internal void Add(Protocal.TradingCommand command)
        {
#if NOBROADCAST
#else
            command.SourceType = AppType.TransactionServer;
            _msgBlock.Post(command);
#endif
        }
        private void UpdateAccount(Protocal.TradingCommand tradingCommand)
        {
            var commands = this.CreateCommands(tradingCommand);

            Logger.InfoFormat("UpdateAccount commands count = {0}", commands.Count);
            if (commands.Count > 0)
            {
                _broadcast.BroadcastCommands(_token, commands.ToArray());
            }
        }
예제 #6
0
 private void GetInitDataForAccount(Protocal.TradingCommand command)
 {
     if (string.IsNullOrEmpty(command.Content))
     {
         return;
     }
     if (!AccountRepository.Default.Contains(command.AccountId))
     {
         _transactionAdaptor.GetAccountsForInit(new Guid[] { command.AccountId });
     }
 }
예제 #7
0
 internal void ProcessTradingCommand(Protocal.TradingCommand tradingCommand)
 {
     try
     {
         Logger.InfoFormat("ProcessTradingCommand, content= {0}", tradingCommand.Content);
         this.GetInitDataForAccount(tradingCommand);
         this.ProcessNormalTradingCommand(tradingCommand);
     }
     catch (Exception ex)
     {
         Logger.Error(tradingCommand.Content, ex);
     }
 }
예제 #8
0
 private void ProcessNormalTradingCommand(Protocal.TradingCommand tradingCommand)
 {
     if (!string.IsNullOrEmpty(tradingCommand.Content))
     {
         _changedContentCommandProcessor.Process(tradingCommand);
     }
     else
     {
         var commandProcessor = this.GetCommandProcessor(tradingCommand);
         if (commandProcessor != null)
         {
             _broadcast.BroadcastCommands(_token, commandProcessor.Process());
         }
     }
 }
        internal List <Command> CreateCommands(Protocal.TradingCommand tradingCommand)
        {
            List <Command> commands    = new List <Command>();
            XElement       accountNode = XElement.Parse(tradingCommand.Content);

            Protocal.Commands.Account account = null;
            if (AccountRepository.Default.TryGet(tradingCommand.AccountId, out account))
            {
                List <Protocal.Commands.OrderPhaseChange> orderChanges = null;
                commands = ((Account)account).UpdateAndCreateCommand(accountNode, out orderChanges);
                Protocal.Commands.TransactionMapping.Default.Update((Account)account, orderChanges);
                this.NotifyFaxEmalEngine(orderChanges);
                this.ProcessExecutedChanges(orderChanges);
            }
            return(commands);
        }
 internal void Process(Protocal.TradingCommand tradingCommand)
 {
     this.ProcessChangedContentForFaxEmail(tradingCommand.Content);
     this.UpdateAccount(tradingCommand);
 }