From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../Gestor.Application/Servicos/ServicoExtrato.cs | 335 +++++++++++++++++++++ 1 file changed, 335 insertions(+) create mode 100644 Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs (limited to 'Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs') diff --git a/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs b/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs new file mode 100644 index 0000000..a2742e4 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/ServicoExtrato.cs @@ -0,0 +1,335 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +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 System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos +{ + internal class ServicoExtrato : BaseServico + { + public ServicoExtrato() + { + } + + internal async Task> BuscarDetalhes(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List detalheExtratos = read.get_DetalheExtratoRepository().Find(id); + Func u003cu003e9_01 = ServicoExtrato.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (DetalheExtrato x) => x.get_Cliente(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IOrderedEnumerable detalheExtratos1 = detalheExtratos.OrderBy(u003cu003e9_01); + Func u003cu003e9_02 = ServicoExtrato.u003cu003ec.u003cu003e9__0_2; + if (u003cu003e9_02 == null) + { + u003cu003e9_02 = (DetalheExtrato x) => x.get_Apolice(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02; + } + IOrderedEnumerable detalheExtratos2 = detalheExtratos1.ThenBy(u003cu003e9_02); + Func u003cu003e9_03 = ServicoExtrato.u003cu003ec.u003cu003e9__0_3; + if (u003cu003e9_03 == null) + { + u003cu003e9_03 = (DetalheExtrato x) => x.get_Endosso(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_3 = u003cu003e9_03; + } + IOrderedEnumerable detalheExtratos3 = detalheExtratos2.ThenBy(u003cu003e9_03); + Func u003cu003e9_04 = ServicoExtrato.u003cu003ec.u003cu003e9__0_4; + if (u003cu003e9_04 == null) + { + u003cu003e9_04 = (DetalheExtrato x) => x.get_NumeroParcela(); + ServicoExtrato.u003cu003ec.u003cu003e9__0_4 = u003cu003e9_04; + } + observableCollection = new ObservableCollection(detalheExtratos3.ThenBy(u003cu003e9_04)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 91, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarExtrato(long id, long idusuario, StatusExtrato status, DateTime inicio, DateTime fim) + { + int num = 3; + List extratos2 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List extratos = read.get_ExtratoRepository().FindBySeguradora(id, idusuario, Recursos.Empresa.get_Id(), inicio, fim, new StatusExtrato?(status)); + Func u003cu003e9_21 = ServicoExtrato.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (Extrato x) => x.get_Numero(); + ServicoExtrato.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + IOrderedEnumerable extratos1 = extratos.OrderBy(u003cu003e9_21); + Func u003cu003e9_22 = ServicoExtrato.u003cu003ec.u003cu003e9__2_2; + if (u003cu003e9_22 == null) + { + u003cu003e9_22 = (Extrato x) => x.get_Data(); + ServicoExtrato.u003cu003ec.u003cu003e9__2_2 = u003cu003e9_22; + } + list = extratos1.ThenByDescending(u003cu003e9_22).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 92, num, new { id = id, status = status, inicio = inicio, fim = fim }, true); + continue; + } + return list; + } + return new List(); + }); + return extratos2; + } + + public async Task> BuscarExtratoPorData(Filtros filtros) + { + int num = 3; + List extratos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List extratos = read.get_ExtratoRepository().FindByData(filtros); + Func u003cu003e9_31 = ServicoExtrato.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (Extrato x) => x.get_Data(); + ServicoExtrato.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + list = extratos.OrderBy(u003cu003e9_31).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 93, num, filtros, true); + continue; + } + return list; + } + return new List(); + }); + return extratos1; + } + + internal async Task BuscarNumExtrato(long? id) + { + string str1; + if (id.HasValue) + { + long? nullable = id; + long num = (long)0; + if (!(nullable.GetValueOrDefault() <= num & nullable.HasValue)) + { + string str2 = ""; + int num1 = 3; + str1 = await Task.Run(() => { + string str; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + DetalheExtrato detalheExtrato = read.get_DetalheExtratoRepository().FindByLongId(id).FirstOrDefault(); + str2 = (detalheExtrato == null || detalheExtrato.get_Id() <= (long)0 ? "" : detalheExtrato.get_Extrato().get_Numero()); + str = str2; + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 91, num1, id, true); + continue; + } + return str; + } + return ""; + }); + return str1; + } + } + str1 = ""; + return str1; + } + + public async Task Delete(Extrato extrato) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ExtratoRepository().Delete(extrato.get_Id()); + registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.GetValorOriginal(), 1, 2)); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 264, num, extrato, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task FindByParcelaId(long id) + { + int num = 3; + DetalheExtrato detalheExtrato1 = await Task.Run(() => { + DetalheExtrato detalheExtrato; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + detalheExtrato = read.get_DetalheExtratoRepository().FindByParcelaId(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 74, num, id, true); + continue; + } + return detalheExtrato; + } + return new DetalheExtrato(); + }); + return detalheExtrato1; + } + + public async Task Save(DetalheExtrato detalhe) + { + int num = 3; + base.Sucesso = true; + DetalheExtrato detalheExtrato1 = detalhe; + DetalheExtrato detalheExtrato2 = await Task.Run(() => { + DetalheExtrato detalheExtrato; + while (num > 0) + { + detalhe = detalheExtrato1; + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (detalhe.get_Id() == 0 ? 0 : 1); + commited.get_DetalheExtratoRepository().Merge(detalhe); + if (tipoAcao != 1) + { + registroLogs.Add(base.CreateLog(detalhe.get_Id(), detalhe.Compare(detalheExtrato1.GetValorOriginal()), 23, tipoAcao)); + } + else + { + registroLogs.Add(base.CreateLog(detalhe.get_Id(), detalhe.GetValorOriginal(), 23, tipoAcao)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + detalheExtrato = detalhe; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 262, num, detalhe, true); + continue; + } + return detalheExtrato; + } + return detalheExtrato1; + }); + return detalheExtrato2; + } + + public async Task Save(Extrato extrato) + { + int num = 3; + base.Sucesso = true; + Extrato extrato1 = extrato; + Extrato extrato2 = await Task.Run(() => { + Extrato extrato3; + while (num > 0) + { + extrato = extrato1; + try + { + List registroLogs = new List(); + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (extrato.get_Id() == 0 ? 0 : 1); + commited.get_ExtratoRepository().Merge(extrato); + if (tipoAcao != 1) + { + registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.Compare(extrato1.GetValorOriginal()), 23, tipoAcao)); + } + else + { + registroLogs.Add(base.CreateLog(extrato.get_Id(), extrato.GetValorOriginal(), 23, tipoAcao)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + extrato3 = extrato; + } + catch (Exception exception) + { + num = base.Registrar(exception, 263, num, extrato, true); + continue; + } + return extrato3; + } + return extrato1; + }); + return extrato2; + } + } +} \ No newline at end of file -- cgit v1.2.3