internal static Protocal.TradingCommand CreateContentChangedCommand(Guid accountId, string content) { Protocal.TradingCommand command = new Protocal.TradingCommand(); command.Content = content; command.AccountId = accountId; return(command); }
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); } }
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); } }
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()); } }
private void GetInitDataForAccount(Protocal.TradingCommand command) { if (string.IsNullOrEmpty(command.Content)) { return; } if (!AccountRepository.Default.Contains(command.AccountId)) { _transactionAdaptor.GetAccountsForInit(new Guid[] { command.AccountId }); } }
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); } }
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); }