summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Seguros.Itens/ItemServico.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 15:29:41 +0000
commit225aa1499e37faf9d38257caabbadc68d78b427e (patch)
tree102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.Servicos.Seguros.Itens/ItemServico.cs
parent1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff)
downloadgestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz
gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.Servicos.Seguros.Itens/ItemServico.cs')
-rw-r--r--Decompiler/Gestor.Application.Servicos.Seguros.Itens/ItemServico.cs1624
1 files changed, 1624 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.Servicos.Seguros.Itens/ItemServico.cs b/Decompiler/Gestor.Application.Servicos.Seguros.Itens/ItemServico.cs
new file mode 100644
index 0000000..d028b46
--- /dev/null
+++ b/Decompiler/Gestor.Application.Servicos.Seguros.Itens/ItemServico.cs
@@ -0,0 +1,1624 @@
+using System;
+using System.Collections.Generic;
+using System.Collections.ObjectModel;
+using System.Linq;
+using System.Net;
+using System.Net.Http;
+using System.Net.Http.Headers;
+using System.Net.Sockets;
+using System.Text;
+using System.Threading.Tasks;
+using Agger.Registro;
+using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Common.Validation;
+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;
+
+namespace Gestor.Application.Servicos.Seguros.Itens;
+
+public class ItemServico : BaseServico
+{
+ private const string GuidGestorFipe = "bbbf4f03-01fc-4300-b430-33e007753578";
+
+ internal async Task<Item> BuscarItemPorIdAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Item>)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.ItemRepository.FindById(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)51, tries, id);
+ }
+ }
+ return new Item();
+ });
+ }
+
+ internal async Task<ObservableCollection<Item>> BuscarItems(long id, StatusItem status = 2, bool sinsitroCompleto = false)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_0050: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<Item>(read.ItemRepository.FindByDocumentsIds(id, status, sinsitroCompleto));
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)52, tries, new { id, status });
+ }
+ }
+ return new ObservableCollection<Item>();
+ });
+ }
+
+ internal async Task<List<Item>> BuscarItems(List<long> ids)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ItemRepository.FindByIds(ids);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)52, tries, ids);
+ }
+ }
+ return new List<Item>();
+ });
+ }
+
+ public async Task<int> BuscarProximoItem(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ItemRepository.FindNextItem(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)54, tries, id);
+ }
+ }
+ return 0;
+ });
+ }
+
+ internal async Task<Auto> BuscaAuto(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Auto>)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.AutoRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)55, tries, id);
+ }
+ }
+ return new Auto();
+ });
+ }
+
+ internal async Task<Granizo> BuscaGranizo(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Granizo>)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.GranizoRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)56, tries, id);
+ }
+ }
+ return new Granizo();
+ });
+ }
+
+ internal async Task<ObservableCollection<Cobertura>> BuscarCoberturasPorItemAsync(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return new ObservableCollection<Cobertura>(read.CoberturaRepository.FindByItemId(id));
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)57, tries, id);
+ }
+ }
+ return new ObservableCollection<Cobertura>();
+ });
+ }
+
+ public async Task<Patrimonial> BuscaPatrimonial(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Patrimonial>)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.PatrimonialRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)59, tries, id);
+ }
+ }
+ return new Patrimonial();
+ });
+ }
+
+ public async Task<Vida> BuscaVida(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Vida>)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.VidaRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)60, tries, id);
+ }
+ }
+ return new Vida();
+ });
+ }
+
+ public async Task<List<TitularesVida>> BuscaTitularesVida(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.TitularesVidaRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)61, tries, id);
+ }
+ }
+ return new List<TitularesVida>();
+ });
+ }
+
+ public async Task<RiscosDiversos> BuscaRiscosDiversos(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<RiscosDiversos>)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.RiscosDiversosRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)62, tries, id);
+ }
+ }
+ return new RiscosDiversos();
+ });
+ }
+
+ public async Task<Aeronautico> BuscaAeronautico(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Aeronautico>)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.AeronauticoRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)63, tries, id);
+ }
+ }
+ return new Aeronautico();
+ });
+ }
+
+ public async Task<Consorcio> BuscaConsorcio(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Consorcio>)delegate
+ {
+ //IL_005c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0062: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ConsorcioRepository.Find(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)330, tries, id);
+ }
+ }
+ return new Consorcio();
+ });
+ }
+
+ public async Task<Fipe> BuscarModelo(string fipe)
+ {
+ try
+ {
+ return await FipeCode(fipe);
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+ public async Task<List<Fipe>> BuscarPorModelo(string modelo)
+ {
+ try
+ {
+ return await FipeModel(modelo);
+ }
+ catch (Exception)
+ {
+ return null;
+ }
+ }
+
+ private async Task<Fipe> FipeCode(string code)
+ {
+ HttpClient client = new HttpClient();
+ try
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ string text = await FipeAuthentication();
+ if (ValidationHelper.IsNotNullOrEmpty(text))
+ {
+ ((HttpHeaders)client.DefaultRequestHeaders).TryAddWithoutValidation("Authorization", "Bearer " + text);
+ }
+ Uri uri = Address.ApiFipe.Append("v1").Append("fipe").AddQuery("fipeCode", code);
+ HttpResponseMessage val = await client.GetAsync(uri);
+ return (Fipe)((!val.IsSuccessStatusCode) ? ((object)new Fipe()) : ((object)JsonConvert.DeserializeObject<Fipe>(await val.Content.ReadAsStringAsync())));
+ }
+ finally
+ {
+ ((IDisposable)client)?.Dispose();
+ }
+ }
+
+ private async Task<List<Fipe>> FipeModel(string model)
+ {
+ HttpClient client = new HttpClient();
+ try
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ string text = await FipeAuthentication();
+ if (ValidationHelper.IsNotNullOrEmpty(text))
+ {
+ ((HttpHeaders)client.DefaultRequestHeaders).TryAddWithoutValidation("Authorization", "Bearer " + text);
+ }
+ Uri uri = Address.ApiFipe.Append("v1").Append("fipe").Append("modelo")
+ .Append(model);
+ HttpResponseMessage val = await client.GetAsync(uri);
+ return (!val.IsSuccessStatusCode) ? new List<Fipe>() : JsonConvert.DeserializeObject<List<Fipe>>(await val.Content.ReadAsStringAsync());
+ }
+ finally
+ {
+ ((IDisposable)client)?.Dispose();
+ }
+ }
+
+ private async Task<string> FipeAuthentication()
+ {
+ HttpClient client = new HttpClient();
+ try
+ {
+ ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
+ string arg = DateTime.Now.ToString("yyyy-MM-dd");
+ string content = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}|{1}|{2}", ApplicationHelper.IdFornecedor, "bbbf4f03-01fc-4300-b430-33e007753578", arg)));
+ Uri uri = Address.ApiFipe.Append("api").Append("auth");
+ HttpResponseMessage val = await client.PostAsync(uri, (HttpContent)(object)content.ToHttpContent());
+ return (!val.IsSuccessStatusCode) ? string.Empty : ((object)val.Content.ToJObject()["token"])?.ToString();
+ }
+ finally
+ {
+ ((IDisposable)client)?.Dispose();
+ }
+ }
+
+ private static async Task<T> Get<T>(string command) where T : class
+ {
+ Uri uri = new Uri(command);
+ HttpResponseMessage obj = await new HttpClient().GetAsync(uri).ConfigureAwait(continueOnCapturedContext: false);
+ if (obj.StatusCode != HttpStatusCode.OK)
+ {
+ throw new Exception("Api connection Error " + Environment.NewLine + " " + command, null);
+ }
+ return JsonConvert.DeserializeObject<T>(obj.Content.ReadAsStringAsync().Result);
+ }
+
+ public async Task<Item> Cancelar(Item item, string descricao, long idDocumento)
+ {
+ return await Task.Run((Func<Item>)delegate
+ {
+ //IL_007d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0084: Expected O, but got Unknown
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ item = commited.ItemRepository.FindById(((DomainBase)item).Id);
+ item.Cancelado = true;
+ item.Status = descricao;
+ item.IdDocumentoCancelado = idDocumento;
+ item = commited.ItemRepository.Merge(item);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)1;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = networkTime;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} CANCELOU, EM {networkTime}, O ITEM DE " + $"ID: '{((DomainBase)item).Id}'" + ", DESCRIÇÃO: '" + (string.IsNullOrWhiteSpace(item.Descricao) ? "" : (item.Descricao ?? "")) + "', OBSERVAÇÃO: '" + (string.IsNullOrWhiteSpace(item.Observacao) ? "" : (item.Observacao ?? "")) + "', STATUS: '" + (string.IsNullOrWhiteSpace(item.Status) ? "" : (item.Status ?? "")) + "' - " + descricao + ".";
+ val.EntidadeId = ((DomainBase)item).Id;
+ val.Tela = (TipoTela)3;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return item;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ return (Item)null;
+ }
+ });
+ }
+
+ public async Task<Item> Reativar(Item item, string descricao)
+ {
+ return await Task.Run((Func<Item>)delegate
+ {
+ //IL_0091: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0098: Expected O, but got Unknown
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ item = commited.ItemRepository.FindById(((DomainBase)item).Id);
+ item.Cancelado = false;
+ item.Substituido = null;
+ item.IdDocumentoCancelado = null;
+ item.Status = descricao;
+ item = commited.ItemRepository.Merge(item);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)1;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = networkTime;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} REATIVOU, EM {networkTime}, O ITEM DE" + $"ID: '{((DomainBase)item).Id}'" + ", DESCRIÇÃO: '" + (string.IsNullOrWhiteSpace(item.Descricao) ? "" : (item.Descricao ?? "")) + "', OBSERVAÇÃO: '" + (string.IsNullOrWhiteSpace(item.Observacao) ? "" : (item.Observacao ?? "")) + "', STATUS: '" + (string.IsNullOrWhiteSpace(item.Status) ? "" : (item.Status ?? "")) + "' - " + descricao + ".";
+ val.EntidadeId = ((DomainBase)item).Id;
+ val.Tela = (TipoTela)3;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return item;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ return (Item)null;
+ }
+ });
+ }
+
+ public async Task<Item> Substituir(Item item, long substituido, string descricao)
+ {
+ return await Task.Run((Func<Item>)delegate
+ {
+ //IL_0071: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0078: Expected O, but got Unknown
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ item = commited.ItemRepository.FindById(((DomainBase)item).Id);
+ item.Substituido = substituido;
+ item.Status = descricao;
+ item = commited.ItemRepository.Merge(item);
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)1;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = networkTime;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} SUBSTITUIU, EM {networkTime}, O ITEM DE" + $"ID: '{((DomainBase)item).Id}'" + ", DESCRIÇÃO: '" + (string.IsNullOrWhiteSpace(item.Descricao) ? "" : (item.Descricao ?? "")) + "', OBSERVAÇÃO: '" + (string.IsNullOrWhiteSpace(item.Observacao) ? "" : (item.Observacao ?? "")) + "', STATUS: '" + (string.IsNullOrWhiteSpace(item.Status) ? "" : (item.Status ?? "")) + "' - " + descricao + ".";
+ val.EntidadeId = ((DomainBase)item).Id;
+ val.Tela = (TipoTela)3;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ return item;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ return (Item)null;
+ }
+ });
+ }
+
+ public async Task<Item> Save(Item item)
+ {
+ int tries = 3;
+ Item itemOriginal = item;
+ base.Sucesso = true;
+ IPHostEntry host = Dns.GetHostEntry(Dns.GetHostName());
+ DateTime now = Funcoes.GetNetworkTime();
+ return await Task.Run((Func<Item>)delegate
+ {
+ //IL_0094: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0250: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0256: Invalid comparison between Unknown and I4
+ //IL_05ed: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0465: Unknown result type (might be due to invalid IL or missing references)
+ //IL_06f0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_03e9: Unknown result type (might be due to invalid IL or missing references)
+ //IL_04e7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_056a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07cf: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07d4: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07d5: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07dc: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07e7: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07f3: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07fa: Unknown result type (might be due to invalid IL or missing references)
+ //IL_07ff: Unknown result type (might be due to invalid IL or missing references)
+ //IL_080b: Expected O, but got Unknown
+ //IL_0810: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0821: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0823: Unknown result type (might be due to invalid IL or missing references)
+ //IL_082d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0838: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0843: Unknown result type (might be due to invalid IL or missing references)
+ //IL_084e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0670: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0891: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ item = itemOriginal;
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ bool flag = ((DomainBase)item).Id == 0;
+ Auto val = item.Auto;
+ Patrimonial val2 = item.Patrimonial;
+ Granizo val3 = item.Granizo;
+ Aeronautico val4 = item.Aeronautico;
+ Vida val5 = item.Vida;
+ RiscosDiversos val6 = item.RiscosDiversos;
+ Consorcio val7 = item.Consorcio;
+ TipoTela tipoTela = (TipoTela)3;
+ IList<Cobertura> list = item.Coberturas;
+ item.StatusInclusao = ((item.Documento.Tipo == 0) ? "ITEM DA APÓLICE" : "ITEM DO ENDOSSO");
+ if (flag)
+ {
+ item.Coberturas = null;
+ }
+ if (!flag && list != null && list.Count > 0)
+ {
+ try
+ {
+ list.ToList().ForEach(delegate(Cobertura x)
+ {
+ x.Item = item;
+ });
+ List<Cobertura> list2 = list.Where((Cobertura c) => ((DomainBase)c).Id == 0).ToList();
+ if (list2.Count > 0)
+ {
+ list2 = unitOfWork.CoberturaRepository.AddRange(list2.ToList());
+ list2.ForEach(delegate(Cobertura c)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003b: Expected O, but got Unknown
+ //IL_0040: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0063: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0079: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c0: Expected O, but got Unknown
+ RegistroLog keyValues3 = new RegistroLog
+ {
+ Acao = (TipoAcao)0,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)c, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)c).Id,
+ Tela = tipoTela,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = host.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues3, unitOfWork);
+ });
+ }
+ List<Cobertura> list3 = list.Where((Cobertura c) => ((DomainBase)c).Id > 0).ToList();
+ if (list3.Count > 0)
+ {
+ list3 = unitOfWork.CoberturaRepository.MergeRange(list3);
+ list3.ForEach(delegate(Cobertura c)
+ {
+ //IL_0000: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0005: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0028: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002a: Unknown result type (might be due to invalid IL or missing references)
+ //IL_002f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_003b: Expected O, but got Unknown
+ //IL_0040: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_004e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0058: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0063: Unknown result type (might be due to invalid IL or missing references)
+ //IL_006e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0079: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c0: Expected O, but got Unknown
+ RegistroLog keyValues2 = new RegistroLog
+ {
+ Acao = (TipoAcao)1,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)c, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)c).Id,
+ Tela = tipoTela,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = host.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues2, unitOfWork);
+ });
+ }
+ list3.AddRange(list2);
+ item.Coberturas = list3;
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)208, tries, list);
+ goto end_IL_0029;
+ }
+ }
+ if (!item.Documento.Sinistro && item.Sinistrado && (int)item.Documento.Situacao == 2 && item.Status != null && !item.Status.Contains("ALTERADO"))
+ {
+ item.Sinistrado = false;
+ }
+ item = (flag ? unitOfWork.ItemRepository.SaveOrUpdate(item) : unitOfWork.ItemRepository.Merge(item));
+ long id = ((DomainBase)item.Documento.Controle.Ramo).Id;
+ if (id <= 38)
+ {
+ long num = id - 1;
+ if ((ulong)num <= 19uL)
+ {
+ switch (num)
+ {
+ case 4L:
+ goto IL_039f;
+ case 0L:
+ case 1L:
+ case 2L:
+ case 14L:
+ case 17L:
+ goto IL_041b;
+ case 12L:
+ goto IL_0497;
+ case 19L:
+ goto IL_051a;
+ case 5L:
+ case 6L:
+ case 8L:
+ case 9L:
+ goto IL_059d;
+ case 3L:
+ case 7L:
+ case 10L:
+ case 11L:
+ case 13L:
+ case 15L:
+ case 16L:
+ case 18L:
+ goto IL_06a3;
+ }
+ }
+ if (id == 30)
+ {
+ goto IL_041b;
+ }
+ long num2 = id - 36;
+ if ((ulong)num2 <= 2uL)
+ {
+ switch (num2)
+ {
+ case 1L:
+ break;
+ case 2L:
+ goto IL_041b;
+ case 0L:
+ goto IL_0620;
+ default:
+ goto IL_06a3;
+ }
+ goto IL_039f;
+ }
+ }
+ else if (id == 47 || id == 53 || id == 66)
+ {
+ goto IL_059d;
+ }
+ goto IL_06a3;
+ IL_06a3:
+ try
+ {
+ if (val6 != null)
+ {
+ val6.Item = item;
+ val6 = (flag ? unitOfWork.RiscosDiversosRepository.SaveOrUpdate(val6) : unitOfWork.RiscosDiversosRepository.Merge(val6));
+ item.RiscosDiversos = val6;
+ tipoTela = (TipoTela)3;
+ }
+ }
+ catch (Exception e2)
+ {
+ tries = Registrar(e2, (TipoErro)198, tries, val6);
+ goto end_IL_0029;
+ }
+ goto IL_071f;
+ IL_039f:
+ try
+ {
+ if (val != null)
+ {
+ val.Item = item;
+ val = (flag ? unitOfWork.AutoRepository.SaveOrUpdate(val) : unitOfWork.AutoRepository.Merge(val));
+ item.Auto = val;
+ tipoTela = (TipoTela)3;
+ }
+ }
+ catch (Exception e3)
+ {
+ tries = Registrar(e3, (TipoErro)204, tries, val);
+ goto end_IL_0029;
+ }
+ goto IL_071f;
+ IL_0620:
+ try
+ {
+ if (val7 != null)
+ {
+ val7.Item = item;
+ val7 = (flag ? unitOfWork.ConsorcioRepository.SaveOrUpdate(val7) : unitOfWork.ConsorcioRepository.Merge(val7));
+ item.Consorcio = val7;
+ tipoTela = (TipoTela)3;
+ }
+ }
+ catch (Exception e4)
+ {
+ tries = Registrar(e4, (TipoErro)331, tries, val7);
+ goto end_IL_0029;
+ }
+ goto IL_071f;
+ IL_041b:
+ try
+ {
+ if (val2 != null)
+ {
+ val2.Item = item;
+ val2 = (flag ? unitOfWork.PatrimonialRepository.SaveOrUpdate(val2) : unitOfWork.PatrimonialRepository.Merge(val2));
+ item.Patrimonial = val2;
+ tipoTela = (TipoTela)3;
+ }
+ }
+ catch (Exception e5)
+ {
+ tries = Registrar(e5, (TipoErro)196, tries, val2);
+ goto end_IL_0029;
+ }
+ goto IL_071f;
+ IL_071f:
+ if (flag && list != null && list.Count > 0)
+ {
+ try
+ {
+ item.Coberturas = new List<Cobertura>();
+ list.ToList().ForEach(delegate(Cobertura x)
+ {
+ ((DomainBase)x).Id = 0L;
+ x.Item = item;
+ });
+ list = unitOfWork.CoberturaRepository.AddRange(list.ToList());
+ item.Coberturas = list;
+ }
+ catch (Exception e6)
+ {
+ tries = Registrar(e6, (TipoErro)208, tries, list);
+ goto end_IL_0029;
+ }
+ }
+ TipoAcao acao = (TipoAcao)(!flag);
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = acao,
+ Usuario = Recursos.Usuario,
+ DataHora = now,
+ Descricao = JsonConvert.SerializeObject((object)item, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)item).Id,
+ Tela = tipoTela,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = host.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ return item;
+ IL_059d:
+ try
+ {
+ if (val5 != null)
+ {
+ val5.Item = item;
+ val5 = (flag ? unitOfWork.VidaRepository.SaveOrUpdate(val5) : unitOfWork.VidaRepository.Merge(val5));
+ item.Vida = val5;
+ tipoTela = (TipoTela)3;
+ }
+ }
+ catch (Exception e7)
+ {
+ tries = Registrar(e7, (TipoErro)200, tries, val5);
+ goto end_IL_0029;
+ }
+ goto IL_071f;
+ IL_051a:
+ try
+ {
+ if (val3 != null)
+ {
+ val3.Item = item;
+ val3 = (flag ? unitOfWork.GranizoRepository.SaveOrUpdate(val3) : unitOfWork.GranizoRepository.Merge(val3));
+ item.Granizo = val3;
+ tipoTela = (TipoTela)3;
+ }
+ }
+ catch (Exception e8)
+ {
+ tries = Registrar(e8, (TipoErro)206, tries, val3);
+ goto end_IL_0029;
+ }
+ goto IL_071f;
+ IL_0497:
+ try
+ {
+ if (val4 != null)
+ {
+ val4.Item = item;
+ val4 = (flag ? unitOfWork.AeronauticoRepository.SaveOrUpdate(val4) : unitOfWork.AeronauticoRepository.Merge(val4));
+ item.Aeronautico = val4;
+ tipoTela = (TipoTela)3;
+ }
+ }
+ catch (Exception e9)
+ {
+ tries = Registrar(e9, (TipoErro)202, tries, val4);
+ goto end_IL_0029;
+ }
+ goto IL_071f;
+ end_IL_0029:;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e10)
+ {
+ tries = Registrar(e10, (TipoErro)195, tries, item);
+ }
+ }
+ return itemOriginal;
+ });
+ }
+
+ public async Task Delete(Item item)
+ {
+ int tries = 3;
+ DateTime dateHora = Funcoes.GetNetworkTime();
+ await Task.Run(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 commited = Instancia.Commited;
+ try
+ {
+ commited.CoberturaRepository.DeletebyItem(((DomainBase)item).Id);
+ commited.ControleSinistroRepository.Delete(((DomainBase)item).Id);
+ commited.ItemRepository.Delete(((DomainBase)item).Id);
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)2;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = dateHora;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} SUBSTITUIU, EM {dateHora}, O ITEM DE" + $"ID: '{((DomainBase)item).Id}'" + ", DESCRIÇÃO: '" + (string.IsNullOrWhiteSpace(item.Descricao) ? "" : (item.Descricao ?? "")) + "', OBSERVAÇÃO: '" + (string.IsNullOrWhiteSpace(item.Observacao) ? "" : (item.Observacao ?? "")) + "', STATUS: '" + (string.IsNullOrWhiteSpace(item.Status) ? "" : (item.Status ?? "")) + "'.";
+ val.EntidadeId = ((DomainBase)item).Id;
+ val.Tela = (TipoTela)3;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)274, tries, item);
+ }
+ }
+ });
+ }
+
+ public async Task DeleteRange(List<Item> itens, long ramo)
+ {
+ if (itens == null || itens.Count == 0)
+ {
+ return;
+ }
+ int tries = 3;
+ DateTime dateHora = Funcoes.GetNetworkTime();
+ await Task.Run(delegate
+ {
+ //IL_014d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0251: Unknown result type (might be due to invalid IL or missing references)
+ //IL_018e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_02cd: Unknown result type (might be due to invalid IL or missing references)
+ //IL_01cf: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0210: Unknown result type (might be due to invalid IL or missing references)
+ //IL_028f: Unknown result type (might be due to invalid IL or missing references)
+ //IL_032e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0335: Expected O, but got Unknown
+ //IL_0465: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.CoberturaRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ commited.ControleSinistroRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ long num = ramo;
+ TipoTela tela;
+ if (num <= 36)
+ {
+ long num2 = num - 1;
+ if ((ulong)num2 <= 19uL)
+ {
+ switch (num2)
+ {
+ case 4L:
+ goto IL_0112;
+ case 0L:
+ case 1L:
+ case 2L:
+ case 14L:
+ case 17L:
+ goto IL_0153;
+ case 12L:
+ goto IL_0194;
+ case 19L:
+ goto IL_01d5;
+ case 5L:
+ case 6L:
+ case 8L:
+ case 9L:
+ goto IL_0216;
+ case 3L:
+ case 7L:
+ case 10L:
+ case 11L:
+ case 13L:
+ case 15L:
+ case 16L:
+ case 18L:
+ goto IL_0292;
+ }
+ }
+ if (num == 36)
+ {
+ commited.ConsorcioRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ tela = (TipoTela)3;
+ goto IL_02ce;
+ }
+ }
+ else
+ {
+ if (num == 37)
+ {
+ goto IL_0112;
+ }
+ if (num == 53)
+ {
+ goto IL_0216;
+ }
+ }
+ goto IL_0292;
+ IL_0112:
+ commited.AutoRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ tela = (TipoTela)3;
+ goto IL_02ce;
+ IL_0194:
+ commited.AeronauticoRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ tela = (TipoTela)3;
+ goto IL_02ce;
+ IL_0292:
+ commited.RiscosDiversosRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ tela = (TipoTela)3;
+ goto IL_02ce;
+ IL_02ce:
+ commited.ItemRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ using (List<Item>.Enumerator enumerator = itens.GetEnumerator())
+ {
+ if (enumerator.MoveNext())
+ {
+ Item current = enumerator.Current;
+ RegistroLog val = new RegistroLog();
+ val.Acao = (TipoAcao)2;
+ val.Usuario = Recursos.Usuario;
+ val.DataHora = dateHora;
+ val.Descricao = $"O USUÁRIO {Recursos.Usuario.Nome} SUBSTITUIU, EM {dateHora}, O ITEM DE" + $"ID: '{((DomainBase)current).Id}'" + ", DESCRIÇÃO: '" + (string.IsNullOrWhiteSpace(current.Descricao) ? "" : (current.Descricao ?? "")) + "', OBSERVAÇÃO: '" + (string.IsNullOrWhiteSpace(current.Observacao) ? "" : (current.Observacao ?? "")) + "', STATUS: '" + (string.IsNullOrWhiteSpace(current.Status) ? "" : (current.Status ?? "")) + "'" + $", RAMO: '{ramo}'.";
+ val.EntidadeId = ((DomainBase)current).Id;
+ val.Tela = tela;
+ val.Versao = LoginViewModel.VersaoAtual;
+ val.NomeMaquina = Environment.MachineName;
+ val.UsuarioMaquina = Environment.UserName;
+ val.Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString();
+ RegistroLog keyValues = val;
+ SaveLog(keyValues, commited);
+ ((GenericUnitOfWork)commited).Commit();
+ break;
+ }
+ }
+ goto end_IL_000c;
+ IL_01d5:
+ commited.GranizoRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ tela = (TipoTela)3;
+ goto IL_02ce;
+ IL_0153:
+ commited.PatrimonialRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ tela = (TipoTela)3;
+ goto IL_02ce;
+ IL_0216:
+ commited.VidaRepository.DeleteRange(itens.Select((Item x) => ((DomainBase)x).Id).ToList());
+ tela = (TipoTela)3;
+ goto IL_02ce;
+ end_IL_000c:;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)275, tries, itens);
+ }
+ }
+ });
+ }
+
+ public async Task<Cliente> BuscarCliente(long id)
+ {
+ int tries = 3;
+ return await Task.Run((Func<Cliente>)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.ItemRepository.BuscarCliente(id);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)27, tries, id);
+ }
+ }
+ return new Cliente();
+ });
+ }
+
+ public async Task SaveRange(List<Item> itens)
+ {
+ int tries = 3;
+ DateTime dateHora = Funcoes.GetNetworkTime();
+ await Task.Run(delegate
+ {
+ //IL_0052: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0057: Unknown result type (might be due to invalid IL or missing references)
+ //IL_005e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0069: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0075: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0077: Unknown result type (might be due to invalid IL or missing references)
+ //IL_007c: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0088: Expected O, but got Unknown
+ //IL_008d: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0099: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00a0: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ab: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00b6: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00c1: Unknown result type (might be due to invalid IL or missing references)
+ //IL_00ff: Expected O, but got Unknown
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ itens.ForEach(delegate(Item x)
+ {
+ unitOfWork.ItemRepository.Merge(x);
+ });
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ foreach (Item iten in itens)
+ {
+ RegistroLog keyValues = new RegistroLog
+ {
+ Acao = (TipoAcao)2,
+ Usuario = Recursos.Usuario,
+ DataHora = dateHora,
+ Descricao = JsonConvert.SerializeObject((object)iten, new JsonSerializerSettings
+ {
+ ReferenceLoopHandling = (ReferenceLoopHandling)1
+ }),
+ EntidadeId = ((DomainBase)iten).Id,
+ Tela = (TipoTela)3,
+ Versao = LoginViewModel.VersaoAtual,
+ NomeMaquina = Environment.MachineName,
+ UsuarioMaquina = Environment.UserName,
+ Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
+ };
+ SaveLog(keyValues, unitOfWork);
+ }
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ base.Sucesso = true;
+ break;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)276, tries, itens);
+ }
+ }
+ });
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(List<long> ids)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ List<Item> list = read.ItemRepository.FindItens(ids);
+ if (list != null)
+ {
+ return new ObservableCollection<Item>(from x in list
+ orderby x.Ordem, x.Descricao
+ select x);
+ }
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)52, tries, ids);
+ }
+ }
+ return new ObservableCollection<Item>();
+ });
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(long id, StatusItem status)
+ {
+ //IL_001e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_001f: Unknown result type (might be due to invalid IL or missing references)
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ //IL_009e: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0019: Unknown result type (might be due to invalid IL or missing references)
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ List<Item> list = read.ItemRepository.FindItens(id, status);
+ if (list != null)
+ {
+ return new ObservableCollection<Item>(from x in list
+ orderby x.Ordem, x.Descricao
+ select x);
+ }
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)53, tries, new { id, status });
+ }
+ }
+ return new ObservableCollection<Item>();
+ });
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(List<Documento> documento)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ List<Item> list = read.ItemRepository.FindItens(documento);
+ if (list != null)
+ {
+ return new ObservableCollection<Item>(from x in list
+ orderby x.Ordem, x.Descricao
+ select x);
+ }
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)305, tries, documento);
+ }
+ }
+ return new ObservableCollection<Item>();
+ });
+ }
+
+ public async Task<ObservableCollection<Item>> BuscarItens(long id)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ List<Item> list = read.ItemRepository.FindItens(id);
+ if (list != null)
+ {
+ return new ObservableCollection<Item>(from x in list
+ orderby x.Ordem, x.Descricao
+ select x);
+ }
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)53, tries, id);
+ }
+ }
+ return new ObservableCollection<Item>();
+ });
+ }
+
+ public async Task<List<TitularesVida>> SaveTitulares(List<TitularesVida> titularesVidas)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Commited;
+ try
+ {
+ titularesVidas.ForEach(delegate(TitularesVida x)
+ {
+ //IL_0009: Unknown result type (might be due to invalid IL or missing references)
+ //IL_000f: Invalid comparison between Unknown and I4
+ if ((int)x.Tipo.GetValueOrDefault() != 2 && x.Dependente != null)
+ {
+ x.Dependente = null;
+ }
+ });
+ titularesVidas.Where((TitularesVida x) => ((DomainBase)x).Id == 0L && (int)x.Tipo.GetValueOrDefault() != 2).ToList().ForEach(delegate(TitularesVida x)
+ {
+ ((DomainBase)titularesVidas.First((TitularesVida y) => y == x)).Id = ((DomainBase)unitOfWork.TitularesVidaRepository.SaveOrUpdate(x)).Id;
+ });
+ titularesVidas.Where((TitularesVida x) => ((DomainBase)x).Id == 0L && (int)x.Tipo.GetValueOrDefault() == 2).ToList().ForEach(delegate(TitularesVida x)
+ {
+ ((DomainBase)titularesVidas.First((TitularesVida y) => y == x)).Id = ((DomainBase)unitOfWork.TitularesVidaRepository.SaveOrUpdate(x)).Id;
+ });
+ titularesVidas.Where((TitularesVida x) => ((DomainBase)x).Id > 0).ToList().ForEach(delegate(TitularesVida x)
+ {
+ unitOfWork.TitularesVidaRepository.Merge(x);
+ });
+ ((GenericUnitOfWork)unitOfWork).Commit();
+ base.Sucesso = true;
+ return titularesVidas;
+ }
+ finally
+ {
+ if (unitOfWork != null)
+ {
+ ((IDisposable)unitOfWork).Dispose();
+ }
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)276, tries, titularesVidas);
+ }
+ }
+ return new List<TitularesVida>();
+ });
+ }
+
+ public async Task<bool> DeleteTitulares(List<TitularesVida> titularesVidas)
+ {
+ int tries = 3;
+ return await Task.Run(delegate
+ {
+ while (tries > 0)
+ {
+ try
+ {
+ UnitOfWork commited = Instancia.Commited;
+ try
+ {
+ commited.TitularesVidaRepository.DeleteRange(titularesVidas.Select((TitularesVida x) => ((DomainBase)x).Id).ToList());
+ ((GenericUnitOfWork)commited).Commit();
+ return true;
+ }
+ finally
+ {
+ ((IDisposable)commited)?.Dispose();
+ }
+ }
+ catch (Exception e)
+ {
+ tries = Registrar(e, (TipoErro)276, tries, titularesVidas);
+ }
+ }
+ return false;
+ });
+ }
+
+ internal async Task<List<PesquisaAvancada>> BuscaItensPorObs(string observacao, FiltroStatusDocumento status, List<VendedorUsuario> vendedorVinculado, bool tipobusca = false)
+ {
+ //IL_0016: Unknown result type (might be due to invalid IL or missing references)
+ //IL_0017: Unknown result type (might be due to invalid IL or missing references)
+ return await Task.Run(async delegate
+ {
+ try
+ {
+ UnitOfWork unitOfWork = Instancia.Read;
+ try
+ {
+ return await unitOfWork.ItemRepository.BuscaItensPorObs(observacao, status, vendedorVinculado, (TipoPesquisa)18, tipobusca);
+ }
+ finally
+ {
+ ((IDisposable)unitOfWork)?.Dispose();
+ }
+ }
+ catch (Exception)
+ {
+ return (List<PesquisaAvancada>)null;
+ }
+ });
+ }
+
+ public async Task<int> ChecarQuantidade(long idDocumento)
+ {
+ return await Task.Run(delegate
+ {
+ try
+ {
+ UnitOfWork read = Instancia.Read;
+ try
+ {
+ return read.ItemRepository.ChecarQuantidade(idDocumento);
+ }
+ finally
+ {
+ ((IDisposable)read)?.Dispose();
+ }
+ }
+ catch
+ {
+ return 0;
+ }
+ });
+ }
+}