public void RouteDocumentCommand(ICommand command) { _log.InfoFormat("RouteDocumentCommand -- commandtype {0} -- commandid {1} -- documentid {1} -- ", command.CommandTypeRef, command.CommandId, command.DocumentId); if (_outgoingCommandQueueRepository.GetByCommandId(command.CommandId) != null) return; CommandType commandType = _resolveCommand.Get(command).CommandType; var queueItem = new OutgoingCommandQueueItemLocal { CommandId = command.CommandId, CommandType = commandType, DateInserted = DateTime.Now, DocumentId = command.DocumentId, IsCommandSent = false, DateSent = DateTime.Now, JsonCommand = JsonConvert.SerializeObject(command, new IsoDateTimeConverter()) }; _outgoingCommandQueueRepository.Add(queueItem); if (!command.IsSystemCommand) { _executeCommandLocally.ExecuteCommand(commandType, command); } }
public void Add(OutgoingCommandQueueItemLocal itemToAdd) { OutgoingCommandQueueItemLocal existing = _ctx.OutgoingCommandQueueItemLocals.FirstOrDefault(p => p.Id == itemToAdd.Id); if (existing == null) { existing = new OutgoingCommandQueueItemLocal(); _ctx.OutgoingCommandQueueItemLocals.Add(existing); } existing.CommandId = itemToAdd.CommandId; existing.CommandType = itemToAdd.CommandType; existing.DateInserted = itemToAdd.DateInserted; existing.DateSent = itemToAdd.DateSent; existing.DocumentId = itemToAdd.DocumentId; existing.IsCommandSent = itemToAdd.IsCommandSent; existing.JsonCommand = itemToAdd.JsonCommand; _ctx.SaveChanges(); }
public void RouteDocumentCommandWithOutSave(ICommand command) { if (_outgoingCommandQueueRepository.GetByCommandId(command.CommandId) != null) return; CommandType commandType = _resolveCommand.Get(command).CommandType; //DateTime executeLocally = DateTime.Now; //_executeCommandLocally.ExecuteCommand(commandType, command); //TimeSpan endexecuteLocally = DateTime.Now.Subtract(executeLocally); DateTime createoutgoingcommads = DateTime.Now; var queueItem = new OutgoingCommandQueueItemLocal { CommandId = command.CommandId, CommandType = commandType, DateInserted = DateTime.Now, DocumentId = command.DocumentId, IsCommandSent = false, DateSent = DateTime.Now, JsonCommand = JsonConvert.SerializeObject(command, new IsoDateTimeConverter()) }; _outgoingCommandQueueRepository.Add(queueItem); //TimeSpan endcreateInvoice = DateTime.Now.Subtract(createoutgoingcommads); }