summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs
diff options
context:
space:
mode:
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs')
-rw-r--r--Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs323
1 files changed, 323 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs b/Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs
new file mode 100644
index 0000000..4f47cdf
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Ferramentas/EmpresaServico.cs
@@ -0,0 +1,323 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Threading.Tasks;
+using ArquivoDigital.Infrastructure.UnitOfWork.Logic;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.API;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Newtonsoft.Json;
+
+namespace Gestor.Application.Servicos.Ferramentas;
+
+internal class EmpresaServico : BaseServico
+{
+ internal async Task<List<Empresa>> BuscarEmpresas()
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.EmpresaRepository.Find((Recursos.Usuario.IdEmpresa == 1) ? 0 : Recursos.Usuario.IdEmpresa);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)113, tries);
+ }
+ }
+ return new List<Empresa>();
+ });
+ }
+
+ internal async Task<Empresa> BuscarEmpresaPorId(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Empresa>)delegate
+ {
+ //IL_0059: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005f: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.EmpresaRepository.FindById(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)114, tries, id);
+ }
+ }
+ return new Empresa();
+ });
+ }
+
+ internal async Task<Customer> Save(Customer customer)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Customer customerOriginal = customer;
+ return await Task.Run((Func<Customer>)delegate
+ {
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0060: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0071: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0082: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0093: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0104: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0116: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ customer = customerOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ Empresa val = new Empresa
+ {
+ Nome = customer.Name,
+ Documento = customer.Document,
+ Bairro = customer.District,
+ Cidade = customer.City,
+ Complemento = customer.Adjunct,
+ Numero = customer.Number,
+ Cep = customer.PostCode,
+ Estado = customer.State,
+ Email = customer.Mail,
+ PrimeiroPrefixo = customer.AreaCode,
+ PrimeiroTelefone = customer.Phone,
+ SegundoPrefixo = customer.SecondAreaCode,
+ SegundoTelefone = customer.SecondPhone,
+ Serial = ApplicationHelper.NumeroSerial,
+ Site = customer.Site
+ };
+ commited.EmpresaRepository.SaveOrUpdate(val);
+ ((GenericUnitOfWork)commited).Commit();
+ return customer;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)277, tries, customer);
+ }
+ }
+ return customerOriginal;
+ });
+ }
+
+ public async Task<Empresa> Save(Empresa empresa)
+ {
+ int tries = 3;
+ base.Sucesso = true;
+ Empresa empresaOriginal = empresa;
+ return await Task.Run((Func<Empresa>)delegate
+ {
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0080: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0086: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0091: Unknown result type (might be due to invalid IL or missing references)
+ //IL_009c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b4: Expected O, but got Unknown
+ //IL_00b9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ca: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00d2: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00dd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00e8: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00f3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0130: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ empresa = empresaOriginal;
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ TipoAcao acao = (TipoAcao)(((DomainBase)empresa).Id != 0L);
+ empresa = ((((DomainBase)empresa).Id == 0L) ? commited.EmpresaRepository.SaveOrUpdate(empresa) : commited.EmpresaRepository.Merge(empresa));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ if (((DomainBase)Recursos.Usuario).Id != 0L)
+ {
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = Funcoes.GetNetworkTime(),
+ Descricao = JsonConvert.SerializeObject((object)empresa, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)empresa).Id,
+ Tela = (TipoTela)18,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, commited);
+ }
+ ((GenericUnitOfWork)commited).Commit();
+ return empresa;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)277, tries, empresa);
+ }
+ }
+ return empresaOriginal;
+ });
+ }
+
+ public string BuscarSenhaAdm()
+ {
+ int num = 3;
+ while (num > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.EmpresaRepository.BuscarSenhaAdm(1L);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ num = Registrar(e, (TipoErro)115, num);
+ }
+ }
+ return null;
+ }
+
+ public async void AtualizarLogoId(long id, string idLogo)
+ {
+ await Task.Run(delegate
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ Empresa val = commited.EmpresaRepository.FindById(id);
+ val.LogoId = idLogo;
+ commited.EmpresaRepository.Merge(val);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ });
+ }
+
+ public async Task<double> ConsultaEspacoBancoInGb()
+ {
+ return await Task.Run(delegate
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ double num = read.EmpresaRepository.ConsultaEspacoBancoInGb();
+ double num2 = 0.0;
+ try
+ {
+ foreach (ControleArquivoDigital item in read.IndiceArquivoDigitalRepository.BuscarBancos())
+ {
+ if (!(item.Tabela.ToLower() == "arquivos"))
+ {
+ try
+ {
+ Gestor.Application.Helpers.ArquivoDigital.SetConnection(item.Catalogo);
+ UnitOfWork read2 = Gestor.Application.Helpers.ArquivoDigital.Read;
+ try
+ {
+ num2 += read2.ArquivoDigitalRepository.ConsultaEspacoBancoInGb();
+ }
+ finally
+ {
+ ((IDisposable)read2)?.Dispose();
+ }
+ }
+ catch
+ {
+ }
+ }
+ }
+ }
+ catch
+ {
+ }
+ return num + num2;
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ }
+ return 0.0;
+ });
+ }
+}