From 674ca83ba9243a9e95a7568c797668dab6aee26a Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:35:25 -0300 Subject: feat: upload files --- .../Servicos/Financeiro/BancosContasServico.cs | 362 ++++++++++ .../Servicos/Financeiro/CentroServico.cs | 92 +++ .../Servicos/Financeiro/FinanceiroServico.cs | 738 +++++++++++++++++++++ .../Servicos/Financeiro/FornecedorServico.cs | 123 ++++ .../Servicos/Financeiro/PlanoServico.cs | 120 ++++ .../Servicos/Financeiro/PlanosServico.cs | 93 +++ 6 files changed, 1528 insertions(+) create mode 100644 Gestor.Application/Servicos/Financeiro/BancosContasServico.cs create mode 100644 Gestor.Application/Servicos/Financeiro/CentroServico.cs create mode 100644 Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs create mode 100644 Gestor.Application/Servicos/Financeiro/FornecedorServico.cs create mode 100644 Gestor.Application/Servicos/Financeiro/PlanoServico.cs create mode 100644 Gestor.Application/Servicos/Financeiro/PlanosServico.cs (limited to 'Gestor.Application/Servicos/Financeiro') diff --git a/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs b/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs new file mode 100644 index 0000000..68c9a50 --- /dev/null +++ b/Gestor.Application/Servicos/Financeiro/BancosContasServico.cs @@ -0,0 +1,362 @@ +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.Domain.Common; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class BancosContasServico : BaseServico + { + public BancosContasServico() + { + } + + public async Task> BuscarBancos() + { + int num = 3; + List bancosContas1 = await Task.Run>(() => { + List bancosContas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + bancosContas = read.get_BancosContasRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 145, num, null, true); + continue; + } + return bancosContas; + } + return new List(); + }); + return bancosContas1; + } + + public async Task BuscarSaldo(DateTime inicio, long id) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo = read.get_SaldoRepository().BuscarPorData(inicio, id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 151, num, new { inicio = inicio, id = id }, true); + continue; + } + return saldo; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task BuscarSaldoAberto(long id) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo = read.get_SaldoRepository().BuscarAberto(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 147, num, id, true); + continue; + } + return saldo; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task> BuscarSaldoAberto(List ids) + { + int num = 3; + List saldos2 = await Task.Run>(() => { + List saldos; + while (num > 0) + { + try + { + List saldos1 = new List(); + using (UnitOfWork read = Instancia.Read) + { + ids.ForEach((long id) => { + Saldo saldo = read.get_SaldoRepository().BuscarAberto(id); + if (saldo == null) + { + return; + } + saldos1.Add(saldo); + }); + } + saldos = saldos1; + } + catch (Exception exception) + { + num = base.Registrar(exception, 148, num, ids, true); + continue; + } + return saldos; + } + return new List(); + }); + return saldos2; + } + + public async Task BuscarSaldoInicial(long id) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo = read.get_SaldoRepository().BuscarPorMenorData(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 151, num, new { id = id }, true); + continue; + } + return saldo; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task> BuscarSaldos(long id) + { + int num = 3; + List saldos1 = await Task.Run>(() => { + List saldos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldos = read.get_SaldoRepository().BuscarPorConta(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 150, num, id, true); + continue; + } + return saldos; + } + return new List(); + }); + return saldos1; + } + + public async Task Delete(BancosContas bancosContas) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(bancosContas.get_Id(), bancosContas.GetValorOriginal(), 26, 2)); + commited.get_BancosContasRepository().Delete(bancosContas.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 246, num, bancosContas, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task DeleteSaldo(Saldo saldo) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(saldo.get_Id(), saldo.GetValorOriginal(), 26, 2)); + commited.get_SaldoRepository().Delete(saldo.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 248, num, saldo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task FecharSaldo(Saldo saldo) + { + int num = 3; + Saldo saldo1 = await Task.Run(() => { + Saldo saldo2; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + saldo2 = read.get_LancamentoRepository().FecharSaldo(saldo); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 149, num, saldo, true); + continue; + } + return saldo2; + } + return new Saldo(); + }); + return saldo1; + } + + public async Task Save(BancosContas bancosContas) + { + int num = 3; + base.Sucesso = true; + BancosContas bancosConta1 = bancosContas; + BancosContas bancosConta2 = await Task.Run(() => { + BancosContas bancosConta; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + bancosContas = bancosConta1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (bancosContas.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(bancosContas.get_Id(), bancosContas, 26)); + } + bancosContas = (bancosContas.get_Id() == 0 ? commited.get_BancosContasRepository().SaveOrUpdate(bancosContas) : commited.get_BancosContasRepository().Merge(bancosContas)); + if (!flag) + { + registroLogs.Add(base.CreateLog(bancosContas.get_Id(), bancosContas.GetValorOriginal(), 26, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + bancosConta = bancosContas; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 245, num, bancosContas, true); + continue; + } + return bancosConta; + } + return bancosConta1; + }); + return bancosConta2; + } + + public async Task Save(Saldo saldo) + { + int num = 3; + base.Sucesso = true; + Saldo saldo1 = saldo; + Saldo saldo2 = await Task.Run(() => { + Saldo saldo3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + saldo = saldo1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (saldo.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(saldo.get_Conta().get_Id(), saldo, 26)); + } + saldo = (saldo.get_Id() == 0 ? commited.get_SaldoRepository().SaveOrUpdate(saldo) : commited.get_SaldoRepository().Merge(saldo)); + if (!flag) + { + registroLogs.Add(base.CreateLog(saldo.get_Conta().get_Id(), saldo.GetValorOriginal(), 26, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + saldo3 = saldo; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 247, num, saldo, true); + continue; + } + return saldo3; + } + return saldo1; + }); + return saldo2; + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Servicos/Financeiro/CentroServico.cs b/Gestor.Application/Servicos/Financeiro/CentroServico.cs new file mode 100644 index 0000000..7d16a58 --- /dev/null +++ b/Gestor.Application/Servicos/Financeiro/CentroServico.cs @@ -0,0 +1,92 @@ +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.Domain.Common; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class CentroServico : BaseServico + { + public CentroServico() + { + } + + public async Task> BuscarCentros() + { + int num = 3; + List centros1 = await Task.Run>(() => { + List centros; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + centros = read.get_CentroRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 153, num, null, true); + continue; + } + return centros; + } + return new List(); + }); + return centros1; + } + + public async Task Save(Centro centro) + { + int num = 3; + base.Sucesso = true; + Centro centro1 = centro; + Centro centro2 = await Task.Run(() => { + Centro centro3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + centro = centro1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (centro.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(centro.get_Id(), centro, 29)); + } + centro = (centro.get_Id() == 0 ? commited.get_CentroRepository().SaveOrUpdate(centro) : commited.get_CentroRepository().Merge(centro)); + if (!flag) + { + registroLogs.Add(base.CreateLog(centro.get_Id(), centro.GetValorOriginal(), 29, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + centro3 = centro; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 249, num, centro, true); + continue; + } + return centro3; + } + return centro1; + }); + return centro2; + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs b/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs new file mode 100644 index 0000000..817dca0 --- /dev/null +++ b/Gestor.Application/Servicos/Financeiro/FinanceiroServico.cs @@ -0,0 +1,738 @@ +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.Financeiro; +using Gestor.Model.Domain.Financeiro.Relatorios; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + public class FinanceiroServico : BaseServico + { + public FinanceiroServico() + { + } + + public async Task> AddRange(List lancamentos) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + List lancamentos1 = lancamentos; + List lancamentos2 = await Task.Run>(() => { + List lancamentos3; + while (num > 0) + { + List registroLogs = new List(); + lancamentos = lancamentos1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ControleFinanceiro controle = lancamentos.First().get_Controle(); + controle = (controle.get_Id() == 0 ? commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle) : commited.get_ControleFinanceiroRepository().Merge(controle)); + lancamentos.ForEach((Lancamento x) => { + x.set_Controle(controle); + x.set_DataLancamento(new DateTime?(networkTime)); + }); + lancamentos = commited.get_LancamentoRepository().AddRange(lancamentos); + lancamentos.ForEach((Lancamento x) => this.logs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 25, 0))); + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamentos3 = lancamentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 279, num, lancamentos, true); + continue; + } + return lancamentos3; + } + return lancamentos1; + }); + return lancamentos2; + } + + public async Task> Atualizar(List lancamentos) + { + int num = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + List lancamentos1 = lancamentos; + List lancamentos2 = await Task.Run>(() => { + List lancamentos3; + while (num > 0) + { + List registroLogs = new List(); + lancamentos = lancamentos1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + lancamentos.ForEach((Lancamento lancamento) => { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento, 25)); + lancamento.set_Controle(commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle())); + lancamento = commited.get_LancamentoRepository().Merge(lancamento); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamentos3 = lancamentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 280, num, lancamentos, true); + continue; + } + return lancamentos3; + } + return lancamentos1; + }); + return lancamentos2; + } + + public async Task> BuscarFechamento(FiltroFinanceiro filtro) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List lancamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamentos = read.get_LancamentoRepository().Fechamento(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 294, num, filtro, true); + continue; + } + return lancamentos; + } + return new List(); + }); + return lancamentos1; + } + + public async Task BuscarLancamento(long id, int parcela) + { + int num = 3; + Lancamento lancamento1 = await Task.Run(() => { + Lancamento lancamento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamento = read.get_LancamentoRepository().FindByControle(id, parcela); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 163, num, new { id = id, parcela = parcela }, true); + continue; + } + return lancamento; + } + return new Lancamento(); + }); + return lancamento1; + } + + public async Task BuscarLancamento(long id) + { + int num = 3; + Lancamento lancamento1 = await Task.Run(() => { + Lancamento lancamento; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamento = read.get_LancamentoRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 164, num, id, true); + continue; + } + return lancamento; + } + return new Lancamento(); + }); + return lancamento1; + } + + public async Task> BuscarLancamentos(DateTime inicio, DateTime fim, StatusLancamento status) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().Find(inicio, fim, status); + Func u003cu003e9_41 = FinanceiroServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + list = lancamentos.OrderByDescending(u003cu003e9_41).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 160, num, new { inicio = inicio, fim = fim, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentos(DateTime inicio, DateTime fim, long conta) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindLancamentosByConta(inicio, fim, conta); + Func u003cu003e9_61 = FinanceiroServico.u003cu003ec.u003cu003e9__6_1; + if (u003cu003e9_61 == null) + { + u003cu003e9_61 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__6_1 = u003cu003e9_61; + } + list = lancamentos.OrderByDescending(u003cu003e9_61).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 165, num, new { inicio = inicio, fim = fim, conta = conta }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPersonalizados(DateTime inicio, DateTime fim, StatusLancamento status, FiltroLancamentoData filtrodata) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindPersonalizado(inicio, fim, status, filtrodata); + Func u003cu003e9_71 = FinanceiroServico.u003cu003ec.u003cu003e9__7_1; + if (u003cu003e9_71 == null) + { + u003cu003e9_71 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__7_1 = u003cu003e9_71; + } + list = lancamentos.OrderByDescending(u003cu003e9_71).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 160, num, new { inicio = inicio, fim = fim, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorBaixa(DateTime inicio, DateTime fim) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByBaixa(inicio, fim); + Func u003cu003e9_81 = FinanceiroServico.u003cu003ec.u003cu003e9__8_1; + if (u003cu003e9_81 == null) + { + u003cu003e9_81 = (Lancamento x) => x.get_Baixa(); + FinanceiroServico.u003cu003ec.u003cu003e9__8_1 = u003cu003e9_81; + } + list = lancamentos.OrderByDescending(u003cu003e9_81).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 161, num, new { inicio = inicio, fim = fim }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorConta(DateTime inicio, DateTime fim, long id) + { + int num = 3; + List extratoContas1 = await Task.Run>(() => { + List extratoContas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + extratoContas = read.get_LancamentoRepository().FindByConta(inicio, fim, id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 165, num, new { inicio = inicio, fim = fim, id = id }, true); + continue; + } + return extratoContas; + } + return new List(); + }); + return extratoContas1; + } + + public async Task> BuscarLancamentosPorControle(long id) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List lancamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + lancamentos = read.get_LancamentoRepository().FindByControle(id, 2); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 158, num, new { id = id }, true); + continue; + } + return lancamentos; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorFornecedor(long id, StatusLancamento status) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByFornecedor(id, status); + Func u003cu003e9_11 = FinanceiroServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + list = lancamentos.OrderByDescending(u003cu003e9_11).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 157, num, new { id = id, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorFornecedor(long id, DateTime date, Sinal sinal) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByFornecedor(id, date, sinal); + Func u003cu003e9_21 = FinanceiroServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (Lancamento x) => x.get_Vencimento(); + FinanceiroServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + list = lancamentos.OrderByDescending(u003cu003e9_21).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 157, num, new { id = id, date = date }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorLancamento(DateTime inicio, DateTime fim, StatusLancamento status) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByLancamento(inicio, fim, status); + Func u003cu003e9_51 = FinanceiroServico.u003cu003ec.u003cu003e9__5_1; + if (u003cu003e9_51 == null) + { + u003cu003e9_51 = (Lancamento x) => x.get_DataLancamento(); + FinanceiroServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51; + } + list = lancamentos.OrderByDescending(u003cu003e9_51).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 329, num, new { inicio = inicio, fim = fim, status = status }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task> BuscarLancamentosPorPagamento(DateTime inicio, DateTime fim) + { + int num = 3; + List lancamentos1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List lancamentos = read.get_LancamentoRepository().FindByPagamento(inicio, fim); + Func u003cu003e9_91 = FinanceiroServico.u003cu003ec.u003cu003e9__9_1; + if (u003cu003e9_91 == null) + { + u003cu003e9_91 = (Lancamento x) => x.get_Pagamento(); + FinanceiroServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91; + } + list = lancamentos.OrderBy(u003cu003e9_91).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 162, num, new { inicio = inicio, fim = fim }, true); + continue; + } + return list; + } + return new List(); + }); + return lancamentos1; + } + + public async Task Excluir(List lancamentos) + { + int num = 3; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + lancamentos.ForEach((Lancamento x) => { + registroLogs.Add(base.CreateLog(x.get_Id(), x.GetValorOriginal(), 25, 2)); + if (commited.get_LancamentoRepository().FindByControle(x.get_Controle().get_Id(), 2).Count == 1) + { + commited.get_ControleFinanceiroRepository().Delete(x.get_Controle().get_Id()); + return; + } + x.get_Controle().set_Parcelas(x.get_Controle().get_Parcelas() - 1); + commited.get_ControleFinanceiroRepository().Merge(x.get_Controle()); + commited.get_LancamentoRepository().Delete(x.get_Id()); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + } + flag = true; + } + catch (Exception exception) + { + num = base.Registrar(exception, 282, num, lancamentos, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Excluir(Lancamento lancamento) + { + int num = 3; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 2)); + if (commited.get_LancamentoRepository().FindByControle(lancamento.get_Controle().get_Id(), 2).Count != 1) + { + lancamento.get_Controle().set_Parcelas(lancamento.get_Controle().get_Parcelas() - 1); + commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle()); + commited.get_LancamentoRepository().Delete(lancamento.get_Id()); + } + else + { + commited.get_ControleFinanceiroRepository().Delete(lancamento.get_Controle().get_Id()); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 282, num, lancamento, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task> IncluirRange(List lancamentos) + { + int num = 3; + base.Sucesso = true; + Funcoes.GetNetworkTime(); + List lancamentos1 = lancamentos; + List lancamentos2 = await Task.Run>(() => { + List lancamentos3; + while (num > 0) + { + List registroLogs = new List(); + lancamentos = lancamentos1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + lancamentos.ForEach((Lancamento lancamento) => { + lancamento.set_Controle(commited.get_ControleFinanceiroRepository().Merge(lancamento.get_Controle())); + lancamento = commited.get_LancamentoRepository().SaveOrUpdate(lancamento); + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 0)); + }); + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamentos3 = lancamentos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 281, num, lancamentos, true); + continue; + } + return lancamentos3; + } + return lancamentos1; + }); + return lancamentos2; + } + + public async Task Save(Lancamento lancamento) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Lancamento lancamento1 = lancamento; + Lancamento lancamento2 = await Task.Run(() => { + Lancamento lancamento3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + lancamento = lancamento1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (lancamento.get_Id() == 0 ? false : true); + if (!flag) + { + lancamento.set_DataLancamento(new DateTime?(networkTime)); + } + if (flag) + { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento, 25)); + } + ControleFinanceiro controle = lancamento.get_Controle(); + controle = (controle.get_Id() == 0 ? commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle) : commited.get_ControleFinanceiroRepository().Merge(controle)); + lancamento.set_Controle(controle); + lancamento = (lancamento.get_Id() == 0 ? commited.get_LancamentoRepository().SaveOrUpdate(lancamento) : commited.get_LancamentoRepository().Merge(lancamento)); + if (!flag) + { + registroLogs.Add(base.CreateLog(lancamento.get_Id(), lancamento.GetValorOriginal(), 25, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + lancamento3 = lancamento; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 279, num, lancamento, true); + continue; + } + return lancamento3; + } + return lancamento1; + }); + return lancamento2; + } + + public async Task TemLancamentosPorFornecedor(long id) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_LancamentoRepository().HasByFornecedor(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 154, num, id, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Transferir(Lancamento lancamentoOrigem, Lancamento lancamentoDestino) + { + int num = 3; + Lancamento lancamento = lancamentoOrigem; + Lancamento lancamento1 = lancamentoDestino; + Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + lancamentoOrigem = lancamento; + lancamentoDestino = lancamento1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ControleFinanceiro controle = lancamentoOrigem.get_Controle(); + controle = commited.get_ControleFinanceiroRepository().SaveOrUpdate(controle); + lancamentoOrigem.set_Controle(controle); + lancamentoDestino.set_Controle(controle); + lancamentoOrigem = commited.get_LancamentoRepository().SaveOrUpdate(lancamentoOrigem); + lancamentoDestino = commited.get_LancamentoRepository().SaveOrUpdate(lancamentoDestino); + registroLogs.Add(base.CreateLog(lancamentoOrigem.get_Id(), lancamentoOrigem.GetValorOriginal(), 25, 0)); + registroLogs.Add(base.CreateLog(lancamentoDestino.get_Id(), lancamentoDestino.GetValorOriginal(), 25, 0)); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 283, num, new { lancamentoOrigem = lancamentoOrigem, lancamentoDestino = lancamentoDestino }, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs b/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs new file mode 100644 index 0000000..674f46a --- /dev/null +++ b/Gestor.Application/Servicos/Financeiro/FornecedorServico.cs @@ -0,0 +1,123 @@ +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.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + public class FornecedorServico : BaseServico + { + public FornecedorServico() + { + } + + public async Task> BuscarFornecedores() + { + int num = 3; + List fornecedors1 = await Task.Run>(() => { + List fornecedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + fornecedors = read.get_FornecedorRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 166, num, null, true); + continue; + } + return fornecedors; + } + return new List(); + }); + return fornecedors1; + } + + public async Task Delete(Fornecedor fornecedor) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + List registroLogs = new List(); + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(fornecedor.get_Id(), fornecedor.GetValorOriginal(), 24, 2)); + commited.get_FornecedorRepository().Delete(fornecedor.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 244, num, fornecedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Fornecedor fornecedor) + { + int num = 3; + base.Sucesso = true; + Fornecedor fornecedor1 = fornecedor; + Fornecedor fornecedor2 = await Task.Run(() => { + Fornecedor fornecedor3; + while (num > 0) + { + List registroLogs = new List(); + fornecedor = fornecedor1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (fornecedor.get_Id() == 0 ? 0 : 1); + if (tipoAcao == 1) + { + registroLogs.Add(base.CreateLog(fornecedor.get_Id(), fornecedor, 24)); + } + fornecedor = (tipoAcao == null ? commited.get_FornecedorRepository().SaveOrUpdate(fornecedor) : commited.get_FornecedorRepository().Merge(fornecedor)); + if (tipoAcao == null) + { + registroLogs.Add(base.CreateLog(fornecedor.get_Id(), fornecedor.GetValorOriginal(), 24, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + fornecedor3 = fornecedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 243, num, fornecedor, true); + continue; + } + return fornecedor3; + } + return fornecedor1; + }); + return fornecedor2; + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Servicos/Financeiro/PlanoServico.cs b/Gestor.Application/Servicos/Financeiro/PlanoServico.cs new file mode 100644 index 0000000..9fc078a --- /dev/null +++ b/Gestor.Application/Servicos/Financeiro/PlanoServico.cs @@ -0,0 +1,120 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +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.Financeiro; +using Gestor.Model.Domain.Generic; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Linq; +using System.Net; +using System.Net.Sockets; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class PlanoServico : BaseServico + { + public PlanoServico() + { + } + + public async Task> BuscarPlanos() + { + int num = 3; + List planos1 = await Task.Run>(() => { + List planos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + planos = read.get_PlanosRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 167, num, null, true); + continue; + } + return planos; + } + return new List(); + }); + return planos1; + } + + public async Task Save(Plano plano) + { + int num = 3; + base.Sucesso = true; + Plano plano2 = plano; + Plano plano3 = await Task.Run(() => { + Plano plano4; + string str; + while (num > 0) + { + plano = plano2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (plano.get_Id() == 0 ? 0 : 1); + plano = (plano.get_Id() == 0 ? commited.get_PlanoRepository().SaveOrUpdate(plano) : commited.get_PlanoRepository().Merge(plano)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Plano plano1 = plano; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(plano1, jsonSerializerSetting)); + registroLog.set_EntidadeId(plano.get_Id()); + registroLog.set_Tela(27); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = PlanoServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + PlanoServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_01); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + plano4 = plano; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 250, num, plano, true); + continue; + } + return plano4; + } + return plano2; + }); + return plano3; + } + } +} \ No newline at end of file diff --git a/Gestor.Application/Servicos/Financeiro/PlanosServico.cs b/Gestor.Application/Servicos/Financeiro/PlanosServico.cs new file mode 100644 index 0000000..b00efbe --- /dev/null +++ b/Gestor.Application/Servicos/Financeiro/PlanosServico.cs @@ -0,0 +1,93 @@ +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.Domain.Common; +using Gestor.Model.Domain.Financeiro; +using Gestor.Model.Domain.Generic; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Financeiro +{ + internal class PlanosServico : BaseServico + { + public PlanosServico() + { + } + + internal async Task> BuscarPlanos() + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_PlanosRepository().Find()); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 168, num, null, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task Save(Planos planos) + { + int num = 3; + base.Sucesso = true; + Planos plano1 = planos; + Planos plano2 = await Task.Run(() => { + Planos plano; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + planos = plano1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (planos.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(planos.get_Id(), planos, 28)); + } + planos = (planos.get_Id() == 0 ? commited.get_PlanosRepository().SaveOrUpdate(planos) : commited.get_PlanosRepository().Merge(planos)); + if (!flag) + { + registroLogs.Add(base.CreateLog(planos.get_Id(), planos.GetValorOriginal(), 28, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + plano = planos; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 251, num, planos, true); + continue; + } + return plano; + } + return plano1; + }); + return plano2; + } + } +} \ No newline at end of file -- cgit v1.2.3