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 --- .../Servicos/Ferramentas/AdiantamentoServico.cs | 281 +++++++ .../Servicos/Ferramentas/AgendaServico.cs | 257 +++++++ .../Servicos/Ferramentas/EmailServico.cs | 127 +++ .../Servicos/Ferramentas/EmpresaServico.cs | 287 +++++++ .../Servicos/Ferramentas/EstipulanteServico.cs | 124 +++ .../Servicos/Ferramentas/ImpostoServico.cs | 171 +++++ .../Servicos/Ferramentas/MetaSeguradoraServico.cs | 182 +++++ .../Servicos/Ferramentas/MetaVendedorServico.cs | 182 +++++ .../Servicos/Ferramentas/NotaFiscalServico.cs | 176 +++++ .../Servicos/Ferramentas/ProdutoServico.cs | 92 +++ .../Servicos/Ferramentas/QualificacaoServico.cs | 57 ++ .../Servicos/Ferramentas/RamoServico.cs | 192 +++++ .../Servicos/Ferramentas/ReciboServico.cs | 123 +++ .../Servicos/Ferramentas/SeguradoraServico.cs | 372 +++++++++ .../Servicos/Ferramentas/SocioServico.cs | 97 +++ .../Ferramentas/StatusProspeccaoServico.cs | 93 +++ .../Servicos/Ferramentas/StatusServico.cs | 124 +++ .../Servicos/Ferramentas/TipoTarefaServico.cs | 93 +++ .../Servicos/Ferramentas/TipoVendedorServico.cs | 131 ++++ .../Servicos/Ferramentas/UsuarioServico.cs | 303 ++++++++ .../Servicos/Ferramentas/VendedorServico.cs | 851 +++++++++++++++++++++ 21 files changed, 4315 insertions(+) create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs create mode 100644 Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs (limited to 'Codemerx/Gestor.Application/Servicos/Ferramentas') diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs new file mode 100644 index 0000000..24289ac --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/AdiantamentoServico.cs @@ -0,0 +1,281 @@ +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.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +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.Ferramentas +{ + public class AdiantamentoServico : BaseServico + { + public AdiantamentoServico() + { + } + + public async Task> BuscarAdiantamentos(long id, bool concluido) + { + int num = 3; + List adiantamentos1 = await Task.Run>(() => { + List adiantamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + adiantamentos = read.get_AdiantamentoRepository().BuscarAdiantamentos(id, concluido); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 16, num, new { id = id, concluido = concluido }, true); + continue; + } + return adiantamentos; + } + return new List(); + }); + return adiantamentos1; + } + + public async Task> BuscarPorData(Filtros filtro, bool segundavia = false) + { + int num = 3; + List adiantamentos1 = await Task.Run>(() => { + List adiantamentos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + adiantamentos = read.get_AdiantamentoRepository().FindByDate(filtro.get_Inicio(), filtro.get_Fim(), filtro.get_Vendedores(), segundavia); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 15, num, filtro, true); + continue; + } + return adiantamentos; + } + return new List(); + }); + return adiantamentos1; + } + + public async Task Delete(Adiantamento adiantamento) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + object obj; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_AdiantamentoRepository().Delete(adiantamento.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, O PARCEIRO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", adiantamento.get_Id()), ", HISTÓRICO: '", null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(adiantamento.get_Historico()) ? "" : adiantamento.get_Historico() ?? ""); + strArrays[4] = "', DATA DO ADIANTAMENTO: '"; + DateTime? data = adiantamento.get_Data(); + if (!data.HasValue) + { + obj = ""; + } + else + { + data = adiantamento.get_Data(); + obj = (data.HasValue ? data.GetValueOrDefault().ToShortDateString() : null) ?? ""; + } + strArrays[5] = (string)obj; + strArrays[6] = "'"; + strArrays[7] = string.Format(", VALOR DO ADIANTAMENTO: 'R${0}'.", adiantamento.get_Valor()); + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(adiantamento.get_Id()); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_Tela(36); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = AdiantamentoServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AdiantamentoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 210, num, adiantamento, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task GerarPagamento(List adiantamentos) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + await Task.Run(() => { + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + adiantamentos.ForEach((Adiantamento x) => { + string str; + Adiantamento adiantamento = commited.get_AdiantamentoRepository().FindById(x.get_Id()); + adiantamento.set_Pago(true); + adiantamento.set_Pagamento(new DateTime?(networkTime)); + adiantamento = commited.get_AdiantamentoRepository().Merge(adiantamento); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(adiantamento, jsonSerializerSetting)); + registroLog.set_EntidadeId(adiantamento.get_Id()); + registroLog.set_Tela(36); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_42 = AdiantamentoServico.u003cu003ec.u003cu003e9__4_2; + if (u003cu003e9_42 == null) + { + u003cu003e9_42 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AdiantamentoServico.u003cu003ec.u003cu003e9__4_2 = u003cu003e9_42; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_42); + str = (pAddress != null ? pAddress.ToString() : null); + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + }); + commited.Commit(); + break; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 194, num, adiantamentos, true); + } + } + }); + } + + public async Task Save(Adiantamento adiatamento) + { + int num = 3; + base.Sucesso = true; + Adiantamento adiantamento2 = adiatamento; + DateTime networkTime = Funcoes.GetNetworkTime(); + Adiantamento adiantamento3 = await Task.Run(() => { + Adiantamento adiantamento; + string str; + while (num > 0) + { + adiatamento = adiantamento2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (adiatamento.get_Id() == 0 ? 0 : 1); + adiatamento.set_Pagamento((adiatamento.get_Pago() ? new DateTime?(networkTime) : null)); + adiatamento = (adiatamento.get_Id() == 0 ? commited.get_AdiantamentoRepository().SaveOrUpdate(adiatamento) : commited.get_AdiantamentoRepository().Merge(adiatamento)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Adiantamento adiantamento1 = adiatamento; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(adiantamento1, jsonSerializerSetting)); + registroLog.set_EntidadeId(adiatamento.get_Id()); + registroLog.set_Tela(36); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = AdiantamentoServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AdiantamentoServico.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(); + adiantamento = adiatamento; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 209, num, adiatamento, true); + continue; + } + return adiantamento; + } + return adiantamento2; + }); + return adiantamento3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs new file mode 100644 index 0000000..d52af23 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/AgendaServico.cs @@ -0,0 +1,257 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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.Ferramentas +{ + internal class AgendaServico : BaseServico + { + public AgendaServico() + { + } + + internal async Task> BuscarEmailsAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_AgendaEmailRepository().FindByAgendaId(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 108, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + internal async Task> BuscarTelefonesAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_AgendaTelefoneRepository().FindByAgendaId(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 107, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task Delete(Agenda agenda) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_AgendaRepository().Delete(agenda.get_Id()); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(string.Concat(new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, O CONTATO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", agenda.get_Id()), ", NOME: '", (string.IsNullOrWhiteSpace(agenda.get_Nome()) ? "" : agenda.get_Nome() ?? ""), "', ENDEREÇO: '", agenda.get_Endereco(), ", ", agenda.get_Numero(), ", ", (string.IsNullOrWhiteSpace(agenda.get_Complemento()) ? "-" : agenda.get_Complemento() ?? ""), ", ", agenda.get_Bairro(), ", ", agenda.get_Cidade(), "/", agenda.get_Estado(), " - ", agenda.get_Cep(), "', OBSERVAÇÃO: '", (string.IsNullOrWhiteSpace(agenda.get_Observacao()) ? "" : agenda.get_Observacao() ?? ""), "'." })); + registroLog.set_EntidadeId(agenda.get_Id()); + registroLog.set_Tela(34); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog1 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = AgendaServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AgendaServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 216, num, agenda, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Agenda agenda) + { + int num = 3; + base.Sucesso = true; + Agenda agenda2 = agenda; + Agenda agenda3 = await Task.Run(() => { + Agenda agenda4; + List list; + List agendaEmails; + string str; + while (num > 0) + { + agenda = agenda2; + try + { + TipoAcao tipoAcao = (agenda.get_Id() == 0 ? 0 : 1); + ObservableCollection telefones = agenda.get_Telefones(); + if (telefones != null) + { + list = telefones.ToList(); + } + else + { + list = null; + } + List agendaTelefones = list; + ObservableCollection emails = agenda.get_Emails(); + if (emails != null) + { + agendaEmails = emails.ToList(); + } + else + { + agendaEmails = null; + } + List agendaEmails1 = agendaEmails; + agenda.set_Telefones(null); + agenda.set_Emails(null); + using (UnitOfWork commited = Instancia.Commited) + { + if (agenda.get_Id() != (long)0) + { + if (agendaTelefones != null) + { + agendaTelefones = commited.get_AgendaTelefoneRepository().Merge(agendaTelefones, agenda); + } + if (agendaEmails1 != null) + { + agendaEmails1 = commited.get_AgendaEmailRepository().Merge(agendaEmails1, agenda); + } + agenda = commited.get_AgendaRepository().Merge(agenda); + } + else + { + agenda = commited.get_AgendaRepository().SaveOrUpdate(agenda); + if (agendaTelefones != null) + { + agendaTelefones = commited.get_AgendaTelefoneRepository().Inserir(agendaTelefones, agenda); + } + if (agendaEmails1 != null) + { + agendaEmails1 = commited.get_AgendaEmailRepository().Inserir(agendaEmails1, agenda); + } + } + agenda.set_Telefones((agendaTelefones == null ? null : new ObservableCollection(agendaTelefones))); + agenda.set_Emails((agendaEmails1 == null ? null : new ObservableCollection(agendaEmails1))); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Agenda agenda1 = agenda; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(agenda1, jsonSerializerSetting)); + registroLog.set_EntidadeId(agenda.get_Id()); + registroLog.set_Tela(34); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = AgendaServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + AgendaServico.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(); + agenda4 = agenda; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 215, num, agenda, true); + continue; + } + return agenda4; + } + return agenda2; + }); + return agenda3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs new file mode 100644 index 0000000..2e8887d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmailServico.cs @@ -0,0 +1,127 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Common.Helpers; +using Gestor.Infrastructure.Repository.Interface; +using Gestor.Infrastructure.UnitOfWork.Generic; +using Gestor.Infrastructure.UnitOfWork.Logic; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class EmailServico : BaseServico + { + public EmailServico() + { + } + + internal async Task> BuscarEmail(string email) + { + int num = 3; + List clienteEmails1 = await Task.Run>(() => { + List clienteEmails; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + clienteEmails = read.get_ClienteEmailRepository().FindEmailCliente(email, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 109, num, email, true); + continue; + } + return clienteEmails; + } + return new List(); + }); + return clienteEmails1; + } + + public async Task Delete(Credencial email) + { + 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(email.get_Id(), email.GetValorOriginal(), 17, 2)); + commited.get_CredencialRepository().Delete(email.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 218, num, email, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Credencial credencial) + { + int num = 3; + base.Sucesso = true; + Credencial credencial1 = credencial; + Credencial credencial2 = await Task.Run(() => { + Credencial credencial3; + bool flag; + List registroLogs = new List(); + credencial = credencial1; + while (num > 0) + { + credencial = credencial1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (credencial.get_Id() == 0 ? false : true); + credencial.set_Senha(EncryptionHelper.Encrypt(credencial.get_Senha())); + if (flag) + { + registroLogs.Add(base.CreateLog(credencial.get_Id(), credencial, 17)); + } + credencial = (credencial.get_Id() == 0 ? commited.get_CredencialRepository().SaveOrUpdate(credencial) : commited.get_CredencialRepository().Merge(credencial)); + if (!flag) + { + registroLogs.Add(base.CreateLog(credencial.get_Id(), credencial.GetValorOriginal(), 17, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + credencial3 = credencial; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 217, num, credencial, true); + continue; + } + return credencial3; + } + return credencial1; + }); + return credencial2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs new file mode 100644 index 0000000..4d6d354 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs @@ -0,0 +1,287 @@ +using ArquivoDigital.Infrastructure.Repository.Interface; +using ArquivoDigital.Infrastructure.UnitOfWork.Logic; +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.API; +using Gestor.Model.Common; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +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.Ferramentas +{ + internal class EmpresaServico : BaseServico + { + public EmpresaServico() + { + } + + public async void AtualizarLogoId(long id, string idLogo) + { + await Task.Run(() => { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + Empresa empresa = commited.get_EmpresaRepository().FindById(id); + empresa.set_LogoId(idLogo); + commited.get_EmpresaRepository().Merge(empresa); + commited.Commit(); + } + } + catch (Exception exception) + { + } + }); + } + + internal async Task BuscarEmpresaPorId(long id) + { + int num = 3; + Empresa empresa1 = await Task.Run(() => { + Empresa empresa; + while (num > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + empresa = read.get_EmpresaRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 114, num, id, true); + continue; + } + return empresa; + } + return new Empresa(); + }); + return empresa1; + } + + internal async Task> BuscarEmpresas() + { + int num = 3; + List empresas1 = await Task.Run>(() => { + List empresas; + while (num > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + empresas = read.get_EmpresaRepository().Find((Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 113, num, null, true); + continue; + } + return empresas; + } + return new List(); + }); + return empresas1; + } + + public string BuscarSenhaAdm() + { + string str; + int num = 3; + while (num > 0) + { + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + str = read.get_EmpresaRepository().BuscarSenhaAdm((long)1); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 115, num, null, true); + continue; + } + return str; + } + return null; + } + + public async Task ConsultaEspacoBancoInGb() + { + double num3 = await Task.Run(() => { + double num; + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork read = Instancia.Read) + { + double num1 = read.get_EmpresaRepository().ConsultaEspacoBancoInGb(); + double num2 = 0; + try + { + foreach (ControleArquivoDigital controleArquivoDigital in read.get_IndiceArquivoDigitalRepository().BuscarBancos()) + { + if (controleArquivoDigital.get_Tabela().ToLower() == "arquivos") + { + continue; + } + try + { + Gestor.Application.Helpers.ArquivoDigital.SetConnection(controleArquivoDigital.get_Catalogo()); + using (ArquivoDigital.Infrastructure.UnitOfWork.Logic.UnitOfWork unitOfWork = Gestor.Application.Helpers.ArquivoDigital.Read) + { + num2 += unitOfWork.get_ArquivoDigitalRepository().ConsultaEspacoBancoInGb(); + } + } + catch + { + } + } + } + catch + { + } + num = num1 + num2; + } + } + catch (Exception exception) + { + return 0; + } + return num; + }); + return num3; + } + + internal async Task Save(Customer customer) + { + int num = 3; + base.Sucesso = true; + Customer customer1 = customer; + Customer customer2 = await Task.Run(() => { + Customer customer3; + while (num > 0) + { + customer = customer1; + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + Empresa empresa = new Empresa(); + empresa.set_Nome(customer.get_Name()); + empresa.set_Documento(customer.get_Document()); + empresa.set_Bairro(customer.get_District()); + empresa.set_Cidade(customer.get_City()); + empresa.set_Complemento(customer.get_Adjunct()); + empresa.set_Numero(customer.get_Number()); + empresa.set_Cep(customer.get_PostCode()); + empresa.set_Estado(customer.get_State()); + empresa.set_Email(customer.get_Mail()); + empresa.set_PrimeiroPrefixo(customer.get_AreaCode()); + empresa.set_PrimeiroTelefone(customer.get_Phone()); + empresa.set_SegundoPrefixo(customer.get_SecondAreaCode()); + empresa.set_SegundoTelefone(customer.get_SecondPhone()); + empresa.set_Serial(ApplicationHelper.NumeroSerial); + empresa.set_Site(customer.get_Site()); + commited.get_EmpresaRepository().SaveOrUpdate(empresa); + commited.Commit(); + customer3 = customer; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 277, num, customer, true); + continue; + } + return customer3; + } + return customer1; + }); + return customer2; + } + + public async Task Save(Empresa empresa) + { + int num = 3; + base.Sucesso = true; + Empresa empresa2 = empresa; + Empresa empresa3 = await Task.Run(() => { + Empresa empresa4; + string str; + while (num > 0) + { + empresa = empresa2; + try + { + using (Gestor.Infrastructure.UnitOfWork.Logic.UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (empresa.get_Id() == 0 ? 0 : 1); + empresa = (empresa.get_Id() == 0 ? commited.get_EmpresaRepository().SaveOrUpdate(empresa) : commited.get_EmpresaRepository().Merge(empresa)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (Recursos.Usuario.get_Id() != 0) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + Empresa empresa1 = empresa; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(empresa1, jsonSerializerSetting)); + registroLog.set_EntidadeId(empresa.get_Id()); + registroLog.set_Tela(18); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_31 = EmpresaServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + EmpresaServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_31); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + } + commited.Commit(); + empresa4 = empresa; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 277, num, empresa, true); + continue; + } + return empresa4; + } + return empresa2; + }); + return empresa3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs new file mode 100644 index 0000000..413a361 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/EstipulanteServico.cs @@ -0,0 +1,124 @@ +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.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class EstipulanteServico : BaseServico + { + public EstipulanteServico() + { + } + + internal async Task BuscarEstipulantePorId(long id) + { + int num = 3; + Estipulante estipulante1 = await Task.Run(() => { + Estipulante estipulante; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + estipulante = read.get_EstipulanteRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 110, num, id, true); + continue; + } + return estipulante; + } + return new Estipulante(); + }); + return estipulante1; + } + + public async Task Delete(Estipulante estipulante) + { + 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(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 2)); + commited.get_EstipulanteRepository().Delete(estipulante.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 220, num, estipulante, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Estipulante estipulante) + { + int num = 3; + base.Sucesso = true; + Estipulante estipulante1 = estipulante; + Estipulante estipulante2 = await Task.Run(() => { + Estipulante estipulante3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + estipulante = estipulante1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + estipulante.set_IdEmpresa(Recursos.Empresa.get_Id()); + flag = (estipulante.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante, 9)); + } + estipulante = (estipulante.get_Id() == 0 ? commited.get_EstipulanteRepository().SaveOrUpdate(estipulante) : commited.get_EstipulanteRepository().Merge(estipulante)); + if (!flag) + { + registroLogs.Add(base.CreateLog(estipulante.get_Id(), estipulante.GetValorOriginal(), 9, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + estipulante3 = estipulante; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 219, num, estipulante, true); + continue; + } + return estipulante3; + } + return estipulante1; + }); + return estipulante2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs new file mode 100644 index 0000000..ac8cd9f --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ImpostoServico.cs @@ -0,0 +1,171 @@ +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.Ferramentas; +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.Ferramentas +{ + public class ImpostoServico : BaseServico + { + public ImpostoServico() + { + } + + public async Task> Buscar(bool? ativo) + { + int num = 3; + List impostos1 = await Task.Run>(() => { + List impostos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + impostos = read.get_ImpostoRepository().DefaultSelect(ativo); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 317, num, ativo, true); + continue; + } + return impostos; + } + return new List(); + }); + return impostos1; + } + + public async Task> BuscarPorRamo(long id) + { + int num = 3; + List impostos1 = await Task.Run>(() => { + List impostos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + impostos = read.get_ImpostoRepository().FindByRamo(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 317, num, id, true); + continue; + } + return impostos; + } + return new List(); + }); + return impostos1; + } + + public async Task> BuscarPorSeguradora(long id) + { + int num = 3; + List impostos1 = await Task.Run>(() => { + List impostos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + impostos = read.get_ImpostoRepository().FindBySeguradora(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 317, num, id, true); + continue; + } + return impostos; + } + return new List(); + }); + return impostos1; + } + + public async Task Salvar(Imposto imposto) + { + int num = 3; + Imposto imposto2 = await Task.Run(() => { + Imposto imposto3; + string str; + while (num > 0) + { + this.Sucesso = true; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (imposto.get_Id() == 0 ? 0 : 1); + Imposto imposto1 = (tipoAcao == null ? commited.get_ImpostoRepository().SaveOrUpdate(imposto) : commited.get_ImpostoRepository().Merge(imposto)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(imposto1, jsonSerializerSetting)); + registroLog.set_EntidadeId(imposto1.get_Id()); + registroLog.set_Tela(56); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_31 = ImpostoServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + ImpostoServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_31); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + imposto3 = imposto1; + } + } + catch (Exception exception1) + { + Exception exception = exception1; + this.Sucesso = false; + num = base.Registrar(exception, 318, num, imposto, false); + continue; + } + return imposto3; + } + return imposto; + }); + return imposto2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs new file mode 100644 index 0000000..3cac6b8 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs @@ -0,0 +1,182 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Common.Validation; +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 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.Ferramentas +{ + internal class MetaSeguradoraServico : BaseServico + { + public MetaSeguradoraServico() + { + } + + public async Task> BuscarMetasSeguradoras(Filtros filtro) + { + int num = 3; + List metaSeguradoras1 = await Task.Run>(() => { + List metaSeguradoras; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + metaSeguradoras = read.get_MetaSeguradoraRepository().FindByMeta(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 284, num, filtro, true); + continue; + } + return metaSeguradoras; + } + return new List(); + }); + return metaSeguradoras1; + } + + public async Task Delete(MetaSeguradora meta) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_MetaSeguradoraRepository().Delete(meta.get_Id()); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(string.Concat(new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A META DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", meta.get_Id()), ", MÊS: '", Gestor.Common.Validation.ValidationHelper.GetDescription(meta.get_Mes()), "'", string.Format(", ANO: '{0}'", meta.get_Ano()), string.Format(", VALOR: 'R${0}'.", meta.get_Valor()) })); + registroLog.set_EntidadeId(meta.get_Id()); + registroLog.set_Tela(31); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog1 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 223, num, meta, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(MetaSeguradora metaSeguradora) + { + int num = 3; + base.Sucesso = true; + MetaSeguradora metaSeguradora2 = metaSeguradora; + MetaSeguradora metaSeguradora3 = await Task.Run(() => { + MetaSeguradora metaSeguradora4; + string str; + while (num > 0) + { + metaSeguradora = metaSeguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (metaSeguradora.get_Id() == 0 ? 0 : 1); + metaSeguradora = (metaSeguradora.get_Id() == 0 ? commited.get_MetaSeguradoraRepository().SaveOrUpdate(metaSeguradora) : commited.get_MetaSeguradoraRepository().Merge(metaSeguradora)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + MetaSeguradora metaSeguradora1 = metaSeguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(metaSeguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(metaSeguradora.get_Id()); + registroLog.set_Tela(31); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaSeguradoraServico.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(); + metaSeguradora4 = metaSeguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 222, num, metaSeguradora, true); + continue; + } + return metaSeguradora4; + } + return metaSeguradora2; + }); + return metaSeguradora3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs new file mode 100644 index 0000000..5e30a23 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaVendedorServico.cs @@ -0,0 +1,182 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Common.Validation; +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 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.Ferramentas +{ + internal class MetaVendedorServico : BaseServico + { + public MetaVendedorServico() + { + } + + public async Task> BuscarMetasVendedores(Filtros filtro) + { + int num = 3; + List metaVendedors1 = await Task.Run>(() => { + List metaVendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + metaVendedors = read.get_MetaVendedorRepository().FindByMeta(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 285, num, filtro, true); + continue; + } + return metaVendedors; + } + return new List(); + }); + return metaVendedors1; + } + + public async Task Delete(MetaVendedor meta) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_MetaVendedorRepository().Delete(meta.get_Id()); + DateTime networkTime = Funcoes.GetNetworkTime(); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + registroLog.set_Descricao(string.Concat(new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A META DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", meta.get_Id()), ", MÊS: '", Gestor.Common.Validation.ValidationHelper.GetDescription(meta.get_Mes()), "'", string.Format(", ANO: '{0}'", meta.get_Ano()), string.Format(", VALOR: 'R${0}'.", meta.get_Valor()) })); + registroLog.set_EntidadeId(meta.get_Id()); + registroLog.set_Tela(30); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog1 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = MetaVendedorServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaVendedorServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog1.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 225, num, meta, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(MetaVendedor metaVendedor) + { + int num = 3; + base.Sucesso = true; + MetaVendedor metaVendedor2 = metaVendedor; + MetaVendedor metaVendedor3 = await Task.Run(() => { + MetaVendedor metaVendedor4; + string str; + while (num > 0) + { + metaVendedor = metaVendedor2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (metaVendedor.get_Id() == 0 ? 0 : 1); + metaVendedor = (metaVendedor.get_Id() == 0 ? commited.get_MetaVendedorRepository().SaveOrUpdate(metaVendedor) : commited.get_MetaVendedorRepository().Merge(metaVendedor)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(Funcoes.GetNetworkTime()); + MetaVendedor metaVendedor1 = metaVendedor; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(metaVendedor1, jsonSerializerSetting)); + registroLog.set_EntidadeId(metaVendedor.get_Id()); + registroLog.set_Tela(30); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_01 = MetaVendedorServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + MetaVendedorServico.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(); + metaVendedor4 = metaVendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 224, num, metaVendedor, true); + continue; + } + return metaVendedor4; + } + return metaVendedor2; + }); + return metaVendedor3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs new file mode 100644 index 0000000..9ea8485 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/NotaFiscalServico.cs @@ -0,0 +1,176 @@ +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class NotaFiscalServico : BaseServico + { + public NotaFiscalServico() + { + } + + internal async Task> BuscarNotasFiscais() + { + int num = 3; + List notaFiscals1 = await Task.Run>(() => { + List notaFiscals; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + notaFiscals = read.get_NotaFiscalRepository().FindAll(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 312, num, null, true); + continue; + } + return notaFiscals; + } + return new List(); + }); + return notaFiscals1; + } + + public async Task> BuscarNotasFiscais(Filtros filtro) + { + int num = 3; + List notaFiscals1 = await Task.Run>(() => { + List notaFiscals; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + notaFiscals = read.get_NotaFiscalRepository().FindByDatas(filtro); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 315, num, filtro, true); + continue; + } + return notaFiscals; + } + return new List(); + }); + return notaFiscals1; + } + + internal async Task Cadatrada(long idExtrato) + { + int num = 3; + bool flag1 = await Task.Run(() => { + bool flag; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + flag = read.get_NotaFiscalRepository().FindByExtrato(idExtrato); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 315, num, idExtrato, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Delete(NotaFiscal notaFiscal) + { + 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(notaFiscal.get_Id(), notaFiscal.GetValorOriginal(), 55, 2)); + commited.get_NotaFiscalRepository().Delete(notaFiscal.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 314, num, notaFiscal, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + internal async Task Save(NotaFiscal notaFiscal) + { + int num = 3; + base.Sucesso = true; + NotaFiscal notaFiscal1 = notaFiscal; + NotaFiscal notaFiscal2 = await Task.Run(() => { + NotaFiscal notaFiscal3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + notaFiscal = notaFiscal1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (notaFiscal.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(notaFiscal.get_Id(), notaFiscal, 55)); + } + notaFiscal = (notaFiscal.get_Id() == 0 ? commited.get_NotaFiscalRepository().SaveOrUpdate(notaFiscal) : commited.get_NotaFiscalRepository().Merge(notaFiscal)); + if (!flag) + { + registroLogs.Add(base.CreateLog(notaFiscal.get_Id(), notaFiscal.GetValorOriginal(), 55, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + notaFiscal3 = notaFiscal; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 313, num, notaFiscal, true); + continue; + } + return notaFiscal3; + } + return notaFiscal1; + }); + return notaFiscal2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.cs new file mode 100644 index 0000000..76fd16d --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ProdutoServico.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.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class ProdutoServico : BaseServico + { + public ProdutoServico() + { + } + + internal async Task BuscarProdutoPorId(long id) + { + int num = 3; + Produto produto1 = await Task.Run(() => { + Produto produto; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + produto = read.get_ProdutoRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 116, num, id, true); + continue; + } + return produto; + } + return new Produto(); + }); + return produto1; + } + + public async Task Save(Produto produto) + { + int num = 3; + base.Sucesso = true; + Produto produto1 = produto; + Produto produto2 = await Task.Run(() => { + Produto produto3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + produto = produto1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (produto.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(produto.get_Id(), produto, 10)); + } + produto = (produto.get_Id() == 0 ? commited.get_ProdutoRepository().SaveOrUpdate(produto) : commited.get_ProdutoRepository().Merge(produto)); + if (!flag) + { + registroLogs.Add(base.CreateLog(produto.get_Id(), produto.GetValorOriginal(), 10, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + produto3 = produto; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 226, num, produto, true); + continue; + } + return produto3; + } + return produto1; + }); + return produto2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs new file mode 100644 index 0000000..5d7507b --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/QualificacaoServico.cs @@ -0,0 +1,57 @@ +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.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class QualificacaoServico : BaseServico + { + public QualificacaoServico() + { + } + + internal async Task Save(Qualificacao qualificacao) + { + int num = 3; + base.Sucesso = true; + Qualificacao qualificacao2 = qualificacao; + Qualificacao qualificacao3 = await Task.Run(() => { + Qualificacao qualificacao4; + while (num > 0) + { + List registroLogs = new List(); + qualificacao = qualificacao2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + registroLogs.Add(base.CreateLog(qualificacao.get_Id(), qualificacao, 48)); + Qualificacao qualificacao1 = commited.get_QualificacaoRepository().SaveOrUpdate(qualificacao); + base.SaveLog(registroLogs, commited); + commited.Commit(); + qualificacao4 = qualificacao1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 229, num, qualificacao, true); + continue; + } + return qualificacao4; + } + return qualificacao2; + }); + return qualificacao3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs new file mode 100644 index 0000000..a347e2c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/RamoServico.cs @@ -0,0 +1,192 @@ +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.Domain.Common; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Seguros; +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.Ferramentas +{ + internal class RamoServico : BaseServico + { + public RamoServico() + { + } + + public async Task> BuscarRamos() + { + int num = 3; + List ramos1 = await Task.Run>(() => { + List ramos; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ramos = commited.get_RamoRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 169, num, null, true); + continue; + } + return ramos; + } + return null; + }); + return ramos1; + } + + public async Task Insert(Ramo ramo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Ramo ramo2 = ramo; + Ramo ramo3 = await Task.Run(() => { + Ramo ramo4; + string str; + while (num > 0) + { + ramo = ramo2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + ramo = commited.get_RamoRepository().SaveOrUpdate(ramo); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Ramo ramo1 = ramo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(ramo1, jsonSerializerSetting)); + registroLog.set_EntidadeId(ramo.get_Id()); + registroLog.set_Tela(12); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_21 = RamoServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + RamoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_21); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + ramo4 = ramo; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 230, num, ramo, true); + continue; + } + return ramo4; + } + return ramo2; + }); + return ramo3; + } + + internal async Task Save(Ramo ramo, List coberturas) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Ramo ramo3 = ramo; + Ramo ramo4 = await Task.Run(() => { + Ramo ramo5; + string str; + while (num > 0) + { + ramo = ramo3; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + Ramo ramo1 = commited.get_RamoRepository().SaveOrUpdate(ramo); + List coberturaPadraos = coberturas; + if (coberturaPadraos != null) + { + coberturaPadraos.ForEach((CoberturaPadrao x) => commited.get_CoberturaPadraoRepository().Merge(x)); + } + else + { + } + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Ramo ramo2 = ramo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(ramo2, jsonSerializerSetting)); + registroLog.set_EntidadeId(ramo.get_Id()); + registroLog.set_Tela(12); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_02 = RamoServico.u003cu003ec.u003cu003e9__0_2; + if (u003cu003e9_02 == null) + { + u003cu003e9_02 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + RamoServico.u003cu003ec.u003cu003e9__0_2 = u003cu003e9_02; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_02); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + ramo5 = ramo1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 228, num, new { ramo = ramo, coberturas = coberturas }, true); + continue; + } + return ramo5; + } + return ramo3; + }); + return ramo4; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.cs new file mode 100644 index 0000000..ceee657 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/ReciboServico.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.Domain.Common; +using Gestor.Model.Domain.Ferramentas; +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.Ferramentas +{ + internal class ReciboServico : BaseServico + { + public ReciboServico() + { + } + + internal async Task> BuscarRecibos() + { + int num = 3; + List recibos1 = await Task.Run>(() => { + List recibos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + recibos = read.get_ReciboRepository().BuscarRecibos(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 123, num, null, true); + continue; + } + return recibos; + } + return new List(); + }); + return recibos1; + } + + public async Task Delete(Recibo recibo) + { + 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(recibo.get_Id(), recibo.GetValorOriginal(), 42, 2)); + commited.get_ReciboRepository().Delete(recibo.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 232, num, recibo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Recibo recibo) + { + int num = 3; + base.Sucesso = true; + Recibo recibo1 = recibo; + Recibo recibo2 = await Task.Run(() => { + Recibo recibo3; + bool flag; + while (num > 0) + { + List registroLogs = new List(); + recibo = recibo1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (recibo.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(recibo.get_Id(), recibo, 42)); + } + recibo = (recibo.get_Id() == 0 ? commited.get_ReciboRepository().SaveOrUpdate(recibo) : commited.get_ReciboRepository().Merge(recibo)); + if (!flag) + { + registroLogs.Add(base.CreateLog(recibo.get_Id(), recibo.GetValorOriginal(), 42, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + recibo3 = recibo; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 231, num, recibo, true); + continue; + } + return recibo3; + } + return recibo1; + }); + return recibo2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs new file mode 100644 index 0000000..fe44719 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/SeguradoraServico.cs @@ -0,0 +1,372 @@ +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.Generic; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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.Ferramentas +{ + internal class SeguradoraServico : BaseServico + { + public SeguradoraServico() + { + } + + public async Task> BuscarAssistencias(long id) + { + int num = 3; + List seguradoraContatos1 = await Task.Run>(() => { + List seguradoraContatos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradoraContatos = read.get_SeguradoraContatoRepository().FindAssistencia(Recursos.Empresa.get_Id(), id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return seguradoraContatos; + } + return new List(); + }); + return seguradoraContatos1; + } + + internal async Task> BuscarConfig(long id) + { + int num = 3; + List configExtratoImports1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List configExtratoImports = read.get_ConfigExtratoImportRepository().FindBySeguradora(id); + Func u003cu003e9_21 = SeguradoraServico.u003cu003ec.u003cu003e9__2_1; + if (u003cu003e9_21 == null) + { + u003cu003e9_21 = (ConfigExtratoImport x) => x.get_Descricao(); + SeguradoraServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21; + } + list = configExtratoImports.OrderBy(u003cu003e9_21).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 124, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return configExtratoImports1; + } + + public async Task> BuscarContatos(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List seguradoraContatos = read.get_SeguradoraContatoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id); + Func u003cu003e9_31 = SeguradoraServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (SeguradoraContato x) => x.get_NomeContato(); + SeguradoraServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + observableCollection = new ObservableCollection(seguradoraContatos.OrderBy(u003cu003e9_31)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 125, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarEnderecos(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List seguradoraEnderecos = read.get_SeguradoraEnderecoRepository().FindBySeguradora(Recursos.Empresa.get_Id(), id); + Func u003cu003e9_41 = SeguradoraServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (SeguradoraEndereco x) => x.get_Id(); + SeguradoraServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + observableCollection = new ObservableCollection(seguradoraEnderecos.OrderBy(u003cu003e9_41)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 126, num, new { Id = Recursos.Empresa.get_Id(), id = id }, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task BuscarSeguradora(long id) + { + int num = 3; + Seguradora seguradora1 = await Task.Run(() => { + Seguradora seguradora; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradora = read.get_SeguradoraRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 128, num, null, true); + continue; + } + return seguradora; + } + return new Seguradora(); + }); + return seguradora1; + } + + public async Task> BuscarSeguradoras() + { + int num = 3; + List seguradoras1 = await Task.Run>(() => { + List seguradoras; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + seguradoras = read.get_SeguradoraRepository().Find(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 127, num, null, true); + continue; + } + return seguradoras; + } + return new List(); + }); + return seguradoras1; + } + + public async Task Insert(Seguradora seguradora) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Seguradora seguradora2 = seguradora; + Seguradora seguradora3 = await Task.Run(() => { + Seguradora seguradora4; + string str; + while (num > 0) + { + seguradora = seguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + seguradora = commited.get_SeguradoraRepository().SaveOrUpdate(seguradora); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(0); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Seguradora seguradora1 = seguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(seguradora.get_Id()); + registroLog.set_Tela(13); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_11 = SeguradoraServico.u003cu003ec.u003cu003e9__1_1; + if (u003cu003e9_11 == null) + { + u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + SeguradoraServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_11); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + seguradora4 = seguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 234, num, seguradora, true); + continue; + } + return seguradora4; + } + return seguradora2; + }); + return seguradora3; + } + + public async Task Save(Seguradora seguradora, List config, bool primeiroAcesso = false) + { + Action action2 = null; + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Seguradora seguradora2 = seguradora; + Seguradora seguradora3 = await Task.Run(() => { + Seguradora seguradora4; + string str; + while (num > 0) + { + seguradora = seguradora2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (seguradora.get_Id() == 0 ? 0 : 1); + List contatos = seguradora.get_Contatos(); + if (contatos != null) + { + List seguradoraContatos = contatos; + Action u003cu003e9_1 = action2; + if (u003cu003e9_1 == null) + { + Action action = (SeguradoraContato x) => x.set_Seguradora(seguradora); + Action action1 = action; + action2 = action; + u003cu003e9_1 = action1; + } + seguradoraContatos.ForEach(u003cu003e9_1); + contatos = commited.get_SeguradoraContatoRepository().Merge(contatos, seguradora, Recursos.Empresa.get_Id()); + } + List enderecos = seguradora.get_Enderecos(); + if (contatos != null) + { + enderecos = commited.get_SeguradoraEnderecoRepository().Merge(enderecos, seguradora, Recursos.Empresa.get_Id()); + } + if (contatos != null | primeiroAcesso) + { + seguradora = commited.get_SeguradoraRepository().Merge(seguradora); + } + seguradora.set_Contatos(contatos); + seguradora.set_Enderecos(enderecos); + List configExtratoImports = config; + if (configExtratoImports != null) + { + configExtratoImports.ForEach((ConfigExtratoImport x) => commited.get_ConfigExtratoImportRepository().Merge(x)); + } + else + { + } + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Seguradora seguradora1 = seguradora; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(seguradora1, jsonSerializerSetting)); + registroLog.set_EntidadeId(seguradora.get_Id()); + registroLog.set_Tela(13); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_03 = SeguradoraServico.u003cu003ec.u003cu003e9__0_3; + if (u003cu003e9_03 == null) + { + u003cu003e9_03 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + SeguradoraServico.u003cu003ec.u003cu003e9__0_3 = u003cu003e9_03; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_03); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + seguradora4 = seguradora; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 233, num, new { seguradora = seguradora, config = config }, true); + continue; + } + return seguradora4; + } + return seguradora2; + }); + return seguradora3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs new file mode 100644 index 0000000..9b46d97 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/SocioServico.cs @@ -0,0 +1,97 @@ +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.Generic; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class SocioServico : BaseServico + { + public SocioServico() + { + } + + public async Task Delete(Socio socio) + { + 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(socio.get_Id(), socio.GetValorOriginal(), 19, 2)); + commited.get_SocioRepository().Delete(socio.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 236, num, socio, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Socio socio) + { + int num = 3; + base.Sucesso = true; + Socio socio1 = socio; + Socio socio2 = await Task.Run(() => { + Socio socio3; + bool flag; + List registroLogs = new List(); + socio = socio1; + while (num > 0) + { + socio = socio1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (socio.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(socio.get_Id(), socio, 19)); + } + socio = (socio.get_Id() == 0 ? commited.get_SocioRepository().SaveOrUpdate(socio) : commited.get_SocioRepository().Merge(socio)); + if (!flag) + { + registroLogs.Add(base.CreateLog(socio.get_Id(), socio.GetValorOriginal(), 19, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + socio3 = socio; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 235, num, socio, true); + continue; + } + return socio3; + } + return socio1; + }); + return socio2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.cs new file mode 100644 index 0000000..1af6770 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusProspeccaoServico.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.Ferramentas; +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.Ferramentas +{ + internal class StatusProspeccaoServico : BaseServico + { + public StatusProspeccaoServico() + { + } + + internal async Task> BuscarProspeccoes() + { + int num = 3; + List statusDeProspeccaos1 = await Task.Run>(() => { + List statusDeProspeccaos; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + statusDeProspeccaos = read.get_StatusProspeccaoRepository().FindAll(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 308, num, null, true); + continue; + } + return statusDeProspeccaos; + } + return new List(); + }); + return statusDeProspeccaos1; + } + + internal async Task Save(StatusDeProspeccao statusProspeccao) + { + int num = 3; + base.Sucesso = true; + StatusDeProspeccao statusDeProspeccao1 = statusProspeccao; + StatusDeProspeccao statusDeProspeccao2 = await Task.Run(() => { + StatusDeProspeccao statusDeProspeccao; + bool flag; + List registroLogs = new List(); + statusProspeccao = statusDeProspeccao1; + while (num > 0) + { + statusProspeccao = statusDeProspeccao1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (statusProspeccao.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(statusProspeccao.get_Id(), statusProspeccao, 57)); + } + statusProspeccao = (statusProspeccao.get_Id() == 0 ? commited.get_StatusProspeccaoRepository().SaveOrUpdate(statusProspeccao) : commited.get_StatusProspeccaoRepository().Merge(statusProspeccao)); + if (!flag) + { + registroLogs.Add(base.CreateLog(statusProspeccao.get_Id(), statusProspeccao.GetValorOriginal(), 57, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + statusDeProspeccao = statusProspeccao; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 307, num, statusProspeccao, true); + continue; + } + return statusDeProspeccao; + } + return statusDeProspeccao1; + }); + return statusDeProspeccao2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs new file mode 100644 index 0000000..88b146c --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/StatusServico.cs @@ -0,0 +1,124 @@ +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.Generic; +using Gestor.Model.Domain.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class StatusServico : BaseServico + { + public StatusServico() + { + } + + internal async Task BuscarStatusPorId(long id) + { + int num = 3; + Status statu1 = await Task.Run(() => { + Status statu; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + statu = read.get_StatusRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 119, num, id, true); + continue; + } + return statu; + } + return new Status(); + }); + return statu1; + } + + public async Task Delete(Status status) + { + 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(status.get_Id(), status.GetValorOriginal(), 11, 2)); + commited.get_StatusRepository().Delete(status.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 221, num, status, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Status status) + { + int num = 3; + base.Sucesso = true; + Status statu1 = status; + Status statu2 = await Task.Run(() => { + Status statu; + bool flag; + List registroLogs = new List(); + status = statu1; + while (num > 0) + { + status = statu1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (status.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(status.get_Id(), status, 11)); + } + status = (status.get_Id() == 0 ? commited.get_StatusRepository().SaveOrUpdate(status) : commited.get_StatusRepository().Merge(status)); + if (!flag) + { + registroLogs.Add(base.CreateLog(status.get_Id(), status.GetValorOriginal(), 11, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + statu = status; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 227, num, status, true); + continue; + } + return statu; + } + return statu1; + }); + return statu2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.cs new file mode 100644 index 0000000..fa7c297 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoTarefaServico.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.Ferramentas; +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.Ferramentas +{ + internal class TipoTarefaServico : BaseServico + { + public TipoTarefaServico() + { + } + + internal async Task> BuscarTarefas() + { + int num = 3; + List tipoDeTarefas1 = await Task.Run>(() => { + List tipoDeTarefas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + tipoDeTarefas = read.get_TipoTarefaRepository().FindAll(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 308, num, null, true); + continue; + } + return tipoDeTarefas; + } + return new List(); + }); + return tipoDeTarefas1; + } + + internal async Task Save(TipoDeTarefa tipoTarefa) + { + int num = 3; + base.Sucesso = true; + TipoDeTarefa tipoDeTarefa1 = tipoTarefa; + TipoDeTarefa tipoDeTarefa2 = await Task.Run(() => { + TipoDeTarefa tipoDeTarefa; + bool flag; + List registroLogs = new List(); + tipoTarefa = tipoDeTarefa1; + while (num > 0) + { + tipoTarefa = tipoDeTarefa1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + flag = (tipoTarefa.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(tipoTarefa.get_Id(), tipoTarefa, 52)); + } + tipoTarefa = (tipoTarefa.get_Id() == 0 ? commited.get_TipoTarefaRepository().SaveOrUpdate(tipoTarefa) : commited.get_TipoTarefaRepository().Merge(tipoTarefa)); + if (!flag) + { + registroLogs.Add(base.CreateLog(tipoTarefa.get_Id(), tipoTarefa.GetValorOriginal(), 52, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + tipoDeTarefa = tipoTarefa; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 306, num, tipoTarefa, true); + continue; + } + return tipoDeTarefa; + } + return tipoDeTarefa1; + }); + return tipoDeTarefa2; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs new file mode 100644 index 0000000..0757820 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/TipoVendedorServico.cs @@ -0,0 +1,131 @@ +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class TipoVendedorServico : BaseServico + { + public TipoVendedorServico() + { + } + + public async Task Delete(TipoVendedor tipoVendedor) + { + 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(tipoVendedor.get_Id(), tipoVendedor.GetValorOriginal(), 14, 2)); + commited.get_TipoVendedorRepository().Delete(tipoVendedor.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 238, num, tipoVendedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task FindLastId() + { + int num1 = 3; + long num2 = await Task.Run(() => { + long num; + while (num1 > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + num = read.get_TipoVendedorRepository().FindLastId(); + } + } + catch (Exception exception) + { + num1 = base.Registrar(exception, 17, num1, null, true); + continue; + } + return num; + } + return (long)0; + }); + return num2; + } + + internal async Task Save(TipoVendedor tipoVendedor) + { + int num = 3; + base.Sucesso = true; + TipoVendedor tipoVendedor2 = tipoVendedor; + TipoVendedor tipoVendedor3 = await Task.Run(async () => { + TipoVendedor tipoVendedor4; + while (num > 0) + { + List registroLogs = new List(); + tipoVendedor = tipoVendedor2; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (tipoVendedor.get_Id() == 0 ? 0 : 1); + if (tipoVendedor.get_Id() == 0) + { + TipoVendedor tipoVendedor1 = tipoVendedor; + tipoVendedor1.set_Id(await this.FindLastId() + (long)1); + tipoVendedor1 = null; + } + TipoAcao tipoAcao1 = tipoAcao; + if (tipoAcao1 == null) + { + registroLogs.Add(base.CreateLog(tipoVendedor.get_Id(), tipoVendedor.GetValorOriginal(), 14, 0)); + } + else if (tipoAcao1 == 1) + { + registroLogs.Add(base.CreateLog(tipoVendedor.get_Id(), tipoVendedor, 14)); + } + tipoVendedor = (tipoAcao == null ? commited.get_TipoVendedorRepository().SaveOrUpdate(tipoVendedor) : commited.get_TipoVendedorRepository().Merge(tipoVendedor)); + base.SaveLog(registroLogs, commited); + commited.Commit(); + tipoVendedor4 = tipoVendedor; + return tipoVendedor4; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 237, num, tipoVendedor, true); + } + registroLogs = null; + } + tipoVendedor4 = tipoVendedor2; + return tipoVendedor4; + }); + return tipoVendedor3; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs new file mode 100644 index 0000000..5b04623 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/UsuarioServico.cs @@ -0,0 +1,303 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Common.Security; +using Gestor.Common.Validation; +using Gestor.Infrastructure.Mappers; +using Gestor.Infrastructure.Repository.Interface; +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.Seguros; +using System; +using System.Collections.Generic; +using System.Diagnostics; +using System.Runtime.CompilerServices; +using System.Threading.Tasks; + +namespace Gestor.Application.Servicos.Ferramentas +{ + internal class UsuarioServico : BaseServico + { + public UsuarioServico() + { + } + + public async Task AddCentralSegurado(long id, bool update = true) + { + await Task.Run(() => { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_ClienteRepository().AddCentralSegurado(id, update); + } + }); + } + + public async Task BuscarLogin(string login) + { + int num = 3; + Usuario usuario2 = await Task.Run(() => { + Usuario usuario; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial); + AuthSso result = base.VerificaUsuarioSso(login, empresa.get_Documento()).Result; + if (result == null || result.get_Code() == 401) + { + usuario = new Usuario(); + } + else + { + Usuario usuario1 = read.get_UsuarioRepository().FindUsuario(login); + usuario = (result.get_Code() == 404 ? usuario1 : CustomMap.FromUserSso(usuario1, result.get_Data().get_User())); + } + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 134, num, login, true); + continue; + } + return usuario; + } + return new Usuario(); + }); + return usuario2; + } + + public async Task> BuscarPermissaoAggilizador() + { + List permissaoAggilizadors2 = await Task.Run>(() => { + List permissaoAggilizadors; + try + { + using (UnitOfWork read = Instancia.Read) + { + permissaoAggilizadors = read.get_UsuarioRepository().PermissaoAggilizador(); + } + } + catch (Exception exception) + { + List permissaoAggilizadors1 = new List(); + PermissaoAggilizador permissaoAggilizador = new PermissaoAggilizador(); + permissaoAggilizador.set_Id((long)1); + permissaoAggilizador.set_Descricao("ADMINISTRADOR"); + permissaoAggilizadors1.Add(permissaoAggilizador); + PermissaoAggilizador permissaoAggilizador1 = new PermissaoAggilizador(); + permissaoAggilizador1.set_Id((long)2); + permissaoAggilizador1.set_Descricao("NORMAL"); + permissaoAggilizadors1.Add(permissaoAggilizador1); + PermissaoAggilizador permissaoAggilizador2 = new PermissaoAggilizador(); + permissaoAggilizador2.set_Id((long)3); + permissaoAggilizador2.set_Descricao("LIMITADO"); + permissaoAggilizadors1.Add(permissaoAggilizador2); + permissaoAggilizadors = permissaoAggilizadors1; + } + return permissaoAggilizadors; + }); + return permissaoAggilizadors2; + } + + internal async Task BuscarUsuarioPorId(long id) + { + int num = 3; + Usuario usuario1 = await Task.Run(() => { + Usuario usuario; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + usuario = read.get_UsuarioRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 130, num, id, true); + continue; + } + return usuario; + } + return new Usuario(); + }); + return usuario1; + } + + public async Task BuscaUsuarioInicial(string usuario, string senha) + { + Usuario usuario2 = await Task.Run(() => { + Usuario usuario3; + using (UnitOfWork read = Instancia.Read) + { + Empresa empresa = read.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial); + string str = (new Token()).AggerEncrypt(senha); + AuthSso result = base.BuscaUsuarioSso(usuario, str, empresa.get_Documento()).Result; + if (result.get_Code() != 401) + { + Usuario usuario1 = read.get_UsuarioRepository().FindUsuario(usuario); + usuario3 = (result.get_Code() != 404 || usuario1 != null ? (result.get_Data() != null || usuario1 == null ? (usuario1 != null || result.get_Data() == null ? usuario1 : CustomMap.ToUsuario(result.get_Data().get_User(), empresa.get_Id())) : usuario1) : new Usuario()); + } + else + { + usuario3 = null; + } + } + return usuario3; + }); + return usuario2; + } + + public async Task Delete(Usuario usuario) + { + 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(usuario.get_Id(), usuario.GetValorOriginal(), 16, 2)); + commited.get_UsuarioRepository().Delete(usuario.get_Id()); + base.SaveLog(registroLogs, commited); + commited.Commit(); + usuario.set_TokenSso(Recursos.Usuario.get_TokenSso()); + base.DeleteUsuarioSso(usuario, Recursos.Empresa.get_Documento()).Wait(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 240, num, usuario, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Usuario usuario) + { + int num = 3; + base.Sucesso = true; + Usuario usuario5 = usuario; + Usuario usuario6 = await Task.Run(() => { + Usuario usuario7; + long? nullable; + string tokenSso; + string documento; + long? nullable1; + bool flag; + List registroLogs = new List(); + while (num > 0) + { + usuario = usuario5; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + Usuario usuario1 = Recursos.Usuario; + if (usuario1 != null) + { + tokenSso = usuario1.get_TokenSso(); + } + else + { + tokenSso = null; + } + string token = tokenSso; + Empresa empresa = Recursos.Empresa; + if (empresa != null) + { + documento = empresa.get_Documento(); + } + else + { + documento = null; + } + string str = documento; + if (ValidationHelper.IsNullOrEmpty(token)) + { + Empresa empresa1 = commited.get_EmpresaRepository().FindBySerial(ApplicationHelper.NumeroSerial); + string senha = usuario.get_Senha(); + if (ValidationHelper.IsNotNullOrEmpty(usuario.get_SenhaAnterior())) + { + if ((new Token()).AggerDecrypt(usuario.get_SenhaAnterior()).ToUpper().Contains("AGGER@")) + { + Usuario result = this.BuscarLogin(usuario.get_Login()).Result; + usuario.set_SenhaAnterior(result.get_Senha()); + } + senha = usuario.get_SenhaAnterior(); + } + AuthSso authSso = base.BuscaUsuarioSso(usuario.get_Login(), senha, empresa1.get_Documento()).Result; + if (authSso == null || authSso.get_Code() == 401) + { + this.Sucesso = false; + usuario7 = usuario5; + return usuario7; + } + else + { + token = authSso.get_Data().get_Token(); + str = empresa1.get_Documento(); + } + } + Usuario usuario2 = usuario; + if (!usuario.get_PermissaoAggilizador().HasValue) + { + Usuario usuario3 = usuario; + long? nullable2 = new long?((long)2); + nullable = nullable2; + usuario3.set_PermissaoAggilizador(nullable2); + nullable1 = nullable; + } + else + { + Usuario usuario4 = usuario; + long? permissaoAggilizador = usuario.get_PermissaoAggilizador(); + nullable = permissaoAggilizador; + usuario4.set_PermissaoAggilizador(permissaoAggilizador); + nullable1 = nullable; + } + usuario2.set_PermissaoAggilizador(nullable1); + flag = (usuario.get_Id() == 0 ? false : true); + if (flag) + { + registroLogs.Add(base.CreateLog(usuario.get_Id(), usuario, 16)); + } + usuario = (usuario.get_Id() == 0 ? commited.get_UsuarioRepository().SaveOrUpdate(usuario) : commited.get_UsuarioRepository().Merge(usuario)); + if (!flag) + { + registroLogs.Add(base.CreateLog(usuario.get_Id(), usuario.GetValorOriginal(), 16, 0)); + } + base.SaveLog(registroLogs, commited); + commited.Commit(); + usuario.set_TokenSso(token); + base.AddOrUpdateUsuarioSso(usuario, str, usuario.get_SsoId()).Wait(); + usuario7 = usuario; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 239, num, usuario, true); + continue; + } + return usuario7; + } + return usuario5; + }); + return usuario6; + } + } +} \ No newline at end of file diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs new file mode 100644 index 0000000..9c81d34 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/VendedorServico.cs @@ -0,0 +1,851 @@ +using Gestor.Application.Helpers; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels; +using Gestor.Common.Validation; +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.Ferramentas; +using Gestor.Model.Domain.Generic; +using Gestor.Model.Domain.Relatorios; +using Gestor.Model.Domain.Seguros; +using Newtonsoft.Json; +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +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.Ferramentas +{ + public class VendedorServico : BaseServico + { + public VendedorServico() + { + } + + public async Task BuscarCorretora() + { + Vendedor vendedor1 = await Task.Run(() => { + Vendedor vendedor; + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedor = read.get_VendedorRepository().FindCorretora(); + } + } + catch (Exception exception) + { + vendedor = null; + } + return vendedor; + }); + return vendedor1; + } + + public async Task> BuscaRepasse(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorParcelas = read.get_VendedorParcelaRepository().FindByDocumentId(id); + Func u003cu003e9_31 = VendedorServico.u003cu003ec.u003cu003e9__3_1; + if (u003cu003e9_31 == null) + { + u003cu003e9_31 = (VendedorParcela x) => x.get_TipoVendedor().get_Id(); + VendedorServico.u003cu003ec.u003cu003e9__3_1 = u003cu003e9_31; + } + list = vendedorParcelas.OrderBy(u003cu003e9_31).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 136, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task> BuscaRepasseParcela(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorParcelas = read.get_VendedorParcelaRepository().FindByParcela(id); + Func u003cu003e9_41 = VendedorServico.u003cu003ec.u003cu003e9__4_1; + if (u003cu003e9_41 == null) + { + u003cu003e9_41 = (VendedorParcela x) => { + TipoVendedor tipoVendedor = x.get_TipoVendedor(); + if (tipoVendedor != null) + { + return new long?(tipoVendedor.get_Id()); + } + return null; + }; + VendedorServico.u003cu003ec.u003cu003e9__4_1 = u003cu003e9_41; + } + list = vendedorParcelas.OrderBy(u003cu003e9_41).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 137, num, id, true); + continue; + } + return list; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task> BuscaRepasses() + { + int num = 3; + List repasses1 = await Task.Run>(() => { + List repasses; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + repasses = read.get_RepasseRepository().DefaultSelect((long)0); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 142, num, null, true); + continue; + } + return repasses; + } + return new List(); + }); + return repasses1; + } + + public async Task> BuscaRepassesPorIdVendedor(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + observableCollection = new ObservableCollection(read.get_RepasseRepository().FindByIdVendedor(id)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + public async Task> BuscarPagos(Filtros filtro) + { + int num = 3; + List manutencaoPagamentos = await Task.Run>(() => { + List list; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + list = read.get_VendedorParcelaRepository().FindByDate(filtro).ToList(); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 80, num, null, true); + continue; + } + return list; + } + return new List(); + }); + return manutencaoPagamentos; + } + + internal async Task> BuscarTelefonesAsync(long id) + { + int num = 3; + ObservableCollection observableCollection1 = await Task.Run>(() => { + ObservableCollection observableCollection; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedorTelefones = read.get_VendedorTelefoneRepository().FindByVendedorId(id); + Func u003cu003e9_51 = VendedorServico.u003cu003ec.u003cu003e9__5_1; + if (u003cu003e9_51 == null) + { + u003cu003e9_51 = (VendedorTelefone x) => x.get_Nome(); + VendedorServico.u003cu003ec.u003cu003e9__5_1 = u003cu003e9_51; + } + observableCollection = new ObservableCollection(vendedorTelefones.OrderBy(u003cu003e9_51)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 138, num, id, true); + continue; + } + return observableCollection; + } + return new ObservableCollection(); + }); + return observableCollection1; + } + + internal async Task> BuscarVendedoresAtivosAsync() + { + int num = 3; + List vendedors2 = await Task.Run>(() => { + List vendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + List vendedors1 = read.get_VendedorRepository().Find(true, (Recursos.Usuario.get_IdEmpresa() == (long)1 ? (long)0 : Recursos.Usuario.get_IdEmpresa())); + Func u003cu003e9_01 = VendedorServico.u003cu003ec.u003cu003e9__0_1; + if (u003cu003e9_01 == null) + { + u003cu003e9_01 = (Vendedor x) => x.get_Nome(); + VendedorServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01; + } + vendedors = new List(vendedors1.OrderBy(u003cu003e9_01)); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 135, num, null, true); + continue; + } + return vendedors; + } + return new List(); + }); + return vendedors2; + } + + public async Task> BuscarVendedorParcela(long id) + { + int num = 3; + List vendedorParcelas1 = await Task.Run>(() => { + List vendedorParcelas; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedorParcelas = read.get_RepasseRepository().FindByIdRepasse(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, id, true); + continue; + } + return vendedorParcelas; + } + return new List(); + }); + return vendedorParcelas1; + } + + public async Task BuscarVendedorParcelaCompleto(long id) + { + int num = 3; + VendedorParcela vendedorParcela1 = await Task.Run(() => { + VendedorParcela vendedorParcela; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedorParcela = read.get_VendedorParcelaRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 81, num, null, true); + continue; + } + return vendedorParcela; + } + return new VendedorParcela(); + }); + return vendedorParcela1; + } + + internal async Task BuscarVendedorPorId(long id) + { + int num = 3; + Vendedor vendedor1 = await Task.Run(() => { + Vendedor vendedor; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + vendedor = read.get_VendedorRepository().FindById(id); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 139, num, id, true); + continue; + } + return vendedor; + } + return new Vendedor(); + }); + return vendedor1; + } + + public async Task> BuscarVinculosCliente(long idCliente) + { + int num = 3; + List vendedors1 = await Task.Run>(() => { + List vendedors; + while (num > 0) + { + try + { + using (UnitOfWork read = Instancia.Read) + { + if (Recursos.Usuario.get_IdEmpresa() != (long)1) + { + Recursos.Usuario.get_IdEmpresa(); + } + vendedors = read.get_VendedorParcelaRepository().FindVinculoByIdCliente(idCliente); + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 143, num, null, true); + continue; + } + return vendedors; + } + return null; + }); + return vendedors1; + } + + public async Task Delete(VinculoRepasse vinculo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_RepasseRepository().DeleteVinculo(vinculo.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + VinculoRepasse vinculoRepasse = vinculo; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse, jsonSerializerSetting)); + registroLog.set_EntidadeId(vinculo.get_Id()); + registroLog.set_Tela(53); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_101 = VendedorServico.u003cu003ec.u003cu003e9__10_1; + if (u003cu003e9_101 == null) + { + u003cu003e9_101 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__10_1 = u003cu003e9_101; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_101); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 311, num, vinculo, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Delete(Vendedor vendedor) + { + int num = 3; + DateTime networkTime = Funcoes.GetNetworkTime(); + bool flag1 = await Task.Run(() => { + bool flag; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + commited.get_VendedorRepository().Delete(vendedor.get_Id()); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(2); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + RegistroLog registroLog1 = registroLog; + string[] strArrays = new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, O VENDEDOR DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", vendedor.get_Id()), ", NOME: '", null, null, null, null, null, null, null, null }; + strArrays[3] = (string.IsNullOrWhiteSpace(vendedor.get_Nome()) ? "" : vendedor.get_Nome() ?? ""); + strArrays[4] = "', DOCUMENTO: '"; + strArrays[5] = (string.IsNullOrWhiteSpace(vendedor.get_Documento()) ? "" : vendedor.get_Documento() ?? ""); + strArrays[6] = "', BANCO: '"; + strArrays[7] = (vendedor.get_Banco() == null ? "" : vendedor.get_Banco().get_Nome() ?? ""); + strArrays[8] = "', CONTA: '"; + strArrays[9] = (string.IsNullOrWhiteSpace(vendedor.get_Conta()) ? "" : vendedor.get_Conta() ?? ""); + strArrays[10] = "'."; + registroLog1.set_Descricao(string.Concat(strArrays)); + registroLog.set_EntidadeId(vendedor.get_Id()); + registroLog.set_Tela(15); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + RegistroLog registroLog2 = registroLog; + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_131 = VendedorServico.u003cu003ec.u003cu003e9__13_1; + if (u003cu003e9_131 == null) + { + u003cu003e9_131 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__13_1 = u003cu003e9_131; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_131); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog2.set_Ip(str); + RegistroLog registroLog3 = registroLog; + if (vendedor.get_Telefones() != null && vendedor.get_Telefones().Count != 0) + { + foreach (VendedorTelefone telefone in vendedor.get_Telefones()) + { + RegistroLog registroLog4 = registroLog3; + string descricao = registroLog4.get_Descricao(); + object[] objArray = new object[] { vendedor.get_Telefones().IndexOf(telefone), null, null, null }; + objArray[1] = (!telefone.get_Tipo().HasValue ? "-" : Gestor.Common.Validation.ValidationHelper.GetDescription(telefone.get_Tipo())); + objArray[2] = (string.IsNullOrWhiteSpace(telefone.get_Prefixo()) ? "" : telefone.get_Prefixo() ?? ""); + objArray[3] = (string.IsNullOrWhiteSpace(telefone.get_Numero()) ? "" : telefone.get_Numero() ?? ""); + registroLog4.set_Descricao(string.Concat(descricao, string.Format(", TELEFONE {0}: {1} ({2}) {3}", objArray))); + } + } + RegistroLog registroLog5 = registroLog3; + registroLog5.set_Descricao(string.Concat(registroLog5.get_Descricao(), ".")); + base.SaveLog(registroLog3, commited); + commited.Commit(); + flag = true; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 242, num, vendedor, true); + continue; + } + return flag; + } + return false; + }); + return flag1; + } + + public async Task Save(Vendedor vendedor, Repasse repasse) + { + int num = 3; + base.Sucesso = true; + Vendedor vendedor1 = vendedor; + Vendedor vendedor2 = await Task.Run(() => { + Vendedor vendedor3; + while (num > 0) + { + vendedor = vendedor1; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa())); + vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor); + repasse.set_Vendedor(vendedor); + repasse = commited.get_RepasseRepository().SaveOrUpdate(repasse); + commited.Commit(); + vendedor3 = vendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasse = repasse }, true); + continue; + } + return vendedor3; + } + return vendedor1; + }); + return vendedor2; + } + + public async Task Save(VinculoRepasse vinculo) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + VinculoRepasse vinculoRepasse2 = await Task.Run(() => { + VinculoRepasse vinculoRepasse; + string str; + while (num > 0) + { + VinculoRepasse vinculoRepasse1 = vinculo; + try + { + using (UnitOfWork commited = Instancia.Commited) + { + TipoAcao tipoAcao = (vinculoRepasse1.get_Id() == 0 ? 0 : 1); + vinculoRepasse1 = (tipoAcao == null ? commited.get_RepasseRepository().SaveOrUpdate(vinculoRepasse1) : commited.get_RepasseRepository().Merge(vinculoRepasse1)); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vinculoRepasse1, jsonSerializerSetting)); + registroLog.set_EntidadeId(vinculoRepasse1.get_Id()); + registroLog.set_Tela(53); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_91 = VendedorServico.u003cu003ec.u003cu003e9__9_1; + if (u003cu003e9_91 == null) + { + u003cu003e9_91 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__9_1 = u003cu003e9_91; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_91); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + vinculoRepasse = vinculoRepasse1; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 311, num, vinculo, true); + continue; + } + return vinculoRepasse; + } + return vinculo; + }); + return vinculoRepasse2; + } + + public async Task Save(Vendedor vendedor, List repasses) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Vendedor vendedor2 = vendedor; + Vendedor vendedor3 = await Task.Run(() => { + Vendedor vendedor4; + string str; + string str1; + while (num > 0) + { + vendedor = vendedor2; + try + { + List telefones = vendedor.get_Telefones(); + using (UnitOfWork commited = Instancia.Commited) + { + List repasses1 = repasses; + Func u003cu003e9_111 = VendedorServico.u003cu003ec.u003cu003e9__11_1; + if (u003cu003e9_111 == null) + { + u003cu003e9_111 = (Repasse r) => { + Ramo ramo = r.get_Ramo(); + if (ramo == null) + { + return false; + } + return ramo.get_Id() == (long)0; + }; + VendedorServico.u003cu003ec.u003cu003e9__11_1 = u003cu003e9_111; + } + foreach (Repasse repasse in repasses1.Where(u003cu003e9_111)) + { + repasse.set_Ramo(null); + } + bool id = vendedor.get_Id() == (long)0; + vendedor.set_IdEmpresa((vendedor.get_IdEmpresa() == 0 ? Recursos.Empresa.get_Id() : vendedor.get_IdEmpresa())); + TipoAcao tipoAcao = (vendedor.get_Id() == 0 ? 0 : 1); + if (!id) + { + vendedor = commited.get_VendedorRepository().Merge(vendedor); + if (telefones != null) + { + telefones = commited.get_VendedorTelefoneRepository().Merge(telefones, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass in repasses) + { + if (repass.get_Id() != 0) + { + commited.get_RepasseRepository().Merge(repass); + } + else + { + commited.get_RepasseRepository().SaveOrUpdate(repass); + } + } + } + } + else + { + vendedor = commited.get_VendedorRepository().SaveOrUpdate(vendedor); + if (telefones != null) + { + telefones = commited.get_VendedorTelefoneRepository().Inserir(telefones, vendedor); + } + if (repasses != null && repasses.Count > 0) + { + foreach (Repasse repass1 in repasses) + { + repass1.set_Vendedor(vendedor); + commited.get_RepasseRepository().SaveOrUpdate(repass1); + } + } + } + vendedor.set_Telefones(telefones); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + if (Recursos.Usuario.get_Id() != 0) + { + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(tipoAcao); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Vendedor vendedor1 = vendedor; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(vendedor1, jsonSerializerSetting)); + registroLog.set_EntidadeId(vendedor.get_Id()); + registroLog.set_Tela(15); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_112 = VendedorServico.u003cu003ec.u003cu003e9__11_2; + if (u003cu003e9_112 == null) + { + u003cu003e9_112 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__11_2 = u003cu003e9_112; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_112); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + foreach (Repasse repasse1 in repasses) + { + RegistroLog registroLog1 = new RegistroLog(); + registroLog1.set_Acao(tipoAcao); + registroLog1.set_Usuario(Recursos.Usuario); + registroLog1.set_DataHora(networkTime); + JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings(); + jsonSerializerSetting1.set_ReferenceLoopHandling(1); + registroLog1.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting1)); + registroLog1.set_EntidadeId(repasse1.get_Id()); + registroLog1.set_Tela(54); + registroLog1.set_Versao(LoginViewModel.VersaoAtual); + registroLog1.set_NomeMaquina(Environment.MachineName); + registroLog1.set_UsuarioMaquina(Environment.UserName); + IPAddress[] pAddressArray = hostEntry.AddressList; + Func u003cu003e9_113 = VendedorServico.u003cu003ec.u003cu003e9__11_3; + if (u003cu003e9_113 == null) + { + u003cu003e9_113 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__11_3 = u003cu003e9_113; + } + IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_113); + if (pAddress1 != null) + { + str1 = pAddress1.ToString(); + } + else + { + str1 = null; + } + registroLog1.set_Ip(str1); + base.SaveLog(registroLog1, commited); + } + } + commited.Commit(); + vendedor4 = vendedor; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { vendedor = vendedor, repasses = repasses }, true); + continue; + } + return vendedor4; + } + return vendedor2; + }); + return vendedor3; + } + + public async Task Save(Repasse repasse) + { + int num = 3; + base.Sucesso = true; + DateTime networkTime = Funcoes.GetNetworkTime(); + Repasse repasse2 = repasse; + Repasse repasse3 = await Task.Run(() => { + Repasse repasse4; + string str; + while (num > 0) + { + try + { + using (UnitOfWork commited = Instancia.Commited) + { + repasse2 = commited.get_RepasseRepository().Merge(repasse2); + IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); + RegistroLog registroLog = new RegistroLog(); + registroLog.set_Acao(1); + registroLog.set_Usuario(Recursos.Usuario); + registroLog.set_DataHora(networkTime); + Repasse repasse1 = repasse; + JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); + jsonSerializerSetting.set_ReferenceLoopHandling(1); + registroLog.set_Descricao(JsonConvert.SerializeObject(repasse1, jsonSerializerSetting)); + registroLog.set_EntidadeId(repasse.get_Id()); + registroLog.set_Tela(54); + registroLog.set_Versao(LoginViewModel.VersaoAtual); + registroLog.set_NomeMaquina(Environment.MachineName); + registroLog.set_UsuarioMaquina(Environment.UserName); + IPAddress[] addressList = hostEntry.AddressList; + Func u003cu003e9_121 = VendedorServico.u003cu003ec.u003cu003e9__12_1; + if (u003cu003e9_121 == null) + { + u003cu003e9_121 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; + VendedorServico.u003cu003ec.u003cu003e9__12_1 = u003cu003e9_121; + } + IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_121); + if (pAddress != null) + { + str = pAddress.ToString(); + } + else + { + str = null; + } + registroLog.set_Ip(str); + base.SaveLog(registroLog, commited); + commited.Commit(); + repasse4 = repasse2; + } + } + catch (Exception exception) + { + num = base.Registrar(exception, 241, num, new { repasse = repasse }, true); + continue; + } + return repasse4; + } + return repasse; + }); + return repasse3; + } + } +} \ No newline at end of file -- cgit v1.2.3