diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 13:38:18 +0000 |
| commit | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch) | |
| tree | e1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs | |
| parent | 674ca83ba9243a9e95a7568c797668dab6aee26a (diff) | |
| download | gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip | |
chore: location
Diffstat (limited to 'Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/Servicos/Ferramentas/EmpresaServico.cs | 287 |
1 files changed, 287 insertions, 0 deletions
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<Empresa> BuscarEmpresaPorId(long id)
+ {
+ int num = 3;
+ Empresa empresa1 = await Task.Run<Empresa>(() => {
+ 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<List<Empresa>> BuscarEmpresas()
+ {
+ int num = 3;
+ List<Empresa> empresas1 = await Task.Run<List<Empresa>>(() => {
+ List<Empresa> 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<Empresa>();
+ });
+ 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<double> ConsultaEspacoBancoInGb()
+ {
+ double num3 = await Task.Run<double>(() => {
+ 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<Customer> Save(Customer customer)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Customer customer1 = customer;
+ Customer customer2 = await Task.Run<Customer>(() => {
+ 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<Empresa> Save(Empresa empresa)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ Empresa empresa2 = empresa;
+ Empresa empresa3 = await Task.Run<Empresa>(() => {
+ 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<IPAddress, bool> 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<IPAddress>)addressList).FirstOrDefault<IPAddress>(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 |