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/Seguros/Itens/ItemServico.cs | 1900 -------------------- 1 file changed, 1900 deletions(-) delete mode 100644 Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs (limited to 'Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs') diff --git a/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs b/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs deleted file mode 100644 index a666367..0000000 --- a/Gestor.Application/Servicos/Seguros/Itens/ItemServico.cs +++ /dev/null @@ -1,1900 +0,0 @@ -using Agger.Registro; -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.Seguros; -using Newtonsoft.Json; -using Newtonsoft.Json.Linq; -using System; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using System.Diagnostics; -using System.Linq; -using System.Net; -using System.Net.Http; -using System.Net.Http.Headers; -using System.Net.Sockets; -using System.Runtime.CompilerServices; -using System.Text; -using System.Threading.Tasks; - -namespace Gestor.Application.Servicos.Seguros.Itens -{ - public class ItemServico : BaseServico - { - private const string GuidGestorFipe = "bbbf4f03-01fc-4300-b430-33e007753578"; - - public ItemServico() - { - } - - public async Task BuscaAeronautico(long id) - { - int num = 3; - Aeronautico aeronautico1 = await Task.Run(() => { - Aeronautico aeronautico; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - aeronautico = read.get_AeronauticoRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 63, num, id, true); - continue; - } - return aeronautico; - } - return new Aeronautico(); - }); - return aeronautico1; - } - - internal async Task BuscaAuto(long id) - { - int num = 3; - Auto auto1 = await Task.Run(() => { - Auto auto; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - auto = read.get_AutoRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 55, num, id, true); - continue; - } - return auto; - } - return new Auto(); - }); - return auto1; - } - - public async Task BuscaConsorcio(long id) - { - int num = 3; - Consorcio consorcio1 = await Task.Run(() => { - Consorcio consorcio; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - consorcio = read.get_ConsorcioRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 330, num, id, true); - continue; - } - return consorcio; - } - return new Consorcio(); - }); - return consorcio1; - } - - internal async Task BuscaGranizo(long id) - { - int num = 3; - Granizo granizo1 = await Task.Run(() => { - Granizo granizo; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - granizo = read.get_GranizoRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 56, num, id, true); - continue; - } - return granizo; - } - return new Granizo(); - }); - return granizo1; - } - - internal async Task> BuscaItensPorObs(string observacao, FiltroStatusDocumento status, List vendedorVinculado, bool tipobusca = false) - { - List pesquisaAvancadas1 = await Task.Run>(async () => { - List pesquisaAvancadas; - try - { - using (UnitOfWork read = Instancia.Read) - { - pesquisaAvancadas = await read.get_ItemRepository().BuscaItensPorObs(observacao, status, vendedorVinculado, 18, tipobusca); - } - } - catch (Exception exception) - { - pesquisaAvancadas = null; - } - return pesquisaAvancadas; - }); - return pesquisaAvancadas1; - } - - public async Task BuscaPatrimonial(long id) - { - int num = 3; - Patrimonial patrimonial1 = await Task.Run(() => { - Patrimonial patrimonial; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - patrimonial = read.get_PatrimonialRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 59, num, id, true); - continue; - } - return patrimonial; - } - return new Patrimonial(); - }); - return patrimonial1; - } - - public async Task BuscarCliente(long id) - { - int num = 3; - Cliente cliente1 = await Task.Run(() => { - Cliente cliente; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - cliente = read.get_ItemRepository().BuscarCliente(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 27, num, id, true); - continue; - } - return cliente; - } - return new Cliente(); - }); - return cliente1; - } - - internal async Task> BuscarCoberturasPorItemAsync(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_CoberturaRepository().FindByItemId(id)); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 57, num, id, true); - continue; - } - return observableCollection; - } - return new ObservableCollection(); - }); - return observableCollection1; - } - - public async Task BuscaRiscosDiversos(long id) - { - int num = 3; - RiscosDiversos riscosDiverso1 = await Task.Run(() => { - RiscosDiversos riscosDiverso; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - riscosDiverso = read.get_RiscosDiversosRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 62, num, id, true); - continue; - } - return riscosDiverso; - } - return new RiscosDiversos(); - }); - return riscosDiverso1; - } - - internal async Task BuscarItemPorIdAsync(long id) - { - int num = 3; - Item item1 = await Task.Run(() => { - Item item; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - item = read.get_ItemRepository().FindById(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 51, num, id, true); - continue; - } - return item; - } - return new Item(); - }); - return item1; - } - - internal async Task> BuscarItems(long id, StatusItem status = 2, bool sinsitroCompleto = false) - { - int num = 3; - ObservableCollection observableCollection1 = await Task.Run>(() => { - ObservableCollection observableCollection; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - observableCollection = new ObservableCollection(read.get_ItemRepository().FindByDocumentsIds(id, status, sinsitroCompleto)); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 52, num, new { id = id, status = status }, true); - continue; - } - return observableCollection; - } - return new ObservableCollection(); - }); - return observableCollection1; - } - - internal async Task> BuscarItems(List ids) - { - int num = 3; - List items1 = await Task.Run>(() => { - List items; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - items = read.get_ItemRepository().FindByIds(ids); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 52, num, ids, true); - continue; - } - return items; - } - return new List(); - }); - return items1; - } - - public async Task> BuscarItens(List ids) - { - int num = 3; - ObservableCollection observableCollection1 = await Task.Run>(() => { - ObservableCollection observableCollection; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - List items = read.get_ItemRepository().FindItens(ids); - if (items != null) - { - List items1 = items; - Func u003cu003e9_281 = ItemServico.u003cu003ec.u003cu003e9__28_1; - if (u003cu003e9_281 == null) - { - u003cu003e9_281 = (Item x) => x.get_Ordem(); - ItemServico.u003cu003ec.u003cu003e9__28_1 = u003cu003e9_281; - } - IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_281); - Func u003cu003e9_282 = ItemServico.u003cu003ec.u003cu003e9__28_2; - if (u003cu003e9_282 == null) - { - u003cu003e9_282 = (Item x) => x.get_Descricao(); - ItemServico.u003cu003ec.u003cu003e9__28_2 = u003cu003e9_282; - } - observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_282)); - return observableCollection; - } - } - continue; - } - catch (Exception exception) - { - num = base.Registrar(exception, 52, num, ids, true); - continue; - } - return observableCollection; - } - return new ObservableCollection(); - }); - return observableCollection1; - } - - public async Task> BuscarItens(long id, StatusItem status) - { - int num = 3; - ObservableCollection observableCollection1 = await Task.Run>(() => { - ObservableCollection observableCollection; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - List items = read.get_ItemRepository().FindItens(id, status); - if (items != null) - { - List items1 = items; - Func u003cu003e9_291 = ItemServico.u003cu003ec.u003cu003e9__29_1; - if (u003cu003e9_291 == null) - { - u003cu003e9_291 = (Item x) => x.get_Ordem(); - ItemServico.u003cu003ec.u003cu003e9__29_1 = u003cu003e9_291; - } - IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_291); - Func u003cu003e9_292 = ItemServico.u003cu003ec.u003cu003e9__29_2; - if (u003cu003e9_292 == null) - { - u003cu003e9_292 = (Item x) => x.get_Descricao(); - ItemServico.u003cu003ec.u003cu003e9__29_2 = u003cu003e9_292; - } - observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_292)); - return observableCollection; - } - } - continue; - } - catch (Exception exception) - { - num = base.Registrar(exception, 53, num, new { id = id, status = status }, true); - continue; - } - return observableCollection; - } - return new ObservableCollection(); - }); - return observableCollection1; - } - - public async Task> BuscarItens(List documento) - { - int num = 3; - ObservableCollection observableCollection1 = await Task.Run>(() => { - ObservableCollection observableCollection; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - List items = read.get_ItemRepository().FindItens(documento); - if (items != null) - { - List items1 = items; - Func u003cu003e9_301 = ItemServico.u003cu003ec.u003cu003e9__30_1; - if (u003cu003e9_301 == null) - { - u003cu003e9_301 = (Item x) => x.get_Ordem(); - ItemServico.u003cu003ec.u003cu003e9__30_1 = u003cu003e9_301; - } - IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_301); - Func u003cu003e9_302 = ItemServico.u003cu003ec.u003cu003e9__30_2; - if (u003cu003e9_302 == null) - { - u003cu003e9_302 = (Item x) => x.get_Descricao(); - ItemServico.u003cu003ec.u003cu003e9__30_2 = u003cu003e9_302; - } - observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_302)); - return observableCollection; - } - } - continue; - } - catch (Exception exception) - { - num = base.Registrar(exception, 305, num, documento, true); - continue; - } - return observableCollection; - } - return new ObservableCollection(); - }); - return observableCollection1; - } - - public async Task> BuscarItens(long id) - { - int num = 3; - ObservableCollection observableCollection1 = await Task.Run>(() => { - ObservableCollection observableCollection; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - List items = read.get_ItemRepository().FindItens(id); - if (items != null) - { - List items1 = items; - Func u003cu003e9_311 = ItemServico.u003cu003ec.u003cu003e9__31_1; - if (u003cu003e9_311 == null) - { - u003cu003e9_311 = (Item x) => x.get_Ordem(); - ItemServico.u003cu003ec.u003cu003e9__31_1 = u003cu003e9_311; - } - IOrderedEnumerable items2 = items1.OrderBy(u003cu003e9_311); - Func u003cu003e9_312 = ItemServico.u003cu003ec.u003cu003e9__31_2; - if (u003cu003e9_312 == null) - { - u003cu003e9_312 = (Item x) => x.get_Descricao(); - ItemServico.u003cu003ec.u003cu003e9__31_2 = u003cu003e9_312; - } - observableCollection = new ObservableCollection(items2.ThenBy(u003cu003e9_312)); - return observableCollection; - } - } - continue; - } - catch (Exception exception) - { - num = base.Registrar(exception, 53, num, id, true); - continue; - } - return observableCollection; - } - return new ObservableCollection(); - }); - return observableCollection1; - } - - public async Task BuscarModelo(string fipe) - { - Fipe fipe1; - try - { - fipe1 = await this.FipeCode(fipe); - } - catch (Exception exception) - { - fipe1 = null; - } - return fipe1; - } - - public async Task> BuscarPorModelo(string modelo) - { - List fipes; - try - { - fipes = await this.FipeModel(modelo); - } - catch (Exception exception) - { - fipes = null; - } - return fipes; - } - - public async Task BuscarProximoItem(long id) - { - int num1 = 3; - int num2 = await Task.Run(() => { - int num; - while (num1 > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - num = read.get_ItemRepository().FindNextItem(id); - } - } - catch (Exception exception) - { - num1 = base.Registrar(exception, 54, num1, id, true); - continue; - } - return num; - } - return 0; - }); - return num2; - } - - public async Task> BuscaTitularesVida(long id) - { - int num = 3; - List titularesVidas1 = await Task.Run>(() => { - List titularesVidas; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - titularesVidas = read.get_TitularesVidaRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 61, num, id, true); - continue; - } - return titularesVidas; - } - return new List(); - }); - return titularesVidas1; - } - - public async Task BuscaVida(long id) - { - int num = 3; - Vida vida1 = await Task.Run(() => { - Vida vida; - while (num > 0) - { - try - { - using (UnitOfWork read = Instancia.Read) - { - vida = read.get_VidaRepository().Find(id); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 60, num, id, true); - continue; - } - return vida; - } - return new Vida(); - }); - return vida1; - } - - public async Task Cancelar(Item item, string descricao, long idDocumento) - { - Item item1 = await Task.Run(() => { - Item item2; - string str; - try - { - using (UnitOfWork commited = Instancia.Commited) - { - item = commited.get_ItemRepository().FindById(item.get_Id()); - item.set_Cancelado(true); - item.set_Status(descricao); - item.set_IdDocumentoCancelado(new long?(idDocumento)); - item = commited.get_ItemRepository().Merge(item); - DateTime networkTime = Funcoes.GetNetworkTime(); - IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); - RegistroLog registroLog = new RegistroLog(); - registroLog.set_Acao(1); - registroLog.set_Usuario(Recursos.Usuario); - registroLog.set_DataHora(networkTime); - RegistroLog registroLog1 = registroLog; - string[] strArrays = new string[] { string.Format("O USUÁRIO {0} CANCELOU, EM {1}, O ITEM DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null }; - strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); - strArrays[4] = "', OBSERVAÇÃO: '"; - strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); - strArrays[6] = "', STATUS: '"; - strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); - strArrays[8] = "' - "; - strArrays[9] = descricao; - strArrays[10] = "."; - registroLog1.set_Descricao(string.Concat(strArrays)); - registroLog.set_EntidadeId(item.get_Id()); - registroLog.set_Tela(3); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - RegistroLog registroLog2 = registroLog; - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_201 = ItemServico.u003cu003ec.u003cu003e9__20_1; - if (u003cu003e9_201 == null) - { - u003cu003e9_201 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__20_1 = u003cu003e9_201; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_201); - if (pAddress != null) - { - str = pAddress.ToString(); - } - else - { - str = null; - } - registroLog2.set_Ip(str); - base.SaveLog(registroLog, commited); - commited.Commit(); - item2 = item; - } - } - catch (Exception exception) - { - item2 = null; - } - return item2; - }); - return item1; - } - - public async Task ChecarQuantidade(long idDocumento) - { - int num1 = await Task.Run(() => { - int num; - try - { - using (UnitOfWork read = Instancia.Read) - { - num = read.get_ItemRepository().ChecarQuantidade(idDocumento); - } - } - catch - { - num = 0; - } - return num; - }); - return num1; - } - - public async Task Delete(Item item) - { - int num = 3; - DateTime networkTime = Funcoes.GetNetworkTime(); - await Task.Run(() => { - string str; - while (num > 0) - { - try - { - using (UnitOfWork commited = Instancia.Commited) - { - commited.get_CoberturaRepository().DeletebyItem(item.get_Id()); - commited.get_ControleSinistroRepository().Delete(item.get_Id()); - commited.get_ItemRepository().Delete(item.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} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null }; - strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); - strArrays[4] = "', OBSERVAÇÃO: '"; - strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); - strArrays[6] = "', STATUS: '"; - strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); - strArrays[8] = "'."; - registroLog1.set_Descricao(string.Concat(strArrays)); - registroLog.set_EntidadeId(item.get_Id()); - registroLog.set_Tela(3); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - RegistroLog registroLog2 = registroLog; - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_241 = ItemServico.u003cu003ec.u003cu003e9__24_1; - if (u003cu003e9_241 == null) - { - u003cu003e9_241 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__24_1 = u003cu003e9_241; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_241); - if (pAddress != null) - { - str = pAddress.ToString(); - } - else - { - str = null; - } - registroLog2.set_Ip(str); - base.SaveLog(registroLog, commited); - commited.Commit(); - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 274, num, item, true); - } - } - }); - } - - public async Task DeleteRange(List itens, long ramo) - { - if (itens != null && itens.Count != 0) - { - int num2 = 3; - DateTime networkTime = Funcoes.GetNetworkTime(); - await Task.Run(() => { - TipoTela tipoTela; - string str; - while (num2 > 0) - { - try - { - using (UnitOfWork commited = Instancia.Commited) - { - ICoberturaRepository coberturaRepository = commited.get_CoberturaRepository(); - List items = itens; - Func u003cu003e9_251 = ItemServico.u003cu003ec.u003cu003e9__25_1; - if (u003cu003e9_251 == null) - { - u003cu003e9_251 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_1 = u003cu003e9_251; - } - coberturaRepository.DeleteRange(items.Select(u003cu003e9_251).ToList()); - IControleSinistroRepository controleSinistroRepository = commited.get_ControleSinistroRepository(); - List items1 = itens; - Func u003cu003e9_252 = ItemServico.u003cu003ec.u003cu003e9__25_2; - if (u003cu003e9_252 == null) - { - u003cu003e9_252 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_2 = u003cu003e9_252; - } - controleSinistroRepository.DeleteRange(items1.Select(u003cu003e9_252).ToList()); - long num = ramo; - if (num > (long)36) - { - if (num == (long)37) - { - goto Label0; - } - if (num == (long)53) - { - goto Label1; - } - } - else - { - long num1 = num - (long)1; - if (num1 <= (long)19) - { - switch ((uint)num1) - { - case 0: - case 1: - case 2: - case 14: - case 17: - { - IPatrimonialRepository patrimonialRepository = commited.get_PatrimonialRepository(); - List items2 = itens; - Func u003cu003e9_254 = ItemServico.u003cu003ec.u003cu003e9__25_4; - if (u003cu003e9_254 == null) - { - u003cu003e9_254 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_4 = u003cu003e9_254; - } - patrimonialRepository.DeleteRange(items2.Select(u003cu003e9_254).ToList()); - tipoTela = 3; - goto Label2; - } - case 3: - case 7: - case 10: - case 11: - case 13: - case 15: - case 16: - case 18: - { - goto Label3; - } - case 4: - { - goto Label0; - } - case 5: - case 6: - case 8: - case 9: - { - goto Label1; - } - case 12: - { - IAeronauticoRepository aeronauticoRepository = commited.get_AeronauticoRepository(); - List items3 = itens; - Func u003cu003e9_255 = ItemServico.u003cu003ec.u003cu003e9__25_5; - if (u003cu003e9_255 == null) - { - u003cu003e9_255 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_5 = u003cu003e9_255; - } - aeronauticoRepository.DeleteRange(items3.Select(u003cu003e9_255).ToList()); - tipoTela = 3; - goto Label2; - } - case 19: - { - IGranizoRepository granizoRepository = commited.get_GranizoRepository(); - List items4 = itens; - Func u003cu003e9_256 = ItemServico.u003cu003ec.u003cu003e9__25_6; - if (u003cu003e9_256 == null) - { - u003cu003e9_256 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_6 = u003cu003e9_256; - } - granizoRepository.DeleteRange(items4.Select(u003cu003e9_256).ToList()); - tipoTela = 3; - goto Label2; - } - } - } - else - { - } - if (num != (long)36) - { - goto Label3; - } - IConsorcioRepository consorcioRepository = commited.get_ConsorcioRepository(); - List items5 = itens; - Func u003cu003e9_258 = ItemServico.u003cu003ec.u003cu003e9__25_8; - if (u003cu003e9_258 == null) - { - u003cu003e9_258 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_8 = u003cu003e9_258; - } - consorcioRepository.DeleteRange(items5.Select(u003cu003e9_258).ToList()); - tipoTela = 3; - goto Label2; - } - Label3: - IRiscosDiversosRepository riscosDiversosRepository = commited.get_RiscosDiversosRepository(); - List items6 = itens; - Func u003cu003e9_259 = ItemServico.u003cu003ec.u003cu003e9__25_9; - if (u003cu003e9_259 == null) - { - u003cu003e9_259 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_9 = u003cu003e9_259; - } - riscosDiversosRepository.DeleteRange(items6.Select(u003cu003e9_259).ToList()); - tipoTela = 3; - Label2: - IItemRepository itemRepository = commited.get_ItemRepository(); - List items7 = itens; - Func u003cu003e9_2510 = ItemServico.u003cu003ec.u003cu003e9__25_10; - if (u003cu003e9_2510 == null) - { - u003cu003e9_2510 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_10 = u003cu003e9_2510; - } - itemRepository.DeleteRange(items7.Select(u003cu003e9_2510).ToList()); - IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); - List.Enumerator enumerator = itens.GetEnumerator(); - try - { - if (enumerator.MoveNext()) - { - Item current = enumerator.Current; - 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} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", current.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null }; - strArrays[3] = (string.IsNullOrWhiteSpace(current.get_Descricao()) ? "" : current.get_Descricao() ?? ""); - strArrays[4] = "', OBSERVAÇÃO: '"; - strArrays[5] = (string.IsNullOrWhiteSpace(current.get_Observacao()) ? "" : current.get_Observacao() ?? ""); - strArrays[6] = "', STATUS: '"; - strArrays[7] = (string.IsNullOrWhiteSpace(current.get_Status()) ? "" : current.get_Status() ?? ""); - strArrays[8] = "'"; - strArrays[9] = string.Format(", RAMO: '{0}'.", ramo); - registroLog1.set_Descricao(string.Concat(strArrays)); - registroLog.set_EntidadeId(current.get_Id()); - registroLog.set_Tela(tipoTela); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - RegistroLog registroLog2 = registroLog; - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_2511 = ItemServico.u003cu003ec.u003cu003e9__25_11; - if (u003cu003e9_2511 == null) - { - u003cu003e9_2511 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__25_11 = u003cu003e9_2511; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_2511); - if (pAddress != null) - { - str = pAddress.ToString(); - } - else - { - str = null; - } - registroLog2.set_Ip(str); - base.SaveLog(registroLog, commited); - commited.Commit(); - break; - } - } - finally - { - ((IDisposable)enumerator).Dispose(); - } - } - } - catch (Exception exception) - { - num2 = base.Registrar(exception, 275, num2, itens, true); - } - } - return; - Label0: - IAutoRepository autoRepository = commited.get_AutoRepository(); - List items8 = itens; - Func u003cu003e9_253 = ItemServico.u003cu003ec.u003cu003e9__25_3; - if (u003cu003e9_253 == null) - { - u003cu003e9_253 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_3 = u003cu003e9_253; - } - autoRepository.DeleteRange(items8.Select(u003cu003e9_253).ToList()); - tipoTela = 3; - goto Label2; - Label1: - IVidaRepository vidaRepository = commited.get_VidaRepository(); - List items9 = itens; - Func u003cu003e9_257 = ItemServico.u003cu003ec.u003cu003e9__25_7; - if (u003cu003e9_257 == null) - { - u003cu003e9_257 = (Item x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__25_7 = u003cu003e9_257; - } - vidaRepository.DeleteRange(items9.Select(u003cu003e9_257).ToList()); - tipoTela = 3; - goto Label2; - }); - } - } - - public async Task DeleteTitulares(List titularesVidas) - { - int num = 3; - bool flag1 = await Task.Run(() => { - bool flag; - while (num > 0) - { - try - { - using (UnitOfWork commited = Instancia.Commited) - { - ITitularesVidaRepository titularesVidaRepository = commited.get_TitularesVidaRepository(); - List titularesVidas1 = titularesVidas; - Func u003cu003e9_331 = ItemServico.u003cu003ec.u003cu003e9__33_1; - if (u003cu003e9_331 == null) - { - u003cu003e9_331 = (TitularesVida x) => x.get_Id(); - ItemServico.u003cu003ec.u003cu003e9__33_1 = u003cu003e9_331; - } - titularesVidaRepository.DeleteRange(titularesVidas1.Select(u003cu003e9_331).ToList()); - commited.Commit(); - flag = true; - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 276, num, titularesVidas, true); - continue; - } - return flag; - } - return false; - }); - return flag1; - } - - private async Task FipeAuthentication() - { - string str; - string empty; - using (HttpClient httpClient = new HttpClient()) - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - string str1 = DateTime.Now.ToString("yyyy-MM-dd"); - string base64String = Convert.ToBase64String(Encoding.UTF8.GetBytes(string.Format("{0}|{1}|{2}", ApplicationHelper.IdFornecedor, "bbbf4f03-01fc-4300-b430-33e007753578", str1))); - Uri apiFipe = Address.get_ApiFipe(); - string[] strArrays = new string[] { "api" }; - Uri uri = apiFipe.Append(strArrays); - string[] strArrays1 = new string[] { "auth" }; - Uri uri1 = uri.Append(strArrays1); - HttpResponseMessage httpResponseMessage = await httpClient.PostAsync(uri1, base64String.ToHttpContent(null, "application/json")); - if (httpResponseMessage.get_IsSuccessStatusCode()) - { - JToken item = httpResponseMessage.get_Content().ToJObject().get_Item("token"); - if (item != null) - { - empty = item.ToString(); - } - else - { - empty = null; - } - } - else - { - empty = string.Empty; - } - str = empty; - } - return str; - } - - private async Task FipeCode(string code) - { - Fipe fipe; - Fipe fipe1; - using (HttpClient httpClient = new HttpClient()) - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - string str = await this.FipeAuthentication(); - if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str)) - { - httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str)); - } - Uri apiFipe = Address.get_ApiFipe(); - string[] strArrays = new string[] { "v1" }; - Uri uri = apiFipe.Append(strArrays); - string[] strArrays1 = new string[] { "fipe" }; - Uri uri1 = uri.Append(strArrays1).AddQuery("fipeCode", code); - HttpResponseMessage async = await httpClient.GetAsync(uri1); - fipe1 = (!async.get_IsSuccessStatusCode() ? new Fipe() : JsonConvert.DeserializeObject(await async.get_Content().ReadAsStringAsync())); - fipe = fipe1; - } - return fipe; - } - - private async Task> FipeModel(string model) - { - List fipes; - List fipes1; - using (HttpClient httpClient = new HttpClient()) - { - ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12; - string str = await this.FipeAuthentication(); - if (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(str)) - { - httpClient.get_DefaultRequestHeaders().TryAddWithoutValidation("Authorization", string.Concat("Bearer ", str)); - } - Uri apiFipe = Address.get_ApiFipe(); - string[] strArrays = new string[] { "v1" }; - Uri uri = apiFipe.Append(strArrays); - string[] strArrays1 = new string[] { "fipe" }; - Uri uri1 = uri.Append(strArrays1); - string[] strArrays2 = new string[] { "modelo" }; - Uri uri2 = uri1.Append(strArrays2); - string[] strArrays3 = new string[] { model }; - Uri uri3 = uri2.Append(strArrays3); - HttpResponseMessage async = await httpClient.GetAsync(uri3); - fipes1 = (!async.get_IsSuccessStatusCode() ? new List() : JsonConvert.DeserializeObject>(await async.get_Content().ReadAsStringAsync())); - fipes = fipes1; - } - return fipes; - } - - private static async Task Get(string command) - where T : class - { - Uri uri = new Uri(command); - ConfiguredTaskAwaitable configuredTaskAwaitable = (new HttpClient()).GetAsync(uri).ConfigureAwait(false); - HttpResponseMessage httpResponseMessage = await configuredTaskAwaitable; - if (httpResponseMessage.get_StatusCode() != HttpStatusCode.OK) - { - throw new Exception(string.Concat("Api connection Error ", Environment.NewLine, " ", command), null); - } - T t = JsonConvert.DeserializeObject(httpResponseMessage.get_Content().ReadAsStringAsync().Result); - return t; - } - - public async Task Reativar(Item item, string descricao) - { - Item item1 = await Task.Run(() => { - Item item2; - string str; - try - { - using (UnitOfWork commited = Instancia.Commited) - { - item = commited.get_ItemRepository().FindById(item.get_Id()); - item.set_Cancelado(false); - long? nullable = null; - item.set_Substituido(nullable); - nullable = null; - item.set_IdDocumentoCancelado(nullable); - item.set_Status(descricao); - item = commited.get_ItemRepository().Merge(item); - DateTime networkTime = Funcoes.GetNetworkTime(); - IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); - RegistroLog registroLog = new RegistroLog(); - registroLog.set_Acao(1); - registroLog.set_Usuario(Recursos.Usuario); - registroLog.set_DataHora(networkTime); - RegistroLog registroLog1 = registroLog; - string[] strArrays = new string[] { string.Format("O USUÁRIO {0} REATIVOU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null }; - strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); - strArrays[4] = "', OBSERVAÇÃO: '"; - strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); - strArrays[6] = "', STATUS: '"; - strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); - strArrays[8] = "' - "; - strArrays[9] = descricao; - strArrays[10] = "."; - registroLog1.set_Descricao(string.Concat(strArrays)); - registroLog.set_EntidadeId(item.get_Id()); - registroLog.set_Tela(3); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - RegistroLog registroLog2 = registroLog; - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_211 = ItemServico.u003cu003ec.u003cu003e9__21_1; - if (u003cu003e9_211 == null) - { - u003cu003e9_211 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__21_1 = u003cu003e9_211; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_211); - if (pAddress != null) - { - str = pAddress.ToString(); - } - else - { - str = null; - } - registroLog2.set_Ip(str); - base.SaveLog(registroLog, commited); - commited.Commit(); - item2 = item; - } - } - catch (Exception exception) - { - item2 = null; - } - return item2; - }); - return item1; - } - - public async Task Save(Item item) - { - Action action3 = null; - Action action4 = null; - int num3 = 3; - Item item2 = item; - base.Sucesso = true; - IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); - DateTime networkTime = Funcoes.GetNetworkTime(); - Item item3 = await Task.Run(() => { - bool id; - Auto auto; - Vida vida; - RiscosDiversos riscosDiversos; - Action action; - Item item4; - string str1; - TipoTela tipoTela; - Label5: - while (num3 > 0) - { - item = item2; - try - { - using (UnitOfWork commited = Instancia.Commited) - { - id = item.get_Id() == (long)0; - auto = item.get_Auto(); - Patrimonial patrimonial = item.get_Patrimonial(); - Granizo granizo = item.get_Granizo(); - Aeronautico aeronautico = item.get_Aeronautico(); - vida = item.get_Vida(); - riscosDiversos = item.get_RiscosDiversos(); - Consorcio consorcio = item.get_Consorcio(); - tipoTela = 3; - IList coberturas = item.get_Coberturas(); - item.set_StatusInclusao((item.get_Documento().get_Tipo() == 0 ? "ITEM DA APÓLICE" : "ITEM DO ENDOSSO")); - if (id) - { - item.set_Coberturas(null); - } - if (!id && coberturas != null && coberturas.Count > 0) - { - try - { - List list = coberturas.ToList(); - Action u003cu003e9_2 = action3; - if (u003cu003e9_2 == null) - { - Action action1 = (Cobertura x) => x.set_Item(item); - action = action1; - action3 = action1; - u003cu003e9_2 = action; - } - list.ForEach(u003cu003e9_2); - IList coberturas1 = coberturas; - Func u003cu003e9_233 = ItemServico.u003cu003ec.u003cu003e9__23_3; - if (u003cu003e9_233 == null) - { - u003cu003e9_233 = (Cobertura c) => c.get_Id() == (long)0; - ItemServico.u003cu003ec.u003cu003e9__23_3 = u003cu003e9_233; - } - List list1 = coberturas1.Where(u003cu003e9_233).ToList(); - if (list1.Count > 0) - { - list1 = commited.get_CoberturaRepository().AddRange(list1.ToList()); - list1.ForEach((Cobertura c) => { - string str; - RegistroLog registroLog = new RegistroLog(); - registroLog.set_Acao(0); - registroLog.set_Usuario(Recursos.Usuario); - registroLog.set_DataHora(networkTime); - JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); - jsonSerializerSetting.set_ReferenceLoopHandling(1); - registroLog.set_Descricao(JsonConvert.SerializeObject(c, jsonSerializerSetting)); - registroLog.set_EntidadeId(c.get_Id()); - registroLog.set_Tela(tipoTela); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_237 = ItemServico.u003cu003ec.u003cu003e9__23_7; - if (u003cu003e9_237 == null) - { - u003cu003e9_237 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__23_7 = u003cu003e9_237; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_237); - str = (pAddress != null ? pAddress.ToString() : null); - registroLog.set_Ip(str); - base.SaveLog(registroLog, commited); - }); - } - IList coberturas2 = coberturas; - Func u003cu003e9_235 = ItemServico.u003cu003ec.u003cu003e9__23_5; - if (u003cu003e9_235 == null) - { - u003cu003e9_235 = (Cobertura c) => c.get_Id() > (long)0; - ItemServico.u003cu003ec.u003cu003e9__23_5 = u003cu003e9_235; - } - List list2 = coberturas2.Where(u003cu003e9_235).ToList(); - if (list2.Count > 0) - { - list2 = commited.get_CoberturaRepository().MergeRange(list2); - list2.ForEach((Cobertura c) => { - string str; - 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(c, jsonSerializerSetting)); - registroLog.set_EntidadeId(c.get_Id()); - registroLog.set_Tela(tipoTela); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_238 = ItemServico.u003cu003ec.u003cu003e9__23_8; - if (u003cu003e9_238 == null) - { - u003cu003e9_238 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__23_8 = u003cu003e9_238; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_238); - str = (pAddress != null ? pAddress.ToString() : null); - registroLog.set_Ip(str); - base.SaveLog(registroLog, commited); - }); - } - list2.AddRange(list1); - item.set_Coberturas(list2); - } - catch (Exception exception) - { - num3 = base.Registrar(exception, 208, num3, coberturas, true); - continue; - } - } - if (!item.get_Documento().get_Sinistro() && item.get_Sinistrado() && item.get_Documento().get_Situacao() == 2 && item.get_Status() != null && !item.get_Status().Contains("ALTERADO")) - { - item.set_Sinistrado(false); - } - item = (id ? commited.get_ItemRepository().SaveOrUpdate(item) : commited.get_ItemRepository().Merge(item)); - long num = item.get_Documento().get_Controle().get_Ramo().get_Id(); - if (num > (long)38) - { - if (num == (long)47 || num == (long)53 || num == (long)66) - { - goto Label0; - } - goto Label1; - } - else - { - long num1 = num - (long)1; - if (num1 <= (long)19) - { - switch ((uint)num1) - { - case 0: - case 1: - case 2: - case 14: - case 17: - { - goto Label3; - } - case 3: - case 7: - case 10: - case 11: - case 13: - case 15: - case 16: - case 18: - { - goto Label1; - } - case 4: - { - goto Label4; - } - case 5: - case 6: - case 8: - case 9: - { - goto Label0; - } - case 12: - { - try - { - if (aeronautico != null) - { - aeronautico.set_Item(item); - aeronautico = (id ? commited.get_AeronauticoRepository().SaveOrUpdate(aeronautico) : commited.get_AeronauticoRepository().Merge(aeronautico)); - item.set_Aeronautico(aeronautico); - tipoTela = 3; - goto Label2; - } - else - { - goto Label2; - } - } - catch (Exception exception1) - { - num3 = base.Registrar(exception1, 202, num3, aeronautico, true); - continue; - } - break; - } - case 19: - { - try - { - if (granizo != null) - { - granizo.set_Item(item); - granizo = (id ? commited.get_GranizoRepository().SaveOrUpdate(granizo) : commited.get_GranizoRepository().Merge(granizo)); - item.set_Granizo(granizo); - tipoTela = 3; - goto Label2; - } - else - { - goto Label2; - } - } - catch (Exception exception2) - { - num3 = base.Registrar(exception2, 206, num3, granizo, true); - continue; - } - break; - } - } - } - else - { - } - if (num != (long)30) - { - long num2 = num - (long)36; - if (num2 <= (long)2) - { - switch ((uint)num2) - { - case 0: - { - try - { - if (consorcio != null) - { - consorcio.set_Item(item); - consorcio = (id ? commited.get_ConsorcioRepository().SaveOrUpdate(consorcio) : commited.get_ConsorcioRepository().Merge(consorcio)); - item.set_Consorcio(consorcio); - tipoTela = 3; - goto Label2; - } - else - { - goto Label2; - } - } - catch (Exception exception3) - { - num3 = base.Registrar(exception3, 331, num3, consorcio, true); - continue; - } - break; - } - case 1: - { - goto Label4; - } - case 2: - { - break; - } - default: - { - goto Label1; - } - } - } - else - { - goto Label1; - } - } - Label3: - try - { - if (patrimonial != null) - { - patrimonial.set_Item(item); - patrimonial = (id ? commited.get_PatrimonialRepository().SaveOrUpdate(patrimonial) : commited.get_PatrimonialRepository().Merge(patrimonial)); - item.set_Patrimonial(patrimonial); - tipoTela = 3; - } - } - catch (Exception exception4) - { - num3 = base.Registrar(exception4, 196, num3, patrimonial, true); - continue; - } - } - Label2: - if (id && coberturas != null && coberturas.Count > 0) - { - try - { - item.set_Coberturas(new List()); - List list3 = coberturas.ToList(); - Action u003cu003e9_1 = action4; - if (u003cu003e9_1 == null) - { - Action action2 = (Cobertura x) => { - x.set_Id((long)0); - x.set_Item(item); - }; - action = action2; - action4 = action2; - u003cu003e9_1 = action; - } - list3.ForEach(u003cu003e9_1); - coberturas = commited.get_CoberturaRepository().AddRange(coberturas.ToList()); - item.set_Coberturas(coberturas); - } - catch (Exception exception5) - { - num3 = base.Registrar(exception5, 208, num3, coberturas, true); - continue; - } - } - TipoAcao tipoAcao = (id ? 0 : 1); - RegistroLog registroLog1 = new RegistroLog(); - registroLog1.set_Acao(tipoAcao); - registroLog1.set_Usuario(Recursos.Usuario); - registroLog1.set_DataHora(networkTime); - Item item1 = item; - JsonSerializerSettings jsonSerializerSetting1 = new JsonSerializerSettings(); - jsonSerializerSetting1.set_ReferenceLoopHandling(1); - registroLog1.set_Descricao(JsonConvert.SerializeObject(item1, jsonSerializerSetting1)); - registroLog1.set_EntidadeId(item.get_Id()); - registroLog1.set_Tela(tipoTela); - registroLog1.set_Versao(LoginViewModel.VersaoAtual); - registroLog1.set_NomeMaquina(Environment.MachineName); - registroLog1.set_UsuarioMaquina(Environment.UserName); - IPAddress[] pAddressArray = hostEntry.AddressList; - Func u003cu003e9_239 = ItemServico.u003cu003ec.u003cu003e9__23_9; - if (u003cu003e9_239 == null) - { - u003cu003e9_239 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__23_9 = u003cu003e9_239; - } - IPAddress pAddress1 = ((IEnumerable)pAddressArray).FirstOrDefault(u003cu003e9_239); - if (pAddress1 != null) - { - str1 = pAddress1.ToString(); - } - else - { - str1 = null; - } - registroLog1.set_Ip(str1); - base.SaveLog(registroLog1, commited); - commited.Commit(); - item4 = item; - } - } - catch (Exception exception6) - { - num3 = base.Registrar(exception6, 195, num3, item, true); - continue; - } - return item4; - } - return item2; - Label0: - try - { - if (vida != null) - { - vida.set_Item(item); - vida = (id ? commited.get_VidaRepository().SaveOrUpdate(vida) : commited.get_VidaRepository().Merge(vida)); - item.set_Vida(vida); - tipoTela = 3; - goto Label2; - } - else - { - goto Label2; - } - } - catch (Exception exception7) - { - num3 = base.Registrar(exception7, 200, num3, vida, true); - goto Label5; - } - Label1: - try - { - if (riscosDiversos != null) - { - riscosDiversos.set_Item(item); - riscosDiversos = (id ? commited.get_RiscosDiversosRepository().SaveOrUpdate(riscosDiversos) : commited.get_RiscosDiversosRepository().Merge(riscosDiversos)); - item.set_RiscosDiversos(riscosDiversos); - tipoTela = 3; - goto Label2; - } - else - { - goto Label2; - } - } - catch (Exception exception8) - { - num3 = base.Registrar(exception8, 198, num3, riscosDiversos, true); - goto Label5; - } - Label4: - try - { - if (auto != null) - { - auto.set_Item(item); - auto = (id ? commited.get_AutoRepository().SaveOrUpdate(auto) : commited.get_AutoRepository().Merge(auto)); - item.set_Auto(auto); - tipoTela = 3; - goto Label2; - } - else - { - goto Label2; - } - } - catch (Exception exception9) - { - num3 = base.Registrar(exception9, 204, num3, auto, true); - goto Label5; - } - }); - return item3; - } - - public async Task SaveRange(List itens) - { - int num = 3; - DateTime networkTime = Funcoes.GetNetworkTime(); - await Task.Run(() => { - string str; - while (num > 0) - { - try - { - using (UnitOfWork commited = Instancia.Commited) - { - itens.ForEach((Item x) => commited.get_ItemRepository().Merge(x)); - IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); - foreach (Item iten in itens) - { - RegistroLog registroLog = new RegistroLog(); - registroLog.set_Acao(2); - registroLog.set_Usuario(Recursos.Usuario); - registroLog.set_DataHora(networkTime); - JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); - jsonSerializerSetting.set_ReferenceLoopHandling(1); - registroLog.set_Descricao(JsonConvert.SerializeObject(iten, jsonSerializerSetting)); - registroLog.set_EntidadeId(iten.get_Id()); - registroLog.set_Tela(3); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_272 = ItemServico.u003cu003ec.u003cu003e9__27_2; - if (u003cu003e9_272 == null) - { - u003cu003e9_272 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__27_2 = u003cu003e9_272; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_272); - if (pAddress != null) - { - str = pAddress.ToString(); - } - else - { - str = null; - } - registroLog.set_Ip(str); - base.SaveLog(registroLog, commited); - } - commited.Commit(); - this.Sucesso = true; - break; - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 276, num, itens, true); - } - } - }); - } - - public async Task> SaveTitulares(List titularesVidas) - { - int num = 3; - List titularesVidas5 = await Task.Run>(() => { - List titularesVidas6; - while (num > 0) - { - try - { - using (UnitOfWork commited = Instancia.Commited) - { - List titularesVidas1 = titularesVidas; - Action u003cu003e9_321 = ItemServico.u003cu003ec.u003cu003e9__32_1; - if (u003cu003e9_321 == null) - { - u003cu003e9_321 = (TitularesVida x) => { - if (x.get_Tipo().GetValueOrDefault() != 2 && x.get_Dependente() != null) - { - x.set_Dependente(null); - } - }; - ItemServico.u003cu003ec.u003cu003e9__32_1 = u003cu003e9_321; - } - titularesVidas1.ForEach(u003cu003e9_321); - List titularesVidas2 = titularesVidas; - Func u003cu003e9_322 = ItemServico.u003cu003ec.u003cu003e9__32_2; - if (u003cu003e9_322 == null) - { - u003cu003e9_322 = (TitularesVida x) => { - if (x.get_Id() != 0) - { - return false; - } - return x.get_Tipo().GetValueOrDefault() != 2; - }; - ItemServico.u003cu003ec.u003cu003e9__32_2 = u003cu003e9_322; - } - titularesVidas2.Where(u003cu003e9_322).ToList().ForEach((TitularesVida x) => titularesVidas.First((TitularesVida y) => (object)y == (object)x).set_Id(commited.get_TitularesVidaRepository().SaveOrUpdate(x).get_Id())); - List titularesVidas3 = titularesVidas; - Func u003cu003e9_324 = ItemServico.u003cu003ec.u003cu003e9__32_4; - if (u003cu003e9_324 == null) - { - u003cu003e9_324 = (TitularesVida x) => { - if (x.get_Id() != 0) - { - return false; - } - return x.get_Tipo().GetValueOrDefault() == 2; - }; - ItemServico.u003cu003ec.u003cu003e9__32_4 = u003cu003e9_324; - } - titularesVidas3.Where(u003cu003e9_324).ToList().ForEach((TitularesVida x) => titularesVidas.First((TitularesVida y) => (object)y == (object)x).set_Id(commited.get_TitularesVidaRepository().SaveOrUpdate(x).get_Id())); - List titularesVidas4 = titularesVidas; - Func u003cu003e9_326 = ItemServico.u003cu003ec.u003cu003e9__32_6; - if (u003cu003e9_326 == null) - { - u003cu003e9_326 = (TitularesVida x) => x.get_Id() > (long)0; - ItemServico.u003cu003ec.u003cu003e9__32_6 = u003cu003e9_326; - } - titularesVidas4.Where(u003cu003e9_326).ToList().ForEach((TitularesVida x) => commited.get_TitularesVidaRepository().Merge(x)); - commited.Commit(); - this.Sucesso = true; - titularesVidas6 = titularesVidas; - } - } - catch (Exception exception) - { - num = base.Registrar(exception, 276, num, titularesVidas, true); - continue; - } - return titularesVidas6; - } - return new List(); - }); - return titularesVidas5; - } - - public async Task Substituir(Item item, long substituido, string descricao) - { - Item item1 = await Task.Run(() => { - Item item2; - string str; - try - { - using (UnitOfWork commited = Instancia.Commited) - { - item = commited.get_ItemRepository().FindById(item.get_Id()); - item.set_Substituido(new long?(substituido)); - item.set_Status(descricao); - item = commited.get_ItemRepository().Merge(item); - DateTime networkTime = Funcoes.GetNetworkTime(); - IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); - RegistroLog registroLog = new RegistroLog(); - registroLog.set_Acao(1); - registroLog.set_Usuario(Recursos.Usuario); - registroLog.set_DataHora(networkTime); - RegistroLog registroLog1 = registroLog; - string[] strArrays = new string[] { string.Format("O USUÁRIO {0} SUBSTITUIU, EM {1}, O ITEM DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", item.get_Id()), ", DESCRIÇÃO: '", null, null, null, null, null, null, null, null }; - strArrays[3] = (string.IsNullOrWhiteSpace(item.get_Descricao()) ? "" : item.get_Descricao() ?? ""); - strArrays[4] = "', OBSERVAÇÃO: '"; - strArrays[5] = (string.IsNullOrWhiteSpace(item.get_Observacao()) ? "" : item.get_Observacao() ?? ""); - strArrays[6] = "', STATUS: '"; - strArrays[7] = (string.IsNullOrWhiteSpace(item.get_Status()) ? "" : item.get_Status() ?? ""); - strArrays[8] = "' - "; - strArrays[9] = descricao; - strArrays[10] = "."; - registroLog1.set_Descricao(string.Concat(strArrays)); - registroLog.set_EntidadeId(item.get_Id()); - registroLog.set_Tela(3); - registroLog.set_Versao(LoginViewModel.VersaoAtual); - registroLog.set_NomeMaquina(Environment.MachineName); - registroLog.set_UsuarioMaquina(Environment.UserName); - RegistroLog registroLog2 = registroLog; - IPAddress[] addressList = hostEntry.AddressList; - Func u003cu003e9_221 = ItemServico.u003cu003ec.u003cu003e9__22_1; - if (u003cu003e9_221 == null) - { - u003cu003e9_221 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork; - ItemServico.u003cu003ec.u003cu003e9__22_1 = u003cu003e9_221; - } - IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault(u003cu003e9_221); - if (pAddress != null) - { - str = pAddress.ToString(); - } - else - { - str = null; - } - registroLog2.set_Ip(str); - base.SaveLog(registroLog, commited); - commited.Commit(); - item2 = item; - } - } - catch (Exception exception) - { - item2 = null; - } - return item2; - }); - return item1; - } - } -} \ No newline at end of file -- cgit v1.2.3