コード例 #1
0
        public void HandleCommand(string commandType, ICommand command, long commandRouteItemId)
        {

           
            try
            {
                ResolveCommandItem rc = _resolveCommand.Get(command);
                if (_incomingCommandQueueRepository.ExitOldCommand())
                {
                    _incomingCommandQueueRepository.DeleteOldCommand();
                }
                IncomingCommandQueueItemLocal cmd = new IncomingCommandQueueItemLocal
                {
                    CommandId = command.CommandId,
                    CommandType = rc.CommandType,
                    DateInserted = DateTime.Now,
                    DocumentId = command.DocumentId,
                    Processed = false,
                    DateReceived = DateTime.Now,
                    JsonCommand = JsonConvert.SerializeObject(command),
                    NoOfRetry = 0
                };
                _incomingCommandQueueRepository.Add(cmd);
             
                _executeCommandLocally.ExecuteCommand(rc.CommandType, command);
                _incomingCommandQueueRepository.MarkAsProcessed(command.CommandId);
                _auditLogWFManager.AuditLogEntry("HandleCommand", string.Format("Command {0} Successfully Executed. Command Type {1}   ", commandRouteItemId, commandType));
            }
            catch(Exception ex)
            {
                
                _errorLogService.Log("IncomingCommandHander", string.Format("Command {0} Failed to Execute. Command Type {1}  error {2}", commandRouteItemId, commandType,ex.Message));
                UnExecutedCommandLocal log = new UnExecutedCommandLocal
                                                 {
                                                     Command = JsonConvert.SerializeObject(command, new IsoDateTimeConverter()),
                                                     CommandType = commandType,
                                                     DocumentId=command.DocumentId,
                                                     Reason=ex.AllMessages()+ ex.StackTrace,
                                                 };
                _unExecutedCommandRepository.Save(log);
            }


            //Config config = _configService.Load();
            //config.LastDeliveredCommandRouteItemId = commandRouteItemId;
            //_configService.Save(config);

            if (_incomingCommandQueueRepository.GetByCommandId(command.CommandId) != null)
            {
                _configRepository.AddDeliveredCommand(commandRouteItemId);
            }
            

        }
コード例 #2
0
 public int Save(UnExecutedCommandLocal log)
 {
     UnExecutedCommandLocal exist = GetById(log.Id);
     if (exist == null)
     {
         exist = new UnExecutedCommandLocal();
         _ctx.UnExecutedCommandLocal.Add(exist);
     }
     exist.Id = log.Id;
     exist.CommandType = log.CommandType;
     exist.Command = log.Command;
     exist.Reason = log.Reason;
     exist.DocumentId = log.DocumentId;
     _ctx.SaveChanges();
     return log.Id;
 }