summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs')
-rw-r--r--Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs269
1 files changed, 269 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs
new file mode 100644
index 0000000..07b5444
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/AdiantamentoServico.cs
@@ -0,0 +1,269 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+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;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos.Ferramentas;
+
+public class AdiantamentoServico : BaseServico
+{
+ public async Task<Adiantamento> Save(Adiantamento adiatamento)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Adiantamento adiantamentoOriginal = adiatamento;
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run((Func<Adiantamento>)delegate
+ {
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d5: Expected O, but got Unknown
+ //IL_00da: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00eb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00fe: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0109: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0114: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0151: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ adiatamento = adiantamentoOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)(((DomainBase)adiatamento).Id != 0L);
+ adiatamento.Pagamento = (adiatamento.Pago ? new DateTime?(now) : null);
+ adiatamento = ((((DomainBase)adiatamento).Id == 0L) ? commited.AdiantamentoRepository.SaveOrUpdate(adiatamento) : commited.AdiantamentoRepository.Merge(adiatamento));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)adiatamento, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)adiatamento).Id,
+ Tela = (TipoTela)36,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return adiatamento;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)209, tries, adiatamento);
+ }
+ }
+ return adiantamentoOriginal;
+ });
+ }
+
+ public async Task<bool> Delete(Adiantamento adiantamento)
+ {
+ int tries = 3;
+ DateTime dateHora = Funcoes.GetNetworkTime();
+ return await Task.Run(delegate
+ {
+ //IL_002d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0033: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.AdiantamentoRepository.Delete(((DomainBase)adiantamento).Id);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)2;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = dateHora;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} EXCLUIU, EM {dateHora}, O PARCEIRO DE " + $"ID: '{((DomainBase)adiantamento).Id}'" + ", HISTÓRICO: '" + (string.IsNullOrWhiteSpace(adiantamento.Historico) ? "" : (adiantamento.Historico ?? "")) + "', DATA DO ADIANTAMENTO: '" + ((!adiantamento.Data.HasValue) ? "" : (adiantamento.Data?.ToShortDateString() ?? "")) + "'" + $", VALOR DO ADIANTAMENTO: 'R${adiantamento.Valor}'.";
+ val.EntidadeId = ((DomainBase)adiantamento).Id;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.Tela = (TipoTela)36;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)210, tries, adiantamento);
+ }
+ }
+ return false;
+ });
+ }
+
+ public async Task<List<Adiantamento>> BuscarPorData(Filtros filtro, bool segundavia = false)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.AdiantamentoRepository.FindByDate(filtro.Inicio, filtro.Fim, filtro.Vendedores, segundavia);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)15, tries, filtro);
+ }
+ }
+ return new List<Adiantamento>();
+ });
+ }
+
+ public async Task<List<Adiantamento>> BuscarAdiantamentos(long id, bool concluido)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.AdiantamentoRepository.BuscarAdiantamentos(id, concluido);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)16, tries, new { id, concluido });
+ }
+ }
+ return new List<Adiantamento>();
+ });
+ }
+
+ public async Task GerarPagamento(List<Adiantamento> adiantamentos)
+ {
+ int tries = 3;
+ DateTime now = Funcoes.GetNetworkTime();
+ await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ adiantamentos.ForEach(delegate(Adiantamento x)
+ {
+ //IL_0051: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0056: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0068: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0079: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007b: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0080: Unknown result type (might be due to invalid IL or missing references)
+ //IL_008c: Expected O, but got Unknown
+ //IL_0091: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00bb: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0103: Expected O, but got Unknown
+ Adiantamento val = unitOfWork.AdiantamentoRepository.FindById(((DomainBase)x).Id);
+ val.Pago = true;
+ val.Pagamento = now;
+ val = unitOfWork.AdiantamentoRepository.Merge(val);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)1,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)val, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)val).Id,
+ Tela = (TipoTela)36,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ });
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ break;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)194, tries, adiantamentos);
+ }
+ }
+ });
+ }
+}