public void Execute(ReRouteDocumentCommand command)
        {
            try
            {
                var commands = _commandRoutingOnRequestRepository.GetByParentDocumentId(command.DocumentId);
                foreach (var commandRouteOnRequest in commands)
                {
                    var routeCentre =
                        _commandRoutingOnRequestRepository.GetByRouteCentreByIdAndCostcentreId(
                            commandRouteOnRequest.Id, command.ReciepientCostCentreId);
                    if (routeCentre == null)
                    {
                        routeCentre = new CommandRouteOnRequestCostcentre();
                        routeCentre.CostCentreId = command.ReciepientCostCentreId;
                        routeCentre.CommandRouteOnRequestId = commandRouteOnRequest.Id;
                        routeCentre.CommandType = commandRouteOnRequest.CommandType;
                        routeCentre.DateAdded = DateTime.Now;
                        routeCentre.IsRetired = commandRouteOnRequest.IsRetired;
                        routeCentre.IsValid = true;
                        _commandRoutingOnRequestRepository.AddRoutingCentre(routeCentre);
                    }


                }
                _commandProcessingAuditRepository.SetCommandStatus(command.CommandId, CommandProcessingStatus.Complete);
            }catch(Exception ex)
            {
                _commandProcessingAuditRepository.SetCommandStatus(command.CommandId, CommandProcessingStatus.MarkedForRetry);
            }
        }
Exemplo n.º 2
0
        private async Task ProcessDispatch(OrderDispatchItemSummary item)
        {
           await Task.Run(() =>
                              {
                                 using(var c = NestedContainer)
                                 {
                                     var mainOrderRepository = Using<IMainOrderRepository>(c);
                                     var mainOrderworkflow = Using<IOrderWorkflow>(c);
                                     MainOrder order = mainOrderRepository.GetById(item.OrderId);
                                     Config config = Using<IConfigService>(c).Load();
                                     Guid costCentreApplicationid = config.CostCentreApplicationId;
                                     order.ChangeccId(costCentreApplicationid);
                                     if(item.ChangeToSalesman!=null)
                                     {
                                         var envelope = new CommandEnvelope();
                                         envelope.DocumentId = order.Id;
                                         envelope.RecipientCostCentreId = item.ChangeToSalesman.Id;
                                         envelope.DocumentTypeId = (int) DocumentType.Order;
                                         envelope.EnvelopeGeneratedTick = DateTime.Now.Ticks;
                                         envelope.GeneratedByCostCentreId = config.CostCentreId;
                                         envelope.Id = Guid.NewGuid();
                                         envelope.ParentDocumentId = order.Id;
                                         envelope.IsSystemEnvelope = true;
                                         var  commandEnvelopeRouter = Using< IOutgoingCommandEnvelopeRouter >(c);
                                         order.ChangeSaleman(item.ChangeToSalesman);
                                         ReRouteDocumentCommand cmd = new ReRouteDocumentCommand();
                                         cmd.CommandGeneratedByCostCentreApplicationId = config.CostCentreApplicationId;
                                         cmd.CommandId = Guid.NewGuid();
                                         cmd.DocumentId = order.Id;
                                         cmd.ReciepientCostCentreId = item.ChangeToSalesman.Id;
                                         envelope.CommandsList.Add(new CommandEnvelopeItem(1, cmd));
                                         commandEnvelopeRouter.RouteCommandEnvelope(envelope);
                                     }
                                     order.DispatchPendingLineItems();
                                     mainOrderworkflow.Submit(order,config);
                                 }

                              }

                ).ConfigureAwait(false);
            //t.Wait();
           // return t;
        }
Exemplo n.º 3
0
 private static void TestRerouteCommand()
 {
     ReRouteDocumentCommand cmd = new ReRouteDocumentCommand();
     var route = ObjectFactory.GetInstance<IOutgoingDocumentCommandRouter>();
     var config = ObjectFactory.GetInstance<IConfigService>().Load();
     cmd.CommandGeneratedByCostCentreApplicationId = config.CostCentreApplicationId;
     cmd.CommandId = Guid.NewGuid();
     cmd.DocumentId = new Guid("71cba9ce-46d5-46b8-8448-2be79281055e");
     cmd.ReciepientCostCentreId = Guid.NewGuid();
     route.RouteDocumentCommand(cmd);
 }