Esempio n. 1
0
            /// <summary>
            /// Processa um item da fila
            /// </summary>
            /// <param name="mediator"></param>
            /// <returns></returns>
            public Task Process(IMediator mediator)
            {
                return(new Task(async() =>
                {
                    ItemVm item = null;

                    while (true)
                    {
                        try
                        {
                            AppContext.waitNext.WaitOne();
                            AppContext.Processando = true;
                            if (await AgenciaDigital.Invalido())
                            {
                                continue;
                            }
                            item = await new GetItemService().ObterProximo();
                            await mediator.Send(new SetBloqueioCommand(item));
                            await mediator.Send(new SetCNPJCommand(item));
                            await mediator.Send(new SetTipoCommand(item));
                            await mediator.Send(new SetSegmentoCommand(item));
                            await mediator.Send(new SetMotivoCommand(item));
                        }
                        catch (Exception ex)
                        {
                            if (item != null)
                            {
                                item.ErrorMessage = ex.Message;
                            }
                            Console.WriteLine(ex.Message);
                        }
                        finally
                        {
                            if (item != null)
                            {
                                await mediator.Send(new FinalizaCommand(item));
                                item = null;
                            }
                            AppContext.Processando = false;
                        }
                    }
                }, TaskCreationOptions.LongRunning));
            }
 public SetCNPJCommand(ItemVm item) : base(item)
 {
 }
Esempio n. 3
0
 public SetBloqueioCommand(ItemVm item) : base(item)
 {
 }
 public FinalizaCommand(ItemVm item) : base(item)
 {
 }
Esempio n. 5
0
 public SetMotivoCommand(ItemVm item) : base(item)
 {
 }
 public SetSegmentoCommand(ItemVm item) : base(item)
 {
 }
 public SetTipoCommand(ItemVm item) : base(item)
 {
 }