summaryrefslogtreecommitdiff
path: root/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers
diff options
context:
space:
mode:
Diffstat (limited to 'Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers')
-rw-r--r--Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Auxiliar.cs2068
-rw-r--r--Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/AuxiliarFinanceiro.cs127
-rw-r--r--Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Comparador.cs38
-rw-r--r--Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Funcoes.cs1403
-rw-r--r--Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/QueryableHelper.cs48
-rw-r--r--Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/SqlDataReaderHelper.cs66
6 files changed, 3750 insertions, 0 deletions
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Auxiliar.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Auxiliar.cs
new file mode 100644
index 0000000..79dbd5f
--- /dev/null
+++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Auxiliar.cs
@@ -0,0 +1,2068 @@
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Common;
+using Gestor.Model.Domain.Ferramentas;
+using Gestor.Model.Domain.Generic;
+using Gestor.Model.Domain.Seguros;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Infrastructure.Helpers
+{
+ public static class Auxiliar
+ {
+ public static List<Gestor.Model.Domain.Common.Banco> Banco
+ {
+ get;
+ set;
+ }
+
+ public static List<Gestor.Model.Domain.Ferramentas.CategoriaTarefa> CategoriaTarefa
+ {
+ get;
+ set;
+ }
+
+ public static List<CoberturaPadrao> CoberturasPadrao
+ {
+ get;
+ set;
+ }
+
+ public static List<Empresa> Empresas
+ {
+ get;
+ set;
+ }
+
+ public static List<Estipulante> Estipulantes
+ {
+ get;
+ set;
+ }
+
+ public static List<Parceiro> Parceiros
+ {
+ get;
+ set;
+ }
+
+ public static List<Produto> Produtos
+ {
+ get;
+ set;
+ }
+
+ public static List<Profissao> Profissoes
+ {
+ get;
+ set;
+ }
+
+ public static List<Ramo> Ramos
+ {
+ get;
+ set;
+ }
+
+ public static List<Repasse> Repasses
+ {
+ get;
+ set;
+ }
+
+ public static List<Seguradora> Seguradoras
+ {
+ get;
+ set;
+ }
+
+ public static List<Status> StatusApolice
+ {
+ get;
+ set;
+ }
+
+ public static List<StatusDeProspeccao> StatusProspeccao
+ {
+ get;
+ set;
+ }
+
+ public static List<TipoDeTarefa> TiposTarefa
+ {
+ get;
+ set;
+ }
+
+ public static List<TipoVendedor> TipoVendedores
+ {
+ get;
+ set;
+ }
+
+ public static List<Usuario> Usuarios
+ {
+ get;
+ set;
+ }
+
+ public static List<Vendedor> Vendedores
+ {
+ get;
+ set;
+ }
+
+ public static void CriarAuxiliar(SqlCommand sqlCommand, bool force = false)
+ {
+ DataTable dataTable = new DataTable();
+ if (force || Auxiliar.Empresas == null)
+ {
+ sqlCommand.CommandText = "SELECT DISTINCT idempresa as id, nome, NomeSocial, cgccpf FROM empresa;";
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ Auxiliar.Empresas = new List<Empresa>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Empresas.Add(new Empresa()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ NomeSocial = a.Field<string>("NomeSocial") ?? a.Field<string>("nome"),
+ Documento = a.Field<string>("cgccpf")
+ }));
+ }
+ if (force || Auxiliar.Seguradoras == null)
+ {
+ Auxiliar.LoadSeguradoras(sqlCommand);
+ }
+ if (force || Auxiliar.Ramos == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idramo as id, nome, ativo, iof FROM ramo;";
+ using (SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter())
+ {
+ sqlDataAdapter1.SelectCommand = sqlCommand;
+ sqlDataAdapter1.Fill(dataTable);
+ }
+ Auxiliar.Ramos = new List<Ramo>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Ramos.Add(new Ramo()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Iof = a.Field<decimal?>("iof").GetValueOrDefault(),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ }
+ if (force || Auxiliar.Banco == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT IDCODIGOBANCO as id, NOMEBANCO as nome FROM codigobanco;";
+ using (SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter())
+ {
+ sqlDataAdapter2.SelectCommand = sqlCommand;
+ sqlDataAdapter2.Fill(dataTable);
+ }
+ Auxiliar.Banco = new List<Gestor.Model.Domain.Common.Banco>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Banco.Add(new Gestor.Model.Domain.Common.Banco()
+ {
+ Id = a.Field<int>("id"),
+ Nome = a.Field<string>("nome")
+ }));
+ }
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idestipulante as id, nome, ativo FROM estipulante;";
+ using (SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter())
+ {
+ sqlDataAdapter3.SelectCommand = sqlCommand;
+ sqlDataAdapter3.Fill(dataTable);
+ }
+ Auxiliar.Estipulantes = new List<Estipulante>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Estipulantes.Add(new Estipulante()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ if (force || Auxiliar.Vendedores == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idvendedor as id, nome, cpfcnpj, corretora, tipoincidenciadesconto, desconto, ativo, idempresa, idcodigobanco, agencia, conta FROM vendedor;";
+ using (SqlDataAdapter sqlDataAdapter4 = new SqlDataAdapter())
+ {
+ sqlDataAdapter4.SelectCommand = sqlCommand;
+ sqlDataAdapter4.Fill(dataTable);
+ }
+ Auxiliar.Vendedores = new List<Vendedor>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Vendedores.Add(new Vendedor()
+ {
+ IdEmpresa = a.Field<long?>("idempresa").GetValueOrDefault((long)1),
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Documento = a.Field<string>("cpfcnpj"),
+ Corretora = (string.IsNullOrEmpty(a.Field<string>("corretora")) ? false : a.Field<string>("corretora") == "1"),
+ TipoIncidenciaDesconto = (a.Field<object>("tipoincidenciadesconto") == null ? TipoIncidenciaDesconto.Ambos : a.Field<int>("tipoincidenciadesconto")),
+ Desconto = new decimal?((a.Field<object>("desconto") == null ? decimal.Zero : a.Field<decimal>("desconto") * new decimal(1, 0, 0, false, 2))),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1"),
+ Banco = (a.Field<object>("idcodigobanco") == null ? null : Auxiliar.Banco.FirstOrDefault<Gestor.Model.Domain.Common.Banco>((Gestor.Model.Domain.Common.Banco p) => p.Id == a.Field<int>("idcodigobanco"))),
+ Agencia = a.Field<string>("agencia"),
+ Conta = a.Field<string>("conta")
+ }));
+ }
+ if (force || Auxiliar.Repasses == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT * FROM repasse;";
+ using (SqlDataAdapter sqlDataAdapter5 = new SqlDataAdapter())
+ {
+ sqlDataAdapter5.SelectCommand = sqlCommand;
+ sqlDataAdapter5.Fill(dataTable);
+ }
+ Auxiliar.Repasses = dataTable.AsEnumerable().Select<DataRow, Repasse>((DataRow x) => {
+ Repasse repasse = new Repasse()
+ {
+ Id = x.Field<long>("idrepasse"),
+ Vendedor = Auxiliar.Vendedores.Find((Vendedor v) => v.Id == x.Field<long>("idvendedor")),
+ Ramo = (x.Field<object>("idramo") != null ? Auxiliar.Ramos.Find((Ramo r) => r.Id == x.Field<long>("idramo")) : null),
+ Ativo = (x.Field<object>("ativo") == null ? true : x.Field<object>("ativo").ToString() == "1"),
+ Tipo = (x.Field<object>("tipo") != null ? new TipoRepasse?((TipoRepasse)int.Parse(x.Field<object>("tipo").ToString())) : null),
+ Incidencia = (x.Field<object>("incidencia") != null ? new TipoIncidencia?((TipoIncidencia)int.Parse(x.Field<object>("incidencia").ToString())) : null),
+ Forma = (x.Field<object>("forma") != null ? new FormaRepasse?((FormaRepasse)int.Parse(x.Field<object>("forma").ToString())) : null),
+ Base = (x.Field<object>("base") != null ? new BaseRepasse?((BaseRepasse)int.Parse(x.Field<object>("base").ToString())) : null)
+ };
+ decimal? nullable = x.Field<decimal?>("vlrnovo");
+ repasse.ValorNovo = nullable.GetValueOrDefault();
+ nullable = x.Field<decimal?>("vlrrenovacao");
+ repasse.ValorRenovacao = nullable.GetValueOrDefault();
+ return repasse;
+ }).ToList<Repasse>();
+ }
+ if (force || Auxiliar.Produtos == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idproduto as id, nome, ativo FROM produto;";
+ using (SqlDataAdapter sqlDataAdapter6 = new SqlDataAdapter())
+ {
+ sqlDataAdapter6.SelectCommand = sqlCommand;
+ sqlDataAdapter6.Fill(dataTable);
+ }
+ Auxiliar.Produtos = new List<Produto>();
+ dataTable.AsEnumerable().OrderBy<DataRow, string>((DataRow x) => x.Field<string>("nome")).ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Produtos.Add(new Produto()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Ativo = a.Field<bool?>("ativo").GetValueOrDefault(true)
+ }));
+ }
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idstatus as id, nome, ativo FROM status;";
+ using (SqlDataAdapter sqlDataAdapter7 = new SqlDataAdapter())
+ {
+ sqlDataAdapter7.SelectCommand = sqlCommand;
+ sqlDataAdapter7.Fill(dataTable);
+ }
+ Auxiliar.StatusApolice = new List<Status>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.StatusApolice.Add(new Status()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Ativo = a.Field<bool?>("ativo").GetValueOrDefault(true)
+ }));
+ if (force || Auxiliar.TipoVendedores == null)
+ {
+ Auxiliar.LoadTipoVendedor(sqlCommand);
+ }
+ if (force || Auxiliar.Usuarios == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idusuario as id, idpermissao, nome, removido, inativo, idempresa, identif, Visita FROM usuario;";
+ using (SqlDataAdapter sqlDataAdapter8 = new SqlDataAdapter())
+ {
+ sqlDataAdapter8.SelectCommand = sqlCommand;
+ sqlDataAdapter8.Fill(dataTable);
+ }
+ Auxiliar.Usuarios = new List<Usuario>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Usuarios.Add(new Usuario()
+ {
+ IdEmpresa = a.Field<long?>("idempresa").GetValueOrDefault((long)1),
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Login = a.Field<string>("identif"),
+ Visita = a.Field<string>("Visita"),
+ Excluido = a.Field<bool?>("removido").GetValueOrDefault(),
+ PermissaoAggilizador = a.Field<long?>("idpermissao")
+ }));
+ }
+ if (force || Auxiliar.Parceiros == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idparceiro as id, nome FROM parceiro;";
+ using (SqlDataAdapter sqlDataAdapter9 = new SqlDataAdapter())
+ {
+ sqlDataAdapter9.SelectCommand = sqlCommand;
+ sqlDataAdapter9.Fill(dataTable);
+ }
+ Auxiliar.Parceiros = new List<Parceiro>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Parceiros.Add(new Parceiro()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome")
+ }));
+ }
+ if (force || Auxiliar.Profissoes == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idprofissao AS id, nome FROM profissao;";
+ using (SqlDataAdapter sqlDataAdapter10 = new SqlDataAdapter())
+ {
+ sqlDataAdapter10.SelectCommand = sqlCommand;
+ sqlDataAdapter10.Fill(dataTable);
+ }
+ Auxiliar.Profissoes = new List<Profissao>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Profissoes.Add(new Profissao()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome")
+ }));
+ }
+ if (force || Auxiliar.TiposTarefa == null)
+ {
+ Auxiliar.LoadTipoTarefa(sqlCommand);
+ }
+ if (force || Auxiliar.StatusProspeccao == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT * FROM StatusProspeccao;";
+ using (SqlDataAdapter sqlDataAdapter11 = new SqlDataAdapter())
+ {
+ sqlDataAdapter11.SelectCommand = sqlCommand;
+ sqlDataAdapter11.Fill(dataTable);
+ }
+ Auxiliar.StatusProspeccao = new List<StatusDeProspeccao>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.StatusProspeccao.Add(new StatusDeProspeccao()
+ {
+ Id = a.Field<long>("Id"),
+ Nome = a.Field<string>("Nome"),
+ Descricao = a.Field<string>("Descricao"),
+ Ativo = a.Field<bool>("Ativo"),
+ Excluido = a.Field<bool>("Excluido")
+ }));
+ }
+ if (force || Auxiliar.CategoriaTarefa == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT * FROM CategoriaTarefa;";
+ using (SqlDataAdapter sqlDataAdapter12 = new SqlDataAdapter())
+ {
+ sqlDataAdapter12.SelectCommand = sqlCommand;
+ sqlDataAdapter12.Fill(dataTable);
+ }
+ Auxiliar.CategoriaTarefa = new List<Gestor.Model.Domain.Ferramentas.CategoriaTarefa>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.CategoriaTarefa.Add(new Gestor.Model.Domain.Ferramentas.CategoriaTarefa()
+ {
+ Id = a.Field<long>("Id"),
+ Descricao = a.Field<string>("Descricao")
+ }));
+ }
+ if (force || Auxiliar.CoberturasPadrao == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT * FROM coberturapadrao;";
+ using (SqlDataAdapter sqlDataAdapter13 = new SqlDataAdapter())
+ {
+ sqlDataAdapter13.SelectCommand = sqlCommand;
+ sqlDataAdapter13.Fill(dataTable);
+ }
+ Auxiliar.CoberturasPadrao = new List<CoberturaPadrao>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.CoberturasPadrao.Add(new CoberturaPadrao()
+ {
+ Id = a.Field<long>("idcoberturapadrao"),
+ IdRamo = a.Field<long>("idramo"),
+ Descricao = a.Field<string>("Descricao"),
+ Padrao = a.Field<string>("padrao") == "1"
+ }));
+ }
+ }
+
+ public static void CriarAuxiliarUsuario(SqlCommand sqlCommand)
+ {
+ if (Auxiliar.Usuarios != null)
+ {
+ return;
+ }
+ DataTable dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idusuario as id, nome, idpermissao, removido, inativo, idempresa, identif, Visita FROM usuario;";
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ Auxiliar.Usuarios = new List<Usuario>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Usuarios.Add(new Usuario()
+ {
+ IdEmpresa = a.Field<long?>("idempresa").GetValueOrDefault((long)1),
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Login = a.Field<string>("identif"),
+ Excluido = a.Field<bool?>("removido").GetValueOrDefault(),
+ Visita = a.Field<string>("Visita"),
+ PermissaoAggilizador = a.Field<long?>("idpermissao")
+ }));
+ }
+
+ public static void CriarVendedor(SqlCommand sqlCommand, bool force = false)
+ {
+ DataTable dataTable = new DataTable();
+ if (force || Auxiliar.Vendedores == null)
+ {
+ sqlCommand.CommandText = "SELECT DISTINCT idvendedor as id, nome, corretora, desconto, tipoincidenciadesconto, ativo, idempresa FROM vendedor;";
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ Auxiliar.Vendedores = new List<Vendedor>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Vendedores.Add(new Vendedor()
+ {
+ IdEmpresa = a.Field<long?>("idempresa").GetValueOrDefault((long)1),
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Corretora = (string.IsNullOrEmpty(a.Field<string>("corretora")) ? false : a.Field<string>("corretora") == "1"),
+ Desconto = new decimal?((a.Field<object>("desconto") == null ? decimal.Zero : a.Field<decimal>("desconto") * new decimal(1, 0, 0, false, 2))),
+ TipoIncidenciaDesconto = (a.Field<object>("tipoincidenciadesconto") == null ? TipoIncidenciaDesconto.Ambos : a.Field<int>("tipoincidenciadesconto")),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ }
+ if (force || Auxiliar.Ramos == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idramo as id, nome, ativo, iof FROM ramo;";
+ using (SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter())
+ {
+ sqlDataAdapter1.SelectCommand = sqlCommand;
+ sqlDataAdapter1.Fill(dataTable);
+ }
+ Auxiliar.Ramos = new List<Ramo>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.Ramos.Add(new Ramo()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ Iof = a.Field<decimal?>("iof").GetValueOrDefault(),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ }
+ if (force || Auxiliar.Repasses == null)
+ {
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT * FROM repasse;";
+ using (SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter())
+ {
+ sqlDataAdapter2.SelectCommand = sqlCommand;
+ sqlDataAdapter2.Fill(dataTable);
+ }
+ Auxiliar.Repasses = dataTable.AsEnumerable().Select<DataRow, Repasse>((DataRow x) => {
+ Repasse repasse = new Repasse()
+ {
+ Id = x.Field<long>("idrepasse"),
+ Vendedor = Auxiliar.Vendedores.Find((Vendedor v) => v.Id == x.Field<long>("idvendedor")),
+ Ramo = (x.Field<object>("idramo") != null ? Auxiliar.Ramos.Find((Ramo r) => r.Id == x.Field<long>("idramo")) : null),
+ Ativo = (x.Field<object>("ativo") == null ? true : x.Field<object>("ativo").ToString() == "1"),
+ Tipo = (x.Field<object>("tipo") != null ? new TipoRepasse?((TipoRepasse)int.Parse(x.Field<object>("tipo").ToString())) : null),
+ Incidencia = (x.Field<object>("incidencia") != null ? new TipoIncidencia?((TipoIncidencia)int.Parse(x.Field<object>("incidencia").ToString())) : null),
+ Forma = (x.Field<object>("forma") != null ? new FormaRepasse?((FormaRepasse)int.Parse(x.Field<object>("forma").ToString())) : null),
+ Base = (x.Field<object>("base") != null ? new BaseRepasse?((BaseRepasse)int.Parse(x.Field<object>("base").ToString())) : null)
+ };
+ decimal? nullable = x.Field<decimal?>("vlrnovo");
+ repasse.ValorNovo = nullable.GetValueOrDefault();
+ nullable = x.Field<decimal?>("vlrrenovacao");
+ repasse.ValorRenovacao = nullable.GetValueOrDefault();
+ return repasse;
+ }).ToList<Repasse>();
+ }
+ }
+
+ public static void LoadSeguradoras(SqlCommand sqlCommand)
+ {
+ DataTable dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idciaseg as id, nome, nomesocial, tolerancia, ativo, id as idaggilizador, LinkAppAndroid, LinkAppIos, cgccpf FROM ciaseg;";
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ Auxiliar.Seguradoras = new List<Seguradora>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => {
+ long id;
+ Seguradora seguradora = new Seguradora()
+ {
+ Id = a.Field<long>("id"),
+ Nome = a.Field<string>("nome"),
+ NomeSocial = a.Field<string>("nomesocial"),
+ Tolerancia = new decimal?((a.Field<object>("tolerancia") == null ? decimal.Zero : Math.Abs(a.Field<decimal>("tolerancia")))),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1"),
+ IdAggilizador = a.Field<long?>("idaggilizador"),
+ LinkAppAndroid = a.Field<string>("LinkAppAndroid"),
+ LinkAppIos = a.Field<string>("LinkAppIos"),
+ Documento = (a.Field<string>("cgccpf") == null || a.Field<string>("cgccpf") == "" ? "" : a.Field<string>("cgccpf"))
+ };
+ if (string.IsNullOrWhiteSpace(seguradora.NomeSocial))
+ {
+ id = seguradora.Id;
+ if (id <= (long)694)
+ {
+ if (id <= (long)678)
+ {
+ long num = id - (long)1;
+ if (num <= (long)606)
+ {
+ switch ((uint)num)
+ {
+ case 0:
+ {
+ seguradora.NomeSocial = "ABSOLUTA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 1:
+ case 2:
+ case 3:
+ case 4:
+ {
+ seguradora.NomeSocial = "ACE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 5:
+ case 6:
+ case 7:
+ case 19:
+ case 20:
+ case 21:
+ case 22:
+ case 23:
+ case 28:
+ case 29:
+ case 30:
+ case 31:
+ case 35:
+ case 36:
+ case 37:
+ case 38:
+ case 42:
+ case 43:
+ case 44:
+ case 45:
+ case 46:
+ case 47:
+ case 49:
+ case 50:
+ case 51:
+ case 57:
+ case 58:
+ case 61:
+ case 62:
+ case 66:
+ case 67:
+ case 68:
+ case 70:
+ case 71:
+ case 72:
+ case 73:
+ case 74:
+ case 75:
+ case 76:
+ case 77:
+ case 78:
+ case 79:
+ case 80:
+ case 81:
+ case 82:
+ case 83:
+ case 84:
+ case 85:
+ case 86:
+ case 87:
+ case 97:
+ case 101:
+ case 102:
+ case 103:
+ case 104:
+ case 109:
+ case 110:
+ case 113:
+ case 114:
+ case 118:
+ case 121:
+ case 122:
+ case 123:
+ case 124:
+ case 127:
+ case 131:
+ case 132:
+ case 133:
+ case 134:
+ case 135:
+ case 136:
+ case 137:
+ case 138:
+ case 139:
+ case 140:
+ case 141:
+ case 142:
+ case 143:
+ case 146:
+ case 147:
+ case 148:
+ case 149:
+ case 150:
+ case 153:
+ case 154:
+ case 155:
+ case 156:
+ case 157:
+ case 158:
+ case 159:
+ case 162:
+ case 163:
+ case 164:
+ case 165:
+ case 166:
+ case 167:
+ case 168:
+ case 169:
+ case 170:
+ case 171:
+ case 172:
+ case 173:
+ case 174:
+ case 175:
+ case 179:
+ case 182:
+ case 183:
+ case 186:
+ case 187:
+ case 189:
+ case 190:
+ case 191:
+ case 192:
+ case 193:
+ case 194:
+ case 195:
+ case 198:
+ case 199:
+ case 202:
+ case 203:
+ case 204:
+ case 207:
+ case 208:
+ case 209:
+ case 210:
+ case 211:
+ case 214:
+ case 219:
+ case 220:
+ case 223:
+ case 224:
+ case 227:
+ case 228:
+ case 229:
+ case 233:
+ case 234:
+ case 237:
+ case 238:
+ case 239:
+ case 240:
+ case 244:
+ case 245:
+ case 246:
+ case 247:
+ case 250:
+ case 252:
+ case 253:
+ case 256:
+ case 261:
+ case 262:
+ case 263:
+ case 270:
+ case 276:
+ case 277:
+ case 278:
+ case 279:
+ case 280:
+ case 281:
+ case 282:
+ case 286:
+ case 287:
+ case 288:
+ case 300:
+ case 301:
+ case 302:
+ case 303:
+ case 304:
+ case 305:
+ case 306:
+ case 312:
+ case 313:
+ case 314:
+ case 315:
+ case 316:
+ case 329:
+ case 331:
+ case 332:
+ case 333:
+ case 334:
+ case 335:
+ case 338:
+ case 339:
+ case 341:
+ case 342:
+ case 343:
+ case 344:
+ case 350:
+ case 357:
+ case 358:
+ case 359:
+ case 360:
+ case 361:
+ case 362:
+ case 363:
+ case 366:
+ case 367:
+ case 368:
+ case 369:
+ case 370:
+ case 371:
+ case 373:
+ case 376:
+ case 377:
+ case 381:
+ case 382:
+ case 383:
+ case 388:
+ case 389:
+ case 390:
+ case 391:
+ case 392:
+ case 393:
+ case 396:
+ case 397:
+ case 402:
+ case 403:
+ case 404:
+ case 405:
+ case 406:
+ case 407:
+ case 408:
+ case 409:
+ case 410:
+ case 413:
+ case 414:
+ case 415:
+ case 419:
+ case 420:
+ case 421:
+ case 422:
+ case 425:
+ case 433:
+ case 434:
+ case 442:
+ case 443:
+ case 444:
+ case 451:
+ case 452:
+ case 453:
+ case 454:
+ case 457:
+ case 460:
+ case 461:
+ case 462:
+ case 463:
+ case 464:
+ case 467:
+ case 468:
+ case 469:
+ case 470:
+ case 472:
+ case 473:
+ case 488:
+ case 495:
+ case 496:
+ case 502:
+ case 504:
+ case 505:
+ case 506:
+ case 510:
+ case 511:
+ case 512:
+ case 519:
+ case 524:
+ case 525:
+ case 526:
+ case 529:
+ case 530:
+ case 531:
+ case 532:
+ case 533:
+ case 534:
+ case 535:
+ case 536:
+ case 552:
+ case 555:
+ case 562:
+ case 563:
+ case 564:
+ case 565:
+ case 566:
+ case 567:
+ case 568:
+ case 575:
+ case 576:
+ case 577:
+ case 578:
+ case 580:
+ case 585:
+ case 586:
+ case 587:
+ case 588:
+ case 589:
+ case 592:
+ case 596:
+ case 598:
+ case 599:
+ case 600:
+ case 601:
+ {
+ goto Label6;
+ }
+ case 8:
+ case 9:
+ case 517:
+ case 518:
+ {
+ seguradora.NomeSocial = "AIG";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 10:
+ {
+ seguradora.NomeSocial = "AJAX";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 11:
+ case 12:
+ case 13:
+ {
+ seguradora.NomeSocial = "ALFA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 14:
+ case 15:
+ case 16:
+ case 176:
+ case 177:
+ {
+ seguradora.NomeSocial = "ALIANÇA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 17:
+ case 18:
+ {
+ seguradora.NomeSocial = "ALLIANZ";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 24:
+ case 25:
+ case 26:
+ case 180:
+ {
+ seguradora.NomeSocial = "ALLSEG";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 27:
+ case 590:
+ case 591:
+ case 593:
+ {
+ seguradora.NomeSocial = "AMIL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 32:
+ case 33:
+ case 34:
+ {
+ seguradora.NomeSocial = "APLUB";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 39:
+ case 40:
+ {
+ seguradora.NomeSocial = "ARCH";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 41:
+ {
+ seguradora.NomeSocial = "ARGO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 48:
+ case 243:
+ {
+ seguradora.NomeSocial = "GENERALI";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 52:
+ case 53:
+ case 54:
+ case 55:
+ case 56:
+ {
+ seguradora.NomeSocial = "ATLANTICA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 59:
+ case 60:
+ {
+ seguradora.NomeSocial = "AUSTRAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 63:
+ case 64:
+ case 65:
+ case 602:
+ {
+ seguradora.NomeSocial = "AXA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 69:
+ {
+ seguradora.NomeSocial = "AZUL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 88:
+ case 89:
+ case 90:
+ case 91:
+ case 92:
+ case 583:
+ {
+ seguradora.NomeSocial = "BRADESCO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 93:
+ {
+ seguradora.NomeSocial = "BRASIL LIBANO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 94:
+ {
+ seguradora.NomeSocial = "BRASILCAP";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 95:
+ case 96:
+ {
+ seguradora.NomeSocial = "BRASILPREV";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 98:
+ case 100:
+ {
+ seguradora.NomeSocial = "BRASILUSITANA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 99:
+ {
+ seguradora.NomeSocial = "BRASIL VEÍCULOS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 105:
+ case 106:
+ case 107:
+ case 108:
+ case 372:
+ {
+ seguradora.NomeSocial = "CAIXA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 111:
+ case 112:
+ {
+ seguradora.NomeSocial = "CAPEMISA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 115:
+ case 116:
+ case 117:
+ {
+ seguradora.NomeSocial = "CARDIF";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 119:
+ case 120:
+ {
+ seguradora.NomeSocial = "CASTELLO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 125:
+ case 126:
+ {
+ seguradora.NomeSocial = "CESCEBRASIL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 128:
+ case 129:
+ {
+ seguradora.NomeSocial = "CHARTIS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 130:
+ {
+ seguradora.NomeSocial = "CHUBB";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 144:
+ case 184:
+ case 185:
+ {
+ seguradora.NomeSocial = "INTERNACIONAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 145:
+ case 289:
+ case 292:
+ case 293:
+ case 294:
+ {
+ seguradora.NomeSocial = "ITAÉ";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 151:
+ case 152:
+ case 188:
+ case 416:
+ case 417:
+ case 418:
+ {
+ seguradora.NomeSocial = "REAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 160:
+ case 161:
+ {
+ seguradora.NomeSocial = "URBANIA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 178:
+ case 251:
+ {
+ seguradora.NomeSocial = "GRALHA AZUL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 181:
+ {
+ seguradora.NomeSocial = "EXCELSIOR";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 196:
+ case 197:
+ {
+ seguradora.NomeSocial = "CREDITO Y CAUCIAN";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 200:
+ case 201:
+ {
+ seguradora.NomeSocial = "CRUZEIRO DO SUL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 205:
+ case 206:
+ {
+ seguradora.NomeSocial = "ECC";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 212:
+ case 213:
+ {
+ seguradora.NomeSocial = "EQUITATIVA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 215:
+ {
+ seguradora.NomeSocial = "ESSOR";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 216:
+ case 217:
+ case 218:
+ {
+ seguradora.NomeSocial = "EULER HERMES";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 221:
+ case 222:
+ {
+ seguradora.NomeSocial = "EVEREST";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 225:
+ case 226:
+ {
+ seguradora.NomeSocial = "FACTORY";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 230:
+ case 231:
+ case 232:
+ {
+ seguradora.NomeSocial = "FEDERAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 235:
+ case 236:
+ {
+ seguradora.NomeSocial = "FINANCIAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 241:
+ case 242:
+ {
+ seguradora.NomeSocial = "GENERAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 248:
+ case 249:
+ {
+ seguradora.NomeSocial = "GNPP";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 254:
+ case 255:
+ {
+ seguradora.NomeSocial = "HANNOVER";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 257:
+ case 258:
+ case 259:
+ case 260:
+ case 569:
+ case 597:
+ {
+ seguradora.NomeSocial = "HDI";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 264:
+ case 265:
+ case 266:
+ case 267:
+ case 268:
+ case 269:
+ {
+ seguradora.NomeSocial = "HSBC";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 271:
+ case 272:
+ {
+ seguradora.NomeSocial = "ICATU";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 273:
+ case 274:
+ {
+ seguradora.NomeSocial = "IF P&C INSURANCE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 275:
+ {
+ seguradora.NomeSocial = "INDIANA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 283:
+ case 284:
+ case 285:
+ case 603:
+ {
+ seguradora.NomeSocial = "KOVR";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 290:
+ case 291:
+ case 295:
+ case 296:
+ {
+ seguradora.NomeSocial = "ITAÚ";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 297:
+ case 298:
+ case 299:
+ {
+ seguradora.NomeSocial = "J. MALUCELLI";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 307:
+ case 308:
+ case 309:
+ {
+ seguradora.NomeSocial = "YELUM";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 310:
+ case 311:
+ {
+ seguradora.NomeSocial = "LIDERANÇA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 317:
+ case 318:
+ case 319:
+ case 320:
+ case 321:
+ case 322:
+ case 323:
+ case 324:
+ case 325:
+ case 326:
+ case 327:
+ case 328:
+ {
+ seguradora.NomeSocial = "MAPFRE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 330:
+ case 542:
+ case 561:
+ {
+ seguradora.NomeSocial = "YASUDA MARITIMA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 336:
+ case 337:
+ {
+ seguradora.NomeSocial = "MBM";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 340:
+ {
+ seguradora.NomeSocial = "METLIFE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 345:
+ case 346:
+ case 347:
+ {
+ seguradora.NomeSocial = "MITSUI";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 348:
+ case 349:
+ {
+ seguradora.NomeSocial = "MONGERAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 351:
+ case 352:
+ case 353:
+ case 354:
+ case 355:
+ case 356:
+ {
+ seguradora.NomeSocial = "MONTEPIO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 364:
+ case 365:
+ case 380:
+ {
+ seguradora.NomeSocial = "NATIONAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 374:
+ case 375:
+ {
+ seguradora.NomeSocial = "NOVA YORK";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 378:
+ case 379:
+ {
+ seguradora.NomeSocial = "ODYSSEY";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 384:
+ case 385:
+ {
+ seguradora.NomeSocial = "PARANÁ";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 386:
+ case 387:
+ {
+ seguradora.NomeSocial = "PARIS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 394:
+ case 395:
+ {
+ seguradora.NomeSocial = "PLANALTO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 398:
+ case 399:
+ case 400:
+ case 401:
+ case 553:
+ case 554:
+ case 573:
+ {
+ seguradora.NomeSocial = "PORTO SEGURO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 411:
+ case 412:
+ {
+ seguradora.NomeSocial = "PRUDENTIAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 423:
+ case 424:
+ {
+ seguradora.NomeSocial = "ROYAL & SUN ALLIANCE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 426:
+ case 427:
+ case 428:
+ {
+ seguradora.NomeSocial = "SABEMI";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 429:
+ case 430:
+ case 431:
+ case 432:
+ {
+ seguradora.NomeSocial = "SAFRA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 435:
+ case 436:
+ case 437:
+ {
+ seguradora.NomeSocial = "SANTANDER";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 438:
+ case 439:
+ {
+ seguradora.NomeSocial = "SANTOS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 440:
+ case 441:
+ {
+ seguradora.NomeSocial = "SANTOS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 445:
+ case 446:
+ case 447:
+ case 448:
+ {
+ seguradora.NomeSocial = "SCOR";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 449:
+ case 450:
+ {
+ seguradora.NomeSocial = "SDB";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 455:
+ case 456:
+ {
+ seguradora.NomeSocial = "MINEIRA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 458:
+ case 459:
+ {
+ seguradora.NomeSocial = "PONTUAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 465:
+ case 466:
+ {
+ seguradora.NomeSocial = "SIRIUS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 471:
+ case 594:
+ {
+ seguradora.NomeSocial = "SOMPO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 474:
+ case 475:
+ case 476:
+ case 477:
+ case 478:
+ case 479:
+ case 480:
+ case 481:
+ case 482:
+ case 483:
+ case 484:
+ case 485:
+ case 486:
+ case 487:
+ case 557:
+ case 579:
+ {
+ seguradora.NomeSocial = "SULAMERICA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 489:
+ case 490:
+ case 491:
+ case 492:
+ case 493:
+ case 494:
+ {
+ seguradora.NomeSocial = "SWISS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 497:
+ case 498:
+ case 499:
+ case 500:
+ case 501:
+ {
+ seguradora.NomeSocial = "TOKIO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 503:
+ {
+ seguradora.NomeSocial = "TOTAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 507:
+ case 508:
+ case 509:
+ {
+ seguradora.NomeSocial = "TREVO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 513:
+ case 514:
+ case 515:
+ case 516:
+ {
+ seguradora.NomeSocial = "UNIÃO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 520:
+ case 521:
+ case 584:
+ case 595:
+ {
+ seguradora.NomeSocial = "UNIMED";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 522:
+ case 523:
+ {
+ seguradora.NomeSocial = "UNIVERSAL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 527:
+ case 528:
+ {
+ seguradora.NomeSocial = "VALOR CAPITALIZAÇÃO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 537:
+ case 538:
+ case 539:
+ case 540:
+ case 541:
+ {
+ seguradora.NomeSocial = "XL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 543:
+ case 544:
+ case 545:
+ case 546:
+ case 547:
+ case 548:
+ case 549:
+ case 550:
+ case 551:
+ {
+ seguradora.NomeSocial = "ZURICH";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 556:
+ {
+ seguradora.NomeSocial = "SUHAI";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 558:
+ {
+ seguradora.NomeSocial = "SANCOR";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 559:
+ {
+ seguradora.NomeSocial = "AGROBRASIL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 560:
+ case 570:
+ {
+ seguradora.NomeSocial = "SURA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 571:
+ case 572:
+ case 574:
+ case 605:
+ case 606:
+ {
+ seguradora.NomeSocial = "SÃO FRANCISCO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 581:
+ {
+ seguradora.NomeSocial = "SANTA CASA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 582:
+ {
+ seguradora.NomeSocial = "AMEX";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 604:
+ {
+ seguradora.NomeSocial = "BANCO DO BRASIL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ }
+ }
+ else
+ {
+ }
+ long num1 = id - (long)621;
+ if (num1 <= (long)57)
+ {
+ switch ((uint)num1)
+ {
+ case 0:
+ case 3:
+ case 24:
+ case 32:
+ case 33:
+ case 34:
+ case 35:
+ case 36:
+ case 37:
+ case 41:
+ case 42:
+ {
+ seguradora.NomeSocial = "UNIMED";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 9:
+ case 18:
+ {
+ seguradora.NomeSocial = "ALIRO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 10:
+ {
+ break;
+ }
+ case 11:
+ {
+ seguradora.NomeSocial = "VR";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 14:
+ {
+ seguradora.NomeSocial = "ALLIANZ";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 15:
+ {
+ seguradora.NomeSocial = "HS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 20:
+ case 22:
+ case 53:
+ {
+ seguradora.NomeSocial = "PORTO SEGURO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 21:
+ {
+ seguradora.NomeSocial = "SURA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 28:
+ {
+ seguradora.NomeSocial = "AMIL";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 29:
+ {
+ seguradora.NomeSocial = "YELUM";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 43:
+ {
+ seguradora.NomeSocial = "SULAMERICA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 45:
+ {
+ seguradora.NomeSocial = "AFFINITY";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 46:
+ {
+ seguradora.NomeSocial = "BR";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 52:
+ {
+ seguradora.NomeSocial = "YAMAHA";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 55:
+ {
+ seguradora.NomeSocial = "SÃO FRANCISCO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 56:
+ {
+ seguradora.NomeSocial = "EMBRACON";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 57:
+ {
+ seguradora.NomeSocial = "MAPFRE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ default:
+ {
+ goto Label6;
+ }
+ }
+ }
+ else
+ {
+ goto Label6;
+ }
+ seguradora.NomeSocial = "METLIFE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ else if (id != (long)683)
+ {
+ long num2 = id - (long)687;
+ if (num2 <= (long)3)
+ {
+ switch ((uint)num2)
+ {
+ case 0:
+ {
+ seguradora.NomeSocial = "ITAÚ";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 1:
+ {
+ goto Label6;
+ }
+ case 2:
+ {
+ seguradora.NomeSocial = "SÃO LUCAS";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 3:
+ {
+ seguradora.NomeSocial = "UNIMED";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (id == (long)694)
+ {
+ seguradora.NomeSocial = "PORTO SEGURO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ goto Label6;
+ }
+ else
+ {
+ seguradora.NomeSocial = "UNIMED";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ seguradora.NomeSocial = "PORTO SEGURO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ else if (id > (long)716)
+ {
+ if (id == (long)717)
+ {
+ seguradora.NomeSocial = "CHUBB";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ if (id != (long)734)
+ {
+ goto Label5;
+ }
+ seguradora.NomeSocial = "RC";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ else
+ {
+ long num3 = id - (long)703;
+ if (num3 <= (long)8)
+ {
+ switch ((uint)num3)
+ {
+ case 0:
+ case 6:
+ {
+ seguradora.NomeSocial = "UNIMED";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 1:
+ case 4:
+ case 8:
+ {
+ seguradora.NomeSocial = "MAPFRE";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ case 2:
+ case 3:
+ case 5:
+ case 7:
+ {
+ goto Label6;
+ }
+ }
+ }
+ else
+ {
+ }
+ if (id == (long)716)
+ {
+ seguradora.NomeSocial = "UNIMED";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ }
+ Label6:
+ seguradora.NomeSocial = seguradora.Nome;
+ }
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ Label5:
+ if (id == (long)741)
+ {
+ seguradora.NomeSocial = "SOMPO";
+ Auxiliar.Seguradoras.Add(seguradora);
+ return;
+ }
+ else
+ {
+ goto Label6;
+ }
+ });
+ }
+
+ public static void LoadTipoTarefa(SqlCommand sqlCommand)
+ {
+ DataTable dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT * FROM TipoTarefa;";
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ Auxiliar.TiposTarefa = new List<TipoDeTarefa>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.TiposTarefa.Add(new TipoDeTarefa()
+ {
+ Id = a.Field<long>("Id"),
+ Nome = a.Field<string>("Nome"),
+ Descricao = a.Field<string>("Descricao"),
+ Ativo = a.Field<bool>("Ativo"),
+ Excluido = a.Field<bool>("Excluido")
+ }));
+ }
+
+ public static void LoadTipoVendedor(SqlCommand sqlCommand)
+ {
+ DataTable dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idtipovendedor as id, descricao, ativo FROM tipovendedor;";
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ Auxiliar.TipoVendedores = new List<TipoVendedor>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => Auxiliar.TipoVendedores.Add(new TipoVendedor()
+ {
+ Id = a.Field<long>("id"),
+ Descricao = a.Field<string>("descricao"),
+ Ativo = new bool?(a.Field<bool?>("ativo").GetValueOrDefault(true))
+ }));
+ }
+
+ public static List<PesquisaAvancada> PesquisaAvancada(FiltroStatusDocumento status, DataTable documentos, DataTable itens, List<long> controles)
+ {
+ DateTime date = Funcoes.GetNetworkTime().Date;
+ switch (status)
+ {
+ case FiltroStatusDocumento.Vencidos:
+ {
+ return documentos.AsEnumerable().Where<DataRow>((DataRow x) => {
+ if (controles == null || controles.Contains(x.Field<long>("idcontrole")) && (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field<object>("situacao").ToString()) == TipoSeguro.Renovado)
+ {
+ return true;
+ }
+ return x.Field<DateTime>("vigencia2") < date.AddDays(-5);
+ }).Select<DataRow, PesquisaAvancada>((DataRow x) => new PesquisaAvancada()
+ {
+ IdCliente = x.Field<long>("idcliente"),
+ IdDocumento = x.Field<long>("iddocumento"),
+ IdItem = itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<long>("iditem"),
+ Nome = x.Field<string>("cliente"),
+ Pesquisa = (x.Field<int>("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta") }) : string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field<string>("endosso") }))
+ }).ToList<PesquisaAvancada>();
+ }
+ case FiltroStatusDocumento.Cancelados:
+ {
+ return documentos.AsEnumerable().Where<DataRow>((DataRow x) => {
+ if (controles == null)
+ {
+ return true;
+ }
+ if (!controles.Contains(x.Field<long>("idcontrole")))
+ {
+ return false;
+ }
+ return (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field<object>("situacao").ToString()) == TipoSeguro.Cancelado;
+ }).Select<DataRow, PesquisaAvancada>((DataRow x) => new PesquisaAvancada()
+ {
+ IdCliente = x.Field<long>("idcliente"),
+ IdDocumento = x.Field<long>("iddocumento"),
+ IdItem = itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<long>("iditem"),
+ Nome = x.Field<string>("cliente"),
+ Pesquisa = (x.Field<int>("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta") }) : string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field<string>("endosso") }))
+ }).ToList<PesquisaAvancada>();
+ }
+ case FiltroStatusDocumento.Recusados:
+ {
+ return documentos.AsEnumerable().Where<DataRow>((DataRow x) => {
+ if (controles == null)
+ {
+ return true;
+ }
+ if (!controles.Contains(x.Field<long>("idcontrole")))
+ {
+ return false;
+ }
+ return (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field<object>("situacao").ToString()) == TipoSeguro.Recusado;
+ }).Select<DataRow, PesquisaAvancada>((DataRow x) => new PesquisaAvancada()
+ {
+ IdCliente = x.Field<long>("idcliente"),
+ IdDocumento = x.Field<long>("iddocumento"),
+ IdItem = itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<long>("iditem"),
+ Nome = x.Field<string>("cliente"),
+ Pesquisa = (x.Field<int>("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta") }) : string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field<string>("endosso") }))
+ }).ToList<PesquisaAvancada>();
+ }
+ case FiltroStatusDocumento.Todos:
+ {
+ return documentos.AsEnumerable().Where<DataRow>((DataRow x) => {
+ if (controles == null)
+ {
+ return true;
+ }
+ return controles.Contains(x.Field<long>("idcontrole"));
+ }).Select<DataRow, PesquisaAvancada>((DataRow x) => new PesquisaAvancada()
+ {
+ IdCliente = x.Field<long>("idcliente"),
+ IdDocumento = x.Field<long>("iddocumento"),
+ IdItem = itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<long>("iditem"),
+ Nome = x.Field<string>("cliente"),
+ Pesquisa = (x.Field<int>("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta") }) : string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field<string>("endosso") }))
+ }).ToList<PesquisaAvancada>();
+ }
+ default:
+ {
+ return documentos.AsEnumerable().Where<DataRow>((DataRow x) => {
+ if (controles == null)
+ {
+ return true;
+ }
+ if (!controles.Contains(x.Field<long>("idcontrole")) || (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field<object>("situacao").ToString()) != TipoSeguro.Novo && (TipoSeguro)Enum.Parse(typeof(TipoSeguro), x.Field<object>("situacao").ToString()) != TipoSeguro.Renovacao)
+ {
+ return false;
+ }
+ return x.Field<DateTime>("vigencia2") >= date.AddDays(-5);
+ }).Select<DataRow, PesquisaAvancada>((DataRow x) => new PesquisaAvancada()
+ {
+ IdCliente = x.Field<long>("idcliente"),
+ IdDocumento = x.Field<long>("iddocumento"),
+ IdItem = itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<long>("iditem"),
+ Nome = x.Field<string>("cliente"),
+ Pesquisa = (x.Field<int>("tipo") == 0 ? string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta") }) : string.Concat(new string[] { "ITEM: ", itens.AsEnumerable().First<DataRow>((DataRow i) => i.Field<long>("id") == x.Field<long>("iddocumento")).Field<string>("descricao"), " - NÚMERO DA APÓLICE: ", x.Field<string>("apolice"), " - NÚMERO DA PROPOSTA: ", x.Field<string>("proposta"), " - NÚMERO DO ENDOSSO: ", x.Field<string>("endosso") }))
+ }).ToList<PesquisaAvancada>();
+ }
+ }
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/AuxiliarFinanceiro.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/AuxiliarFinanceiro.cs
new file mode 100644
index 0000000..b9ecf17
--- /dev/null
+++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/AuxiliarFinanceiro.cs
@@ -0,0 +1,127 @@
+using Gestor.Model.Domain.Financeiro;
+using Gestor.Model.Domain.Generic;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+using System.Data.SqlClient;
+using System.Linq;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Infrastructure.Helpers
+{
+ public static class AuxiliarFinanceiro
+ {
+ public static List<Centro> Centros
+ {
+ get;
+ set;
+ }
+
+ public static List<BancosContas> Contas
+ {
+ get;
+ set;
+ }
+
+ public static List<Gestor.Model.Domain.Financeiro.Plano> Plano
+ {
+ get;
+ set;
+ }
+
+ public static List<Gestor.Model.Domain.Financeiro.Planos> Planos
+ {
+ get;
+ set;
+ }
+
+ public static List<TipoConta> TiposConta
+ {
+ get;
+ set;
+ }
+
+ public static void Criar(SqlCommand sqlCommand)
+ {
+ DataTable dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idcplano as id, descricao as nome, ativo FROM cplano;";
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ AuxiliarFinanceiro.Plano = new List<Gestor.Model.Domain.Financeiro.Plano>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Plano.Add(new Gestor.Model.Domain.Financeiro.Plano()
+ {
+ Id = a.Field<long>("id"),
+ Descricao = a.Field<string>("nome"),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT cs.idcplanos as id, cs.descricao as nome, cs.ativo, cs.idcplano, cp.descricao FROM cplanos cs INNER JOIN cplano cp ON cs.idcplano = cp.idcplano;";
+ using (SqlDataAdapter sqlDataAdapter1 = new SqlDataAdapter())
+ {
+ sqlDataAdapter1.SelectCommand = sqlCommand;
+ sqlDataAdapter1.Fill(dataTable);
+ }
+ AuxiliarFinanceiro.Planos = new List<Gestor.Model.Domain.Financeiro.Planos>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Planos.Add(new Gestor.Model.Domain.Financeiro.Planos()
+ {
+ Id = a.Field<long>("id"),
+ Descricao = a.Field<string>("nome"),
+ Nome = a.Field<string>("descricao"),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1"),
+ Plano = AuxiliarFinanceiro.Plano.FirstOrDefault<Gestor.Model.Domain.Financeiro.Plano>((Gestor.Model.Domain.Financeiro.Plano x) => {
+ if (x == null)
+ {
+ return false;
+ }
+ return x.Id == a.Field<long>("idcplano");
+ })
+ }));
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idconta as id, descricao as nome, ativo FROM conta;";
+ using (SqlDataAdapter sqlDataAdapter2 = new SqlDataAdapter())
+ {
+ sqlDataAdapter2.SelectCommand = sqlCommand;
+ sqlDataAdapter2.Fill(dataTable);
+ }
+ AuxiliarFinanceiro.Contas = new List<BancosContas>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Contas.Add(new BancosContas()
+ {
+ Id = a.Field<long>("id"),
+ Descricao = a.Field<string>("nome"),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idcentro as id, descricao as nome, ativo FROM centro;";
+ using (SqlDataAdapter sqlDataAdapter3 = new SqlDataAdapter())
+ {
+ sqlDataAdapter3.SelectCommand = sqlCommand;
+ sqlDataAdapter3.Fill(dataTable);
+ }
+ AuxiliarFinanceiro.Centros = new List<Centro>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.Centros.Add(new Centro()
+ {
+ Id = a.Field<long>("id"),
+ Descricao = a.Field<string>("nome"),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ dataTable = new DataTable();
+ sqlCommand.CommandText = "SELECT DISTINCT idtipoconta as id, descricao as nome, ativo FROM tipoconta;";
+ using (SqlDataAdapter sqlDataAdapter4 = new SqlDataAdapter())
+ {
+ sqlDataAdapter4.SelectCommand = sqlCommand;
+ sqlDataAdapter4.Fill(dataTable);
+ }
+ AuxiliarFinanceiro.TiposConta = new List<TipoConta>();
+ dataTable.AsEnumerable().ToList<DataRow>().ForEach((DataRow a) => AuxiliarFinanceiro.TiposConta.Add(new TipoConta()
+ {
+ Id = a.Field<long>("id"),
+ Descricao = a.Field<string>("nome"),
+ Ativo = (a.Field<object>("ativo") == null ? true : a.Field<object>("ativo").ToString() == "1")
+ }));
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Comparador.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Comparador.cs
new file mode 100644
index 0000000..9ce4873
--- /dev/null
+++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Comparador.cs
@@ -0,0 +1,38 @@
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Infrastructure.Helpers
+{
+ public class Comparador : IEqualityComparer<DataRow>
+ {
+ private string Comparacao1
+ {
+ get;
+ set;
+ }
+
+ private string Comparacao2
+ {
+ get;
+ set;
+ }
+
+ public Comparador(string comparacao1 = "id", string comparacao2 = "id")
+ {
+ this.Comparacao1 = comparacao1;
+ this.Comparacao2 = comparacao2;
+ }
+
+ public bool Equals(DataRow x, DataRow y)
+ {
+ return (long)x[this.Comparacao1] == (long)y[this.Comparacao2];
+ }
+
+ public int GetHashCode(DataRow obj)
+ {
+ return obj.ToString().GetHashCode();
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Funcoes.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Funcoes.cs
new file mode 100644
index 0000000..d3fdcde
--- /dev/null
+++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/Funcoes.cs
@@ -0,0 +1,1403 @@
+using Gestor.Infrastructure.UnitOfWork.Generic;
+using Gestor.Model.Common;
+using Gestor.Model.Domain.Relatorios;
+using Gestor.Model.Validation;
+using Microsoft.CSharp.RuntimeBinder;
+using NHibernate;
+using NHibernate.Connection;
+using NHibernate.Impl;
+using NHibernate.Util;
+using System;
+using System.Collections.Generic;
+using System.Data;
+using System.Data.Common;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Net;
+using System.Net.Sockets;
+using System.Reflection;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Infrastructure.Helpers
+{
+ internal static class Funcoes
+ {
+ public static System.Diagnostics.Stopwatch Stopwatch;
+
+ public static DateTime? StartTime;
+
+ private static Dictionary<Type, SqlDbType> TypeMap
+ {
+ get;
+ }
+
+ static Funcoes()
+ {
+ Dictionary<Type, SqlDbType> types = new Dictionary<Type, SqlDbType>();
+ types[typeof(string)] = SqlDbType.NVarChar;
+ types[typeof(char[])] = SqlDbType.NVarChar;
+ types[typeof(byte)] = SqlDbType.TinyInt;
+ types[typeof(short)] = SqlDbType.SmallInt;
+ types[typeof(int)] = SqlDbType.Int;
+ types[typeof(long)] = SqlDbType.BigInt;
+ types[typeof(long)] = SqlDbType.BigInt;
+ types[typeof(byte[])] = SqlDbType.Image;
+ types[typeof(bool)] = SqlDbType.Bit;
+ types[typeof(DateTime)] = SqlDbType.DateTime2;
+ types[typeof(DateTimeOffset)] = SqlDbType.DateTimeOffset;
+ types[typeof(decimal)] = SqlDbType.Money;
+ types[typeof(float)] = SqlDbType.Real;
+ types[typeof(double)] = SqlDbType.Float;
+ types[typeof(TimeSpan)] = SqlDbType.Time;
+ Gestor.Infrastructure.Helpers.Funcoes.TypeMap = types;
+ }
+
+ public static T Campo<T>(this DataRow row, string field)
+ {
+ string name;
+ bool isEnum;
+ string str;
+ object obj = row.Obj(field);
+ if (!typeof(T).IsNullable())
+ {
+ if (typeof(T).IsEnum)
+ {
+ if (obj == null)
+ {
+ return (T)typeof(T).GetEnumValues().First();
+ }
+ return (T)Enum.Parse(typeof(T), obj.ToString());
+ }
+ name = typeof(T).Name;
+ if (name == "String")
+ {
+ if (obj == null)
+ {
+ return (T)"";
+ }
+ return (T)obj.ToString();
+ }
+ if (name == "DateTime")
+ {
+ if (obj == null)
+ {
+ return (T)(object)DateTime.MinValue;
+ }
+ return (T)(object)DateTime.Parse(obj.ToString());
+ }
+ if (name == "Decimal")
+ {
+ if (obj == null)
+ {
+ return (T)(object)0;
+ }
+ return (T)(object)decimal.Parse(obj.ToString());
+ }
+ if (name == "Int64")
+ {
+ if (obj == null)
+ {
+ return (T)(object)0;
+ }
+ return (T)(object)long.Parse(obj.ToString());
+ }
+ if (name != "Int")
+ {
+ return (T)null;
+ }
+ if (obj == null)
+ {
+ return (T)(object)0;
+ }
+ return (T)(object)int.Parse(obj.ToString());
+ }
+ Type underlyingType = Nullable.GetUnderlyingType(typeof(T));
+ if (underlyingType != null)
+ {
+ isEnum = underlyingType.IsEnum;
+ }
+ else
+ {
+ isEnum = false;
+ }
+ if (isEnum)
+ {
+ if (obj == null)
+ {
+ return (T)null;
+ }
+ return (T)Enum.Parse(typeof(T), obj.ToString());
+ }
+ Type type = Nullable.GetUnderlyingType(typeof(T));
+ if (type != null)
+ {
+ str = type.Name;
+ }
+ else
+ {
+ str = null;
+ }
+ name = str;
+ if (name == "String")
+ {
+ if (obj == null)
+ {
+ return (T)null;
+ }
+ return (T)obj.ToString();
+ }
+ if (name == "DateTime")
+ {
+ if (obj == null)
+ {
+ return (T)null;
+ }
+ return (T)(object)DateTime.Parse(obj.ToString());
+ }
+ if (name == "Decimal")
+ {
+ if (obj == null)
+ {
+ return (T)null;
+ }
+ return (T)(object)decimal.Parse(obj.ToString());
+ }
+ if (name == "Int64")
+ {
+ if (obj == null)
+ {
+ return (T)null;
+ }
+ return (T)(object)long.Parse(obj.ToString());
+ }
+ if (name != "Int")
+ {
+ return (T)null;
+ }
+ if (obj == null)
+ {
+ return (T)null;
+ }
+ return (T)(object)int.Parse(obj.ToString());
+ }
+
+ public static TipoTela? Convert(this string form)
+ {
+ TipoTela tipoTela;
+ TipoTela? nullable;
+ char chr;
+ if (string.IsNullOrWhiteSpace(form))
+ {
+ nullable = null;
+ return nullable;
+ }
+ if (form.Contains("View") || form.Contains("Renovacao"))
+ {
+ nullable = null;
+ return nullable;
+ }
+ string lower = form.ToLower();
+ if (lower != null)
+ {
+ switch (lower.Length)
+ {
+ case 7:
+ {
+ chr = lower[3];
+ if (chr == 'N')
+ {
+ if (lower == "frmNota")
+ {
+ return new TipoTela?(TipoTela.NotaFiscal);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'a')
+ {
+ if (lower == "frmauto")
+ {
+ break;
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 8:
+ case 9:
+ case 11:
+ case 15:
+ case 16:
+ case 19:
+ case 20:
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ case 10:
+ {
+ chr = lower[3];
+ if (chr == 'e')
+ {
+ if (lower == "frmendosso")
+ {
+ return new TipoTela?(TipoTela.Apolice);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'i')
+ {
+ if (lower == "frmitemman")
+ {
+ break;
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'p')
+ {
+ if (lower == "frmparcela")
+ {
+ return new TipoTela?(TipoTela.Parcela);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 12:
+ {
+ chr = lower[3];
+ if (chr == 'r')
+ {
+ if (lower == "frmrenovacao")
+ {
+ return new TipoTela?(TipoTela.Apolice);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'v')
+ {
+ if (lower == "frmvidagrupo")
+ {
+ break;
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 13:
+ {
+ chr = lower[3];
+ if (chr == 'c')
+ {
+ if (lower == "frmcriticapdf")
+ {
+ return new TipoTela?(TipoTela.CriticaApolice);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ switch (chr)
+ {
+ case 'p':
+ {
+ if (lower == "frmparcelanew")
+ {
+ return new TipoTela?(TipoTela.Parcela);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ case 'q':
+ case 's':
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ case 'r':
+ {
+ if (lower == "frmresidencia")
+ {
+ return new TipoTela?(TipoTela.Item);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ case 't':
+ {
+ if (lower == "frmtransporte")
+ {
+ return new TipoTela?(TipoTela.Item);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ default:
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ }
+ }
+ break;
+ }
+ case 14:
+ {
+ chr = lower[3];
+ if (chr == 'a')
+ {
+ if (lower == "frmaeronautico")
+ {
+ break;
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'e')
+ {
+ if (lower == "frmeducacional")
+ {
+ break;
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 17:
+ {
+ chr = lower[3];
+ if (chr == 'm')
+ {
+ if (lower == "frmmanutpagamento")
+ {
+ return new TipoTela?(TipoTela.ManutencaoPagamentos);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'r')
+ {
+ if (lower == "frmriscosdiversos")
+ {
+ break;
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'v')
+ {
+ if (lower == "frmvidaindividual")
+ {
+ break;
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 18:
+ {
+ if (lower == "frmparcelascritica")
+ {
+ return new TipoTela?(TipoTela.Parcela);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ case 21:
+ {
+ if (lower == "frmredirecionacritica")
+ {
+ return new TipoTela?(TipoTela.CriticaApolice);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ default:
+ {
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+ }
+ return new TipoTela?(TipoTela.Item);
+ }
+ tipoTela = ((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => form.ToLower().Contains(x.ToString().ToLower()));
+ if (tipoTela != TipoTela.Todas)
+ {
+ return new TipoTela?(tipoTela);
+ }
+ nullable = null;
+ return nullable;
+ }
+
+ public static Relatorio? ConvertRelatorio(this string form)
+ {
+ Relatorio? nullable;
+ char chr;
+ if (string.IsNullOrWhiteSpace(form))
+ {
+ nullable = null;
+ return nullable;
+ }
+ if (form != null)
+ {
+ int length = form.Length;
+ switch (length)
+ {
+ case 9:
+ {
+ if (form == "Renovacao")
+ {
+ break;
+ }
+ nullable = null;
+ return nullable;
+ }
+ case 10:
+ case 13:
+ case 16:
+ {
+ nullable = null;
+ return nullable;
+ }
+ case 11:
+ {
+ chr = form[3];
+ if (chr == 'M')
+ {
+ if (form == "frmMetaView")
+ {
+ return new Relatorio?(Relatorio.MetaSeguradora);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'N')
+ {
+ if (form == "frmNotaView")
+ {
+ return new Relatorio?(Relatorio.NotaFiscal);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 12:
+ {
+ if (form == "frmRenovacao")
+ {
+ break;
+ }
+ nullable = null;
+ return nullable;
+ }
+ case 14:
+ {
+ chr = form[3];
+ if (chr == 'C')
+ {
+ if (form == "frmClienteView")
+ {
+ return new Relatorio?(Relatorio.Cliente);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'E')
+ {
+ if (form == "frmExtratoView")
+ {
+ return new Relatorio?(Relatorio.ExtratosBaixados);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 15:
+ {
+ chr = form[3];
+ if (chr == 'C')
+ {
+ if (form == "frmComissaoView")
+ {
+ return new Relatorio?(Relatorio.Comissao);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'P')
+ {
+ if (form == "frmProducaoView")
+ {
+ return new Relatorio?(Relatorio.Producao);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'S')
+ {
+ if (form == "frmSinistroView")
+ {
+ return new Relatorio?(Relatorio.Sinistro);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ nullable = null;
+ return nullable;
+ }
+ }
+ case 17:
+ {
+ chr = form[3];
+ if (chr == 'F')
+ {
+ if (form == "frmFechamentoView")
+ {
+ return new Relatorio?(Relatorio.Fechamento);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else if (chr == 'U')
+ {
+ if (form == "frmUtilizacaoView")
+ {
+ return new Relatorio?(Relatorio.LogsUtilizacao);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ nullable = null;
+ return nullable;
+ }
+ }
+ default:
+ {
+ if (length == 23)
+ {
+ if (form == "frmAgendaVencimentoView")
+ {
+ return new Relatorio?(Relatorio.Renovacao);
+ }
+ nullable = null;
+ return nullable;
+ }
+ else
+ {
+ nullable = null;
+ return nullable;
+ }
+ }
+ }
+ return new Relatorio?(Relatorio.Renovacao);
+ }
+ nullable = null;
+ return nullable;
+ }
+
+ public static SqlQueryCondition CreateParameters(this List<Condicao> keyValues, int indexStart = 0)
+ {
+ if (keyValues == null)
+ {
+ return null;
+ }
+ List<SqlParameter> sqlParameters = new List<SqlParameter>();
+ List<string> strs2 = new List<string>();
+ int num = indexStart;
+ (
+ from x in keyValues
+ orderby x.Grupo
+ group x by x.Grupo).ForEach<IGrouping<int, Condicao>>((IGrouping<int, Condicao> g) => {
+ List<string> strs1 = new List<string>();
+ g.ForEach<Condicao>((Condicao x) => {
+ string str = string.Concat(x.Campo, " ");
+ List<string> strs = new List<string>();
+ if (x.Valores != null)
+ {
+ List<object> valores = x.Valores;
+ if (valores != null)
+ {
+ valores.ForEach((object v) => {
+ SqlParameter sqlParameter;
+ SqlParameter sqlParameter1;
+ if (Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__0 == null)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__0 = CallSite<Func<CallSite, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.None, "GetType", null, typeof(Gestor.Infrastructure.Helpers.Funcoes), (IEnumerable<CSharpArgumentInfo>)(new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })));
+ }
+ object target = Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__0.Target(Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__0, v);
+ if (Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__2 == null)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__2 = CallSite<Func<CallSite, object, bool>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.UnaryOperation(CSharpBinderFlags.None, ExpressionType.IsTrue, typeof(Gestor.Infrastructure.Helpers.Funcoes), (IEnumerable<CSharpArgumentInfo>)(new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })));
+ }
+ !0 _u00210 = Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__2.Target;
+ CallSite<Func<CallSite, object, bool>> u003cu003ep_2 = Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__2;
+ if (Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__1 == null)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__1 = CallSite<Func<CallSite, object, Type, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.BinaryOperation(CSharpBinderFlags.None, ExpressionType.Equal, typeof(Gestor.Infrastructure.Helpers.Funcoes), (IEnumerable<CSharpArgumentInfo>)(new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType, null) })));
+ }
+ if (_u00210(u003cu003ep_2, Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__1.Target(Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__1, target, typeof(string))))
+ {
+ sqlParameter = new SqlParameter()
+ {
+ ParameterName = string.Format("@param_{0}", num)
+ };
+ SqlParameter target1 = sqlParameter;
+ if (Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__4 == null)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__4 = CallSite<Func<CallSite, object, SqlDbType>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(SqlDbType), typeof(Gestor.Infrastructure.Helpers.Funcoes)));
+ }
+ !0 _u002101 = Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__4.Target;
+ CallSite<Func<CallSite, object, SqlDbType>> u003cu003ep_4 = Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__4;
+ if (Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__3 == null)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__3 = CallSite<Func<CallSite, Type, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.None, "GetDbType", null, typeof(Gestor.Infrastructure.Helpers.Funcoes), (IEnumerable<CSharpArgumentInfo>)(new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.IsStaticType, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })));
+ }
+ target1.SqlDbType = _u002101(u003cu003ep_4, Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__3.Target(Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__3, typeof(Gestor.Infrastructure.Helpers.Funcoes), target));
+ sqlParameter.Size = 255;
+ sqlParameter.Value = (x.Operador == Operador.Like || x.Operador == Operador.NotLike ? string.Format("%{0}%", v) : (x.Operador == Operador.ComecaCom ? string.Format("{0}%", v) : (x.Operador == Operador.TerminaCom ? string.Format("%{0}", v) : v)));
+ sqlParameter1 = sqlParameter;
+ }
+ else
+ {
+ sqlParameter = new SqlParameter()
+ {
+ ParameterName = string.Format("@param_{0}", num)
+ };
+ SqlParameter target2 = sqlParameter;
+ if (Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__6 == null)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__6 = CallSite<Func<CallSite, object, SqlDbType>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.Convert(CSharpBinderFlags.None, typeof(SqlDbType), typeof(Gestor.Infrastructure.Helpers.Funcoes)));
+ }
+ !0 _u002102 = Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__6.Target;
+ CallSite<Func<CallSite, object, SqlDbType>> u003cu003ep_6 = Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__6;
+ if (Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__5 == null)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__5 = CallSite<Func<CallSite, Type, object, object>>.Create(Microsoft.CSharp.RuntimeBinder.Binder.InvokeMember(CSharpBinderFlags.None, "GetDbType", null, typeof(Gestor.Infrastructure.Helpers.Funcoes), (IEnumerable<CSharpArgumentInfo>)(new CSharpArgumentInfo[] { CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.UseCompileTimeType | CSharpArgumentInfoFlags.IsStaticType, null), CSharpArgumentInfo.Create(CSharpArgumentInfoFlags.None, null) })));
+ }
+ target2.SqlDbType = _u002102(u003cu003ep_6, Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__5.Target(Gestor.Infrastructure.Helpers.Funcoes.u003cu003eo__15.u003cu003ep__5, typeof(Gestor.Infrastructure.Helpers.Funcoes), target));
+ sqlParameter.Value = v;
+ sqlParameter1 = sqlParameter;
+ }
+ SqlParameter sqlParameter2 = sqlParameter1;
+ sqlParameters.Add(sqlParameter2);
+ int cSu0024u003cu003e8_locals1 = num;
+ num = cSu0024u003cu003e8_locals1 + 1;
+ strs.Add(sqlParameter2.ParameterName);
+ });
+ }
+ else
+ {
+ }
+ }
+ else
+ {
+ str = string.Concat(str, (x.Operador == Operador.Igual ? "IS NULL" : "IS NOT NULL"));
+ }
+ if (strs.Count == 1)
+ {
+ str = string.Concat(str, x.Operador.GetDescription(), " ");
+ str = string.Concat(str, strs.First<string>());
+ }
+ if (strs.Count > 1)
+ {
+ str = string.Concat(str, (x.Operador == Operador.Igual ? "IN" : (x.Operador == Operador.Diferente ? "NOT IN" : x.Operador.GetDescription())), " ");
+ str = string.Concat(str, "(", string.Join(",", strs), ")");
+ }
+ strs1.Add(str);
+ });
+ strs2.Add(string.Concat("(", string.Join(g.First<Condicao>().Operacao.GetDescription(), strs1), ")"));
+ });
+ return new SqlQueryCondition()
+ {
+ Condicao = string.Join(" AND ", strs2),
+ Parametros = sqlParameters
+ };
+ }
+
+ public static DataTable CriarAuxiliar(this GenericUnitOfWork _unitOfWork)
+ {
+ DataTable dataTable;
+ object connection;
+ DataTable dataTable1 = new DataTable();
+ SessionFactoryImpl sessionFactory = _unitOfWork.Session.SessionFactory as SessionFactoryImpl;
+ if (sessionFactory != null)
+ {
+ connection = sessionFactory.ConnectionProvider.GetConnection();
+ }
+ else
+ {
+ connection = null;
+ }
+ using (SqlConnection sqlConnection = connection as SqlConnection)
+ {
+ if (sqlConnection != null)
+ {
+ using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
+ {
+ sqlCommand.CommandTimeout = 15000;
+ Auxiliar.CriarAuxiliar(sqlCommand, true);
+ return dataTable1;
+ }
+ }
+ else
+ {
+ dataTable = null;
+ }
+ }
+ return dataTable;
+ }
+
+ public static List<Condicao> CriarCondicao(this Filtros filtro, string referencia)
+ {
+ bool count;
+ bool flag;
+ bool count1;
+ bool flag1;
+ bool count2;
+ bool flag2;
+ bool count3;
+ bool flag3;
+ bool count4;
+ bool flag4;
+ bool count5;
+ List<Condicao> condicaos = new List<Condicao>()
+ {
+ new Condicao()
+ {
+ Campo = referencia,
+ Valores = filtro.Inicio.CriarValor<DateTime>(),
+ Operador = Operador.MaiorEIgual
+ },
+ new Condicao()
+ {
+ Campo = referencia,
+ Valores = filtro.Fim.CriarValor<DateTime>(),
+ Operador = Operador.MenorEIgual
+ }
+ };
+ List<long> seguradoras = filtro.Seguradoras;
+ if (seguradoras != null)
+ {
+ count = seguradoras.Count > 0;
+ }
+ else
+ {
+ count = false;
+ }
+ if (count)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "c.idciaseg",
+ Valores = filtro.Seguradoras.CriarValor<long>()
+ });
+ }
+ List<long> ramos = filtro.Ramos;
+ if (ramos != null)
+ {
+ flag = ramos.Count > 0;
+ }
+ else
+ {
+ flag = false;
+ }
+ if (flag)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "c.idramo",
+ Valores = filtro.Ramos.CriarValor<long>()
+ });
+ }
+ List<long> status = filtro.Status;
+ if (status != null)
+ {
+ count1 = status.Count > 0;
+ }
+ else
+ {
+ count1 = false;
+ }
+ if (count1)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "d.situacao",
+ Valores = filtro.Status.CriarValor<long>()
+ });
+ }
+ List<long> vendedores = filtro.Vendedores;
+ if (vendedores != null)
+ {
+ flag1 = vendedores.Count > 0;
+ }
+ else
+ {
+ flag1 = false;
+ }
+ if (flag1)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "vp.idvendedor",
+ Valores = filtro.Vendedores.CriarValor<long>()
+ });
+ }
+ List<long> estipulantes = filtro.Estipulantes;
+ if (estipulantes != null)
+ {
+ count2 = estipulantes.Count > 0;
+ }
+ else
+ {
+ count2 = false;
+ }
+ if (count2)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "d.idestipulante",
+ Valores = filtro.Estipulantes.CriarValor<long>()
+ });
+ }
+ List<long> produtos = filtro.Produtos;
+ if (produtos != null)
+ {
+ flag2 = produtos.Count > 0;
+ }
+ else
+ {
+ flag2 = false;
+ }
+ if (flag2)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "c.idproduto",
+ Valores = filtro.Produtos.CriarValor<long>()
+ });
+ }
+ List<long> negocio = filtro.Negocio;
+ if (negocio != null)
+ {
+ count3 = negocio.Count > 0;
+ }
+ else
+ {
+ count3 = false;
+ }
+ if (count3)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "d.NegocioCorretora",
+ Valores = filtro.Negocio.CriarValor<long>()
+ });
+ }
+ List<long> usuarios = filtro.Usuarios;
+ if (usuarios != null)
+ {
+ flag3 = usuarios.Count > 0;
+ }
+ else
+ {
+ flag3 = false;
+ }
+ if (flag3)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "IdUsuario",
+ Valores = filtro.Usuarios.CriarValor<long>()
+ });
+ }
+ List<long> telas = filtro.Telas;
+ if (telas != null)
+ {
+ count4 = telas.Count > 0;
+ }
+ else
+ {
+ count4 = false;
+ }
+ if (count4)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "Tela",
+ Valores = filtro.Telas.CriarValor<long>()
+ });
+ }
+ List<long> relatorios = filtro.Relatorios;
+ if (relatorios != null)
+ {
+ flag4 = relatorios.Count > 0;
+ }
+ else
+ {
+ flag4 = false;
+ }
+ if (flag4)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "Relatorio",
+ Valores = filtro.Relatorios.CriarValor<long>()
+ });
+ }
+ List<FiltroTipoParcela> parcelasEspeciais = filtro.ParcelasEspeciais;
+ if (parcelasEspeciais != null)
+ {
+ count5 = parcelasEspeciais.Count > 0;
+ }
+ else
+ {
+ count5 = false;
+ }
+ if (count5)
+ {
+ if (filtro.ParcelasEspeciais.Any<FiltroTipoParcela>((FiltroTipoParcela x) => x.Selecionado))
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "p.idsubtipo",
+ Valores = (
+ from x in filtro.ParcelasEspeciais
+ where x.Selecionado
+ select (int)x.Tipo).CriarValor<IEnumerable<int>>()
+ });
+ }
+ }
+ if (filtro.IdEmpresa > (long)0)
+ {
+ condicaos.Add(new Condicao()
+ {
+ Campo = "c.idempresa",
+ Valores = filtro.IdEmpresa.CriarValor<long>()
+ });
+ }
+ return condicaos;
+ }
+
+ public static List<dynamic> CriarValor<T>(this T valor)
+ {
+ return new List<object>()
+ {
+ valor
+ };
+ }
+
+ public static List<dynamic> CriarValor<T>(this List<T> lista)
+ {
+ return (
+ from in lista
+ select x).ToList<object>();
+ }
+
+ public static SqlDbType GetDbType(Type giveType)
+ {
+ giveType = Nullable.GetUnderlyingType(giveType) ?? giveType;
+ if (!Gestor.Infrastructure.Helpers.Funcoes.TypeMap.ContainsKey(giveType))
+ {
+ throw new ArgumentException(string.Concat(giveType.FullName, " is not a supported .NET class"));
+ }
+ return Gestor.Infrastructure.Helpers.Funcoes.TypeMap[giveType];
+ }
+
+ public static SqlDbType GetDbType<T>()
+ {
+ return Gestor.Infrastructure.Helpers.Funcoes.GetDbType(typeof(T));
+ }
+
+ public static DateTime GetNetworkTime()
+ {
+ DateTime value;
+ try
+ {
+ if (!Gestor.Infrastructure.Helpers.Funcoes.StartTime.HasValue)
+ {
+ byte[] numArray = new byte[48];
+ numArray[0] = 27;
+ IPEndPoint pEndPoint = new IPEndPoint(((IEnumerable<IPAddress>)Dns.GetHostEntry("time.google.com").AddressList).First<IPAddress>((IPAddress a) => a.AddressFamily == AddressFamily.InterNetwork), 123);
+ using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
+ {
+ socket.Connect(pEndPoint);
+ socket.ReceiveTimeout = 3000;
+ socket.Send(numArray);
+ socket.Receive(numArray);
+ socket.Close();
+ }
+ ulong num = (ulong)numArray[40] << 24 | (ulong)numArray[41] << 16 | (ulong)numArray[42] << 8 | (ulong)numArray[43];
+ ulong num1 = (ulong)numArray[44] << 24 | (ulong)numArray[45] << 16 | (ulong)numArray[46] << 8 | (ulong)numArray[47];
+ ulong num2 = num * (long)1000 + num1 * (long)1000 / 4294967296L;
+ DateTime dateTime = new DateTime(1900, 1, 1);
+ dateTime = dateTime.AddMilliseconds((double)num2);
+ Gestor.Infrastructure.Helpers.Funcoes.StartTime = new DateTime?(dateTime.ToLocalTime());
+ Gestor.Infrastructure.Helpers.Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
+ value = Gestor.Infrastructure.Helpers.Funcoes.StartTime.Value;
+ }
+ else
+ {
+ value = Gestor.Infrastructure.Helpers.Funcoes.StartTime.Value;
+ value = value.AddMilliseconds((double)Gestor.Infrastructure.Helpers.Funcoes.Stopwatch.ElapsedMilliseconds);
+ }
+ }
+ catch (Exception exception)
+ {
+ Gestor.Infrastructure.Helpers.Funcoes.StartTime = new DateTime?(DateTime.Now);
+ Gestor.Infrastructure.Helpers.Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
+ value = Gestor.Infrastructure.Helpers.Funcoes.StartTime.Value;
+ }
+ return value;
+ }
+
+ public static bool IsNull(this DataRow row, string field)
+ {
+ return row.Obj(field) == null;
+ }
+
+ public static IQueryable<T> NullSafeWhere<T>(this IQueryable<T> source, Expression<Func<T, bool>> predicate)
+ {
+ if (predicate == null)
+ {
+ return source;
+ }
+ return source.Where<T>(predicate);
+ }
+
+ public static object Obj(this DataRow row, string field)
+ {
+ return row.Field<object>(field);
+ }
+
+ public static DataTable Select(this SqlCommand sqlCommand, SqlQueryCondition sqlCondition, string command, string group = "")
+ {
+ bool count;
+ DataTable dataTable = new DataTable();
+ try
+ {
+ sqlCommand.CommandText = string.Concat(new string[] { command, " ", sqlCondition.Condicao, " ", group });
+ List<SqlParameter> parametros = sqlCondition.Parametros;
+ if (parametros != null)
+ {
+ count = parametros.Count > 0;
+ }
+ else
+ {
+ count = false;
+ }
+ if (count)
+ {
+ sqlCondition.Parametros.ForEach((SqlParameter x) => sqlCommand.Parameters.Add(x));
+ }
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable);
+ }
+ sqlCommand.Parameters.Clear();
+ }
+ catch (Exception exception)
+ {
+ sqlCommand.CommandText = string.Empty;
+ sqlCommand.Parameters.Clear();
+ throw;
+ }
+ return dataTable;
+ }
+
+ public static DataTable Select(this GenericUnitOfWork _unitOfWork, SqlQueryCondition sqlCondition, string command, string group = "")
+ {
+ DataTable dataTable;
+ object connection;
+ bool count;
+ DataTable dataTable1 = new DataTable();
+ SessionFactoryImpl sessionFactory = _unitOfWork.Session.SessionFactory as SessionFactoryImpl;
+ if (sessionFactory != null)
+ {
+ connection = sessionFactory.ConnectionProvider.GetConnection();
+ }
+ else
+ {
+ connection = null;
+ }
+ using (SqlConnection sqlConnection = connection as SqlConnection)
+ {
+ if (sqlConnection != null)
+ {
+ using (SqlCommand sqlCommand = sqlConnection.CreateCommand())
+ {
+ sqlCommand.CommandTimeout = 15000;
+ sqlCommand.CommandText = string.Concat(new string[] { command, " ", sqlCondition.Condicao, " ", group });
+ List<SqlParameter> parametros = sqlCondition.Parametros;
+ if (parametros != null)
+ {
+ count = parametros.Count > 0;
+ }
+ else
+ {
+ count = false;
+ }
+ if (count)
+ {
+ sqlCondition.Parametros.ForEach((SqlParameter x) => sqlCommand.Parameters.Add(x));
+ }
+ using (SqlDataAdapter sqlDataAdapter = new SqlDataAdapter())
+ {
+ sqlDataAdapter.SelectCommand = sqlCommand;
+ sqlDataAdapter.Fill(dataTable1);
+ return dataTable1;
+ }
+ }
+ }
+ else
+ {
+ dataTable = null;
+ }
+ }
+ return dataTable;
+ }
+
+ public static bool Update(this SqlCommand sqlCommand, SqlQueryCondition sqlCondition, string command, List<SqlParameter> parameters = null)
+ {
+ bool flag;
+ string condicao;
+ bool count;
+ if (string.IsNullOrEmpty(command))
+ {
+ return false;
+ }
+ if (sqlCondition != null)
+ {
+ condicao = sqlCondition.Condicao;
+ }
+ else
+ {
+ condicao = null;
+ }
+ if (string.IsNullOrEmpty(condicao))
+ {
+ return false;
+ }
+ if (sqlCondition.Parametros.Count == 0)
+ {
+ return false;
+ }
+ if (command.ToUpper().Contains("SELECT"))
+ {
+ return false;
+ }
+ try
+ {
+ sqlCommand.CommandText = string.Concat(command, " ", sqlCondition.Condicao);
+ List<SqlParameter> parametros = sqlCondition.Parametros;
+ if (parametros != null)
+ {
+ count = parametros.Count > 0;
+ }
+ else
+ {
+ count = false;
+ }
+ if (count)
+ {
+ sqlCondition.Parametros.ForEach((SqlParameter x) => sqlCommand.Parameters.Add(x));
+ }
+ if (parameters != null && parameters.Count > 0)
+ {
+ parameters.ForEach((SqlParameter x) => sqlCommand.Parameters.Add(x));
+ }
+ sqlCommand.ExecuteNonQuery();
+ sqlCommand.Parameters.Clear();
+ return true;
+ }
+ catch (Exception exception)
+ {
+ sqlCommand.CommandText = string.Empty;
+ sqlCommand.Parameters.Clear();
+ flag = false;
+ }
+ return flag;
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/QueryableHelper.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/QueryableHelper.cs
new file mode 100644
index 0000000..1848882
--- /dev/null
+++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/QueryableHelper.cs
@@ -0,0 +1,48 @@
+using System;
+using System.Linq;
+using System.Linq.Expressions;
+using System.Runtime.CompilerServices;
+
+namespace Gestor.Infrastructure.Helpers
+{
+ public static class QueryableHelper
+ {
+ public static IQueryable<TSource> WhereNotEmpty<TSource, T>(this IQueryable<TSource> source, T compareVaue, Expression<Func<TSource, bool>> predicateIf, Expression<Func<TSource, bool>> predicateElse = null)
+ {
+ //
+ // Current member / type: System.Linq.IQueryable`1<TSource> Gestor.Infrastructure.Helpers.QueryableHelper::WhereNotEmpty(System.Linq.IQueryable`1<TSource>,T,System.Linq.Expressions.Expression`1<System.Func`2<TSource,System.Boolean>>,System.Linq.Expressions.Expression`1<System.Func`2<TSource,System.Boolean>>)
+ // File path: C:\AggerSeguros\Lib\Gestor.Infrastructure.dll
+ //
+ // Product version: 0.0.0.0
+ // Exception in: System.Linq.IQueryable<TSource> WhereNotEmpty(System.Linq.IQueryable<TSource>,T,System.Linq.Expressions.Expression<System.Func<TSource,System.Boolean>>,System.Linq.Expressions.Expression<System.Func<TSource,System.Boolean>>)
+ //
+ // Managed pointer usage not in SSA
+ // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.CheckForAssignment(BinaryExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 100
+ // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.VisitBinaryExpression(BinaryExpression node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 80
+ // at Telerik.JustDecompiler.Ast.BaseCodeVisitor.Visit(ICodeNode node) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Ast\BaseCodeVisitor.cs:line 351
+ // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.VisitExpressions() in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 41
+ // at Telerik.JustDecompiler.Steps.ManagedPointersRemovalStep.Process(DecompilationContext context, BlockStatement body) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Steps\ManagedPointersRemovalStep.cs:line 29
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.RunInternal(MethodBody body, BlockStatement block, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 100
+ // at Telerik.JustDecompiler.Decompiler.DecompilationPipeline.Run(MethodBody body, ILanguage language) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\DecompilationPipeline.cs:line 72
+ // at Telerik.JustDecompiler.Decompiler.Extensions.RunPipeline(DecompilationPipeline pipeline, ILanguage language, MethodBody body, DecompilationContext& context) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 95
+ // at Telerik.JustDecompiler.Decompiler.Extensions.Decompile(MethodBody body, ILanguage language, DecompilationContext& context, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\Extensions.cs:line 61
+ // at Telerik.JustDecompiler.Decompiler.WriterContextServices.BaseWriterContextService.DecompileMethod(ILanguage language, MethodDefinition method, TypeSpecificContext typeContext) in D:\a\CodemerxDecompile\CodemerxDecompile\src\JustDecompileEngine\src\JustDecompiler.Shared\Decompiler\WriterContextServices\BaseWriterContextService.cs:line 118
+ //
+ // mailto: JustDecompilePublicFeedback@telerik.com
+
+ }
+
+ public static IQueryable<TSource> WhereTrue<TSource>(this IQueryable<TSource> source, bool compareVaue, Expression<Func<TSource, bool>> predicateIf, Expression<Func<TSource, bool>> predicateElse = null)
+ {
+ if (compareVaue)
+ {
+ return source.Where<TSource>(predicateIf);
+ }
+ if (predicateElse == null)
+ {
+ return source;
+ }
+ return source.Where<TSource>(predicateElse);
+ }
+ }
+} \ No newline at end of file
diff --git a/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/SqlDataReaderHelper.cs b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/SqlDataReaderHelper.cs
new file mode 100644
index 0000000..c4087f8
--- /dev/null
+++ b/Codemerx/Gestor.Infrastructure/Gestor.Infrastructure.Helpers/SqlDataReaderHelper.cs
@@ -0,0 +1,66 @@
+using System;
+using System.Data.Common;
+using System.Data.SqlClient;
+using System.Diagnostics;
+using System.Runtime.CompilerServices;
+using System.Threading.Tasks;
+
+namespace Gestor.Infrastructure.Helpers
+{
+ internal static class SqlDataReaderHelper
+ {
+ public static bool FieldIsNull(this SqlDataReader rd, string fieldName)
+ {
+ return rd.IsDBNull(rd.GetOrdinal(fieldName));
+ }
+
+ public static async Task<bool> FieldIsNullAsync(SqlDataReader rd, string fieldName)
+ {
+ return await rd.IsDBNullAsync(rd.GetOrdinal(fieldName));
+ }
+
+ public static T GetFieldValue<T>(this SqlDataReader rd, string fieldName, bool normalizeNull = true, bool transformField = true)
+ {
+ Type type = rd[fieldName].GetType();
+ Type type1 = typeof(T);
+ if (type == typeof(DBNull))
+ {
+ if (normalizeNull && (!type1.IsGenericType || !(type1.GetGenericTypeDefinition() == typeof(Nullable<>))))
+ {
+ if (type1 == typeof(int) || type1 == typeof(double) || type1 == typeof(decimal) || type1 == typeof(long))
+ {
+ return (T)Convert.ChangeType(0, type1);
+ }
+ if (type1 == typeof(DateTime))
+ {
+ return (T)Convert.ChangeType(DateTime.MinValue, type1);
+ }
+ if (type1 == typeof(bool))
+ {
+ return (T)Convert.ChangeType(false, type1);
+ }
+ }
+ return default(T);
+ }
+ Type underlyingType = Nullable.GetUnderlyingType(type1) ?? type1;
+ if (type == underlyingType)
+ {
+ return (T)rd[fieldName];
+ }
+ if (!transformField)
+ {
+ return (T)rd[fieldName];
+ }
+ object item = rd[fieldName];
+ if (underlyingType.IsEnum)
+ {
+ item = Enum.Parse(underlyingType, item.ToString());
+ }
+ if (type == typeof(string) && underlyingType == typeof(bool))
+ {
+ item = (string)item == "1";
+ }
+ return (T)Convert.ChangeType(item, underlyingType);
+ }
+ }
+} \ No newline at end of file