summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs')
-rw-r--r--Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs310
1 files changed, 310 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs b/Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs
new file mode 100644
index 0000000..d8dc8d4
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos/ServicoExtrato.cs
@@ -0,0 +1,310 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+
+namespace Gestor.Application.Servicos;
+
+internal class ServicoExtrato : BaseServico
+{
+ internal async Task<ObservableCollection<DetalheExtrato>> BuscarDetalhes(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<DetalheExtrato>(from x in read.DetalheExtratoRepository.Find(id)
+ orderby x.Cliente, x.Apolice, x.Endosso, x.NumeroParcela
+ select x);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)91, tries, id);
+ }
+ }
+ return new ObservableCollection<DetalheExtrato>();
+ });
+ }
+
+ internal async Task<string> BuscarNumExtrato(long? id)
+ {
+ if (!id.HasValue || id <= 0)
+ {
+ return "";
+ }
+ string numeroExtrato = "";
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ DetalheExtrato val = read.DetalheExtratoRepository.FindByLongId(id).FirstOrDefault();
+ numeroExtrato = ((val != null && ((DomainBase)val).Id > 0) ? val.Extrato.Numero : "");
+ return numeroExtrato;
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)91, tries, id);
+ }
+ }
+ return "";
+ });
+ }
+
+ public async Task<List<Extrato>> BuscarExtrato(long id, long idusuario, StatusExtrato status, DateTime inicio, DateTime fim)
+ {
+ //IL_0026: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0027: Unknown result type (might be due to invalid IL or missing references)
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_00b6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0035: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return (from x in read.ExtratoRepository.FindBySeguradora(id, idusuario, ((DomainBase)Recursos.Empresa).Id, inicio, fim, (StatusExtrato?)status)
+ orderby x.Numero, x.Data descending
+ select x).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)92, tries, new { id, status, inicio, fim });
+ }
+ }
+ return new List<Extrato>();
+ });
+ }
+
+ public async Task<List<Extrato>> BuscarExtratoPorData(Filtros filtros)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return (from x in read.ExtratoRepository.FindByData(filtros)
+ orderby x.Data
+ select x).ToList();
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)93, tries, filtros);
+ }
+ }
+ return new List<Extrato>();
+ });
+ }
+
+ public async Task<DetalheExtrato> Save(DetalheExtrato detalhe)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ DetalheExtrato detalheOriginal = detalhe;
+ return await Task.Run((Func<DetalheExtrato>)delegate
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0041: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0043: Invalid comparison between Unknown and I4
+ //IL_009b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ detalhe = detalheOriginal;
+ try
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao val = (TipoAcao)(((DomainBase)detalhe).Id != 0L);
+ commited.DetalheExtratoRepository.Merge(detalhe);
+ if ((int)val == 1)
+ {
+ list.Add(CreateLog(((DomainBase)detalhe).Id, ((DomainBase)detalhe).GetValorOriginal(), (TipoTela)23, val));
+ }
+ else
+ {
+ list.Add(CreateLog(((DomainBase)detalhe).Id, ((DomainBase)detalhe).Compare(((DomainBase)detalheOriginal).GetValorOriginal()), (TipoTela)23, val));
+ }
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return detalhe;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)262, tries, detalhe);
+ }
+ }
+ return detalheOriginal;
+ });
+ }
+
+ public async Task<Extrato> Save(Extrato extrato)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Extrato extratoOriginal = extrato;
+ return await Task.Run((Func<Extrato>)delegate
+ {
+ //IL_002e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0041: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0043: Invalid comparison between Unknown and I4
+ //IL_009b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0064: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ extrato = extratoOriginal;
+ try
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao val = (TipoAcao)(((DomainBase)extrato).Id != 0L);
+ commited.ExtratoRepository.Merge(extrato);
+ if ((int)val == 1)
+ {
+ list.Add(CreateLog(((DomainBase)extrato).Id, ((DomainBase)extrato).GetValorOriginal(), (TipoTela)23, val));
+ }
+ else
+ {
+ list.Add(CreateLog(((DomainBase)extrato).Id, ((DomainBase)extrato).Compare(((DomainBase)extratoOriginal).GetValorOriginal()), (TipoTela)23, val));
+ }
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ return extrato;
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)263, tries, extrato);
+ }
+ }
+ return extratoOriginal;
+ });
+ }
+
+ public async Task<bool> Delete(Extrato extrato)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ List<RegistroLog> list = new List<RegistroLog>();
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.ExtratoRepository.Delete(((DomainBase)extrato).Id);
+ list.Add(CreateLog(((DomainBase)extrato).Id, ((DomainBase)extrato).GetValorOriginal(), (TipoTela)1, (TipoAcao)2));
+ SaveLog(list, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)264, tries, extrato);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<DetalheExtrato> FindByParcelaId(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<DetalheExtrato>)delegate
+ {
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.DetalheExtratoRepository.FindByParcelaId(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)74, tries, id);
+ }
+ }
+ return new DetalheExtrato();
+ });
+ }
+}