using Agger.Registro; using ClosedXML.Excel; using CsQuery.ExtensionMethods; using Gestor.Application; using Gestor.Application.Actions; using Gestor.Application.Properties; using Gestor.Application.Servicos; using Gestor.Application.Servicos.Configuracoes; using Gestor.Application.Servicos.Ferramentas; using Gestor.Application.Servicos.Generic; using Gestor.Application.Servicos.Seguros; using Gestor.Application.Servicos.Seguros.Itens; using Gestor.Application.ViewModels.Generic; using Gestor.Application.Views.Generic; using Gestor.Common.Validation; using Gestor.Infrastructure.Repository.Interface; using Gestor.Infrastructure.UnitOfWork.Generic; using Gestor.Infrastructure.UnitOfWork.Logic; using Gestor.Model.API; using Gestor.Model.Attributes; using Gestor.Model.Common; using Gestor.Model.Domain.Card; using Gestor.Model.Domain.Common; using Gestor.Model.Domain.Configuracoes; using Gestor.Model.Domain.Generic; using Gestor.Model.Domain.MalaDireta; using Gestor.Model.Domain.Relatorios; using Gestor.Model.Domain.Seguros; using HtmlAgilityPack; using MaterialDesignThemes.Wpf; using Newtonsoft.Json; using OfxSharpLib; using System; using System.Collections; using System.Collections.Generic; using System.Collections.ObjectModel; using System.ComponentModel; using System.Diagnostics; using System.Globalization; using System.Linq; using System.Net; using System.Net.Sockets; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using System.Text; using System.Text.RegularExpressions; using System.Threading; using System.Threading.Tasks; using System.Web; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Input; using System.Windows.Threading; using Xceed.Wpf.AvalonDock.Controls; namespace Gestor.Application.Helpers { public static class Funcoes { public static System.Diagnostics.Stopwatch Stopwatch; public static DateTime? StartTime; public static string AdicionarLog(string html) { string innerHtml; HtmlDocument htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); DateTime networkTime = Funcoes.GetNetworkTime(); using (IEnumerator enumerator = htmlDocument.get_DocumentNode().get_ChildNodes().GetEnumerator()) { while (enumerator.MoveNext()) { HtmlNode current = enumerator.Current; if (current.get_Name() != "body") { continue; } current.set_InnerHtml(string.Format("

{0} ID-{1} {2:g}

{3}
", new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), networkTime, current.get_InnerHtml() })); innerHtml = current.get_InnerHtml(); return innerHtml; } return ""; } return innerHtml; } public static async Task AtualizarAssistencia(Assistance assistance, string id) { string str; if (await Gestor.Application.Helpers.Connection.Put(string.Concat("Assistance/", id), assistance) == null) { str = id; } else { str = null; } return str; } public static async Task AtualizarCartao(Gestor.Model.Domain.Card.Card card, string id) { string str; if (await Gestor.Application.Helpers.Connection.Put(string.Concat("Card/", id), card) == null) { str = id; } else { str = null; } return str; } public static async Task Atualizarlogo(Logo logo, string id) { string str = await Gestor.Application.Helpers.Connection.Put(string.Concat("Card/Logo/", id), logo); return str; } public static async Task AtualizarSeguradora(AssistenciaCia cia, string id) { string str = await Gestor.Application.Helpers.Connection.Put(string.Concat("Assistance/Seguradora/", id), cia); return str; } public static async Task BaixarComissao(Parcela parcela, List parcelas, List repasses, [DecimalConstant(0, 0, 0, 0, 2)] decimal tolerancia = default(decimal), bool comissaoAuto = false) { Parcela parcela1; long? nullable1; Parcela parcela2; decimal num1; decimal num2; bool flag; object nome; object apolice; long? nullable2; bool flag1; object empty; string str; string proposta; Funcoes.u003cu003ec__DisplayClass2_0 variable; Parcela parcela3 = parcela; ParcelaServico parcelaServico = new ParcelaServico(); Parcela parcela4 = parcela3; num1 = (!(parcela3.get_ValorComDesconto() == decimal.Zero) || !(Math.Abs(parcela3.get_ValorComDesconto()) < Math.Abs(parcela3.get_ValorComissao())) ? parcela3.get_ValorComDesconto() : parcela3.get_ValorComissao()); parcela4.set_ValorComDesconto(num1); List vendedorParcelas = repasses; var groupings = from x in vendedorParcelas group x by new { Id = x.get_Parcela().get_Id(), vendedor = x.get_Vendedor().get_Id(), tipovendedor = x.get_TipoVendedor().get_Id() }; BaseDialogViewModel baseDialogViewModel = new BaseDialogViewModel(); if (!groupings.Any((g) => g.Count() > 1)) { DateTime networkTime = Funcoes.GetNetworkTime(); if (parcela3.get_SubTipo() != 1 || parcela3.get_Documento().get_TipoRecebimento().GetValueOrDefault() != 1) { List vendedorParcelas1 = repasses.Where((VendedorParcela x) => { FormaRepasse? nullable; FormaRepasse? forma; if (x.get_Parcela().get_Id() != parcela3.get_Id() || x.get_DataPagamento().HasValue) { return false; } if (x == null) { return false; } Repasse repasse = x.get_Repasse(); if (repasse != null) { forma = repasse.get_Forma(); } else { nullable = null; forma = nullable; } nullable = forma; return nullable.GetValueOrDefault() == 1; }).ToList(); vendedorParcelas1.ForEach((VendedorParcela x) => { x.set_DataPrePagamento(parcela3.get_DataRecebimento()); x.set_ValorRepasse(new decimal?(Funcoes.CalculaRepasse(x.get_Repasse(), parcela3, false))); }); parcela2 = await parcelaServico.Save(parcela3, parcelas, vendedorParcelas1, false); parcela3 = parcela2; if (!parcelaServico.Sucesso) { await Funcoes.MostrarErro(24); parcela1 = parcela3; variable = null; parcelaServico = null; baseDialogViewModel = null; return parcela1; } } else { num2 = (parcela3.get_Documento().get_AdicionalComiss() ? parcela3.get_Documento().get_PremioLiquido() + parcela3.get_Documento().get_PremioAdicional() : parcela3.get_Documento().get_PremioLiquido()); decimal num3 = num2; decimal comissao = (num3 * parcela3.get_Documento().get_Comissao()) * new decimal(1, 0, 0, false, 2); List parcelas1 = parcelas; IEnumerable parcelas2 = parcelas1.Where((Parcela x) => { if (x.get_SubTipo() != 1) { return false; } return x.get_DataRecebimento().HasValue; }); decimal num4 = parcelas2.Sum((Parcela x) => x.get_ValorComissao()); decimal num5 = Math.Abs(comissao) - Math.Abs(num4); flag = (num5 <= tolerancia ? true : num5 < new decimal(1, 0, 0, false, 2)); bool flag2 = flag; TipoRecebimento? tipoRecebimento = parcela3.get_Documento().get_TipoRecebimento(); bool flag3 = tipoRecebimento.GetValueOrDefault() == 1 & flag2; bool flag4 = true; if (flag3) { List configuracoes = Recursos.Configuracoes; if (configuracoes.Any((ConfiguracaoSistema c) => c.get_Configuracao() == 54)) { Parcela parcela5 = parcela3; if (parcela5 != null) { Documento documento = parcela5.get_Documento(); if (documento != null) { Controle controle = documento.get_Controle(); if (controle != null) { Cliente cliente = controle.get_Cliente(); if (cliente != null) { nome = cliente.get_Nome(); } else { nome = null; } } else { nome = null; } } else { nome = null; } } else { nome = null; } if (nome == null) { nome = string.Empty; } string str1 = (string)nome; if (string.IsNullOrEmpty(str1)) { Documento documento1 = parcela3.get_Documento(); if (documento1 != null) { Controle controle1 = documento1.get_Controle(); if (controle1 != null) { Cliente cliente1 = controle1.get_Cliente(); if (cliente1 != null) { nullable2 = new long?(cliente1.get_Id()); } else { nullable1 = null; nullable2 = nullable1; } } else { nullable1 = null; nullable2 = nullable1; } long? nullable3 = nullable2; long num6 = (long)0; flag1 = nullable3.GetValueOrDefault() > num6 & nullable3.HasValue; } else { flag1 = false; } if (flag1) { Cliente cliente2 = await (new ClienteServico()).BuscarClienteAsync(parcela3.get_Documento().get_Controle().get_Cliente().get_Id()); if (cliente2 != null) { empty = cliente2.get_Nome(); } else { empty = null; } if (empty == null) { empty = string.Empty; } str1 = (string)empty; } } if (!string.IsNullOrEmpty(str1)) { str1 = string.Concat(", DO CLIENTE ", str1); } Parcela parcela6 = parcela3; if (parcela6 != null) { Documento documento2 = parcela6.get_Documento(); if (documento2 != null) { apolice = documento2.get_Apolice(); } else { apolice = null; } } else { apolice = null; } if (apolice == null) { apolice = string.Empty; } string str2 = (string)apolice; if (!string.IsNullOrEmpty(str2)) { str2 = string.Concat(" - APÓLICE ", str2); } if (parcela3.get_Documento().get_NumeroParcelas() != parcela3.get_NumeroParcela()) { bool flag5 = await baseDialogViewModel.ShowMessage(string.Format("AINDA RESTA {0:c}{1}{2} QUE NÃO SERÁ REPASSADO, CONTINUAR A BAIXA POR ESGOTAMENTO?", num5, str1, str2), "SIM, BAIXAR POR ESGOMENTO", "NÃO", false); bool flag6 = flag5; flag3 = flag5; flag4 = flag6; } } } List vendedorParcelas2 = repasses.Where((VendedorParcela x) => { bool valueOrDefault; if (x.get_Parcela().get_Id() == this.parcela.get_Id()) { Repasse repasse = x.get_Repasse(); valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false); if (valueOrDefault) { return !x.get_DataPagamento().HasValue; } } return false; }).ToList(); List vendedorParcelas3 = new List(); Parcela parcela7 = parcelas.FirstOrDefault((Parcela x) => { if (x.get_SubTipo() != 1) { return false; } return x.get_NumeroParcela() == this.parcela.get_NumeroParcela() + 1; }); Parcela parcela8 = parcela3; List vendedorParcelas4 = vendedorParcelas2; ExtensionMethods.ForEach( from g in vendedorParcelas4 group g by new { Id = g.get_Parcela().get_Id(), vendedor = g.get_Vendedor().get_Id(), tipovendedor = g.get_TipoVendedor().get_Id() }, (x) => { if (x.First().get_CoCorretagem()) { return; } decimal valueOrDefault = x.First().get_ValorRepasse().GetValueOrDefault(); decimal num = Funcoes.CalculaPagamento(x.First(), parcela8, comissao); x.First().set_ValorRepasse(new decimal?((Math.Abs(valueOrDefault) > Math.Abs(num) ? num : valueOrDefault))); x.First().set_DataPrePagamento(parcela8.get_DataRecebimento()); if (flag4 && (Math.Abs(comissao) - Math.Abs(num4)) <= Math.Abs(tolerancia) || parcela7 == null) { return; } VendedorParcela vendedorParcela = new VendedorParcela(); vendedorParcela.set_Repasse(x.First().get_Repasse()); vendedorParcela.set_Parcela(parcela7); vendedorParcela.set_Documento(parcela8.get_Documento()); vendedorParcela.set_ValorRepasse(new decimal?(valueOrDefault - num)); vendedorParcela.set_Vendedor(x.First().get_Vendedor()); vendedorParcela.set_ValorTotal(x.First().get_ValorTotal()); vendedorParcela.set_PorcentagemRepasse(x.First().get_PorcentagemRepasse()); vendedorParcela.set_TipoVendedor(x.First().get_TipoVendedor()); vendedorParcela.set_CoCorretagem(x.First().get_CoCorretagem()); vendedorParcelas3.Add(vendedorParcela); }); if (vendedorParcelas3.Count > 0) { vendedorParcelas2.AddRange(vendedorParcelas3); } if (await parcelaServico.SaveRange(vendedorParcelas2)) { parcela2 = await parcelaServico.Save(parcela3, parcelas, null, false); parcela3 = parcela2; if (parcelaServico.Sucesso) { if (flag3) { List parcelas3 = parcelas; List parcelas4 = parcelas3.Where((Parcela x) => { if (x.get_DataRecebimento().HasValue) { return false; } return x.get_SubTipo() == 1; }).ToList(); List vendedorParcelas5 = new List(); parcelas4.ForEach((Parcela x) => { x.set_Documento(parcela3.get_Documento()); x.set_DataRecebimento(parcela3.get_DataRecebimento()); x.set_DataCredito(parcela3.get_DataRecebimento()); x.set_ValorRealizado(decimal.Zero); x.set_ValorComissao(decimal.Zero); x.set_ValorComDesconto(decimal.Zero); x.set_Irr(decimal.Zero); x.set_Iss(decimal.Zero); List list = repasses.Where((VendedorParcela p) => { bool valueOrDefault; if (p.get_Parcela().get_Id() == x.get_Id()) { Repasse repasse = p.get_Repasse(); valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false); if (valueOrDefault) { Repasse repasse1 = p.get_Repasse(); if (repasse1 == null) { return true; } return repasse1.get_Tipo().GetValueOrDefault() != 3; } } return false; }).ToList(); list.ForEach((VendedorParcela p) => { decimal? nullable; p.set_Parcela(x); p.set_Documento(parcela3.get_Documento()); p.set_DataPrePagamento(new DateTime?(networkTime)); VendedorParcela vendedorParcela = p; decimal? valorRepasse = p.get_ValorRepasse(); decimal cSu0024u003cu003e8_locals1 = tolerancia; if ((valorRepasse.GetValueOrDefault() > cSu0024u003cu003e8_locals1) & valorRepasse.HasValue) { cSu0024u003cu003e8_locals1 = new decimal(); nullable = new decimal?(cSu0024u003cu003e8_locals1); } else { nullable = p.get_ValorRepasse(); } vendedorParcela.set_ValorRepasse(nullable); }); vendedorParcelas5.AddRange(list); }); await parcelaServico.SaveRange(parcelas); if (!parcelaServico.Sucesso) { await Funcoes.MostrarErro(24); parcela1 = parcela3; variable = null; parcelaServico = null; baseDialogViewModel = null; return parcela1; } else if (await parcelaServico.SaveRange(vendedorParcelas5)) { } else { await Funcoes.MostrarErro(24); parcela1 = parcela3; variable = null; parcelaServico = null; baseDialogViewModel = null; return parcela1; } } } else { await Funcoes.MostrarErro(24); parcela1 = parcela3; variable = null; parcelaServico = null; baseDialogViewModel = null; return parcela1; } } else { await Funcoes.MostrarErro(24); parcela1 = parcela3; variable = null; parcelaServico = null; baseDialogViewModel = null; return parcela1; } } if (!comissaoAuto) { Funcoes.RegistrarLogBaixa(parcela3.get_Documento().get_Id(), networkTime); } parcela1 = parcela3; } else { Documento documento3 = parcela3.get_Documento(); if (documento3 != null) { str = documento3.get_Apolice(); } else { str = null; } if (string.IsNullOrWhiteSpace(str)) { Documento documento4 = parcela3.get_Documento(); if (documento4 != null) { proposta = documento4.get_Apolice(); } else { proposta = null; } } else { Documento documento5 = parcela3.get_Documento(); if (documento5 != null) { proposta = documento5.get_Proposta(); } else { proposta = null; } } string str3 = proposta; await baseDialogViewModel.ShowMessage(string.Format("HÁ VENDEDORES DUPLICADOS PARA A PARCELA {0} DO DOCUMENTO {1}, BAIXA DE COMISSÃO INTERROMPIDA.{2}REALIZE A CORREÇÃO DOS VENDEDORES E TENTE NOVAMENTE.", parcela3.get_NumeroParcela(), str3, Environment.NewLine), "OK", "", false); parcela3.set_DataRecebimento(null); parcela3.set_ValorComissao(decimal.Zero); parcela3.set_ValorComDesconto(decimal.Zero); parcela3.set_Irr(decimal.Zero); parcela3.set_Iss(decimal.Zero); parcela3.set_Outros(decimal.Zero); parcela3.set_Desconto(decimal.Zero); parcela1 = parcela3; } variable = null; parcelaServico = null; baseDialogViewModel = null; return parcela1; } public static string BoolToString(this bool boolean) { if (!boolean) { return "0"; } return "1"; } public static void BringToFront(this string programName) { try { Process[] processesByName = Process.GetProcessesByName(programName); if (processesByName.Length != 0) { IntPtr mainWindowHandle = processesByName[0].MainWindowHandle; Funcoes.ShowWindow(mainWindowHandle, 5); Funcoes.ShowWindow(mainWindowHandle, 9); Funcoes.SetForegroundWindow(mainWindowHandle); } } catch (Exception exception) { } } public static decimal CalculaPagamento(VendedorParcela pagamento, Parcela parcela, decimal comissaoPrevista) { TipoRepasse? tipo; bool valueOrDefault; bool flag; bool valueOrDefault1; bool flag1; decimal num; decimal num1 = pagamento.get_PorcentagemRepasse().GetValueOrDefault(); decimal valueOrDefault2 = pagamento.get_ValorRepasse().GetValueOrDefault(); decimal valorComDesconto = parcela.get_ValorComDesconto(); Repasse repasse = pagamento.get_Repasse(); if (repasse != null) { valueOrDefault = repasse.get_Incidencia().GetValueOrDefault() == 2; } else { valueOrDefault = false; } if (valueOrDefault) { decimal comissao = (parcela.get_Documento().get_Comissao() * parcela.get_Documento().get_PremioLiquido()) * new decimal(1, 0, 0, false, 2); num = (parcela.get_ValorComissao() != decimal.Zero ? parcela.get_ValorComissao() / comissao : decimal.Zero); valorComDesconto = parcela.get_Documento().get_PremioLiquido() * num; } Repasse repasse1 = pagamento.get_Repasse(); if (repasse1 != null) { tipo = repasse1.get_Tipo(); flag = tipo.GetValueOrDefault() != 1; } else { flag = true; } if (flag) { decimal? porcentagemRepasse = pagamento.get_PorcentagemRepasse(); num1 = (valorComDesconto * porcentagemRepasse.GetValueOrDefault()) * new decimal(1, 0, 0, false, 2); } Repasse repasse2 = pagamento.get_Repasse(); if (repasse2 != null) { tipo = repasse2.get_Tipo(); valueOrDefault1 = tipo.GetValueOrDefault() == 1; } else { valueOrDefault1 = false; } if (valueOrDefault1) { Repasse repasse3 = pagamento.get_Repasse(); if (repasse3 != null) { flag1 = repasse3.get_Forma().GetValueOrDefault() == 1; } else { flag1 = false; } if (flag1) { if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 25)) { num1 *= (comissaoPrevista == decimal.Zero ? decimal.One : parcela.get_ValorComissao() / comissaoPrevista); } } } if (Math.Abs(num1) <= Math.Abs(valueOrDefault2)) { return num1; } return valueOrDefault2; } public static decimal CalculaRepasse(Repasse repasse, Parcela parcela, bool apolice = true) { decimal num; decimal num1; decimal num2; decimal comissao; decimal num3; if (repasse == null) { return decimal.Zero; } NegocioCorretora? negocioCorretora = parcela.get_Documento().get_NegocioCorretora(); bool valueOrDefault = negocioCorretora.GetValueOrDefault() == 1; if (!apolice || parcela.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2 || parcela.get_SubTipo() != 1) { decimal num4 = (parcela.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2 ? parcela.get_ValorLiquidoFatura() : parcela.get_Valor()); if (repasse.get_Incidencia().GetValueOrDefault() == 2) { num3 = num4; } else { num3 = (parcela.get_ValorComDesconto() == decimal.Zero ? num4 : parcela.get_ValorComDesconto()); } num1 = num3; num2 = num1; comissao = (parcela.get_ValorComDesconto() == decimal.Zero ? parcela.get_Comissao() * new decimal(1, 0, 0, false, 2) : decimal.One); } else { num1 = (parcela.get_Documento().get_AdicionalComiss() ? parcela.get_Documento().get_PremioLiquido() + parcela.get_Documento().get_PremioAdicional() : parcela.get_Documento().get_PremioLiquido()); num2 = (parcela.get_Documento().get_AdicionalComiss() ? parcela.get_Documento().get_PremioLiquido() + parcela.get_Documento().get_PremioAdicional() : parcela.get_Documento().get_PremioLiquido()); comissao = parcela.get_Documento().get_Comissao() * new decimal(1, 0, 0, false, 2); } num1 = (repasse.get_Incidencia().GetValueOrDefault() == 2 ? num1 : num1 * comissao); num1 = (repasse.get_Tipo().GetValueOrDefault() == 1 ? num1 : (num1 * (valueOrDefault ? repasse.get_ValorRenovacao() : repasse.get_ValorNovo())) * new decimal(1, 0, 0, false, 2)); decimal num5 = (repasse.get_Incidencia().GetValueOrDefault() == 2 ? num2 : num2 * comissao); if (repasse.get_Tipo().GetValueOrDefault() != 1) { num = (num5 * (valueOrDefault ? repasse.get_ValorRenovacao() : repasse.get_ValorNovo())) * new decimal(1, 0, 0, false, 2); } else { num = (valueOrDefault ? repasse.get_ValorRenovacao() : repasse.get_ValorNovo()); if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => x.get_Configuracao() == 24) && parcela.get_Valor() < decimal.Zero) { num = -num; } } if (parcela.get_Documento().get_TipoRecebimento().GetValueOrDefault() != 2 && parcela.get_SubTipo() == 1 && parcela.get_Documento().get_TipoEndosso().GetValueOrDefault() != 2) { if (Math.Abs(num) > Math.Abs(num1)) { (new BaseDialogViewModel()).ShowMessage("OS VALORES DE REPASSE ULTRAPASSARAM O VALOR DE COMISSÃO FECHADA. REVEJA OS VALORES.", "OK", "", false); } if (Math.Abs(num) <= Math.Abs(num1)) { return num; } return num1; } if (parcela.get_ValorComDesconto() != decimal.Zero && Math.Abs(num) > Math.Abs(parcela.get_ValorComDesconto())) { if (Recursos.Configuracoes.All((ConfiguracaoSistema x) => x.get_Configuracao() != 15)) { return parcela.get_ValorComDesconto(); } } return num; } public static string Clear(this string stringToClean) { if (stringToClean == null) { return null; } return Regex.Replace(stringToClean, "[^\\d]", string.Empty); } private static void CloseSlackBar() { Thread.Sleep(5000); Dispatcher dispatcher = App.ProgressRing.Dispatcher; if (dispatcher == null) { return; } dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => Funcoes.ToggleSnackBar("", false))); } public static List ColunasRelatorio(Relatorio relatorio, List parametrosAdicionados) { long id; int ordem; List parametrosRelatorios = new List(); foreach (PropertyInfo propertyInfo in from in (IEnumerable)typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public) orderby x.GetDescriptionAttribute() select ) { if (propertyInfo.Name == "ValidationEvent" || propertyInfo.GetTypeAttribute() == "INVALID" || parametrosAdicionados.Any((ParametrosRelatorio x) => x.get_Campo() == propertyInfo.Name)) { continue; } ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio(); ParametrosRelatorio parametrosRelatorio1 = parametrosAdicionados.FirstOrDefault((ParametrosRelatorio x) => { if (x.get_IdUsuario() == 0) { return false; } return x.get_Campo() == propertyInfo.Name; }); if (parametrosRelatorio1 != null) { id = parametrosRelatorio1.get_Id(); } else { id = (long)0; } parametrosRelatorio.set_Id(id); parametrosRelatorio.set_Campo(propertyInfo.Name); parametrosRelatorio.set_Header(propertyInfo.GetDescriptionAttribute()); parametrosRelatorio.set_IdUsuario(Recursos.Usuario.get_Id()); parametrosRelatorio.set_Relatorio(relatorio); parametrosRelatorio.set_Tipo(propertyInfo.GetTypeAttribute()); parametrosRelatorio.set_Width(0); ParametrosRelatorio parametrosRelatorio2 = parametrosAdicionados.FirstOrDefault((ParametrosRelatorio x) => x.get_Campo() == propertyInfo.Name); if (parametrosRelatorio2 != null) { ordem = parametrosRelatorio2.get_Ordem(); } else { ordem = 0; } parametrosRelatorio.set_Ordem(ordem); parametrosRelatorios.Add(parametrosRelatorio); } return parametrosRelatorios; } public static List ConstruirSintetico(this List sintetico, Relatorio relatorio) { if (sintetico == null) { return null; } List sinteticModelLists = new List(); typeof(Sintetico).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList().ForEach((PropertyInfo props) => { char chr; if (props.GetValue(sintetico.First()) == null) { return; } string descriptionAttribute = props.GetDescriptionAttribute(); TipoRestricao? nullable = null; if (descriptionAttribute != null) { switch (descriptionAttribute.Length) { case 5: { if (descriptionAttribute == "VALOR") { nullable = new TipoRestricao?(100); goto Label0; } else { goto Label0; } } case 7: { if (descriptionAttribute == "REPASSE") { nullable = new TipoRestricao?(81); goto Label0; } else { goto Label0; } } case 8: { if (descriptionAttribute == "IMPOSTOS") { nullable = new TipoRestricao?(93); goto Label0; } else { goto Label0; } } case 10: { if (descriptionAttribute == "VALOR PAGO") { nullable = new TipoRestricao?(104); goto Label0; } else { goto Label0; } } case 11: { if (descriptionAttribute == "TOTAL GERAL") { nullable = new TipoRestricao?(75); goto Label0; } else { goto Label0; } } case 12: { chr = descriptionAttribute[0]; if (chr == 'M') { if (descriptionAttribute == "META ATINGIR") { nullable = new TipoRestricao?(88); goto Label0; } else { goto Label0; } } else if (chr == 'P') { if (descriptionAttribute == "PRÊMIO TOTAL") { nullable = new TipoRestricao?(65); goto Label0; } else { goto Label0; } } else if (chr != 'V') { goto Label0; } else if (descriptionAttribute == "VALOR ORÇADO") { nullable = new TipoRestricao?(101); goto Label0; } else { goto Label0; } } case 13: { chr = descriptionAttribute[0]; if (chr == 'M') { if (descriptionAttribute == "META CUMPRIDA") { nullable = new TipoRestricao?(89); goto Label0; } else { goto Label0; } } else if (chr != 'V') { goto Label0; } else if (descriptionAttribute == "VALOR SALVADO") { nullable = new TipoRestricao?(105); goto Label0; } else { goto Label0; } } case 14: { chr = descriptionAttribute[8]; switch (chr) { case 'A': { if (descriptionAttribute == "VALOR FRANQUIA") { nullable = new TipoRestricao?(106); goto Label0; } else { goto Label0; } } case 'B': { if (descriptionAttribute == "VALOR LIBERADO") { nullable = new TipoRestricao?(103); goto Label0; } else { goto Label0; } } case 'C': case 'D': { goto Label0; } case 'E': { if (descriptionAttribute == "TOTAL PREVISTO") { nullable = new TipoRestricao?(82); goto Label0; } else { goto Label0; } } default: { if (chr == 'R') { if (descriptionAttribute == "TOTAL PARCELAS") { nullable = new TipoRestricao?(102); goto Label0; } else { goto Label0; } } else if (chr != 'Í') { goto Label0; } else if (descriptionAttribute == "PRÊMIO LÍQUIDO") { nullable = new TipoRestricao?(67); goto Label0; } else { goto Label0; } } } break; } case 15: { if (descriptionAttribute == "VALOR LIQUIDADO") { nullable = new TipoRestricao?(86); goto Label0; } else { goto Label0; } } case 16: { if (descriptionAttribute == "TOTAL DE LÍQUIDO") { nullable = new TipoRestricao?(76); goto Label0; } else { goto Label0; } } case 17: { chr = descriptionAttribute[10]; if (chr == 'E') { if (descriptionAttribute == "COMISSÃO PENDENTE") { nullable = new TipoRestricao?(87); goto Label0; } else { goto Label0; } } else if (chr == 'L') { if (descriptionAttribute == "TOTAL DE CLIENTES") { goto Label1; } goto Label0; } else if (chr != 'R') { goto Label0; } else if (descriptionAttribute == "COMISSÃO PREVISTA") { nullable = new TipoRestricao?(80); goto Label0; } else { goto Label0; } } case 18: { if (descriptionAttribute == "TOTAL DE TERCEIROS") { nullable = new TipoRestricao?(83); goto Label0; } else { goto Label0; } } case 19: { if (descriptionAttribute == "QUANTIDADE PENDENTE") { nullable = new TipoRestricao?(85); goto Label0; } else { goto Label0; } } case 20: { if (descriptionAttribute == "QUANTIDADE LIQUIDADO") { nullable = new TipoRestricao?(84); goto Label0; } else { goto Label0; } } case 21: { if (descriptionAttribute == "QUANTIDADE DE FATURAS") { nullable = new TipoRestricao?(74); goto Label0; } else { goto Label0; } } case 22: { chr = descriptionAttribute[14]; if (chr == 'A') { if (descriptionAttribute == "QUANTIDADE DE APÓLICES") { nullable = new TipoRestricao?(72); goto Label0; } else { goto Label0; } } else if (chr != 'E') { goto Label0; } else if (descriptionAttribute == "QUANTIDADE DE ENDOSSOS") { nullable = new TipoRestricao?(73); goto Label0; } else { goto Label0; } } case 23: { if (descriptionAttribute == "COMISSÃO RECEBIDA BRUTA") { nullable = new TipoRestricao?(79); goto Label0; } else { goto Label0; } } case 24: { chr = descriptionAttribute[0]; if (chr == 'M') { if (descriptionAttribute == "MÉDIA DE COMISSÃO GERADA") { break; } goto Label0; } else if (chr == 'Q') { if (descriptionAttribute == "QUANTIDADE DE RENOVAÇÕES") { goto Label2; } goto Label0; } else if (chr == 'T') { if (descriptionAttribute == "TOTAL DE CLIENTES ATIVOS") { goto Label1; } if (descriptionAttribute == "TOTAL DE COMISSÃO GERADA") { nullable = new TipoRestricao?(78); goto Label0; } else { goto Label0; } } else { goto Label0; } } case 25: { chr = descriptionAttribute[0]; if (chr == 'C') { if (descriptionAttribute == "COMISSÃO RECEBIDA LÍQUIDA") { nullable = new TipoRestricao?(92); goto Label0; } else { goto Label0; } } else if (chr == 'M') { if (descriptionAttribute == "MÉDIA DE COMISSÃO FECHADA") { break; } goto Label0; } else if (chr != 'Q') { goto Label0; } else if (descriptionAttribute == "QUANTIDADE DE PROSPECÇÕES") { nullable = new TipoRestricao?(77); goto Label0; } else { goto Label0; } } case 26: { if (descriptionAttribute == "TOTAL DE CLIENTES INATIVOS") { goto Label1; } goto Label0; } case 27: { chr = descriptionAttribute[15]; if (chr == 'A') { if (descriptionAttribute == "QUANTIDADE DE CANCELAMENTOS") { nullable = new TipoRestricao?(71); goto Label0; } else { goto Label0; } } else if (chr == 'E') { if (descriptionAttribute == "QUANTIDADE DE SEGUROS NOVOS") { goto Label2; } goto Label0; } else if (chr == 'Ã') { if (descriptionAttribute == "MÉDIA DE COMISSÃO PONDERADA") { break; } goto Label0; } else { goto Label0; } } case 28: { if (descriptionAttribute == "QUANTIDADE DE NOVOS NEGÓCIOS") { goto Label3; } goto Label0; } case 31: { if (descriptionAttribute == "QUANTIDADE DE NEGÓCIOS PRÓPRIOS") { goto Label3; } goto Label0; } default: { goto Label0; } } nullable = new TipoRestricao?(68); } Label0: if (nullable.HasValue) { RestricaoUsuario restricaoUsuario = (new RestricaoUsuarioServico()).BuscarRestricao(Recursos.Usuario, nullable.Value); if (restricaoUsuario != null && restricaoUsuario.get_Restricao()) { return; } } List parametrosTotalizacaos = (new ConfuguracoesServico()).BuscarParametroTotalizacao(relatorio); if (parametrosTotalizacaos != null && parametrosTotalizacaos.Count > 0 && parametrosTotalizacaos.All((ParametrosTotalizacao y) => y.get_Campo() != props.Name) && !props.Name.ToUpperInvariant().Contains("AGRUPAMENTO")) { return; } SinteticModelList sinteticModelList = new SinteticModelList(); sinteticModelList.set_Hint(descriptionAttribute); sinteticModelList.set_Value(new List()); SinteticModelList sinteticModelList1 = sinteticModelList; string typeAttribute = props.GetTypeAttribute(); sintetico.ForEach((Sintetico s) => { object obj; DateTime? value; DateTime valueOrDefault; object str; object str1; string str2 = typeAttribute; if (str2 == "DATA/TIME" || str2 == "DATA/TIME?") { value = (DateTime?)props.GetValue(s); if (value.HasValue) { valueOrDefault = value.GetValueOrDefault(); str = valueOrDefault.ToString("G"); } else { str = null; } obj = str; } else if (str2 == "DATA" || str2 == "DATA?") { value = (DateTime?)props.GetValue(s); if (value.HasValue) { valueOrDefault = value.GetValueOrDefault(); str1 = valueOrDefault.ToString("d"); } else { str1 = null; } obj = str1; } else { obj = (str2 == "PERCENTUAL" ? string.Format("{0:n2} %", props.GetValue(s)) : (str2 == "VALOR" ? ((decimal)props.GetValue(s)).ToString("c2") : string.Format("{0}", props.GetValue(s)))); } sinteticModelList1.get_Value().Add(obj); }); sinteticModelLists.Add(sinteticModelList1); return; Label1: nullable = new TipoRestricao?(66); goto Label0; Label2: nullable = new TipoRestricao?(70); goto Label0; Label3: nullable = new TipoRestricao?(69); goto Label0; }); return sinteticModelLists; } public static List ConstruirSintetico(this Sintetico sintetico, Relatorio relatorio) { if (sintetico == null) { return null; } List sinteticModels = new List(); typeof(Sintetico).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList().ForEach((PropertyInfo x) => { int length; char chr; DateTime? value; DateTime valueOrDefault; decimal num; object str; SinteticModel sinteticModel; object obj; if (x.GetValue(sintetico) == null) { return; } string descriptionAttribute = x.GetDescriptionAttribute(); TipoRestricao? nullable = null; string str1 = null; if (descriptionAttribute != null) { length = descriptionAttribute.Length; switch (length) { case 5: { if (descriptionAttribute == "VALOR") { nullable = new TipoRestricao?(100); goto Label0; } else { goto Label0; } } case 7: { if (descriptionAttribute == "REPASSE") { nullable = new TipoRestricao?(81); goto Label0; } else { goto Label0; } } case 8: { if (descriptionAttribute == "IMPOSTOS") { nullable = new TipoRestricao?(93); goto Label0; } else { goto Label0; } } case 10: { if (descriptionAttribute == "VALOR PAGO") { nullable = new TipoRestricao?(104); goto Label0; } else { goto Label0; } } case 11: { if (descriptionAttribute == "TOTAL GERAL") { nullable = new TipoRestricao?(75); str1 = "CONTAGEM GERAL DE DOCUMENTOS"; goto Label0; } else { goto Label0; } } case 12: { chr = descriptionAttribute[0]; if (chr == 'M') { if (descriptionAttribute == "META ATINGIR") { nullable = new TipoRestricao?(88); goto Label0; } else { goto Label0; } } else if (chr == 'P') { if (descriptionAttribute == "PRÊMIO TOTAL") { nullable = new TipoRestricao?(65); goto Label0; } else { goto Label0; } } else if (chr != 'V') { goto Label0; } else if (descriptionAttribute == "VALOR ORÇADO") { nullable = new TipoRestricao?(101); goto Label0; } else { goto Label0; } } case 13: { chr = descriptionAttribute[0]; if (chr == 'M') { if (descriptionAttribute == "META CUMPRIDA") { nullable = new TipoRestricao?(89); goto Label0; } else { goto Label0; } } else if (chr != 'V') { goto Label0; } else if (descriptionAttribute == "VALOR SALVADO") { nullable = new TipoRestricao?(105); goto Label0; } else { goto Label0; } } case 14: { chr = descriptionAttribute[8]; switch (chr) { case 'A': { if (descriptionAttribute == "VALOR FRANQUIA") { nullable = new TipoRestricao?(106); goto Label0; } else { goto Label0; } } case 'B': { if (descriptionAttribute == "VALOR LIBERADO") { nullable = new TipoRestricao?(103); goto Label0; } else { goto Label0; } } case 'C': case 'D': { goto Label0; } case 'E': { if (descriptionAttribute == "TOTAL PREVISTO") { nullable = new TipoRestricao?(82); goto Label0; } else { goto Label0; } } default: { if (chr == 'R') { if (descriptionAttribute == "TOTAL PARCELAS") { nullable = new TipoRestricao?(102); goto Label0; } else { goto Label0; } } else if (chr != 'Í') { goto Label0; } else if (descriptionAttribute == "PRÊMIO LÍQUIDO") { nullable = new TipoRestricao?(67); goto Label0; } else { goto Label0; } } } break; } case 15: { if (descriptionAttribute == "VALOR LIQUIDADO") { nullable = new TipoRestricao?(86); goto Label0; } else { goto Label0; } } case 16: { if (descriptionAttribute == "TOTAL DE LÍQUIDO") { nullable = new TipoRestricao?(76); str1 = "CONTAGEM GERAL DOS DOCUMENTOS ATIVOS"; goto Label0; } else { goto Label0; } } case 17: { chr = descriptionAttribute[10]; if (chr == 'E') { if (descriptionAttribute == "COMISSÃO PENDENTE") { nullable = new TipoRestricao?(87); goto Label0; } else { goto Label0; } } else if (chr == 'L') { if (descriptionAttribute == "TOTAL DE CLIENTES") { goto Label1; } goto Label0; } else if (chr != 'R') { goto Label0; } else if (descriptionAttribute == "COMISSÃO PREVISTA") { nullable = new TipoRestricao?(80); goto Label0; } else { goto Label0; } } case 18: { if (descriptionAttribute == "TOTAL DE TERCEIROS") { nullable = new TipoRestricao?(83); goto Label0; } else { goto Label0; } } case 19: { if (descriptionAttribute == "QUANTIDADE PENDENTE") { nullable = new TipoRestricao?(85); goto Label0; } else { goto Label0; } } case 20: { if (descriptionAttribute == "QUANTIDADE LIQUIDADO") { nullable = new TipoRestricao?(84); goto Label0; } else { goto Label0; } } case 21: { if (descriptionAttribute == "QUANTIDADE DE FATURAS") { nullable = new TipoRestricao?(74); goto Label0; } else { goto Label0; } } case 22: { chr = descriptionAttribute[14]; if (chr == 'A') { if (descriptionAttribute == "QUANTIDADE DE APÓLICES") { nullable = new TipoRestricao?(72); goto Label0; } else { goto Label0; } } else if (chr != 'E') { goto Label0; } else if (descriptionAttribute == "QUANTIDADE DE ENDOSSOS") { nullable = new TipoRestricao?(73); goto Label0; } else { goto Label0; } } case 23: { if (descriptionAttribute == "COMISSÃO RECEBIDA BRUTA") { nullable = new TipoRestricao?(79); goto Label0; } else { goto Label0; } } case 24: { chr = descriptionAttribute[0]; if (chr == 'M') { if (descriptionAttribute == "MÉDIA DE COMISSÃO GERADA") { break; } goto Label0; } else if (chr == 'Q') { if (descriptionAttribute == "QUANTIDADE DE RENOVAÇÕES") { goto Label2; } goto Label0; } else if (chr == 'T') { if (descriptionAttribute == "TOTAL DE CLIENTES ATIVOS") { goto Label1; } if (descriptionAttribute == "TOTAL DE COMISSÃO GERADA") { nullable = new TipoRestricao?(78); goto Label0; } else { goto Label0; } } else { goto Label0; } } case 25: { chr = descriptionAttribute[0]; if (chr == 'C') { if (descriptionAttribute == "COMISSÃO RECEBIDA LÍQUIDA") { nullable = new TipoRestricao?(92); goto Label0; } else { goto Label0; } } else if (chr == 'M') { if (descriptionAttribute == "MÉDIA DE COMISSÃO FECHADA") { break; } goto Label0; } else if (chr != 'Q') { goto Label0; } else if (descriptionAttribute == "QUANTIDADE DE PROSPECÇÕES") { nullable = new TipoRestricao?(77); goto Label0; } else { goto Label0; } } case 26: { if (descriptionAttribute == "TOTAL DE CLIENTES INATIVOS") { goto Label1; } goto Label0; } case 27: { chr = descriptionAttribute[15]; if (chr == 'A') { if (descriptionAttribute == "QUANTIDADE DE CANCELAMENTOS") { nullable = new TipoRestricao?(71); goto Label0; } else { goto Label0; } } else if (chr == 'E') { if (descriptionAttribute == "QUANTIDADE DE SEGUROS NOVOS") { goto Label2; } goto Label0; } else if (chr == 'Ã') { if (descriptionAttribute == "MÉDIA DE COMISSÃO PONDERADA") { break; } goto Label0; } else { goto Label0; } } case 28: { if (descriptionAttribute == "QUANTIDADE DE NOVOS NEGÓCIOS") { goto Label3; } goto Label0; } case 31: { if (descriptionAttribute == "QUANTIDADE DE NEGÓCIOS PRÓPRIOS") { goto Label3; } goto Label0; } default: { goto Label0; } } nullable = new TipoRestricao?(68); } Label0: if (nullable.HasValue) { RestricaoUsuario restricaoUsuario = (new RestricaoUsuarioServico()).BuscarRestricao(Recursos.Usuario, nullable.Value); if (restricaoUsuario != null && restricaoUsuario.get_Restricao()) { return; } } List parametrosTotalizacaos = (new ConfuguracoesServico()).BuscarParametroTotalizacao(relatorio); if (parametrosTotalizacaos != null && parametrosTotalizacaos.Count > 0 && parametrosTotalizacaos.All((ParametrosTotalizacao y) => y.get_Campo() != x.Name)) { return; } SinteticModel sinteticModel1 = new SinteticModel(); sinteticModel1.set_Hint(descriptionAttribute); sinteticModel1.set_DescriptionField(str1); SinteticModel sinteticModel2 = sinteticModel1; string typeAttribute = x.GetTypeAttribute(); if (typeAttribute != null) { length = typeAttribute.Length; switch (length) { case 4: { if (typeAttribute == "DATA") { break; } sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } case 5: { chr = typeAttribute[0]; if (chr == 'D') { if (typeAttribute == "DATA?") { break; } sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } else if (chr != 'V') { sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } else if (typeAttribute == "VALOR") { num = (decimal)x.GetValue(sintetico); sinteticModel2.set_Value(num.ToString("c2")); sinteticModels.Add(sinteticModel2); return; } else { sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } } case 6: case 7: case 8: { sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } case 9: { if (typeAttribute == "DATA/TIME") { sinteticModel = sinteticModel2; value = (DateTime?)x.GetValue(sintetico); if (value.HasValue) { valueOrDefault = value.GetValueOrDefault(); obj = valueOrDefault.ToString("G"); } else { obj = null; } sinteticModel.set_Value(obj); sinteticModels.Add(sinteticModel2); return; } sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } case 10: { chr = typeAttribute[0]; if (chr == 'D') { if (typeAttribute == "DATA/TIME?") { sinteticModel = sinteticModel2; value = (DateTime?)x.GetValue(sintetico); if (value.HasValue) { valueOrDefault = value.GetValueOrDefault(); obj = valueOrDefault.ToString("G"); } else { obj = null; } sinteticModel.set_Value(obj); sinteticModels.Add(sinteticModel2); return; } sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } else if (chr != 'P') { sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } else if (typeAttribute == "PERCENTUAL") { sinteticModel2.set_Value(string.Format("{0} %", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } else { sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } } default: { if (length == 13) { if (typeAttribute != "VALORDECIMAL2") { sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } num = (decimal)x.GetValue(sintetico); sinteticModel2.set_Value(num.ToString("n2")); sinteticModels.Add(sinteticModel2); return; } else { sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; } } } SinteticModel sinteticModel3 = sinteticModel2; value = (DateTime?)x.GetValue(sintetico); if (value.HasValue) { valueOrDefault = value.GetValueOrDefault(); str = valueOrDefault.ToString("d"); } else { str = null; } sinteticModel3.set_Value(str); sinteticModels.Add(sinteticModel2); return; } sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico))); sinteticModels.Add(sinteticModel2); return; Label1: nullable = new TipoRestricao?(66); goto Label0; Label2: nullable = new TipoRestricao?(70); goto Label0; Label3: nullable = new TipoRestricao?(69); goto Label0; }); return sinteticModels; } public static async Task ContruirLista(DataGrid grid, Relatorio relatorio) { List list = await (new ConfuguracoesServico()).BuscarParametros(relatorio); if (list == null || list.Count == 0) { list = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public).Select((PropertyInfo x) => { ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio(); parametrosRelatorio.set_Campo(x.Name); parametrosRelatorio.set_Header(x.GetDescriptionAttribute()); parametrosRelatorio.set_Tipo(x.GetTypeAttribute()); parametrosRelatorio.set_Relatorio(relatorio); parametrosRelatorio.set_Width(0); parametrosRelatorio.set_Ordem(0); return parametrosRelatorio; }).ToList(); } if (!Recursos.Usuario.get_Administrador()) { list = await Funcoes.GetRestricoesColunas(list); } List parametrosRelatorios = list; IOrderedEnumerable ordem = from in parametrosRelatorios orderby x.get_Ordem() select ; ordem.ThenBy((ParametrosRelatorio x) => x.get_Header()).ToList().ForEach((ParametrosRelatorio x) => { char chr; object upper; if (x.get_Tipo() == "INVALID") { return; } if (x.get_Campo() == "DataControle" && !Recursos.Usuario.get_Administrador()) { List configuracoes = Recursos.Configuracoes; Func u003cu003e9_324 = Funcoes.u003cu003ec__32.u003cu003e9__32_4; if (u003cu003e9_324 == null) { u003cu003e9_324 = (ConfiguracaoSistema c) => c.get_Configuracao() == 33; Funcoes.u003cu003ec__32.u003cu003e9__32_4 = u003cu003e9_324; } if (configuracoes.Any(u003cu003e9_324)) { return; } } string str = ""; Style item = (Style)System.Windows.Application.Current.Resources["VerticalCenterStyle3"]; Style style = (Style)System.Windows.Application.Current.Resources["MaterialDesignDataGridColumnHeaderNew"]; string tipo = x.get_Tipo(); if (tipo != null) { int length = tipo.Length; switch (length) { case 4: { if (tipo == "DATA") { break; } ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } case 5: { chr = tipo[0]; if (chr == 'D') { if (tipo == "DATA?") { break; } ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else if (chr != 'V') { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else if (tipo == "VALOR") { str = "c"; item = (Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"]; style = (Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyleNew"]; ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } } case 6: case 7: case 8: { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } case 9: { if (tipo == "DATA/TIME") { goto Label1; } ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } case 10: { chr = tipo[0]; if (chr == 'D') { if (tipo == "DATA/TIME?") { goto Label1; } ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else if (chr == 'P') { if (tipo == "PERCENTUAL") { str = "{0:0.00}%"; item = (Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"]; style = (Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyleNew"]; ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } } else if (chr != 'Q') { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else if (tipo == "QUANTIDADE") { item = (Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"]; style = (Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyleNew"]; ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } } default: { if (length != 13) { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else if (tipo == "VALORDECIMAL2") { str = "n2"; item = (Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"]; style = (Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyleNew"]; ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } else { ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; } } } str = "d"; item = (Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"]; style = (Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyleNew"]; } ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; Label1: str = "G"; item = (Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"]; style = (Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyleNew"]; ObservableCollection columns = grid.Columns; MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn(); string header = x.get_Header(); if (header != null) { upper = header.ToUpper(); } else { upper = null; } if (upper == null) { upper = x.get_Campo().ToUpper(); } materialDataGridTextColumn.Header = upper; materialDataGridTextColumn.Binding = new Binding() { Path = new PropertyPath(x.get_Campo(), Array.Empty()), StringFormat = str, Mode = BindingMode.TwoWay, UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged }; materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width()); materialDataGridTextColumn.ElementStyle = item; materialDataGridTextColumn.HeaderStyle = style; columns.Add(materialDataGridTextColumn); return; }); } public static string ConvertGaragemTrabalhoEstudoCalculo(this GaragemTrabalhoEstudo garagemTrabalhoEstudo) { switch (garagemTrabalhoEstudo) { case 0: { return "0"; } case 1: { return "1"; } case 2: { return "2"; } case 3: { return string.Empty; } case 4: case 5: { return "3"; } default: { return string.Empty; } } } public static TipoTela? ConvertTela(string name) { return new TipoTela?(((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList().FirstOrDefault((TipoTela x) => Gestor.Common.Validation.ValidationHelper.GetEntity(x) == name)); } public static TempoHabilitacao ConvertTempoHabilitacao(int tempoHabilitacao = 0) { if (tempoHabilitacao == 1) { return 0; } if (tempoHabilitacao == 2) { return 1; } if (tempoHabilitacao == 3) { return 2; } if (tempoHabilitacao == 4) { return 3; } if (tempoHabilitacao == 5) { return 4; } if (tempoHabilitacao == 6) { return 5; } if (tempoHabilitacao == 7) { return 6; } if (tempoHabilitacao == 8) { return 7; } if (tempoHabilitacao == 9) { return 8; } if (tempoHabilitacao == 10) { return 9; } if (tempoHabilitacao >= 11) { return 10; } return 0; } public static string ConvertTempoHabilitacaoCalculo(this DateTime tempoHabilitacao) { if (tempoHabilitacao == DateTime.MinValue) { return "0"; } int year = DateTime.Now.Year - tempoHabilitacao.Year; if (year >= 11) { return "11"; } return year.ToString(); } public static string ConvertTipoSeguroCalculo(this TipoSeguro tipoSeguro) { if (tipoSeguro - 1 <= 1) { return "1"; } return "0"; } public static void CopyToClipboard(this string text) { try { Clipboard.SetText(text); } catch (Exception exception) { } } public static string CreateCard(string title, string body, bool pageBreak = false) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append((pageBreak ? "
" : "
")); stringBuilder.Append("
"); stringBuilder.Append(string.Concat("
", title, "
")); stringBuilder.Append(body); stringBuilder.Append("
"); stringBuilder.Append("
"); return stringBuilder.ToString(); } public static async Task CriarAssistencia(Assistance assistance) { return await Gestor.Application.Helpers.Connection.Post("Assistance", assistance); } public static async Task CriarCartao(Gestor.Model.Domain.Card.Card card) { return await Gestor.Application.Helpers.Connection.Post("Card", card); } public static async Task Criarlogo(Logo logo) { return await Gestor.Application.Helpers.Connection.Post("Card/Logo", logo); } public static string CriarRecibo(Vendedor vendedor, decimal valor, Filtros filtro, bool segundavia) { string str = (segundavia ? " acima listados" : string.Format(" no periodo de {0:d} até {1:d}", filtro.get_Inicio(), filtro.get_Fim())); string str1 = "CPF"; if (vendedor.get_Documento() != null && Gestor.Common.Validation.ValidationHelper.OnlyNumber(vendedor.get_Documento()).Length > 12) { str1 = "CNPJ"; } object[] nome = new object[] { vendedor.get_Nome(), str1, vendedor.get_Documento(), Recursos.Empresa.get_Nome(), valor, str, null }; nome[6] = Funcoes.GetNetworkTime().Date; return string.Format("
\r\n
RECIBO DE PAGAMENTO
\r\n
\r\n
Declaração de recebimento de Comissão
\r\n

Eu {0}, portador(a) do {1} {2} declaro que recebi de {3} o valor de {4:c} referente a comissão dos seguros{5}.

\r\n\r\n

Para maior clareza firmo(a) o presente recibo para que produza os seus efeitos, dando plena, rasa e irrevogável quitação, pelo valor recebido.

\r\n\r\n

_____________________________________________________________
{6:d}

\r\n
\r\n
", nome); } public static async Task CriarSeguradora(AssistenciaCia cia) { return await Gestor.Application.Helpers.Connection.Post("Assistance/Seguradora", cia); } public static void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { DatePicker datePicker = (DatePicker)sender; datePicker.Text = Gestor.Common.Validation.ValidationHelper.FormatDate(datePicker.Text); } public static void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) { if (e.Key != Key.Return) { return; } DatePicker str = (DatePicker)sender; DateTime date = Funcoes.GetNetworkTime().Date; str.Text = date.ToString("dd/MM/yyyy"); } public static void Destroy() where T : Window { object obj = System.Windows.Application.Current.Windows.OfType().FirstOrDefault(); if (obj == null) { return; } ((Window)obj).Close(); } public static void Destroy(string title) where T : Window { object obj = System.Windows.Application.Current.Windows.OfType().FirstOrDefault((T x) => x.Title == title); if (obj == null) { return; } ((Window)obj).Close(); } public static string DiaDaSemana(this int? dia) { if (!dia.HasValue) { return ""; } switch (dia.Value) { case 0: { return "DOMINGO"; } case 1: { return "SEGUNDA-FEIRA"; } case 2: { return "TERÇA-FEIRA"; } case 3: { return "QUARTA-FEIRA"; } case 4: { return "QUINTA-FEIRA"; } case 5: { return "SEXTA-FEIRA"; } case 6: { return "SABADO"; } } return ""; } public static IEnumerable DistinctBy(IEnumerable source, Func keySelector) { HashSet tKeys = new HashSet(); foreach (TSource tSource in source) { if (!tKeys.Add(keySelector(tSource))) { continue; } yield return tSource; } } public static bool EnviarWhatsapp(this string numero, string anotacoes = null) { bool flag; Uri uri = (string.IsNullOrEmpty(anotacoes) ? Recursos.WhatsAppLink.SetQuery("phone", numero, true) : Recursos.WhatsAppLink.AddQuery("phone", numero).SetQuery("text", anotacoes, true)); try { Process.Start(new ProcessStartInfo(uri.AbsoluteUri)); flag = true; } catch (Exception exception) { uri.AbsoluteUri.CopyToClipboard(); flag = false; } return flag; } public static async Task ExcluirBaixa(Parcela parcela, List repasses, List parcelas = null) { Parcela parcela1; string str; decimal num1; List parcelas1; List parcelas2; Funcoes.u003cu003ec__DisplayClass9_0 variable; ParcelaServico parcelaServico; VendedorServico vendedorServico; Parcela parcela2 = parcela; ParcelaServico parcelaServico1 = new ParcelaServico(); if (parcela2.get_SubTipo() != 1 || parcela2.get_Documento().get_TipoRecebimento().GetValueOrDefault() != 1) { List list = repasses.Where((VendedorParcela x) => { if (x.get_Parcela().get_Id() != parcela2.get_Id()) { return false; } return !x.get_DataPagamento().HasValue; }).ToList(); List vendedorParcelas1 = list; vendedorParcelas1.ForEach((VendedorParcela x) => { x.set_DataPrePagamento(null); VendedorParcela vendedorParcela = x; decimal? valorTotal = x.get_ValorTotal(); vendedorParcela.set_ValorRepasse(new decimal?((valorTotal.HasValue ? valorTotal.GetValueOrDefault() : Funcoes.CalculaPagamento(x, x.get_Parcela(), decimal.Zero)))); }); parcela2.set_ValorComissao(decimal.Zero); parcela2.set_ValorComDesconto(decimal.Zero); DateTime? nullable1 = null; parcela2.set_DataRecebimento(nullable1); nullable1 = null; parcela2.set_DataCredito(nullable1); parcela2.set_ValorRealizado(decimal.Zero); Parcela parcela3 = await parcelaServico1.Save(parcela2, parcelas, list, false); parcela2 = parcela3; if (!parcelaServico1.Sucesso) { await Funcoes.MostrarErro(191); parcela1 = parcela2; variable = null; parcelaServico1 = null; parcelaServico = null; vendedorServico = null; return parcela1; } } else { List list1 = repasses.Where((VendedorParcela x) => { bool valueOrDefault; if (x.get_Parcela().get_SubTipo() == 1) { Repasse repasse = x.get_Repasse(); valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false); if (valueOrDefault) { if (x.get_Parcela().get_Id() == this.parcela.get_Id()) { return true; } return !x.get_DataPrePagamento().HasValue; } } return false; }).ToList(); decimal premioLiquido = parcela2.get_Documento().get_PremioLiquido(); num1 = (parcela2.get_Documento().get_AdicionalComiss() ? parcela2.get_Documento().get_PremioAdicional() : decimal.Zero); decimal comissao = ((premioLiquido + num1) * parcela2.get_Documento().get_Comissao()) * new decimal(1, 0, 0, false, 2); List vendedorParcelas2 = list1; List list2 = ( from x in vendedorParcelas2 group x by x.get_Vendedor().get_Id()).Select, VendedorParcela>((IGrouping x) => { TipoRepasse? nullable; decimal? valorTotal; decimal num; TipoRepasse? tipo; bool valueOrDefault; bool hasValue; decimal? valorRepasse; bool flag; VendedorParcela vendedorParcela = new VendedorParcela(); vendedorParcela.set_Repasse(x.First().get_Repasse()); vendedorParcela.set_Parcela(parcela2); vendedorParcela.set_Documento(parcela2.get_Documento()); VendedorParcela vendedorParcela1 = x.First(); if (vendedorParcela1 != null) { Repasse repasse = vendedorParcela1.get_Repasse(); if (repasse != null) { tipo = repasse.get_Tipo(); } else { nullable = null; tipo = nullable; } nullable = tipo; valueOrDefault = nullable.GetValueOrDefault() != 3; } else { valueOrDefault = true; } if (valueOrDefault) { VendedorParcela vendedorParcela2 = x.First(); if (vendedorParcela2 != null) { valorTotal = vendedorParcela2.get_ValorTotal(); hasValue = valorTotal.HasValue; } else { hasValue = false; } if (hasValue) { VendedorParcela vendedorParcela3 = x.First(); if (vendedorParcela3 != null) { valorTotal = vendedorParcela3.get_ValorTotal(); num = new decimal(); flag = !((valorTotal.GetValueOrDefault() == num) & valorTotal.HasValue); } else { flag = true; } if (!flag) { goto Label1; } VendedorParcela vendedorParcela4 = x.First(); if (vendedorParcela4 != null) { valorRepasse = vendedorParcela4.get_ValorTotal(); vendedorParcela.set_ValorTotal(valorRepasse); vendedorParcela.set_Vendedor(x.First().get_Vendedor()); vendedorParcela.set_PorcentagemRepasse(x.First().get_PorcentagemRepasse()); vendedorParcela.set_TipoVendedor(x.First().get_TipoVendedor()); vendedorParcela.set_CoCorretagem(x.First().get_CoCorretagem()); return vendedorParcela; } else { valorTotal = null; valorRepasse = valorTotal; vendedorParcela.set_ValorTotal(valorRepasse); vendedorParcela.set_Vendedor(x.First().get_Vendedor()); vendedorParcela.set_PorcentagemRepasse(x.First().get_PorcentagemRepasse()); vendedorParcela.set_TipoVendedor(x.First().get_TipoVendedor()); vendedorParcela.set_CoCorretagem(x.First().get_CoCorretagem()); return vendedorParcela; } } Label1: num = comissao; valorTotal = x.First().get_PorcentagemRepasse(); valorRepasse = (valorTotal.HasValue ? new decimal?((num * valorTotal.GetValueOrDefault()) * new decimal(1, 0, 0, false, 2)) : null); } else { valorRepasse = x.First().get_ValorRepasse(); } vendedorParcela.set_ValorTotal(valorRepasse); vendedorParcela.set_Vendedor(x.First().get_Vendedor()); vendedorParcela.set_PorcentagemRepasse(x.First().get_PorcentagemRepasse()); vendedorParcela.set_TipoVendedor(x.First().get_TipoVendedor()); vendedorParcela.set_CoCorretagem(x.First().get_CoCorretagem()); return vendedorParcela; }).ToList(); parcelas1 = (parcelas != null ? parcelas.Where((Parcela x) => { if (x.get_SubTipo() != 1) { return false; } return x.get_NumeroParcela() < this.parcela.get_NumeroParcela(); }).ToList() : new List()); List parcelas3 = parcelas1; list2.ForEach((VendedorParcela y) => { VendedorParcela vendedorParcela = y; decimal? valorTotal = y.get_ValorTotal(); IEnumerable vendedorParcelas = repasses.Where((VendedorParcela x) => { bool valueOrDefault; if (x.get_Parcela().get_SubTipo() == 1) { Repasse repasse = x.get_Repasse(); valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false); if (valueOrDefault && x.get_Vendedor().get_Id() == y.get_Vendedor().get_Id()) { List cSu0024u003cu003e8_locals2 = parcelas3; Func u003cu003e9_912 = Funcoes.u003cu003ec.u003cu003e9__9_12; if (u003cu003e9_912 == null) { u003cu003e9_912 = (Parcela z) => z.get_Id(); Funcoes.u003cu003ec.u003cu003e9__9_12 = u003cu003e9_912; } return cSu0024u003cu003e8_locals2.Select(u003cu003e9_912).ToList().Contains(x.get_Parcela().get_Id()); } } return false; }); Func u003cu003e9_911 = Funcoes.u003cu003ec.u003cu003e9__9_11; if (u003cu003e9_911 == null) { u003cu003e9_911 = (VendedorParcela x) => x.get_ValorRepasse(); Funcoes.u003cu003ec.u003cu003e9__9_11 = u003cu003e9_911; } decimal? nullable = vendedorParcelas.Sum(u003cu003e9_911); vendedorParcela.set_ValorRepasse((valorTotal.HasValue & nullable.HasValue ? new decimal?(valorTotal.GetValueOrDefault() - nullable.GetValueOrDefault()) : null)); }); parcelas2 = (parcelas != null ? parcelas.Where((Parcela x) => { if (x.get_SubTipo() != 1) { return false; } return x.get_NumeroParcela() > this.parcela.get_NumeroParcela(); }).ToList() : new List()); List list3 = parcelas2; list3.Add(parcela2); List vendedorParcelas3 = repasses.Where((VendedorParcela x) => { bool valueOrDefault; if (x.get_Parcela().get_SubTipo() == 1) { Repasse repasse = x.get_Repasse(); valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false); if (valueOrDefault) { if (x.get_Parcela().get_NumeroParcela() >= this.parcela.get_NumeroParcela()) { return true; } return !x.get_DataPrePagamento().HasValue; } } return false; }).ToList(); if (!await parcelaServico1.DeletePagamentoRange(vendedorParcelas3)) { await Funcoes.MostrarErro(191); parcela1 = parcela2; variable = null; parcelaServico1 = null; parcelaServico = null; vendedorServico = null; return parcela1; } else if (await parcelaServico1.SaveRange(list2)) { List parcelas4 = list3; list3 = parcelas4.Where((Parcela dParcela) => { if (dParcela.get_ValorComissao() != decimal.Zero || dParcela.get_ValorComissao() != decimal.Zero || dParcela.get_DataRecebimento().HasValue || dParcela.get_DataCredito().HasValue) { return true; } return dParcela.get_ValorRealizado() != decimal.Zero; }).ToList(); if (list3 != null && list3.Count > 0) { list3.ForEach((Parcela dParcela) => { dParcela.set_Documento(this.parcela.get_Documento()); dParcela.set_ValorComissao(decimal.Zero); dParcela.set_ValorComDesconto(decimal.Zero); DateTime? nullable = null; dParcela.set_DataRecebimento(nullable); nullable = null; dParcela.set_DataCredito(nullable); dParcela.set_ValorRealizado(decimal.Zero); }); list3 = await parcelaServico1.UpdateRange(list3); if (parcelaServico1.Sucesso) { parcela2 = list3.FirstOrDefault((Parcela x) => x.get_Id() == this.parcela.get_Id()); } else { await Funcoes.MostrarErro(191); parcela1 = parcela2; variable = null; parcelaServico1 = null; parcelaServico = null; vendedorServico = null; return parcela1; } } list2 = null; list3 = null; } else { await Funcoes.MostrarErro(191); parcela1 = parcela2; variable = null; parcelaServico1 = null; parcelaServico = null; vendedorServico = null; return parcela1; } } ApoliceServico apoliceServico = new ApoliceServico(); parcelaServico = new ParcelaServico(); vendedorServico = new VendedorServico(); if (parcela2 != null) { Documento documento = await apoliceServico.BuscarApoliceAsync(parcela2.get_Documento().get_Id(), false, false); Documento documento1 = documento; ObservableCollection observableCollection = await parcelaServico.BuscarParcelasAsync(documento.get_Id()); documento1.set_Parcelas(observableCollection); documento1 = null; List vendedorParcelas4 = await vendedorServico.BuscaRepasse(documento.get_Id()); foreach (Parcela parcela4 in documento.get_Parcelas()) { foreach (VendedorParcela vendedorParcela5 in vendedorParcelas4) { if (vendedorParcela5.get_Parcela().get_Id() != parcela4.get_Id()) { continue; } if (parcela4.get_Vendedores() == null) { parcela4.set_Vendedores(new ObservableCollection()); } parcela4.get_Vendedores().Add(vendedorParcela5); } } IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); RegistroLog registroLog = new RegistroLog(); registroLog.set_Acao(2); registroLog.set_Usuario(Recursos.Usuario); registroLog.set_DataHora(Funcoes.GetNetworkTime()); Documento documento2 = documento; JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); jsonSerializerSetting.set_ReferenceLoopHandling(1); registroLog.set_Descricao(JsonConvert.SerializeObject(documento2, jsonSerializerSetting)); registroLog.set_EntidadeId(documento.get_Id()); registroLog.set_Tela(2); registroLog.set_NomeMaquina(Environment.MachineName); registroLog.set_UsuarioMaquina(Environment.UserName); IPAddress[] addressList = hostEntry.AddressList; IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); if (pAddress != null) { str = pAddress.ToString(); } else { str = null; } registroLog.set_Ip(str); RegistroLog registroLog1 = registroLog; await Task.Run(() => { using (UnitOfWork commited = Instancia.Commited) { commited.get_RegistroLogRepository().SaveOrUpdate(registroLog1); commited.Commit(); } }); documento = null; } parcela1 = parcela2; variable = null; parcelaServico1 = null; parcelaServico = null; vendedorServico = null; return parcela1; } public static async Task ExcluirPagamento(VendedorParcela pagamento) { pagamento.set_DataPagamento(null); ParcelaServico parcelaServico = new ParcelaServico() { Sucesso = true }; await parcelaServico.Save(pagamento); bool sucesso = parcelaServico.Sucesso; parcelaServico = null; return sucesso; } public static string ExportarHtml(TipoRelatorio tipo, string dados, string porcentagem = "60", string orientation = "landscape", bool search = false, string grafico = "") { string str = string.Format("DATA DE EMISSÃO DO RELATÓRIO EM {0:G}", Funcoes.GetNetworkTime()); if (tipo.get_Inicio() != DateTime.MinValue && tipo.get_Nome() != "RELATÓRIO DE CLIENTE") { str = string.Format("PERÍODO DE {0:d} ATÉ {1:d}. DATA DE EMISSÃO DO RELATÓRIO EM {2:G}", tipo.get_Inicio(), tipo.get_Fim(), Funcoes.GetNetworkTime()); } string str1 = (!search ? "" : ""); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Resources.RelatorioTemplate.Replace("{style}", str1).Replace("Orientation", orientation).Replace("{NomeRelatorio}", string.Concat(Recursos.Empresa.get_NomeSocial(), " - ", tipo.get_Nome())).Replace("{EmissaoRelatorio}", str).Replace("{Grafico}", grafico).Replace("{DadosRelatorio}", dados)); return stringBuilder.ToString(); } public static string ExportarMultipleHtml(TipoRelatorio tipo, string dados, string porcentagem = "60", string orientation = "landscape", bool search = false, string grafico = "") { string str = string.Format("DATA DE EMISSÃO DO RELATÓRIO EM {0:G}", Funcoes.GetNetworkTime()); if (tipo.get_Inicio() != DateTime.MinValue && tipo.get_Nome() != "RELATÓRIO DE CLIENTE") { str = string.Format("PERÍODO DE {0:d} ATÉ {1:d}. DATA DE EMISSÃO DO RELATÓRIO EM {2:G}", tipo.get_Inicio(), tipo.get_Fim(), Funcoes.GetNetworkTime()); } string str1 = (!search ? "" : ""); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Resources.RelatorioMultipleTemplate.Replace("{style}", str1).Replace("Orientation", orientation).Replace("{NomeRelatorio}", string.Concat(Recursos.Empresa.get_NomeSocial(), " - ", tipo.get_Nome())).Replace("{EmissaoRelatorio}", str).Replace("{Grafico}", grafico).Replace("{DadosRelatorio}", dados)); return stringBuilder.ToString(); } public static async Task GenerateMultipleTable(List> analiticos, List colunasOcultas, bool grafico = false, bool propertyName = false, string footer = "", ConfiguracaoImpressao config = null) { string str4; string str5; Action action2 = null; if (analiticos == null) { str4 = ""; } else if (analiticos.Count != 0) { int tamanhoFonte = 0; if (config != null) { tamanhoFonte = config.get_TamanhoFonte(); } str5 = (tamanhoFonte == 0 ? "" : string.Format("fs-{0}'", tamanhoFonte)); string str6 = str5; str4 = await Task.Run(() => { StringBuilder stringBuilder2 = new StringBuilder(); int num = 0; foreach (List analitico in analiticos) { StringBuilder stringBuilder3 = new StringBuilder(); StringBuilder stringBuilder4 = new StringBuilder(); StringBuilder stringBuilder5 = new StringBuilder(); int num1 = 0; stringBuilder4.Append(Resources.HeaderTemplate.Replace("{Align}", "text-start").Replace("{Size}", "").Replace("{FontWeight}", "fw-bold").Replace("{Content}", analitico[0].get_NomeRelatorio())); stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", "")); List listagems = analitico; Action u003cu003e9_1 = action2; if (u003cu003e9_1 == null) { Action action = (Listagem x) => { Sinal sinal; string str; char chr; string str1; PropertyInfo[] properties = x.GetType().GetProperties(); Func u003cu003e9_222 = Funcoes.u003cu003ec.u003cu003e9__22_2; if (u003cu003e9_222 == null) { u003cu003e9_222 = (PropertyInfo b) => b.Name == "Bold"; Funcoes.u003cu003ec.u003cu003e9__22_2 = u003cu003e9_222; } PropertyInfo propertyInfo = ((IEnumerable)properties).FirstOrDefault(u003cu003e9_222); bool flag = (propertyInfo == null ? false : (bool)propertyInfo.GetValue(x)); Func u003cu003e9_223 = Funcoes.u003cu003ec.u003cu003e9__22_3; if (u003cu003e9_223 == null) { u003cu003e9_223 = (PropertyInfo b) => b.Name == "Sinal"; Funcoes.u003cu003ec.u003cu003e9__22_3 = u003cu003e9_223; } PropertyInfo propertyInfo1 = ((IEnumerable)properties).FirstOrDefault(u003cu003e9_223); string str2 = (!(propertyInfo1 != null) || propertyInfo1.GetValue(x) == null || !Enum.TryParse(propertyInfo1.GetValue(x).ToString(), true, out sinal) || sinal != 1 ? "color: black;" : "color: red;"); if (flag) { string.Concat(""); } else { string.Concat(""); } StringBuilder stringBuilder = new StringBuilder(); PropertyInfo[] propertyInfoArray = properties; for (int i = 0; i < (int)propertyInfoArray.Length; i++) { PropertyInfo propertyInfo2 = propertyInfoArray[i]; if (propertyInfo2.Name != "ValidationEvent") { object obj = propertyInfo2.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); if (obj != null) { string description = ((DescriptionAttribute)obj).Description; if ((!propertyName || !colunasOcultas.Contains(propertyInfo2.Name)) && (propertyName || !colunasOcultas.Contains(description))) { object obj1 = propertyInfo2.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault(); string description1 = ""; if (obj1 != null) { description1 = ((TipoAttribute)obj1).get_Description(); } string str3 = "text-start"; if (description1 != null) { switch (description1.Length) { case 4: { chr = description1[0]; if (chr == 'D') { if (description1 == "DATA") { str3 = "text-center"; str = (propertyInfo2.GetValue(x) == null || (DateTime)propertyInfo2.GetValue(x) == DateTime.MinValue ? "" : string.Format("{0:d}", (DateTime)propertyInfo2.GetValue(x))); goto Label0; } else { goto Label1; } } else if (chr != 'E') { goto Label1; } else if (description1 == "ENUM") { str = (propertyInfo2.GetValue(x) != null ? Gestor.Common.Validation.ValidationHelper.GetDescription((Enum)propertyInfo2.GetValue(x)) ?? "" : ""); goto Label0; } else { goto Label1; } } case 5: { chr = description1[0]; if (chr == 'D') { if (description1 == "DATA?") { str3 = "text-center"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:d}", (DateTime?)propertyInfo2.GetValue(x)) : ""); goto Label0; } else { goto Label1; } } else if (chr != 'V') { goto Label1; } else if (description1 == "VALOR") { str3 = "text-end"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal)propertyInfo2.GetValue(x)) : ""); goto Label0; } else { goto Label1; } } case 6: { if (description1 != "VALOR?") { goto Label1; } str3 = "text-end"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal?)propertyInfo2.GetValue(x)) : ""); goto Label0; } case 9: { if (description1 == "DATA/TIME") { break; } goto Label1; } case 10: { chr = description1[0]; if (chr == 'D') { if (description1 == "DATA/TIME?") { break; } goto Label1; } else if (chr == 'P') { if (description1 == "PERCENTUAL") { str3 = "text-end"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:p2}", (decimal)propertyInfo2.GetValue(x) * new decimal(1, 0, 0, false, 2)) : ""); goto Label0; } else { goto Label1; } } else if (chr != 'Q') { goto Label1; } else if (description1 == "QUANTIDADE") { str3 = "text-center"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : ""); goto Label0; } else { goto Label1; } } default: { goto Label1; } } str3 = "text-center"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:G}", (DateTime?)propertyInfo2.GetValue(x)) : ""); goto Label0; } Label1: str1 = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : ""); str = str1; Label0: StringBuilder stringBuilder1 = stringBuilder; stringBuilder1.Append(Resources.ColumnTemplate.Replace("{Align}", str3).Replace("{Size}", str6).Replace("{FontWeight}", (flag ? "fw-bold" : "")).Replace("{Content}", str)); } } } } }; Action action1 = action; action2 = action; u003cu003e9_1 = action1; } listagems.ForEach(u003cu003e9_1); StringBuilder stringBuilder6 = new StringBuilder(); if (grafico) { stringBuilder5.Append(string.Format("
", num)); } num++; stringBuilder6.Append(Resources.TableMultipleTemplate.Replace("{Head}", stringBuilder3.ToString()).Replace("{Body}", stringBuilder5.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer) ? Resources.FooterTemplate.Replace("{Content}", string.Format("{1}", num1, footer)) : ""))); stringBuilder2.Append(stringBuilder6.ToString()); } return stringBuilder2.ToString(); }); } else { str4 = ""; } return str4; } public static async Task GenerateTable(List analitico, List colunasOcultas, bool grafico = false, bool propertyName = false, string footer = "", ConfiguracaoImpressao config = null) { string str7; string str8; if (analitico == null) { str7 = ""; } else if (analitico.Count != 0) { int tamanhoFonte = 0; if (config != null) { tamanhoFonte = config.get_TamanhoFonte(); } str8 = (tamanhoFonte == 0 ? "" : string.Format("fs-{0}'", tamanhoFonte)); string str9 = str8; str7 = await Task.Run(() => { StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); StringBuilder stringBuilder4 = new StringBuilder(); Type type = analitico[0].GetType(); PropertyInfo[] properties = type.GetProperties(); int num = 0; PropertyInfo[] propertyInfoArray3 = properties; for (int i1 = 0; i1 < (int)propertyInfoArray3.Length; i1++) { PropertyInfo propertyInfo3 = propertyInfoArray3[i1]; if (propertyInfo3.Name != "ValidationEvent") { object obj2 = propertyInfo3.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); if (obj2 != null) { string str4 = ((DescriptionAttribute)obj2).Description; if ((!propertyName || !colunasOcultas.Contains(propertyInfo3.Name)) && (propertyName || !colunasOcultas.Contains(str4))) { object obj3 = propertyInfo3.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault(); string str5 = ""; if (obj3 != null) { str5 = ((TipoAttribute)obj3).get_Description(); } string str6 = "text-start"; if (str5 == "PERCENTUAL" || str5 == "VALOR") { str6 = "text-center"; } else if (str5 == "QUANTIDADE" || str5 == "DATA") { str6 = "text-end"; } stringBuilder3.Append(Resources.HeaderTemplate.Replace("{Align}", str6).Replace("{Size}", str9).Replace("{FontWeight}", "fw-bold").Replace("{Content}", str4)); num++; } } } } stringBuilder2.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder3.ToString()).Replace("{Color}", "")); analitico.ForEach((T x) => { Sinal sinal; string str; char chr; string str1; type = x.GetType(); properties = type.GetProperties(); PropertyInfo[] propertyInfoArray = properties; Func u003cu003e9_212 = Funcoes.u003cu003ec__21.u003cu003e9__21_2; if (u003cu003e9_212 == null) { u003cu003e9_212 = (PropertyInfo b) => b.Name == "Bold"; Funcoes.u003cu003ec__21.u003cu003e9__21_2 = u003cu003e9_212; } PropertyInfo propertyInfo = ((IEnumerable)propertyInfoArray).FirstOrDefault(u003cu003e9_212); bool flag = (propertyInfo == null ? false : (bool)propertyInfo.GetValue(x)); PropertyInfo[] propertyInfoArray1 = properties; Func u003cu003e9_213 = Funcoes.u003cu003ec__21.u003cu003e9__21_3; if (u003cu003e9_213 == null) { u003cu003e9_213 = (PropertyInfo b) => b.Name == "Sinal"; Funcoes.u003cu003ec__21.u003cu003e9__21_3 = u003cu003e9_213; } PropertyInfo propertyInfo1 = ((IEnumerable)propertyInfoArray1).FirstOrDefault(u003cu003e9_213); string str2 = (!(propertyInfo1 != null) || propertyInfo1.GetValue(x) == null || !Enum.TryParse(propertyInfo1.GetValue(x).ToString(), true, out sinal) || sinal != 1 ? "color: black;" : "color: red;"); if (flag) { string.Concat(""); } else { string.Concat(""); } StringBuilder stringBuilder = new StringBuilder(); PropertyInfo[] propertyInfoArray2 = properties; for (int i = 0; i < (int)propertyInfoArray2.Length; i++) { PropertyInfo propertyInfo2 = propertyInfoArray2[i]; if (propertyInfo2.Name != "ValidationEvent") { object obj = propertyInfo2.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); if (obj != null) { string description = ((DescriptionAttribute)obj).Description; if ((!propertyName || !colunasOcultas.Contains(propertyInfo2.Name)) && (propertyName || !colunasOcultas.Contains(description))) { object obj1 = propertyInfo2.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault(); string description1 = ""; if (obj1 != null) { description1 = ((TipoAttribute)obj1).get_Description(); } string str3 = "text-start"; if (description1 != null) { switch (description1.Length) { case 4: { chr = description1[0]; if (chr == 'D') { if (description1 == "DATA") { str3 = "text-center"; str = (propertyInfo2.GetValue(x) == null || (DateTime)propertyInfo2.GetValue(x) == DateTime.MinValue ? "" : string.Format("{0:d}", (DateTime)propertyInfo2.GetValue(x))); goto Label0; } else { goto Label1; } } else if (chr != 'E') { goto Label1; } else if (description1 == "ENUM") { str = (propertyInfo2.GetValue(x) != null ? Gestor.Common.Validation.ValidationHelper.GetDescription((Enum)propertyInfo2.GetValue(x)) ?? "" : ""); goto Label0; } else { goto Label1; } } case 5: { chr = description1[0]; if (chr == 'D') { if (description1 == "DATA?") { str3 = "text-center"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:d}", (DateTime?)propertyInfo2.GetValue(x)) : ""); goto Label0; } else { goto Label1; } } else if (chr != 'V') { goto Label1; } else if (description1 == "VALOR") { str3 = "text-end"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal)propertyInfo2.GetValue(x)) : ""); goto Label0; } else { goto Label1; } } case 6: { if (description1 != "VALOR?") { goto Label1; } str3 = "text-end"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal?)propertyInfo2.GetValue(x)) : ""); goto Label0; } case 9: { if (description1 == "DATA/TIME") { break; } goto Label1; } case 10: { chr = description1[0]; if (chr == 'D') { if (description1 == "DATA/TIME?") { break; } goto Label1; } else if (chr == 'P') { if (description1 == "PERCENTUAL") { str3 = "text-end"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:p2}", (decimal)propertyInfo2.GetValue(x) * new decimal(1, 0, 0, false, 2)) : ""); goto Label0; } else { goto Label1; } } else if (chr != 'Q') { goto Label1; } else if (description1 == "QUANTIDADE") { str3 = "text-center"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : ""); goto Label0; } else { goto Label1; } } case 13: { if (description1 == "VALORDECIMAL2") { str3 = "text-end"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:n2}", (decimal)propertyInfo2.GetValue(x)) : ""); goto Label0; } else { goto Label1; } } default: { goto Label1; } } str3 = "text-center"; str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:G}", (DateTime?)propertyInfo2.GetValue(x)) : ""); goto Label0; } Label1: str1 = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : ""); str = str1; Label0: StringBuilder stringBuilder1 = stringBuilder; stringBuilder1.Append(Resources.ColumnTemplate.Replace("{Align}", str3).Replace("{Size}", str9).Replace("{FontWeight}", (flag ? "fw-bold" : "")).Replace("{Content}", str)); } } } } stringBuilder4.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder.ToString()).Replace("{Color}", string.Concat("style='", str2, "'"))); }); StringBuilder stringBuilder5 = new StringBuilder(); if (grafico) { stringBuilder4.Append(""); stringBuilder4.Append("
"); stringBuilder4.Append("
*VALORES NEGATIVOS NÃO SÃO REPRESENTADOS NO GRÁFICO DE PIZZA.
"); stringBuilder4.Append(""); } stringBuilder5.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder2.ToString()).Replace("{Body}", stringBuilder4.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer) ? Resources.FooterTemplate.Replace("{Content}", string.Format("{1}", num, footer)) : ""))); return stringBuilder5.ToString(); }); } else { str7 = ""; } return str7; } public static async Task GenerateTable(List analitico, Relatorio relatorio, bool grafico = false, bool verificarColunas = true, string footer = "", ConfiguracaoImpressao config = null) { string str6; List restricoesColunas; string str7; List campos; int tamanhoFonte = 0; if (config != null) { campos = config.get_Campos(); tamanhoFonte = config.get_TamanhoFonte(); } else { if (!verificarColunas) { restricoesColunas = null; } else { restricoesColunas = await (new ConfuguracoesServico()).BuscarParametros(relatorio); } campos = restricoesColunas; if (campos == null || campos.Count == 0) { PropertyInfo[] propertyInfoArray2 = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public); campos = propertyInfoArray2.Select((PropertyInfo x) => { ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio(); parametrosRelatorio.set_Campo(x.Name); parametrosRelatorio.set_Header(x.GetDescriptionAttribute()); parametrosRelatorio.set_Tipo(x.GetTypeAttribute()); parametrosRelatorio.set_Relatorio(relatorio); parametrosRelatorio.set_Width(0); parametrosRelatorio.set_Ordem(0); return parametrosRelatorio; }).ToList(); } } str7 = (tamanhoFonte == 0 ? "" : string.Format("fs-{0}'", tamanhoFonte)); string str8 = str7; restricoesColunas = await Funcoes.GetRestricoesColunas(campos); campos = restricoesColunas; if (analitico == null) { str6 = ""; } else if (analitico.Count != 0) { str6 = await Task.Run(() => { StringBuilder stringBuilder3 = new StringBuilder(); StringBuilder stringBuilder4 = new StringBuilder(); StringBuilder stringBuilder5 = new StringBuilder(); Type type = analitico[0].GetType(); PropertyInfo[] properties = type.GetProperties(); int num = 0; List parametrosRelatorios1 = campos; Func u003cu003e9_242 = Funcoes.u003cu003ec__24.u003cu003e9__24_2; if (u003cu003e9_242 == null) { u003cu003e9_242 = (ParametrosRelatorio x) => x.get_Ordem(); Funcoes.u003cu003ec__24.u003cu003e9__24_2 = u003cu003e9_242; } IOrderedEnumerable parametrosRelatorios2 = parametrosRelatorios1.OrderBy(u003cu003e9_242); Func u003cu003e9_243 = Funcoes.u003cu003ec__24.u003cu003e9__24_3; if (u003cu003e9_243 == null) { u003cu003e9_243 = (ParametrosRelatorio x) => x.get_Header(); Funcoes.u003cu003ec__24.u003cu003e9__24_3 = u003cu003e9_243; } ExtensionMethods.ForEach(parametrosRelatorios2.ThenBy(u003cu003e9_243), (ParametrosRelatorio x) => { if (x.get_Tipo() == "INVALID") { return; } PropertyInfo propertyInfo = properties.FirstOrDefault((PropertyInfo p) => p.Name == x.get_Campo()); if (propertyInfo == null) { return; } string descriptionAttribute = propertyInfo.GetDescriptionAttribute(); string str = "text-start"; string tipo = x.get_Tipo(); if (tipo == "PERCENTUAL" || tipo == "VALOR") { str = "text-center"; } else if (tipo == "QUANTIDADE" || tipo == "DATA") { str = "text-end"; } stringBuilder4.Append(Resources.HeaderTemplate.Replace("{Align}", str).Replace("{Size}", str8).Replace("{FontWeight}", "fw-bold").Replace("{Content}", descriptionAttribute)); num++; }); stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", "")); analitico.ForEach((T a) => { Sinal sinal; StringBuilder stringBuilder2 = new StringBuilder(); type = a.GetType(); properties = type.GetProperties(); PropertyInfo[] propertyInfoArray = properties; Func u003cu003e9_247 = Funcoes.u003cu003ec__24.u003cu003e9__24_7; if (u003cu003e9_247 == null) { u003cu003e9_247 = (PropertyInfo b) => b.Name == "Bold"; Funcoes.u003cu003ec__24.u003cu003e9__24_7 = u003cu003e9_247; } PropertyInfo propertyInfo1 = ((IEnumerable)propertyInfoArray).FirstOrDefault(u003cu003e9_247); bool flag = (propertyInfo1 == null ? false : (bool)propertyInfo1.GetValue(a)); PropertyInfo[] propertyInfoArray1 = properties; Func u003cu003e9_248 = Funcoes.u003cu003ec__24.u003cu003e9__24_8; if (u003cu003e9_248 == null) { u003cu003e9_248 = (PropertyInfo b) => b.Name == "Sinal"; Funcoes.u003cu003ec__24.u003cu003e9__24_8 = u003cu003e9_248; } PropertyInfo propertyInfo2 = ((IEnumerable)propertyInfoArray1).FirstOrDefault(u003cu003e9_248); string str5 = (!(propertyInfo2 != null) || propertyInfo2.GetValue(a) == null || !Enum.TryParse(propertyInfo2.GetValue(a).ToString(), true, out sinal) || sinal != 1 ? "color: black;" : "color: red;"); if (flag) { string.Concat(""); } else { string.Concat(""); } List cSu0024u003cu003e8_locals1 = campos; Func u003cu003e9_249 = Funcoes.u003cu003ec__24.u003cu003e9__24_9; if (u003cu003e9_249 == null) { u003cu003e9_249 = (ParametrosRelatorio x) => x.get_Ordem(); Funcoes.u003cu003ec__24.u003cu003e9__24_9 = u003cu003e9_249; } IOrderedEnumerable parametrosRelatorios = cSu0024u003cu003e8_locals1.OrderBy(u003cu003e9_249); Func u003cu003e9_2410 = Funcoes.u003cu003ec__24.u003cu003e9__24_10; if (u003cu003e9_2410 == null) { u003cu003e9_2410 = (ParametrosRelatorio x) => x.get_Header(); Funcoes.u003cu003ec__24.u003cu003e9__24_10 = u003cu003e9_2410; } ExtensionMethods.ForEach(parametrosRelatorios.ThenBy(u003cu003e9_2410), (ParametrosRelatorio x) => { string str; char chr; string str1; string str2; string str3; StringBuilder stringBuilder; StringBuilder stringBuilder1; if (x.get_Tipo() == "INVALID") { return; } PropertyInfo propertyInfo = properties.FirstOrDefault((PropertyInfo p) => p.Name == x.get_Campo()); if (propertyInfo == null) { return; } string str4 = "text-start"; string tipo = x.get_Tipo(); if (tipo != null) { switch (tipo.Length) { case 4: { chr = tipo[0]; if (chr == 'D') { if (tipo == "DATA") { str4 = "text-center"; str = (propertyInfo.GetValue(a) == null || (DateTime)propertyInfo.GetValue(a) == DateTime.MinValue ? "" : string.Format("{0:d}", (DateTime)propertyInfo.GetValue(a))); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } else if (chr != 'E') { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else if (tipo == "ENUM") { str = (propertyInfo.GetValue(a) == null || Convert.ToInt32(propertyInfo.GetValue(a)) == 0 ? "" : Gestor.Common.Validation.ValidationHelper.GetDescription((Enum)propertyInfo.GetValue(a)) ?? ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } case 5: { chr = tipo[0]; if (chr == 'D') { if (tipo == "DATA?") { str4 = "text-center"; str = (propertyInfo.GetValue(a) != null ? string.Format("{0:d}", (DateTime?)propertyInfo.GetValue(a)) : ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } else if (chr != 'V') { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else if (tipo == "VALOR") { str4 = "text-end"; str = (propertyInfo.GetValue(a) != null ? string.Format("{0:c2}", (decimal)propertyInfo.GetValue(a)) : ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } case 6: { if (tipo != "VALOR?") { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } str4 = "text-end"; str = (propertyInfo.GetValue(a) != null ? string.Format("{0:c2}", (decimal?)propertyInfo.GetValue(a)) : ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } case 7: case 8: case 11: case 12: { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } case 9: { if (tipo == "DATA/TIME") { break; } str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } case 10: { chr = tipo[0]; if (chr == 'D') { if (tipo == "DATA/TIME?") { break; } str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else if (chr == 'P') { if (tipo == "PERCENTUAL") { str4 = "text-end"; str = (propertyInfo.GetValue(a) != null ? string.Format("{0:p2}", (decimal)propertyInfo.GetValue(a) * new decimal(1, 0, 0, false, 2)) : ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } else if (chr != 'Q') { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else if (tipo == "QUANTIDADE") { str4 = "text-center"; str = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } case 13: { if (tipo == "VALORDECIMAL2") { str4 = "text-end"; str = (propertyInfo.GetValue(a) != null ? string.Format("{0:n2}", (decimal)propertyInfo.GetValue(a)) : ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } else { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } default: { str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } } str4 = "text-center"; str = (propertyInfo.GetValue(a) != null ? string.Format("{0:G}", (DateTime?)propertyInfo.GetValue(a)) : ""); stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); return; } str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : ""); str = str1; stringBuilder = stringBuilder2; str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8); str3 = (flag ? "fw-bold" : ""); stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str)); }); stringBuilder5.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder2.ToString()).Replace("{Color}", string.Concat("style='", str5, "'"))); }); StringBuilder stringBuilder6 = new StringBuilder(); stringBuilder6.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder3.ToString()).Replace("{Body}", stringBuilder5.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer) ? Resources.FooterTemplate.Replace("{Content}", string.Format("{1}", num, footer)) : ""))); return stringBuilder6.ToString(); }); } else { str6 = ""; } return str6; } public static async Task GenerateTableSintetic(List sintetic, int fontSize = 0) { string str; string str1; if (sintetic == null || sintetic.Count == 0) { str = ""; } else { str1 = (fontSize == 0 ? "" : string.Format("fs-{0}'", fontSize)); string str2 = str1; str = await Task.Run(() => { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder1 = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); StringBuilder stringBuilder4 = new StringBuilder(); sintetic.ForEach((SinteticModel x) => { stringBuilder2.Append(Resources.HeaderTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", "fw-bold").Replace("{Content}", x.get_Hint())); stringBuilder4.Append(Resources.ColumnTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", "").Replace("{Content}", (x.get_Value() == null ? "" : x.get_Value().ToString()))); }); stringBuilder1.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder2.ToString()).Replace("{Color}", "")); stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", "")); stringBuilder.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder1.ToString()).Replace("{Body}", stringBuilder3.ToString()).Replace("{Footer}", "")); return stringBuilder.ToString(); }); } return str; } public static async Task GenerateTableSintetic(List sintetic, int fontSize = 0) { string str; string str1; if (sintetic == null || sintetic.Count == 0) { str = ""; } else { str1 = (fontSize == 0 ? "" : string.Format("fs-{0}'", fontSize)); string str2 = str1; str = await Task.Run(() => { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder1 = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); sintetic.ForEach((SinteticModelList x) => stringBuilder2.Append(Resources.HeaderTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", "fw-bold").Replace("{Content}", x.get_Hint()))); stringBuilder1.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder2.ToString()).Replace("{Color}", "")); for (int i = 0; i < sintetic.First().get_Value().Count; i++) { StringBuilder stringBuilder4 = new StringBuilder(); bool flag = false; foreach (SinteticModelList sinteticModelList in sintetic) { flag = (flag ? true : (sinteticModelList.get_Value()[0] == null ? false : sinteticModelList.get_Value()[i].ToString() == "TOTAL")); stringBuilder4.Append(Resources.ColumnTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", (flag ? "fw-bold" : "")).Replace("{Content}", string.Format("{0}", sinteticModelList.get_Value()[i]))); } stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", "")); } stringBuilder.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder1.ToString()).Replace("{Body}", stringBuilder3.ToString()).Replace("{Footer}", "")); return stringBuilder.ToString(); }); } return str; } public static string GeraAssistencia(this long id) { string str; try { DateTime now = DateTime.Now; str = HttpUtility.UrlEncode(string.Format("{0}:{1}:A:{2}", now.Ticks, ApplicationHelper.IdFornecedor, id).Base64Encode()); } catch { return ""; } return str; } public static string GeraCartaoVisita(this long id) { string str; try { DateTime now = DateTime.Now; str = HttpUtility.UrlEncode(string.Format("{0}:{1}:V:{2}", now.Ticks, ApplicationHelper.IdFornecedor, id).Base64Encode()); } catch { return ""; } return str; } public static async Task GerarCsv(List Conteudo, IEnumerable colunasExportacao) { PropertyInfo[] array = ( from in typeof(T).GetProperties() where colunasExportacao.Contains(p.Name) select ).ToArray(); StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder1 = stringBuilder; PropertyInfo[] propertyInfoArray = array; stringBuilder1.AppendLine(string.Join(";", from in (IEnumerable)propertyInfoArray select p.Name)); foreach (T conteudo in Conteudo) { IEnumerable strs = array.Select((PropertyInfo p) => { object str; object value = p.GetValue(conteudo, null); if (value != null) { str = value.ToString(); } else { str = null; } if (str == null) { str = string.Empty; } return str; }); stringBuilder.AppendLine(string.Join(";", strs)); } return stringBuilder.ToString(); } public static string GerarGrafico(List sinteticoLista) { string str = "['NOME', 'VALOR'], "; sinteticoLista.ForEach((ValorSintetico x) => { if (x.get_Indice() != "TOTAL" && x.get_Valor() > decimal.Zero) { string[] indice = new string[] { str, "[`", x.get_Indice(), " ", x.get_Porcentagem(), "`, ", null, null }; indice[6] = x.get_Valor().ToString("F2", CultureInfo.InvariantCulture); indice[7] = "], "; str = string.Concat(indice); } }); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(""); stringBuilder.Append(""); return stringBuilder.ToString(); } public static string GerarGraficoUnico(List> sinteticosListas) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(""); stringBuilder.Append(""); return stringBuilder.ToString(); } public static async Task GerarXls(XLWorkbook xlWorkbook, string nome, List analitico, Relatorio relatorio, bool verificarColunas = true) { List restricoesColunas; string str = nome; str = str.ValidaNomePlanilha("", 0); if (!verificarColunas) { restricoesColunas = null; } else { restricoesColunas = await (new ConfuguracoesServico()).BuscarParametros(relatorio); } List list = restricoesColunas; if (list == null || list.Count == 0) { PropertyInfo[] propertyInfoArray = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public); list = propertyInfoArray.Select((PropertyInfo x) => { ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio(); parametrosRelatorio.set_Campo(x.Name); parametrosRelatorio.set_Header(x.GetDescriptionAttribute()); parametrosRelatorio.set_Tipo(x.GetTypeAttribute()); parametrosRelatorio.set_Relatorio(relatorio); parametrosRelatorio.set_Width(0); parametrosRelatorio.set_Ordem(0); return parametrosRelatorio; }).ToList(); } restricoesColunas = await Funcoes.GetRestricoesColunas(list); list = restricoesColunas; XLWorkbook xLWorkbook1 = await Task.Run(() => { XLWorkbook xLWorkbook; try { IXLWorksheet xLWorksheet = xlWorkbook.get_Worksheets().Add(str); PropertyInfo[] properties = analitico[0].GetType().GetProperties(); int num1 = 1; List parametrosRelatorios1 = list; Func u003cu003e9_252 = Funcoes.u003cu003ec__25.u003cu003e9__25_2; if (u003cu003e9_252 == null) { u003cu003e9_252 = (ParametrosRelatorio x) => x.get_Ordem(); Funcoes.u003cu003ec__25.u003cu003e9__25_2 = u003cu003e9_252; } IOrderedEnumerable parametrosRelatorios2 = parametrosRelatorios1.OrderBy(u003cu003e9_252); Func u003cu003e9_253 = Funcoes.u003cu003ec__25.u003cu003e9__25_3; if (u003cu003e9_253 == null) { u003cu003e9_253 = (ParametrosRelatorio x) => x.get_Header(); Funcoes.u003cu003ec__25.u003cu003e9__25_3 = u003cu003e9_253; } ExtensionMethods.ForEach(parametrosRelatorios2.ThenBy(u003cu003e9_253), (ParametrosRelatorio x) => { if (x.get_Tipo() == "INVALID") { return; } PropertyInfo propertyInfo = properties.FirstOrDefault((PropertyInfo p) => { if (p.Name == x.get_Campo() || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("VENDEDOR") && str.Equals("SINTÉTICO POR VENDEDOR") && relatorio == 7 || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("SEGURADORA") && str.Equals("SINTÉTICO POR SEGURADORA") && relatorio == 7) { return true; } if (!p.Name.ToUpper().Equals("NOME") || !x.get_Campo().ToUpper().Equals("RAMO") || !str.Equals("SINTÉTICO POR RAMO")) { return false; } return relatorio == 7; }); if (propertyInfo == null) { return; } xLWorksheet.Cell(1, num1).set_Value(propertyInfo.GetDescriptionAttribute()); num1++; }); int num2 = 2; analitico.ForEach((T a) => { num1 = 1; int num = num2; List cSu0024u003cu003e8_locals1 = list; Func u003cu003e9_257 = Funcoes.u003cu003ec__25.u003cu003e9__25_7; if (u003cu003e9_257 == null) { u003cu003e9_257 = (ParametrosRelatorio x) => x.get_Ordem(); Funcoes.u003cu003ec__25.u003cu003e9__25_7 = u003cu003e9_257; } IOrderedEnumerable parametrosRelatorios = cSu0024u003cu003e8_locals1.OrderBy(u003cu003e9_257); Func u003cu003e9_258 = Funcoes.u003cu003ec__25.u003cu003e9__25_8; if (u003cu003e9_258 == null) { u003cu003e9_258 = (ParametrosRelatorio x) => x.get_Header(); Funcoes.u003cu003ec__25.u003cu003e9__25_8 = u003cu003e9_258; } ExtensionMethods.ForEach(parametrosRelatorios.ThenBy(u003cu003e9_258), (ParametrosRelatorio x) => { int cSu0024u003cu003e8_locals3; char chr; if (x.get_Tipo() == "INVALID") { return; } PropertyInfo propertyInfo = properties.FirstOrDefault((PropertyInfo p) => { if (p.Name == x.get_Campo() || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("VENDEDOR") && str.Equals("SINTÉTICO POR VENDEDOR") && relatorio == 7 || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("SEGURADORA") && str.Equals("SINTÉTICO POR SEGURADORA") && relatorio == 7) { return true; } if (!p.Name.ToUpper().Equals("NOME") || !x.get_Campo().ToUpper().Equals("RAMO") || !str.Equals("SINTÉTICO POR RAMO")) { return false; } return relatorio == 7; }); if (propertyInfo == null) { return; } Regex regex = new Regex("\\<[^\\>]*\\>"); object value = propertyInfo.GetValue(a); if (value != null && value.ToString().Contains(">") && value.ToString().Contains("<")) { value = regex.Replace(value.ToString(), ""); } string tipo = x.get_Tipo(); if (tipo != null) { switch (tipo.Length) { case 4: { if (tipo == "DATA") { break; } xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } case 5: { chr = tipo[0]; if (chr == 'D') { if (tipo == "DATA?") { break; } xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } else if (chr == 'V') { if (tipo != "VALOR") { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().SetNumberFormatId(2); xLWorksheet.Cell(num, num1).set_Value(((decimal?)value).GetValueOrDefault()); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } else { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } } case 6: case 7: case 8: { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } case 9: { if (tipo == "DATA/TIME") { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("dd/MM/yyyy HH:mm:ss"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } case 10: { chr = tipo[0]; if (chr == 'D') { if (tipo == "DATA/TIME?") { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("dd/MM/yyyy HH:mm:ss"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } else if (chr == 'P') { if (tipo == "PERCENTUAL") { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().SetNumberFormatId(10); xLWorksheet.Cell(num, num1).set_Value(((decimal?)value).GetValueOrDefault() * new decimal(1, 0, 0, false, 2)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } else { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } } else if (chr != 'Q') { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } else if (tipo == "QUANTIDADE") { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().SetNumberFormatId(1); xLWorksheet.Cell(num, num1).set_Value(value); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } else { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } } default: { xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } } xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("dd/MM/yyyy"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; return; } xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@"); xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value)); cSu0024u003cu003e8_locals3 = num1; num1 = cSu0024u003cu003e8_locals3 + 1; }); num2++; }); xLWorksheet.Row(1).get_Style().get_Font().set_Bold(true); xLWorksheet.Columns().AdjustToContents(); xLWorkbook = xlWorkbook; } catch (Exception exception) { xLWorkbook = null; } return xLWorkbook; }); return xLWorkbook1; } public static async Task GerarXls(XLWorkbook xlWorkbook, string nome, List analitico, List colunasOcultas = null) { XLWorkbook xLWorkbook1 = await Task.Run(() => { XLWorkbook xLWorkbook; try { nome = nome.ValidaNomePlanilha("", 0); IXLWorksheet xLWorksheet = xlWorkbook.get_Worksheets().Add(nome); Type type = analitico[0].GetType(); PropertyInfo[] properties = type.GetProperties(); int num = 1; PropertyInfo[] propertyInfoArray1 = properties; for (int i1 = 0; i1 < (int)propertyInfoArray1.Length; i1++) { PropertyInfo propertyInfo1 = propertyInfoArray1[i1]; if (propertyInfo1.Name != "ValidationEvent") { object obj1 = propertyInfo1.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); if (obj1 != null) { string str = ((DescriptionAttribute)obj1).Description; if (colunasOcultas == null || !colunasOcultas.Contains(str)) { xLWorksheet.Cell(1, num).set_Value(str); num++; } } } } int num1 = 2; analitico.ForEach((T x) => { int i; num = 1; type = x.GetType(); properties = type.GetProperties(); PropertyInfo[] propertyInfoArray = properties; for (i = 0; i < (int)propertyInfoArray.Length; i++) { PropertyInfo propertyInfo = propertyInfoArray[i]; if (propertyInfo.Name != "ValidationEvent") { object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); if (obj != null) { string description = ((DescriptionAttribute)obj).Description; if (colunasOcultas == null || !colunasOcultas.Contains(description)) { string name = propertyInfo.Name; if (name.Contains("Fipe") || name == "NumeroProposta" || name == "NumeroApolice" || name == "NumeroPedidoEndosso") { xLWorksheet.Cell(num1, num).get_Style().get_NumberFormat().set_Format("@"); } xLWorksheet.Cell(num1, num).set_Value(propertyInfo.GetValue(x)); num++; } } } } i = num1; num1 = i + 1; }); xLWorksheet.Row(1).get_Style().get_Font().set_Bold(true); xLWorksheet.Columns().AdjustToContents(); xLWorkbook = xlWorkbook; } catch (Exception exception) { xLWorkbook = null; } return xLWorkbook; }); return xLWorkbook1; } public static async Task GerarXlsSintetico(XLWorkbook xlWorkbook, string nome, List sintetic) { XLWorkbook xLWorkbook1 = await Task.Run(() => { XLWorkbook xLWorkbook; try { nome = nome.ValidaNomePlanilha("", 0); IXLWorksheet xLWorksheet = xlWorkbook.get_Worksheets().Add(nome); int num = 1; sintetic.ForEach((SinteticModel x) => { xLWorksheet.Cell(1, num).set_Value(x.get_Hint()); xLWorksheet.Cell(2, num).set_Value(x.get_Value()); num++; }); xLWorksheet.Row(1).get_Style().get_Font().set_Bold(true); xLWorksheet.Columns().AdjustToContents(); xLWorkbook = xlWorkbook; } catch (Exception exception) { xLWorkbook = null; } return xLWorkbook; }); return xLWorkbook1; } public static string GetBody(this string html) { HtmlDocument htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); HtmlNode htmlNode = htmlDocument.get_DocumentNode().SelectSingleNode("//body"); if (htmlNode != null) { return htmlNode.get_InnerHtml(); } return null; } public static Categoria? GetCategoria(string text) { Categoria categorium; if (text.Contains("caminhao") || text.Contains("caminhão")) { return new Categoria?(4); } if (text.Contains("onibus") || text.Contains("ônibus")) { return new Categoria?(6); } if (text.Contains("utilitario") || text.Contains("utilitário")) { return new Categoria?(6); } if (text.Contains("moto")) { return new Categoria?(9); } if (!Enum.TryParse(text, true, out categorium)) { return null; } return new Categoria?((Categoria)Enum.Parse(typeof(Categoria), text, true)); } public static Combustivel? GetCombustivel(string text) { Combustivel combustivel; if (text.Contains("flex")) { return new Combustivel?(4); } if (text.Contains("gasolina") && (text.Contains("alcool") || text.Contains("álcool"))) { if (text.Contains("gnv")) { return new Combustivel?(8); } if (!text.Contains("eletrico") && !text.Contains("elétrico")) { return new Combustivel?(4); } return new Combustivel?(12); } if (text.Contains("gasolina") && text.Contains("gnv")) { return new Combustivel?(7); } if (text.Contains("gasolina") && (text.Contains("eletrico") || text.Contains("elétrico"))) { return new Combustivel?(9); } if (text.Contains("eletrico") || text.Contains("elétrico")) { return new Combustivel?(11); } if (text.Contains("alcool") || text.Contains("álcool")) { return new Combustivel?(1); } if (text.Contains("hibrido") || text.Contains("híbrido")) { return new Combustivel?(10); } if (text.Contains("outro")) { return new Combustivel?(6); } if (!Enum.TryParse(text, true, out combustivel)) { return null; } return new Combustivel?((Combustivel)Enum.Parse(typeof(Combustivel), text, true)); } public static Cor? GetCor(string text) { Cor cor; if (text.Contains("outro")) { return new Cor?(16); } if (!Enum.TryParse(text, true, out cor)) { return null; } return new Cor?((Cor)Enum.Parse(typeof(Cor), text, true)); } public static Correcao? GetCorrecao(string text) { if (text.Contains("mercado")) { return new Correcao?(0); } if (text.Contains("determinado")) { return new Correcao?(1); } return null; } public static string GetDescriptionAttribute(this PropertyInfo pi) { object obj = pi.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); if (obj == null) { return pi.Name.ToUpper(); } return ((DescriptionAttribute)obj).Description; } public static async Task GetFabricante(string text) { Fabricante fabricante; List fabricantes = await (new BaseServico()).BuscarFabricante(text); if (fabricantes.Count < 1) { fabricante = null; } else { fabricante = fabricantes.First(); } return fabricante; } public static Isencao? GetIsencao(string text) { if (text.Contains("sem")) { return new Isencao?(0); } if (text.Contains("ipi") && text.Contains("icms")) { return new Isencao?(3); } if (text.Contains("ipi")) { return new Isencao?(2); } if (text.Contains("icms")) { return new Isencao?(1); } return null; } public static DateTime GetNetworkTime() { DateTime value; try { if (!Funcoes.StartTime.HasValue) { byte[] numArray = new byte[48]; numArray[0] = 27; IPEndPoint pEndPoint = new IPEndPoint(((IEnumerable)Dns.GetHostEntry("time.google.com").AddressList).First((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); Funcoes.StartTime = new DateTime?(dateTime.ToLocalTime()); Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew(); value = Funcoes.StartTime.Value; } else { value = Funcoes.StartTime.Value; value = value.AddMilliseconds((double)Funcoes.Stopwatch.ElapsedMilliseconds); } } catch (Exception exception) { Funcoes.StartTime = new DateTime?(DateTime.Now); Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew(); value = Funcoes.StartTime.Value; } return value; } private static async Task> GetRestricoesColunas(List parametros) { List restricaoUsuarioCamposRelatorios = await (new RestricaoUsuarioServico()).BuscarRestricoesCamposRelatorios(Recursos.Usuario.get_Id()); List list = restricaoUsuarioCamposRelatorios; List restricaoUsuarioCamposRelatorios1 = list; list = ( from x in restricaoUsuarioCamposRelatorios1 where x.get_Restricao() select x).ToList(); List parametrosRelatorios = ( from x in parametros where ( from y in list where x.get_Relatorio() == y.get_Relatorio() select y).All((RestricaoUsuarioCamposRelatorios y) => x.get_Header() != y.get_Campo()) select x).ToList(); return parametrosRelatorios; } public static TabelaReferencia? GetTabelaReferencia(string text) { TabelaReferencia tabelaReferencium; if (!Enum.TryParse(text, true, out tabelaReferencium)) { return null; } return new TabelaReferencia?((TabelaReferencia)Enum.Parse(typeof(TabelaReferencia), text, true)); } public static string GetText(string html) { HtmlDocument htmlDocument = new HtmlDocument(); htmlDocument.LoadHtml(html); return Funcoes.NodeText(htmlDocument.get_DocumentNode()); } public static TipoCobertura? GetTipoCobertura(string text) { TipoCobertura tipoCobertura; if (text.Contains("incendio") || text.Contains("incêndio")) { return new TipoCobertura?(2); } if (text.Contains("roubo") && text.Contains("furto")) { return new TipoCobertura?(5); } if (text.Contains("terceiros")) { return new TipoCobertura?(3); } if (text.Contains("compreensiva")) { return new TipoCobertura?(1); } if (!Enum.TryParse(text, true, out tipoCobertura)) { return null; } return new TipoCobertura?((TipoCobertura)Enum.Parse(typeof(TipoCobertura), text, true)); } public static string GetTypeAttribute(this PropertyInfo pi) { object obj = pi.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault(); if (obj == null) { return ""; } return ((TipoAttribute)obj).get_Description(); } public static UsoVeiculo? GetUsoveiculo(string text) { UsoVeiculo usoVeiculo; UsoVeiculo usoVeiculo1; if (Enum.TryParse(text, true, out usoVeiculo)) { usoVeiculo1 = usoVeiculo; } else { usoVeiculo1 = 0; } return new UsoVeiculo?(usoVeiculo1); } public static T GetValueFromType(this object objeto) { Type type = typeof(T); PropertyInfo[] properties = objeto.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < (int)properties.Length; i++) { PropertyInfo propertyInfo = properties[i]; if (propertyInfo.PropertyType == type) { return (T)propertyInfo.GetValue(objeto); } } return default(T); } public static async Task InativarItens(long id, long ramo, bool delete = true) { bool sucesso; ItemServico itemServico = new ItemServico(); ObservableCollection observableCollection = await itemServico.BuscarItens(id); ObservableCollection observableCollection1 = observableCollection; IEnumerable hasValue = from x in observableCollection1 where x.get_Substituicao().HasValue select x; if (await Funcoes.ReativarItens(( from x in hasValue select x.get_Substituicao().Value).ToList())) { if (!delete) { List list = observableCollection.ToList(); list.ForEach((Item x) => x.set_Cancelado(true)); await itemServico.SaveRange(observableCollection.ToList()); } else { await itemServico.DeleteRange(observableCollection.ToList(), ramo); } sucesso = itemServico.Sucesso; } else { sucesso = false; } itemServico = null; observableCollection = null; return sucesso; } public static bool IsEmpty(this string html) { int count = Regex.Matches(html, "").Count; bool flag = true; int num = 0; for (int i = 0; i < count; i++) { int num1 = html.IndexOf("", num, StringComparison.Ordinal) + 6; if (num1 == 5) { break; } int num2 = html.IndexOf("", num, StringComparison.Ordinal); num = num2 + 7; flag = string.IsNullOrWhiteSpace(html.Substring(num1, num2 - num1)); if (!flag) { break; } } return flag; } public static Window IsHosterOpen(string name) { return System.Windows.Application.Current.Windows.OfType().ToList().FirstOrDefault((HosterWindow x) => { string str; ContentControl contentControl = Extentions.FindVisualChildren(x).FirstOrDefault(); if (contentControl != null) { str = contentControl.Tag.ToString(); } else { str = null; } return str == name; }); } public static bool IsWindowOpen(string title) where T : Window { return System.Windows.Application.Current.Windows.OfType().Any((T x) => x.Title == title); } public static List LogList(this List valores, bool restricaoComissao = false) { List> tuples = new List>(); valores.ForEach((ValorOriginal x) => { if (restricaoComissao && x.get_Campo().ToUpper().Contains("COMISSÃO")) { return; } tuples.Add(new Tuple(x.get_Descricao(), (string.IsNullOrEmpty(x.get_ValorAtual()) ? "NÃO PREENCHIDO" : (x.get_ValorAtual() == "True" ? "SIM" : (x.get_ValorAtual() == "False" ? "NÃO" : x.get_ValorAtual()))), "")); }); List tupleLists = new List(); TupleList tupleList = new TupleList(); tupleList.set_Tuples(new ObservableCollection>(tuples)); tupleLists.Add(tupleList); return tupleLists; } public static List LogList(this List valores, bool restricaoComissao = false) { List> tuples = new List>(); valores.ForEach((Diferenca x) => { if (restricaoComissao && x.get_Campo().ToUpper().Contains("COMISSÃO")) { return; } tuples.Add(new Tuple(x.get_Descricao(), (string.IsNullOrEmpty(x.get_ValorAtual()) ? "NÃO PREENCHIDO" : (x.get_ValorAtual() == "True" ? "SIM" : (x.get_ValorAtual() == "False" ? "NÃO" : x.get_ValorAtual()))), (string.IsNullOrEmpty(x.get_ValorAnterior()) ? "NÃO PREENCHIDO" : (x.get_ValorAnterior() == "True" ? "SIM" : (x.get_ValorAnterior() == "False" ? "NÃO" : x.get_ValorAnterior()))))); }); List tupleLists = new List(); TupleList tupleList = new TupleList(); tupleList.set_Tuples(new ObservableCollection>(tuples)); tupleLists.Add(tupleList); return tupleLists; } public static async Task MostrarErro(TipoErro erro) { await System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => (new ErrorWindow(erro, true)).ShowDialog())); } private static string NodeText(HtmlNode node) { string innerText = ""; if (node.get_HasChildNodes()) { foreach (HtmlNode childNode in node.get_ChildNodes()) { innerText = string.Concat(innerText, (childNode.get_NodeType() == 3 ? childNode.get_InnerText() : Funcoes.NodeText(childNode))); } } else if (node.get_NodeType() == 3) { innerText = node.get_InnerText(); } return innerText; } public static async Task> OcultarColunas(Relatorio relatorio) { List strs; List strs1 = new List(); List restricoesColunas = await (new ConfuguracoesServico()).BuscarParametros(relatorio); if (restricoesColunas == null || restricoesColunas.Count == 0) { strs = strs1; } else { restricoesColunas = await Funcoes.GetRestricoesColunas(restricoesColunas); PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public); for (int i = 0; i < (int)properties.Length; i++) { PropertyInfo propertyInfo = properties[i]; object obj = propertyInfo.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault(); string description = ""; if (obj != null) { description = ((TipoAttribute)obj).get_Description(); } string descriptionAttribute = propertyInfo.GetDescriptionAttribute(); if (description == "INVALID") { strs1.Add(descriptionAttribute); } if (!restricoesColunas.Any((ParametrosRelatorio x) => x.get_Campo() == propertyInfo.Name) && !(propertyInfo.Name == "ValidationEvent")) { strs1.Add(descriptionAttribute); } } strs = strs1; } strs1 = null; return strs; } public static List OcultarColunasDescricao(Type type, string categoria) { List strs = new List(); PropertyInfo[] properties = type.GetProperties(); for (int i = 0; i < (int)properties.Length; i++) { PropertyInfo propertyInfo = properties[i]; if (propertyInfo.Name != "ValidationEvent") { object obj = propertyInfo.GetCustomAttributes(typeof(CategoryAttribute), true).FirstOrDefault(); if (obj != null && !(((CategoryAttribute)obj).Category == categoria)) { object obj1 = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault(); if (obj1 != null) { strs.Add(((DescriptionAttribute)obj1).Description); } } } } return strs; } public static async Task OrganizarDocumentos(long id) { ApoliceServico apoliceServico = new ApoliceServico(); Controle controle = await apoliceServico.BuscarControleAsync(id); int num = 1; IList documentos = controle.get_Documentos(); IEnumerable excluido = from x in documentos where !x.get_Excluido() select x; ( from x in excluido orderby x.get_Vigencia1() select x).ToList().ForEach((Documento x) => { if (x.get_Tipo() == 0) { x.set_Ordem(0); return; } x.set_Ordem(num); num++; }); await apoliceServico.UpdateRange(controle); apoliceServico = null; } public static ParentescoVinculo? ParentescoInverso(ParentescoVinculo? parentesco) { if (parentesco.HasValue) { switch (parentesco.GetValueOrDefault()) { case 0: { return new ParentescoVinculo?(1); } case 1: { return new ParentescoVinculo?(0); } case 3: { return new ParentescoVinculo?(4); } case 4: { return new ParentescoVinculo?(3); } case 5: { return new ParentescoVinculo?(6); } case 6: { return new ParentescoVinculo?(5); } case 7: { return new ParentescoVinculo?(8); } case 8: { return new ParentescoVinculo?(7); } case 10: { return new ParentescoVinculo?(11); } case 11: { return new ParentescoVinculo?(10); } case 13: { return new ParentescoVinculo?(14); } case 14: { return new ParentescoVinculo?(13); } case 19: { return new ParentescoVinculo?(20); } case 20: { return new ParentescoVinculo?(19); } case 21: { return new ParentescoVinculo?(22); } case 22: { return new ParentescoVinculo?(21); } } } return parentesco; } public static TipoPagamento ParseTransactionType(this OfxTransactionType type) { switch (type) { case 0: { return 5; } case 1: case 4: { return 7; } case 6: case 13: { return 8; } case 7: case 12: { return 10; } case 10: { return 4; } case 11: { return 15; } case 14: { return 6; } default: { return 12; } } } public static string PlacaVencimento(string placa, Categoria? categoria) { if (string.IsNullOrEmpty(placa)) { return ""; } string str = placa.Substring(placa.Length - 1, 1); if (str != null && str.Length == 1) { switch (str[0]) { case '0': { return "DEZEMBRO"; } case '1': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "SETEMBRO"; } return "ABRIL"; } case '2': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "SETEMBRO"; } return "MAIO"; } case '3': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "OUTUBRO"; } return "JUNHO"; } case '4': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "OUTUBRO"; } return "JULHO"; } case '5': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "OUTUBRO"; } return "AGOSTO"; } case '6': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "NOVEMBRO"; } return "AGOSTO"; } case '7': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "NOVEMBRO"; } return "SETEMBRO"; } case '8': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "NOVEMBRO"; } return "OUTUBRO"; } case '9': { if (categoria.HasValue && categoria.GetValueOrDefault() == 4) { return "DEZEMBRO"; } return "NOVEMBRO"; } } } return ""; } public static List PopularFiltroFinanceiro() { List filtroPersonalizados = new List(); FiltroPersonalizado filtroPersonalizado = new FiltroPersonalizado(); filtroPersonalizado.set_Propriedade("Id"); filtroPersonalizado.set_Nome("ID"); filtroPersonalizado.set_Tipo(typeof(long)); filtroPersonalizados.Add(filtroPersonalizado); FiltroPersonalizado filtroPersonalizado1 = new FiltroPersonalizado(); filtroPersonalizado1.set_Propriedade("Controle.Fornecedor.NomeSocial"); filtroPersonalizado1.set_Nome("FORNECEDOR"); filtroPersonalizado1.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado1); FiltroPersonalizado filtroPersonalizado2 = new FiltroPersonalizado(); filtroPersonalizado2.set_Propriedade("Controle.Fornecedor.Ativo"); filtroPersonalizado2.set_Nome("FORNECEDOR ATIVO"); filtroPersonalizado2.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado2); FiltroPersonalizado filtroPersonalizado3 = new FiltroPersonalizado(); filtroPersonalizado3.set_Propriedade("Historico"); filtroPersonalizado3.set_Nome("HISTÓRICO"); filtroPersonalizado3.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado3); FiltroPersonalizado filtroPersonalizado4 = new FiltroPersonalizado(); filtroPersonalizado4.set_Propriedade("Parcela"); filtroPersonalizado4.set_Nome("PARCELA"); filtroPersonalizado4.set_Tipo(typeof(int)); filtroPersonalizados.Add(filtroPersonalizado4); FiltroPersonalizado filtroPersonalizado5 = new FiltroPersonalizado(); filtroPersonalizado5.set_Propriedade("Documento"); filtroPersonalizado5.set_Nome("DOCUMENTO"); filtroPersonalizado5.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado5); FiltroPersonalizado filtroPersonalizado6 = new FiltroPersonalizado(); filtroPersonalizado6.set_Propriedade("Competencia"); filtroPersonalizado6.set_Nome("COMPETÊNCIA"); filtroPersonalizado6.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado6); FiltroPersonalizado filtroPersonalizado7 = new FiltroPersonalizado(); filtroPersonalizado7.set_Propriedade("Complemento"); filtroPersonalizado7.set_Nome("COMPLEMENTO"); filtroPersonalizado7.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado7); FiltroPersonalizado filtroPersonalizado8 = new FiltroPersonalizado(); filtroPersonalizado8.set_Propriedade("Vencimento"); filtroPersonalizado8.set_Nome("VENCIMENTO"); filtroPersonalizado8.set_Tipo(typeof(DateTime)); filtroPersonalizados.Add(filtroPersonalizado8); FiltroPersonalizado filtroPersonalizado9 = new FiltroPersonalizado(); filtroPersonalizado9.set_Propriedade("Valor"); filtroPersonalizado9.set_Nome("VALOR"); filtroPersonalizado9.set_Tipo(typeof(decimal)); filtroPersonalizados.Add(filtroPersonalizado9); FiltroPersonalizado filtroPersonalizado10 = new FiltroPersonalizado(); filtroPersonalizado10.set_Propriedade("Baixa"); filtroPersonalizado10.set_Nome("DATA BAIXA"); filtroPersonalizado10.set_Tipo(typeof(DateTime)); filtroPersonalizados.Add(filtroPersonalizado10); FiltroPersonalizado filtroPersonalizado11 = new FiltroPersonalizado(); filtroPersonalizado11.set_Propriedade("ValorPago"); filtroPersonalizado11.set_Nome("VALOR PAGO"); filtroPersonalizado11.set_Tipo(typeof(decimal)); filtroPersonalizados.Add(filtroPersonalizado11); FiltroPersonalizado filtroPersonalizado12 = new FiltroPersonalizado(); filtroPersonalizado12.set_Propriedade("Pagamento"); filtroPersonalizado12.set_Nome("PAGAMENTO"); filtroPersonalizado12.set_Tipo(typeof(DateTime)); filtroPersonalizados.Add(filtroPersonalizado12); FiltroPersonalizado filtroPersonalizado13 = new FiltroPersonalizado(); filtroPersonalizado13.set_Propriedade("Conta.Descricao"); filtroPersonalizado13.set_Nome("CONTA"); filtroPersonalizado13.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado13); FiltroPersonalizado filtroPersonalizado14 = new FiltroPersonalizado(); filtroPersonalizado14.set_Propriedade("Controle.Plano.Descricao"); filtroPersonalizado14.set_Nome("PLANO DE CONTAS"); filtroPersonalizado14.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado14); FiltroPersonalizado filtroPersonalizado15 = new FiltroPersonalizado(); filtroPersonalizado15.set_Propriedade("Controle.Centro.Descricao"); filtroPersonalizado15.set_Nome("CENTRO DE CUSTO"); filtroPersonalizado15.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado15); FiltroPersonalizado filtroPersonalizado16 = new FiltroPersonalizado(); filtroPersonalizado16.set_Propriedade("Sinal"); filtroPersonalizado16.set_Nome("SINAL"); filtroPersonalizado16.set_Tipo(typeof(Enum)); filtroPersonalizados.Add(filtroPersonalizado16); FiltroPersonalizado filtroPersonalizado17 = new FiltroPersonalizado(); filtroPersonalizado17.set_Propriedade("TipoPagamento"); filtroPersonalizado17.set_Nome("FORMA PAGAMENTO"); filtroPersonalizado17.set_Tipo(typeof(Enum)); filtroPersonalizados.Add(filtroPersonalizado17); FiltroPersonalizado filtroPersonalizado18 = new FiltroPersonalizado(); filtroPersonalizado18.set_Propriedade("Observacao"); filtroPersonalizado18.set_Nome("OBSERVAÇÃO"); filtroPersonalizado18.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado18); FiltroPersonalizado filtroPersonalizado19 = new FiltroPersonalizado(); filtroPersonalizado19.set_Propriedade("Controle.Plano.Nome"); filtroPersonalizado19.set_Nome("PLANO"); filtroPersonalizado19.set_Tipo(typeof(string)); filtroPersonalizados.Add(filtroPersonalizado19); return filtroPersonalizados; } public static List PopularFiltroPersonalizado() { List filtroPersonalizados = new List(); foreach (PropertyInfo propertyInfo in from in (IEnumerable)typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public) orderby Gestor.Common.Validation.ValidationHelper.DescriptionAttribute(x) select ) { if (propertyInfo.Name == "ValidationEvent") { continue; } FiltroPersonalizado filtroPersonalizado = new FiltroPersonalizado(); filtroPersonalizado.set_Propriedade(propertyInfo.Name); filtroPersonalizado.set_Nome(propertyInfo.GetDescriptionAttribute()); FiltroPersonalizado filtroPersonalizado1 = filtroPersonalizado; if (propertyInfo.GetTypeAttribute() == "INVALID") { continue; } Type propertyType = propertyInfo.PropertyType; if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) { propertyType = propertyType.GetGenericArguments()[0]; } filtroPersonalizado1.set_Tipo((propertyType.BaseType == typeof(Enum) ? propertyType.BaseType : propertyType)); filtroPersonalizados.Add(filtroPersonalizado1); } return filtroPersonalizados; } public static bool ProgramaEmExecucao(this string programName) { return Process.GetProcessesByName(programName).Length != 0; } public static async Task ReativarItens(List ids) { ItemServico itemServico = new ItemServico(); List items = await itemServico.BuscarItems(ids); List items1 = items; items1.ForEach((Item x) => { x.set_Substituido(null); x.set_Cancelado(false); x.set_Status(x.get_StatusInclusao()); }); await itemServico.SaveRange(items); bool sucesso = itemServico.Sucesso; itemServico = null; return sucesso; } public static async Task RecusarApolice(Documento documento, string motivo, bool estorno) { bool flag; string str; NegocioCorretora negocioCorretora; NegocioCorretora negocioCorretora1; ApoliceServico apoliceServico = new ApoliceServico(); CriticaApoliceServico criticaApoliceServico = new CriticaApoliceServico(); if (documento.get_Tipo() != 0 || !string.IsNullOrEmpty(documento.get_Apolice())) { str = (documento.get_Tipo() != 0 || string.IsNullOrEmpty(documento.get_Apolice()) ? "ENDOSSO RECUSADO" : "APÓLICE RECUSADA"); } else { str = "PROPOSTA RECUSADA"; } string str1 = str; if (!string.IsNullOrWhiteSpace(motivo)) { Documento documento1 = documento; object[] nome = new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), Funcoes.GetNetworkTime(), Environment.NewLine, motivo, Environment.NewLine, Environment.NewLine, documento.get_Observacao() }; documento1.set_Observacao(string.Format("{0}, ID: {1}, {2:g}{3}RECUSA: {4}{5}{6}{7}", nome)); } if (documento.get_Tipo() != 0) { if (!documento.get_NegocioCorretora().HasValue) { Documento documento2 = documento; negocioCorretora = (!documento.get_Negocio().HasValue || documento.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1); documento2.set_NegocioCorretora(new NegocioCorretora?(negocioCorretora)); } documento.set_Situacao(7); documento.set_Apolice("RECUSADA"); documento.set_Endosso("RECUSADA"); flag = await apoliceServico.BaixarParcelasCancelamento(documento, estorno); if (!flag) { Action acessaTela = Gestor.Application.Actions.Actions.AcessaTela; if (acessaTela != null) { acessaTela(21, ""); } else { } } await apoliceServico.Save(documento, false, false); if (!apoliceServico.Sucesso) { Action action = Gestor.Application.Actions.Actions.AcessaTela; if (action != null) { action(21, ""); } else { } } if (!apoliceServico.Sucesso) { Action acessaTela1 = Gestor.Application.Actions.Actions.AcessaTela; if (acessaTela1 != null) { acessaTela1(21, ""); } else { } } flag = await Funcoes.InativarItens(documento.get_Id(), documento.get_Controle().get_Ramo().get_Id(), false); if (!flag) { Action action1 = Gestor.Application.Actions.Actions.AcessaTela; if (action1 != null) { action1(21, ""); } else { } } } else { await apoliceServico.Save(documento, false, false); Controle controle = await apoliceServico.BuscarControleAsync(documento.get_Controle().get_Id()); if (controle.get_Id() != 0) { foreach (Documento documento3 in controle.get_Documentos()) { if (!documento3.get_NegocioCorretora().HasValue) { Documento documento4 = documento3; negocioCorretora1 = (!documento3.get_Negocio().HasValue || documento3.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1); documento4.set_NegocioCorretora(new NegocioCorretora?(negocioCorretora1)); } documento3.set_Situacao(7); documento3.set_Apolice("RECUSADA"); flag = await apoliceServico.BaixarParcelasCancelamento(documento3, estorno); if (flag) { continue; } Action acessaTela2 = Gestor.Application.Actions.Actions.AcessaTela; if (acessaTela2 != null) { acessaTela2(21, ""); } else { } } flag = await apoliceServico.UpdateRange(controle); controle = null; } else { apoliceServico = null; criticaApoliceServico = null; str1 = null; return; } } if (!flag) { Action action2 = Gestor.Application.Actions.Actions.AcessaTela; if (action2 != null) { action2(21, ""); } else { } } List criticaApolices = await criticaApoliceServico.BuscarCritica(documento.get_Id()); if (criticaApolices != null) { foreach (CriticaApolice criticaApolouse in criticaApolices) { criticaApolouse.set_Critica(new bool?(true)); await criticaApoliceServico.Save(criticaApolouse); } } Action acessaTela3 = Gestor.Application.Actions.Actions.AcessaTela; if (acessaTela3 != null) { acessaTela3(21, ""); } else { } Funcoes.ToggleSnackBar(string.Concat(str1, " COM SUCESSO"), true); apoliceServico = null; criticaApoliceServico = null; str1 = null; } private static async void RegistrarLogBaixa(long id, DateTime now) { string str; ApoliceServico apoliceServico = new ApoliceServico(); ParcelaServico parcelaServico = new ParcelaServico(); VendedorServico vendedorServico = new VendedorServico(); Documento documento = await apoliceServico.BuscarApoliceAsync(id, false, false); Documento documento1 = documento; ObservableCollection observableCollection = await parcelaServico.BuscarParcelasAsync(documento.get_Id()); documento1.set_Parcelas(observableCollection); documento1 = null; List vendedorParcelas = await vendedorServico.BuscaRepasse(documento.get_Id()); foreach (Parcela parcela in documento.get_Parcelas()) { foreach (VendedorParcela vendedorParcela in vendedorParcelas) { if (vendedorParcela.get_Parcela().get_Id() != parcela.get_Id()) { continue; } if (parcela.get_Vendedores() == null) { parcela.set_Vendedores(new ObservableCollection()); } parcela.get_Vendedores().Add(vendedorParcela); } } IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); RegistroLog registroLog = new RegistroLog(); registroLog.set_Acao(1); registroLog.set_Usuario(Recursos.Usuario); registroLog.set_DataHora(now); Documento documento2 = documento; JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings(); jsonSerializerSetting.set_ReferenceLoopHandling(1); registroLog.set_Descricao(JsonConvert.SerializeObject(documento2, jsonSerializerSetting)); registroLog.set_EntidadeId(documento.get_Id()); registroLog.set_Tela(2); registroLog.set_NomeMaquina(Environment.MachineName); registroLog.set_UsuarioMaquina(Environment.UserName); IPAddress[] addressList = hostEntry.AddressList; IPAddress pAddress = ((IEnumerable)addressList).FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork); if (pAddress != null) { str = pAddress.ToString(); } else { str = null; } registroLog.set_Ip(str); RegistroLog registroLog1 = registroLog; using (UnitOfWork commited = Instancia.Commited) { commited.get_RegistroLogRepository().SaveOrUpdate(registroLog1); commited.Commit(); } parcelaServico = null; vendedorServico = null; documento = null; } public static string RemoverAcentos(string text) { string str = text.Normalize(NormalizationForm.FormD); StringBuilder stringBuilder = new StringBuilder(); foreach (char chr in from c in str let unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c) where unicodeCategory != UnicodeCategory.NonSpacingMark select c) { stringBuilder.Append(chr); } return stringBuilder.ToString().Normalize(NormalizationForm.FormC); } [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] private static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); public static string SubstituirVariaveis(string corpo, MalaDireta envio) { DateTime? vigencia2; DateTime vigencia1; decimal valor; decimal? nullable; bool controle; bool flag; string str; string str1; string str2; string str3; object obj; string str4; string str5; string description; decimal? nullable1; string str6; decimal? nullable2; string str7; DateTime networkTime = Funcoes.GetNetworkTime(); VariaveisMalaDireta[] values = (VariaveisMalaDireta[])Enum.GetValues(typeof(VariaveisMalaDireta)); for (int i = 0; i < (int)values.Length; i++) { VariaveisMalaDireta variaveisMalaDiretum = values[i]; switch (variaveisMalaDiretum) { case 0: { corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), networkTime.ToString(new CultureInfo("pt-BR"))); break; } case 1: { corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(envio.get_Cliente().get_NomeSocialRg()) ? envio.get_Cliente().get_NomeSocialRg() : envio.get_Cliente().get_Nome())); break; } case 2: { corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Cliente().get_Documento()); break; } case 3: { if (envio.get_Apolice() == null) { break; } corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Apolice().get_Proposta()); break; } case 4: { if (envio.get_Apolice() == null) { break; } corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), string.Concat(envio.get_Apolice().get_Apolice(), (envio.get_Apolice().get_Tipo() != 0 ? string.Concat(", endosso de número: ", envio.get_Apolice().get_Endosso()) : ""))); break; } case 5: { Documento apolice = envio.get_Apolice(); if (apolice != null) { controle = apolice.get_Controle(); } else { controle = false; } if (!controle) { break; } corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Apolice().get_Controle().get_Ramo().get_Nome()); break; } case 6: { Documento documento = envio.get_Apolice(); if (documento != null) { flag = documento.get_Controle(); } else { flag = false; } if (!flag) { break; } corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Apolice().get_Controle().get_Seguradora().get_Nome()); break; } case 7: { if (envio.get_Apolice() == null) { break; } string entity = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); vigencia1 = envio.get_Apolice().get_Vigencia1(); corpo = corpo.Replace(entity, vigencia1.ToString("d")); break; } case 8: { if (envio.get_Apolice() == null) { break; } string str8 = corpo; string entity1 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); vigencia2 = envio.get_Apolice().get_Vigencia2(); if (vigencia2.HasValue) { vigencia1 = vigencia2.GetValueOrDefault(); str = vigencia1.ToString("d"); } else { str = null; } corpo = str8.Replace(entity1, str); break; } case 9: { if (envio.get_Parcela() == null) { break; } string entity2 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); vigencia1 = envio.get_Parcela().get_Vencimento(); corpo = corpo.Replace(entity2, vigencia1.ToString("d")); break; } case 10: { if (envio.get_Parcela() == null) { break; } string entity3 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); valor = envio.get_Parcela().get_Valor(); corpo = corpo.Replace(entity3, valor.ToString("c2")); break; } case 11: { if (envio.get_Item() == null) { break; } corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Item().get_Descricao()); break; } case 12: { if (envio.get_Sinistro() == null) { break; } corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Sinistro().get_Numero()); break; } case 13: { if (envio.get_Parcela() == null) { break; } string entity4 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); int numeroParcela = envio.get_Parcela().get_NumeroParcela(); corpo = corpo.Replace(entity4, numeroParcela.ToString()); break; } case 14: { vigencia2 = envio.get_Cliente().get_Nascimento(); if (!vigencia2.HasValue) { break; } string str9 = corpo; string entity5 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); vigencia2 = envio.get_Cliente().get_Nascimento(); if (vigencia2.HasValue) { vigencia1 = vigencia2.GetValueOrDefault(); str1 = vigencia1.ToString("dd/MM"); } else { str1 = null; } corpo = str9.Replace(entity5, str1); break; } case 15: { vigencia2 = envio.get_Cliente().get_Nascimento(); if (!vigencia2.HasValue) { break; } string str10 = corpo; string entity6 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); vigencia2 = envio.get_Cliente().get_Nascimento(); if (vigencia2.HasValue) { vigencia1 = vigencia2.GetValueOrDefault(); str2 = vigencia1.ToString("d"); } else { str2 = null; } corpo = str10.Replace(entity6, str2); break; } case 16: { string str11 = corpo; string entity7 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); vigencia2 = envio.get_Cliente().get_VencimentoHabilitacao(); if (vigencia2.HasValue) { vigencia1 = vigencia2.GetValueOrDefault(); str3 = vigencia1.ToString("d"); } else { str3 = null; } corpo = str11.Replace(entity7, str3); break; } case 17: { if (envio.get_ArquivoDigital() != null) { if (!envio.get_ArquivoDigital().All((IndiceArquivoDigital x) => string.IsNullOrWhiteSpace(x.get_UrlAssinatura()))) { string str12 = ""; ( from x in envio.get_ArquivoDigital() where !string.IsNullOrWhiteSpace(x.get_UrlAssinatura()) select x).ToList().ForEach((IndiceArquivoDigital x) => str12 = string.Concat(new string[] { str12, "" })); str12 = string.Concat(str12, "
ABAIXO OS DOCUMENTOS PARA ASSINATURA
", x.get_Descricao(), "
"); corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), str12); break; } } corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), string.Empty); break; } case 18: { string str13 = string.Format("ABAIXO O LINK PARA MEU CARTÃO DE VISITA.
CARTÃO DE VISITA ELETRÔNICO", Address.get_Card(), Recursos.Usuario.get_Id().GeraCartaoVisita()); corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), str13); break; } case 19: { if (envio.get_Apolice() != null) { Uri assistance = Address.get_Assistance(); if (envio != null) { Documento apolice1 = envio.get_Apolice(); if (apolice1 != null) { obj = apolice1.get_Id().GeraAssistencia(); } else { obj = null; } } else { obj = null; } string str14 = string.Format("ABAIXO O LINK PARA O SEU CARTÃO ASSISTÊNCIA.
CARTÃO ASSISTÊNCIA", assistance, obj); corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), str14); break; } else { corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), string.Empty); break; } } case 20: { string str15 = corpo; string entity8 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); Documento documento1 = envio.get_Apolice(); if (documento1 != null) { str4 = documento1.get_PremioLiquido().ToString("c"); } else { str4 = null; } corpo = str15.Replace(entity8, str4); break; } case 21: { string str16 = corpo; string entity9 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); Documento apolice2 = envio.get_Apolice(); if (apolice2 != null) { str5 = apolice2.get_PremioTotal().ToString("c"); } else { str5 = null; } corpo = str16.Replace(entity9, str5); break; } case 22: { string str17 = corpo; string entity10 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); Documento documento2 = envio.get_Apolice(); if (documento2 != null) { FormaPagamento? formaPagamento = documento2.get_FormaPagamento(); if (formaPagamento.HasValue) { description = Gestor.Common.Validation.ValidationHelper.GetDescription(formaPagamento.GetValueOrDefault()); } else { description = null; } } else { description = null; } corpo = str17.Replace(entity10, description); break; } case 23: { string str18 = corpo; string entity11 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); Documento apolice3 = envio.get_Apolice(); if (apolice3 != null) { nullable1 = new decimal?(apolice3.get_NumeroParcelas()); } else { nullable = null; nullable1 = nullable; } if (!nullable1.HasValue || envio.get_Apolice().get_TipoRecebimento().GetValueOrDefault() == 2) { str6 = "Indefinido"; } else { Documento documento3 = envio.get_Apolice(); if (documento3 != null) { str6 = documento3.get_NumeroParcelas().ToString(); } else { str6 = null; } } corpo = str18.Replace(entity11, str6); break; } case 24: { string str19 = corpo; string entity12 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum); Documento apolice4 = envio.get_Apolice(); if (apolice4 != null) { nullable2 = new decimal?(apolice4.get_NumeroParcelas()); } else { nullable = null; nullable2 = nullable; } if (!nullable2.HasValue || envio.get_Apolice().get_NumeroParcelas() == decimal.Zero || envio.get_Apolice().get_TipoRecebimento().GetValueOrDefault() == 2) { str7 = "Verificar documento anexado"; } else { valor = envio.get_Apolice().get_PremioTotal() / envio.get_Apolice().get_NumeroParcelas(); str7 = valor.ToString(); } corpo = str19.Replace(entity12, str7); break; } } } return corpo; } public static void ToggleSnackBar(string message, bool active = true) { App.SnackBar.get_Message().Content = message; App.SnackBar.set_IsActive(active); if (!active) { return; } Task.Factory.StartNew(new Action(Funcoes.CloseSlackBar)); } public static List TotalizacoesRelatorio(Relatorio relatorio, List parametrosAdicionados) { long id; List parametrosTotalizacaos = new List(); List strs = new List(); switch (relatorio) { case 2: case 3: { strs.Add("PremioTotal"); strs.Add("PremioLiquido"); strs.Add("MediaComissao"); strs.Add("ComissaoGerada"); strs.Add("Cancelamentos"); strs.Add("Novos"); strs.Add("NegociosProprios"); strs.Add("Renovacoes"); strs.Add("SegurosNovos"); strs.Add("Apolices"); strs.Add("Endossos"); strs.Add("Faturas"); strs.Add("TotalGeral"); strs.Add("MediaPonderada"); goto case 15; } case 4: { strs.Add("Cancelamentos"); strs.Add("Novos"); strs.Add("Renovacoes"); strs.Add("Apolices"); strs.Add("Endossos"); strs.Add("Faturas"); strs.Add("TotalProspeccao"); strs.Add("TotalGeral"); strs.Add("PremioTotal"); strs.Add("PremioLiquido"); strs.Add("ComissaoGerada"); goto case 15; } case 5: { strs.Add("ComissaoRecebidaBruta"); strs.Add("ComissaoRecebidaLiquida"); strs.Add("ComissaoPrevista"); strs.Add("Repasse"); strs.Add("Impostos"); strs.Add("PremioTotal"); strs.Add("PremioLiquido"); goto case 15; } case 6: case 16: { strs.Add("ComissaoPrevista"); strs.Add("TotalPrevista"); strs.Add("TotalGeral"); strs.Add("TotalParcela"); goto case 15; } case 7: case 11: case 12: case 13: case 14: case 15: { PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in from in (IEnumerable)properties orderby x.GetDescriptionAttribute() select ) { if (propertyInfo.Name == "ValidationEvent" || propertyInfo.GetTypeAttribute() == "INVALID" || !strs.Contains(propertyInfo.Name) || propertyInfo.Name == "Agrupamento" || parametrosAdicionados.Any((ParametrosTotalizacao x) => x.get_Campo() == propertyInfo.Name)) { continue; } ParametrosTotalizacao parametrosTotalizacao = new ParametrosTotalizacao(); ParametrosTotalizacao parametrosTotalizacao1 = parametrosAdicionados.FirstOrDefault((ParametrosTotalizacao x) => { if (x.get_IdUsuario() == 0) { return false; } return x.get_Campo() == propertyInfo.Name; }); if (parametrosTotalizacao1 != null) { id = parametrosTotalizacao1.get_Id(); } else { id = (long)0; } parametrosTotalizacao.set_Id(id); parametrosTotalizacao.set_Campo(propertyInfo.Name); parametrosTotalizacao.set_Header(propertyInfo.GetDescriptionAttribute()); parametrosTotalizacao.set_IdUsuario(Recursos.Usuario.get_Id()); parametrosTotalizacao.set_Relatorio(relatorio); parametrosTotalizacaos.Add(parametrosTotalizacao); } return parametrosTotalizacaos; } case 8: { strs.Add("PremioTotal"); strs.Add("PremioLiquido"); strs.Add("ComissaoRecebidaBruta"); strs.Add("MediaComissao"); strs.Add("TotalPrevista"); strs.Add("ComissaoGerada"); strs.Add("Cancelamentos"); strs.Add("Novos"); strs.Add("Renovacoes"); strs.Add("Apolices"); strs.Add("Endossos"); strs.Add("Faturas"); strs.Add("TotalGeral"); goto case 15; } case 9: case 10: { strs.Add("Liquidado"); strs.Add("ValorLiquidado"); strs.Add("Pendente"); strs.Add("TotalGeral"); strs.Add("TotalClientes"); strs.Add("TotalTerceiros"); goto case 15; } default: { goto case 15; } } } public static long UnixTimeStamp() { DateTime utcNow = DateTime.UtcNow; TimeSpan timeSpan = utcNow.Subtract(new DateTime(1970, 1, 1)); return (long)timeSpan.TotalSeconds; } public static string ValidaNomePlanilha(this string nome, string agrupamento = "", int index = 0) { if (string.IsNullOrWhiteSpace(nome)) { nome = agrupamento; } nome = nome.Replace("/", "_").Replace(":", " ").Replace("*", " ").Replace("?", "").Trim(); if (index > 0) { nome = string.Format("{0} {1}", index, nome); } if (nome.Length > 30) { nome = nome.Substring(0, 30); } return nome; } public static async Task VerificarPagamento(long id) { bool[] flagArray = new bool[2]; List parcelas = await (new ParcelaServico()).BuscarParcelas(id); if (parcelas.Any((Parcela x) => x.get_DataRecebimento().HasValue)) { flagArray[0] = true; } List vendedorParcelas = await (new VendedorServico()).BuscaRepasse(id); if (vendedorParcelas.Any((VendedorParcela x) => x.get_DataPagamento().HasValue)) { flagArray[1] = true; } bool[] flagArray1 = flagArray; flagArray = null; return flagArray1; } } }