diff options
Diffstat (limited to 'Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs')
| -rw-r--r-- | Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs | 182 |
1 files changed, 182 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs new file mode 100644 index 0000000..3cac6b8 --- /dev/null +++ b/Codemerx/Gestor.Application/Servicos/Ferramentas/MetaSeguradoraServico.cs @@ -0,0 +1,182 @@ +using Gestor.Application.Helpers;
+using Gestor.Application.Servicos.Generic;
+using Gestor.Application.ViewModels;
+using Gestor.Common.Validation;
+using Gestor.Infrastructure.Repository.Interface;
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Infrastructure.UnitOfWork.Logic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Domain.Seguros;
+using Newtonsoft.Json;
+using System;
+using System.Collections.Generic;
+using System.Diagnostics;
+using System.Linq;
+using System.Net;
+using System.Net.Sockets;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Application.Servicos.Ferramentas
+{
+ internal class MetaSeguradoraServico : BaseServico
+ {
+ public MetaSeguradoraServico()
+ {
+ }
+
+ public async Task<List<MetaSeguradora>> BuscarMetasSeguradoras(Filtros filtro)
+ {
+ int num = 3;
+ List<MetaSeguradora> metaSeguradoras1 = await Task.Run<List<MetaSeguradora>>(() => {
+ List<MetaSeguradora> metaSeguradoras;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork read = Instancia.Read)
+ {
+ metaSeguradoras = read.get_MetaSeguradoraRepository().FindByMeta(filtro);
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 284, num, filtro, true);
+ continue;
+ }
+ return metaSeguradoras;
+ }
+ return new List<MetaSeguradora>();
+ });
+ return metaSeguradoras1;
+ }
+
+ public async Task<bool> Delete(MetaSeguradora meta)
+ {
+ int num = 3;
+ bool flag1 = await Task.Run<bool>(() => {
+ bool flag;
+ string str;
+ while (num > 0)
+ {
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ commited.get_MetaSeguradoraRepository().Delete(meta.get_Id());
+ DateTime networkTime = Funcoes.GetNetworkTime();
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(2);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(networkTime);
+ registroLog.set_Descricao(string.Concat(new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A META DE", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", meta.get_Id()), ", MÊS: '", Gestor.Common.Validation.ValidationHelper.GetDescription(meta.get_Mes()), "'", string.Format(", ANO: '{0}'", meta.get_Ano()), string.Format(", VALOR: 'R${0}'.", meta.get_Valor()) }));
+ registroLog.set_EntidadeId(meta.get_Id());
+ registroLog.set_Tela(31);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ RegistroLog registroLog1 = registroLog;
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_11 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1;
+ if (u003cu003e9_11 == null)
+ {
+ u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MetaSeguradoraServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog1.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ flag = true;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 223, num, meta, true);
+ continue;
+ }
+ return flag;
+ }
+ return false;
+ });
+ return flag1;
+ }
+
+ public async Task<MetaSeguradora> Save(MetaSeguradora metaSeguradora)
+ {
+ int num = 3;
+ base.Sucesso = true;
+ MetaSeguradora metaSeguradora2 = metaSeguradora;
+ MetaSeguradora metaSeguradora3 = await Task.Run<MetaSeguradora>(() => {
+ MetaSeguradora metaSeguradora4;
+ string str;
+ while (num > 0)
+ {
+ metaSeguradora = metaSeguradora2;
+ try
+ {
+ using (UnitOfWork commited = Instancia.Commited)
+ {
+ TipoAcao tipoAcao = (metaSeguradora.get_Id() == 0 ? 0 : 1);
+ metaSeguradora = (metaSeguradora.get_Id() == 0 ? commited.get_MetaSeguradoraRepository().SaveOrUpdate(metaSeguradora) : commited.get_MetaSeguradoraRepository().Merge(metaSeguradora));
+ IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
+ RegistroLog registroLog = new RegistroLog();
+ registroLog.set_Acao(tipoAcao);
+ registroLog.set_Usuario(Recursos.Usuario);
+ registroLog.set_DataHora(Funcoes.GetNetworkTime());
+ MetaSeguradora metaSeguradora1 = metaSeguradora;
+ JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
+ jsonSerializerSetting.set_ReferenceLoopHandling(1);
+ registroLog.set_Descricao(JsonConvert.SerializeObject(metaSeguradora1, jsonSerializerSetting));
+ registroLog.set_EntidadeId(metaSeguradora.get_Id());
+ registroLog.set_Tela(31);
+ registroLog.set_Versao(LoginViewModel.VersaoAtual);
+ registroLog.set_NomeMaquina(Environment.MachineName);
+ registroLog.set_UsuarioMaquina(Environment.UserName);
+ IPAddress[] addressList = hostEntry.AddressList;
+ Func<IPAddress, bool> u003cu003e9_01 = MetaSeguradoraServico.u003cu003ec.u003cu003e9__0_1;
+ if (u003cu003e9_01 == null)
+ {
+ u003cu003e9_01 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
+ MetaSeguradoraServico.u003cu003ec.u003cu003e9__0_1 = u003cu003e9_01;
+ }
+ IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_01);
+ if (pAddress != null)
+ {
+ str = pAddress.ToString();
+ }
+ else
+ {
+ str = null;
+ }
+ registroLog.set_Ip(str);
+ base.SaveLog(registroLog, commited);
+ commited.Commit();
+ metaSeguradora4 = metaSeguradora;
+ }
+ }
+ catch (Exception exception)
+ {
+ num = base.Registrar(exception, 222, num, metaSeguradora, true);
+ continue;
+ }
+ return metaSeguradora4;
+ }
+ return metaSeguradora2;
+ });
+ return metaSeguradora3;
+ }
+ }
+}
\ No newline at end of file |