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 Agger.Registro; using ClosedXML.Excel; using CsQuery.ExtensionMethods; 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.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 Xceed.Wpf.AvalonDock.Controls; namespace Gestor.Application.Helpers; public static class Funcoes { [CompilerGenerated] private sealed class _003CDistinctBy_003Ed__55 : IEnumerable, IEnumerable, IEnumerator, IDisposable, IEnumerator { private int _003C_003E1__state; private TSource _003C_003E2__current; private int _003C_003El__initialThreadId; private IEnumerable source; public IEnumerable _003C_003E3__source; private Func keySelector; public Func _003C_003E3__keySelector; private HashSet _003CseenKeys_003E5__2; private IEnumerator _003C_003E7__wrap2; TSource IEnumerator.Current { [DebuggerHidden] get { return _003C_003E2__current; } } object IEnumerator.Current { [DebuggerHidden] get { return _003C_003E2__current; } } [DebuggerHidden] public _003CDistinctBy_003Ed__55(int _003C_003E1__state) { this._003C_003E1__state = _003C_003E1__state; _003C_003El__initialThreadId = Environment.CurrentManagedThreadId; } [DebuggerHidden] void IDisposable.Dispose() { int num = _003C_003E1__state; if (num == -3 || num == 1) { try { } finally { _003C_003Em__Finally1(); } } _003CseenKeys_003E5__2 = null; _003C_003E7__wrap2 = null; _003C_003E1__state = -2; } private bool MoveNext() { try { switch (_003C_003E1__state) { default: return false; case 0: _003C_003E1__state = -1; _003CseenKeys_003E5__2 = new HashSet(); _003C_003E7__wrap2 = source.GetEnumerator(); _003C_003E1__state = -3; break; case 1: _003C_003E1__state = -3; break; } while (_003C_003E7__wrap2.MoveNext()) { TSource current = _003C_003E7__wrap2.Current; if (_003CseenKeys_003E5__2.Add(keySelector(current))) { _003C_003E2__current = current; _003C_003E1__state = 1; return true; } } _003C_003Em__Finally1(); _003C_003E7__wrap2 = null; return false; } catch { //try-fault ((IDisposable)this).Dispose(); throw; } } bool IEnumerator.MoveNext() { //ILSpy generated this explicit interface implementation from .override directive in MoveNext return this.MoveNext(); } private void _003C_003Em__Finally1() { _003C_003E1__state = -1; if (_003C_003E7__wrap2 != null) { _003C_003E7__wrap2.Dispose(); } } [DebuggerHidden] void IEnumerator.Reset() { throw new NotSupportedException(); } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { _003CDistinctBy_003Ed__55 _003CDistinctBy_003Ed__; if (_003C_003E1__state == -2 && _003C_003El__initialThreadId == Environment.CurrentManagedThreadId) { _003C_003E1__state = 0; _003CDistinctBy_003Ed__ = this; } else { _003CDistinctBy_003Ed__ = new _003CDistinctBy_003Ed__55(0); } _003CDistinctBy_003Ed__.source = _003C_003E3__source; _003CDistinctBy_003Ed__.keySelector = _003C_003E3__keySelector; return _003CDistinctBy_003Ed__; } [DebuggerHidden] IEnumerator IEnumerable.GetEnumerator() { return ((IEnumerable)this).GetEnumerator(); } } public static Stopwatch Stopwatch; public static DateTime? StartTime; public static async Task VerificarPagamento(long id) { bool[] pagamento = new bool[2]; if ((await new ParcelaServico().BuscarParcelas(id)).Any((Parcela x) => x.DataRecebimento.HasValue)) { pagamento[0] = true; } if ((await new VendedorServico().BuscaRepasse(id)).Any((VendedorParcela x) => x.DataPagamento.HasValue)) { pagamento[1] = true; } return pagamento; } public static decimal CalculaPagamento(VendedorParcela pagamento, Parcela parcela, decimal comissaoPrevista) { //IL_003b: Unknown result type (might be due to invalid IL or missing references) //IL_0041: Invalid comparison between Unknown and I4 //IL_00c2: Unknown result type (might be due to invalid IL or missing references) //IL_00c8: Invalid comparison between Unknown and I4 //IL_0109: Unknown result type (might be due to invalid IL or missing references) //IL_010f: Invalid comparison between Unknown and I4 //IL_0129: Unknown result type (might be due to invalid IL or missing references) //IL_012f: Invalid comparison between Unknown and I4 decimal num = pagamento.PorcentagemRepasse.GetValueOrDefault(); decimal valueOrDefault = pagamento.ValorRepasse.GetValueOrDefault(); decimal num2 = parcela.ValorComDesconto; Repasse repasse = pagamento.Repasse; if (repasse != null && (int)repasse.Incidencia.GetValueOrDefault() == 2) { decimal num3 = parcela.Documento.Comissao * parcela.Documento.PremioLiquido * 0.01m; decimal num4 = ((parcela.ValorComissao != 0m) ? (parcela.ValorComissao / num3) : 0m); num2 = parcela.Documento.PremioLiquido * num4; } Repasse repasse2 = pagamento.Repasse; if (repasse2 == null || (int)repasse2.Tipo.GetValueOrDefault() != 1) { num = num2 * pagamento.PorcentagemRepasse.GetValueOrDefault() * 0.01m; } Repasse repasse3 = pagamento.Repasse; if (repasse3 != null && (int)repasse3.Tipo.GetValueOrDefault() == 1) { Repasse repasse4 = pagamento.Repasse; if (repasse4 != null && (int)repasse4.Forma.GetValueOrDefault() == 1 && Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 25)) { decimal num5 = ((comissaoPrevista == 0m) ? 1m : (parcela.ValorComissao / comissaoPrevista)); num *= num5; } } if (!(Math.Abs(num) > Math.Abs(valueOrDefault))) { return num; } return valueOrDefault; } public static async Task BaixarComissao(Parcela parcela, List parcelas, List repasses, decimal tolerancia = 2m, bool comissaoAuto = false) { ParcelaServico servico = new ParcelaServico(); parcela.ValorComDesconto = ((parcela.ValorComDesconto == 0m && Math.Abs(parcela.ValorComDesconto) < Math.Abs(parcela.ValorComissao)) ? parcela.ValorComissao : parcela.ValorComDesconto); var source = from x in repasses group x by new { Id = ((DomainBase)x.Parcela).Id, vendedor = ((DomainBase)x.Vendedor).Id, tipovendedor = ((DomainBase)x.TipoVendedor).Id }; BaseDialogViewModel viewmodel = new BaseDialogViewModel(); if (source.Any(g => g.Count() > 1)) { Documento documento = parcela.Documento; object obj; if (!string.IsNullOrWhiteSpace((documento != null) ? documento.Apolice : null)) { Documento documento2 = parcela.Documento; obj = ((documento2 != null) ? documento2.Proposta : null); } else { Documento documento3 = parcela.Documento; obj = ((documento3 != null) ? documento3.Apolice : null); } string arg = (string)obj; await viewmodel.ShowMessage($"HÁ VENDEDORES DUPLICADOS PARA A PARCELA {parcela.NumeroParcela} DO DOCUMENTO {arg}, BAIXA DE COMISSÃO INTERROMPIDA.{Environment.NewLine}REALIZE A CORREÇÃO DOS VENDEDORES E TENTE NOVAMENTE."); parcela.DataRecebimento = null; parcela.ValorComissao = 0m; parcela.ValorComDesconto = 0m; parcela.Irr = 0m; parcela.Iss = 0m; parcela.Outros = 0m; parcela.Desconto = 0m; return parcela; } DateTime now = GetNetworkTime(); if ((int)parcela.SubTipo == 1 && (int)parcela.Documento.TipoRecebimento.GetValueOrDefault() == 1) { decimal num = (parcela.Documento.AdicionalComiss ? (parcela.Documento.PremioLiquido + parcela.Documento.PremioAdicional) : parcela.Documento.PremioLiquido); decimal comissaoPrevista = num * parcela.Documento.Comissao * 0.01m; decimal comissaoRecebida = parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && x.DataRecebimento.HasValue).Sum((Parcela x) => x.ValorComissao); decimal diferenca = Math.Abs(comissaoPrevista) - Math.Abs(comissaoRecebida); bool flag = diferenca <= tolerancia || diferenca < 0.01m; bool baixarProximas = (int)parcela.Documento.TipoRecebimento.GetValueOrDefault() == 1 && flag; bool esgotarParcelas = true; if (baixarProximas && Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 54)) { Parcela obj2 = parcela; object obj3; if (obj2 == null) { obj3 = null; } else { Documento documento4 = obj2.Documento; if (documento4 == null) { obj3 = null; } else { Controle controle = documento4.Controle; if (controle == null) { obj3 = null; } else { Cliente cliente = controle.Cliente; obj3 = ((cliente != null) ? cliente.Nome : null); } } } if (obj3 == null) { obj3 = string.Empty; } string text = (string)obj3; if (string.IsNullOrEmpty(text)) { Documento documento5 = parcela.Documento; int num2; if (documento5 == null) { num2 = 0; } else { Controle controle2 = documento5.Controle; long? obj4; if (controle2 == null) { obj4 = null; } else { Cliente cliente2 = controle2.Cliente; obj4 = ((cliente2 != null) ? new long?(((DomainBase)cliente2).Id) : null); } num2 = ((obj4 > 0) ? 1 : 0); } if (num2 != 0) { Cliente obj5 = await new ClienteServico().BuscarClienteAsync(((DomainBase)parcela.Documento.Controle.Cliente).Id); text = ((obj5 != null) ? obj5.Nome : null) ?? string.Empty; } } if (!string.IsNullOrEmpty(text)) { text = ", DO CLIENTE " + text; } Parcela obj6 = parcela; object obj7; if (obj6 == null) { obj7 = null; } else { Documento documento6 = obj6.Documento; obj7 = ((documento6 != null) ? documento6.Apolice : null); } if (obj7 == null) { obj7 = string.Empty; } string text2 = (string)obj7; if (!string.IsNullOrEmpty(text2)) { text2 = " - APÓLICE " + text2; } if (parcela.Documento.NumeroParcelas != (decimal)parcela.NumeroParcela) { bool flag2; baixarProximas = (flag2 = await viewmodel.ShowMessage($"AINDA RESTA {diferenca:c}{text}{text2} QUE NÃO SERÁ REPASSADO, CONTINUAR A BAIXA POR ESGOTAMENTO?", "SIM, BAIXAR POR ESGOMENTO", "NÃO")); esgotarParcelas = flag2; } } List list = repasses.Where(delegate(VendedorParcela x) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 if (((DomainBase)x.Parcela).Id == ((DomainBase)parcela).Id) { Repasse repasse4 = x.Repasse; if (repasse4 != null && (int)repasse4.Forma.GetValueOrDefault() == 1) { return !x.DataPagamento.HasValue; } } return false; }).ToList(); List demaisRepasses = new List(); Parcela proximaParcela = ((IEnumerable)parcelas).FirstOrDefault((Func)((Parcela x) => (int)x.SubTipo == 1 && x.NumeroParcela == parcela.NumeroParcela + 1)); Parcela parcela2 = parcela; ExtensionMethods.ForEach(from g in list group g by new { Id = ((DomainBase)g.Parcela).Id, vendedor = ((DomainBase)g.Vendedor).Id, tipovendedor = ((DomainBase)g.TipoVendedor).Id }, x => { //IL_00ba: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Unknown result type (might be due to invalid IL or missing references) //IL_00d0: Unknown result type (might be due to invalid IL or missing references) //IL_00dc: Unknown result type (might be due to invalid IL or missing references) //IL_00ed: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0110: Unknown result type (might be due to invalid IL or missing references) //IL_0121: Unknown result type (might be due to invalid IL or missing references) //IL_0132: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Unknown result type (might be due to invalid IL or missing references) //IL_0155: Expected O, but got Unknown if (!x.First().CoCorretagem) { decimal valueOrDefault = x.First().ValorRepasse.GetValueOrDefault(); decimal num4 = CalculaPagamento(x.First(), parcela2, comissaoPrevista); x.First().ValorRepasse = ((Math.Abs(valueOrDefault) > Math.Abs(num4)) ? num4 : valueOrDefault); x.First().DataPrePagamento = parcela2.DataRecebimento; if ((!esgotarParcelas || !(Math.Abs(comissaoPrevista) - Math.Abs(comissaoRecebida) <= Math.Abs(tolerancia))) && proximaParcela != null) { VendedorParcela item = new VendedorParcela { Repasse = x.First().Repasse, Parcela = proximaParcela, Documento = parcela2.Documento, ValorRepasse = valueOrDefault - num4, Vendedor = x.First().Vendedor, ValorTotal = x.First().ValorTotal, PorcentagemRepasse = x.First().PorcentagemRepasse, TipoVendedor = x.First().TipoVendedor, CoCorretagem = x.First().CoCorretagem }; demaisRepasses.Add(item); } } }); if (demaisRepasses.Count > 0) { list.AddRange(demaisRepasses); } if (!(await servico.SaveRange(list))) { await MostrarErro((TipoErro)24); return parcela; } Parcela val = await servico.Save(parcela, parcelas, null, abrirTela: false); parcela = val; if (!servico.Sucesso) { await MostrarErro((TipoErro)24); return parcela; } if (baixarProximas) { List list2 = parcelas.Where((Parcela x) => !x.DataRecebimento.HasValue && (int)x.SubTipo == 1).ToList(); List baixarRepasses = new List(); list2.ForEach(delegate(Parcela x) { x.Documento = parcela.Documento; x.DataRecebimento = parcela.DataRecebimento; x.DataCredito = parcela.DataRecebimento; x.ValorRealizado = 0m; x.ValorComissao = 0m; x.ValorComDesconto = 0m; x.Irr = 0m; x.Iss = 0m; List list4 = repasses.Where(delegate(VendedorParcela p) { //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0033: Invalid comparison between Unknown and I4 //IL_004b: Unknown result type (might be due to invalid IL or missing references) //IL_0051: Invalid comparison between Unknown and I4 if (((DomainBase)p.Parcela).Id == ((DomainBase)x).Id) { Repasse repasse2 = p.Repasse; if (repasse2 != null && (int)repasse2.Forma.GetValueOrDefault() == 1) { Repasse repasse3 = p.Repasse; if (repasse3 == null) { return true; } return (int)repasse3.Tipo.GetValueOrDefault() != 3; } } return false; }).ToList(); list4.ForEach(delegate(VendedorParcela p) { p.Parcela = x; p.Documento = parcela.Documento; p.DataPrePagamento = now; decimal? valorRepasse = p.ValorRepasse; decimal num3 = tolerancia; p.ValorRepasse = (((valorRepasse.GetValueOrDefault() > num3) & valorRepasse.HasValue) ? new decimal?(default(decimal)) : p.ValorRepasse); }); baixarRepasses.AddRange(list4); }); await servico.SaveRange(parcelas); if (!servico.Sucesso) { await MostrarErro((TipoErro)24); return parcela; } if (!(await servico.SaveRange(baixarRepasses))) { await MostrarErro((TipoErro)24); return parcela; } } } else { List list3 = repasses.Where(delegate(VendedorParcela x) { //IL_004a: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Invalid comparison between Unknown and I4 if (((DomainBase)x.Parcela).Id == ((DomainBase)parcela).Id && !x.DataPagamento.HasValue) { if (x == null) { return false; } Repasse repasse = x.Repasse; return (int)((repasse != null) ? repasse.Forma : null).GetValueOrDefault() == 1; } return false; }).ToList(); list3.ForEach(delegate(VendedorParcela x) { x.DataPrePagamento = parcela.DataRecebimento; x.ValorRepasse = CalculaRepasse(x.Repasse, parcela, apolice: false); }); parcela = await servico.Save(parcela, parcelas, list3, abrirTela: false); if (!servico.Sucesso) { await MostrarErro((TipoErro)24); return parcela; } } if (!comissaoAuto) { RegistrarLogBaixa(((DomainBase)parcela.Documento).Id, now); } return parcela; } private static async void RegistrarLogBaixa(long id, DateTime now) { ApoliceServico apoliceServico = new ApoliceServico(); ParcelaServico parcelaServico = new ParcelaServico(); VendedorServico vendedoresServico = new VendedorServico(); Documento apolice = await apoliceServico.BuscarApoliceAsync(id); Documento val = apolice; val.Parcelas = await parcelaServico.BuscarParcelasAsync(((DomainBase)apolice).Id); List list = await vendedoresServico.BuscaRepasse(((DomainBase)apolice).Id); foreach (Parcela parcela in apolice.Parcelas) { foreach (VendedorParcela item in list) { if (((DomainBase)item.Parcela).Id == ((DomainBase)parcela).Id) { if (parcela.Vendedores == null) { parcela.Vendedores = new ObservableCollection(); } parcela.Vendedores.Add(item); } } } IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); RegistroLog val2 = new RegistroLog { Acao = (TipoAcao)1, Usuario = Recursos.Usuario, DataHora = now, Descricao = JsonConvert.SerializeObject((object)apolice, new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1 }), EntidadeId = ((DomainBase)apolice).Id, Tela = (TipoTela)2, NomeMaquina = Environment.MachineName, UsuarioMaquina = Environment.UserName, Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() }; UnitOfWork commited = Instancia.Commited; try { commited.RegistroLogRepository.SaveOrUpdate(val2); ((GenericUnitOfWork)commited).Commit(); } finally { ((IDisposable)commited)?.Dispose(); } } public static async Task MostrarErro(TipoErro erro) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) await ((DispatcherObject)Application.Current).Dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate { //IL_0001: Unknown result type (might be due to invalid IL or missing references) ((Window)new ErrorWindow(erro, fecharSistema: true)).ShowDialog(); }); } public static async Task RecusarApolice(Documento documento, string motivo, bool estorno) { ApoliceServico servico = new ApoliceServico(); CriticaApoliceServico criticaServico = new CriticaApoliceServico(); string label = ((documento.Tipo == 0 && string.IsNullOrEmpty(documento.Apolice)) ? "PROPOSTA RECUSADA" : ((documento.Tipo == 0 && !string.IsNullOrEmpty(documento.Apolice)) ? "APÓLICE RECUSADA" : "ENDOSSO RECUSADO")); if (!string.IsNullOrWhiteSpace(motivo)) { documento.Observacao = $"{Recursos.Usuario.Nome}, ID: {((DomainBase)Recursos.Usuario).Id}, {GetNetworkTime():g}{Environment.NewLine}RECUSA: {motivo}{Environment.NewLine}{Environment.NewLine}{documento.Observacao}"; } bool flag; if (documento.Tipo == 0) { await servico.Save(documento, updateParcelas: false, criarParcelas: false); Controle controle = await servico.BuscarControleAsync(((DomainBase)documento.Controle).Id); if (((DomainBase)controle).Id == 0L) { return; } foreach (Documento documento2 in controle.Documentos) { if (!documento2.NegocioCorretora.HasValue) { documento2.NegocioCorretora = (NegocioCorretora)((documento2.Negocio.HasValue && (int)documento2.Negocio.GetValueOrDefault() == 1) ? 1 : 0); } documento2.Situacao = (TipoSeguro)7; documento2.Apolice = "RECUSADA"; if (!(await servico.BaixarParcelasCancelamento(documento2, estorno))) { Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); } } flag = await servico.UpdateRange(controle); } else { if (!documento.NegocioCorretora.HasValue) { documento.NegocioCorretora = (NegocioCorretora)((documento.Negocio.HasValue && (int)documento.Negocio.GetValueOrDefault() == 1) ? 1 : 0); } documento.Situacao = (TipoSeguro)7; documento.Apolice = "RECUSADA"; documento.Endosso = "RECUSADA"; if (!(await servico.BaixarParcelasCancelamento(documento, estorno))) { Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); } await servico.Save(documento, updateParcelas: false, criarParcelas: false); if (!servico.Sucesso) { Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); } if (!servico.Sucesso) { Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); } flag = await InativarItens(((DomainBase)documento).Id, ((DomainBase)documento.Controle.Ramo).Id, delete: false); if (!flag) { Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); } } if (!flag) { Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); } List list = await criticaServico.BuscarCritica(((DomainBase)documento).Id); if (list != null) { foreach (CriticaApolice item in list) { item.Critica = true; await criticaServico.Save(item); } } Gestor.Application.Actions.Actions.AcessaTela?.Invoke((TipoTela)21, ""); ToggleSnackBar(label + " COM SUCESSO"); } public static void ToggleSnackBar(string message, bool active = true) { ((ContentControl)App.SnackBar.Message).Content = message; App.SnackBar.IsActive = active; if (active) { Task.Factory.StartNew(CloseSlackBar); } } private static void CloseSlackBar() { Thread.Sleep(5000); Dispatcher dispatcher = ((DispatcherObject)App.ProgressRing).Dispatcher; if (dispatcher != null) { dispatcher.BeginInvoke((DispatcherPriority)4, (Delegate)(Action)delegate { ToggleSnackBar("", active: false); }); } } public static decimal CalculaRepasse(Repasse repasse, Parcela parcela, bool apolice = true) { //IL_0018: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Invalid comparison between Unknown and I4 //IL_00e9: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Invalid comparison between Unknown and I4 //IL_0036: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Invalid comparison between Unknown and I4 //IL_0042: Unknown result type (might be due to invalid IL or missing references) //IL_0048: Invalid comparison between Unknown and I4 //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0111: Invalid comparison between Unknown and I4 //IL_0170: Unknown result type (might be due to invalid IL or missing references) //IL_0176: Invalid comparison between Unknown and I4 //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0194: Invalid comparison between Unknown and I4 //IL_01ca: Unknown result type (might be due to invalid IL or missing references) //IL_01d0: Invalid comparison between Unknown and I4 //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Invalid comparison between Unknown and I4 //IL_0280: Unknown result type (might be due to invalid IL or missing references) //IL_0286: Invalid comparison between Unknown and I4 //IL_0289: Unknown result type (might be due to invalid IL or missing references) //IL_028f: Invalid comparison between Unknown and I4 //IL_02a0: Unknown result type (might be due to invalid IL or missing references) //IL_02a6: Invalid comparison between Unknown and I4 if (repasse == null) { return 0m; } bool flag = (int)parcela.Documento.NegocioCorretora.GetValueOrDefault() == 1; decimal num2; decimal num3; decimal num; if (apolice && (int)parcela.Documento.TipoRecebimento.GetValueOrDefault() != 2 && (int)parcela.SubTipo == 1) { num = (parcela.Documento.AdicionalComiss ? (parcela.Documento.PremioLiquido + parcela.Documento.PremioAdicional) : parcela.Documento.PremioLiquido); num2 = (parcela.Documento.AdicionalComiss ? (parcela.Documento.PremioLiquido + parcela.Documento.PremioAdicional) : parcela.Documento.PremioLiquido); num3 = parcela.Documento.Comissao * 0.01m; } else { decimal num4 = (((int)parcela.Documento.TipoRecebimento.GetValueOrDefault() == 2) ? parcela.ValorLiquidoFatura : parcela.Valor); num = (((int)repasse.Incidencia.GetValueOrDefault() == 2) ? num4 : ((parcela.ValorComDesconto == 0m) ? num4 : parcela.ValorComDesconto)); num2 = num; num3 = ((parcela.ValorComDesconto == 0m) ? (parcela.Comissao * 0.01m) : 1m); } num = (((int)repasse.Incidencia.GetValueOrDefault() == 2) ? num : (num * num3)); num = (((int)repasse.Tipo.GetValueOrDefault() == 1) ? num : (num * (flag ? repasse.ValorRenovacao : repasse.ValorNovo) * 0.01m)); decimal num5 = (((int)repasse.Incidencia.GetValueOrDefault() == 2) ? num2 : (num2 * num3)); decimal num6; if ((int)repasse.Tipo.GetValueOrDefault() == 1) { num6 = (flag ? repasse.ValorRenovacao : repasse.ValorNovo); if (Recursos.Configuracoes.Any((ConfiguracaoSistema x) => (int)x.Configuracao == 24) && parcela.Valor < 0m) { num6 = -num6; } } else { num6 = num5 * (flag ? repasse.ValorRenovacao : repasse.ValorNovo) * 0.01m; } if ((int)parcela.Documento.TipoRecebimento.GetValueOrDefault() != 2 && (int)parcela.SubTipo == 1 && (int)parcela.Documento.TipoEndosso.GetValueOrDefault() != 2) { if (Math.Abs(num6) > Math.Abs(num)) { new BaseDialogViewModel().ShowMessage("OS VALORES DE REPASSE ULTRAPASSARAM O VALOR DE COMISSÃO FECHADA. REVEJA OS VALORES."); } if (!(Math.Abs(num6) > Math.Abs(num))) { return num6; } return num; } if (!(parcela.ValorComDesconto != 0m) || !(Math.Abs(num6) > Math.Abs(parcela.ValorComDesconto)) || !Recursos.Configuracoes.All((ConfiguracaoSistema x) => (int)x.Configuracao != 15)) { return num6; } return parcela.ValorComDesconto; } public static async Task ExcluirBaixa(Parcela parcela, List repasses, List parcelas = null) { ParcelaServico servico = new ParcelaServico(); if ((int)parcela.SubTipo == 1 && (int)parcela.Documento.TipoRecebimento.GetValueOrDefault() == 1) { List source = repasses.Where(delegate(VendedorParcela x) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if ((int)x.Parcela.SubTipo == 1) { Repasse repasse4 = x.Repasse; if (repasse4 != null && (int)repasse4.Forma.GetValueOrDefault() == 1) { if (((DomainBase)x.Parcela).Id != ((DomainBase)parcela).Id) { return !x.DataPrePagamento.HasValue; } return true; } } return false; }).ToList(); decimal comiss = (parcela.Documento.PremioLiquido + (parcela.Documento.AdicionalComiss ? parcela.Documento.PremioAdicional : 0m)) * parcela.Documento.Comissao * 0.01m; List refazerRepasses = (from x in source group x by ((DomainBase)x.Vendedor).Id).Select((Func, VendedorParcela>)delegate(IGrouping x) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) //IL_003d: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Invalid comparison between Unknown and I4 //IL_013e: Unknown result type (might be due to invalid IL or missing references) //IL_014f: Unknown result type (might be due to invalid IL or missing references) //IL_0160: Unknown result type (might be due to invalid IL or missing references) //IL_0171: Unknown result type (might be due to invalid IL or missing references) //IL_0183: Expected O, but got Unknown VendedorParcela val2 = new VendedorParcela { Repasse = x.First().Repasse, Parcela = parcela, Documento = parcela.Documento }; VendedorParcela obj = x.First(); decimal? valorTotal; if (obj != null) { Repasse repasse3 = obj.Repasse; if ((int)((repasse3 != null) ? repasse3.Tipo : null).GetValueOrDefault() == 3) { valorTotal = x.First().ValorRepasse; goto IL_0139; } } VendedorParcela obj2 = x.First(); if (obj2 == null || !obj2.ValorTotal.HasValue) { goto IL_00d5; } VendedorParcela obj3 = x.First(); decimal? valorTotal2; if (obj3 != null) { valorTotal2 = obj3.ValorTotal; if ((valorTotal2.GetValueOrDefault() == default(decimal)) & valorTotal2.HasValue) { goto IL_00d5; } } VendedorParcela obj4 = x.First(); valorTotal = ((obj4 != null) ? obj4.ValorTotal : null); goto IL_0139; IL_0139: val2.ValorTotal = valorTotal; val2.Vendedor = x.First().Vendedor; val2.PorcentagemRepasse = x.First().PorcentagemRepasse; val2.TipoVendedor = x.First().TipoVendedor; val2.CoCorretagem = x.First().CoCorretagem; return val2; IL_00d5: decimal value = comiss; valorTotal2 = x.First().PorcentagemRepasse; valorTotal = (decimal?)value * valorTotal2 * (decimal?)0.01m; goto IL_0139; }).ToList(); List parcelasAnteriores = ((parcelas != null) ? parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && x.NumeroParcela < parcela.NumeroParcela).ToList() : new List()); refazerRepasses.ForEach(delegate(VendedorParcela y) { y.ValorRepasse = y.ValorTotal - repasses.Where(delegate(VendedorParcela x) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_002c: Invalid comparison between Unknown and I4 if ((int)x.Parcela.SubTipo == 1) { Repasse repasse2 = x.Repasse; if (repasse2 != null && (int)repasse2.Forma.GetValueOrDefault() == 1 && ((DomainBase)x.Vendedor).Id == ((DomainBase)y.Vendedor).Id) { return parcelasAnteriores.Select((Parcela z) => ((DomainBase)z).Id).ToList().Contains(((DomainBase)x.Parcela).Id); } } return false; }).Sum((VendedorParcela x) => x.ValorRepasse); }); List demaisParcelas3 = ((parcelas != null) ? parcelas.Where((Parcela x) => (int)x.SubTipo == 1 && x.NumeroParcela > parcela.NumeroParcela).ToList() : new List()); demaisParcelas3.Add(parcela); List repasses2 = repasses.Where(delegate(VendedorParcela x) { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000c: Invalid comparison between Unknown and I4 //IL_0023: Unknown result type (might be due to invalid IL or missing references) //IL_0029: Invalid comparison between Unknown and I4 if ((int)x.Parcela.SubTipo == 1) { Repasse repasse = x.Repasse; if (repasse != null && (int)repasse.Forma.GetValueOrDefault() == 1) { if (x.Parcela.NumeroParcela < parcela.NumeroParcela) { return !x.DataPrePagamento.HasValue; } return true; } } return false; }).ToList(); if (!(await servico.DeletePagamentoRange(repasses2))) { await MostrarErro((TipoErro)191); return parcela; } if (!(await servico.SaveRange(refazerRepasses))) { await MostrarErro((TipoErro)191); return parcela; } demaisParcelas3 = demaisParcelas3.Where((Parcela dParcela) => dParcela.ValorComissao != 0m || dParcela.ValorComissao != 0m || dParcela.DataRecebimento.HasValue || dParcela.DataCredito.HasValue || dParcela.ValorRealizado != 0m).ToList(); if (demaisParcelas3 != null && demaisParcelas3.Count > 0) { demaisParcelas3.ForEach(delegate(Parcela dParcela) { dParcela.Documento = parcela.Documento; dParcela.ValorComissao = 0m; dParcela.ValorComDesconto = 0m; dParcela.DataRecebimento = null; dParcela.DataCredito = null; dParcela.ValorRealizado = 0m; }); demaisParcelas3 = await servico.UpdateRange(demaisParcelas3); if (!servico.Sucesso) { await MostrarErro((TipoErro)191); return parcela; } parcela = ((IEnumerable)demaisParcelas3).FirstOrDefault((Func)((Parcela x) => ((DomainBase)x).Id == ((DomainBase)parcela).Id)); } } else { List list = repasses.Where((VendedorParcela x) => ((DomainBase)x.Parcela).Id == ((DomainBase)parcela).Id && !x.DataPagamento.HasValue).ToList(); list.ForEach(delegate(VendedorParcela x) { x.DataPrePagamento = null; x.ValorRepasse = x.ValorTotal ?? CalculaPagamento(x, x.Parcela, 0m); }); parcela.ValorComissao = 0m; parcela.ValorComDesconto = 0m; parcela.DataRecebimento = null; parcela.DataCredito = null; parcela.ValorRealizado = 0m; parcela = await servico.Save(parcela, parcelas, list, abrirTela: false); if (!servico.Sucesso) { await MostrarErro((TipoErro)191); return parcela; } } ApoliceServico apoliceServico = new ApoliceServico(); ParcelaServico parcelaServico = new ParcelaServico(); VendedorServico vendedoresServico = new VendedorServico(); if (parcela != null) { Documento apolice = await apoliceServico.BuscarApoliceAsync(((DomainBase)parcela.Documento).Id); Documento val = apolice; val.Parcelas = await parcelaServico.BuscarParcelasAsync(((DomainBase)apolice).Id); List list2 = await vendedoresServico.BuscaRepasse(((DomainBase)apolice).Id); foreach (Parcela parcela2 in apolice.Parcelas) { foreach (VendedorParcela item in list2) { if (((DomainBase)item.Parcela).Id == ((DomainBase)parcela2).Id) { if (parcela2.Vendedores == null) { parcela2.Vendedores = new ObservableCollection(); } parcela2.Vendedores.Add(item); } } } IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName()); RegistroLog registroLog = new RegistroLog { Acao = (TipoAcao)2, Usuario = Recursos.Usuario, DataHora = GetNetworkTime(), Descricao = JsonConvert.SerializeObject((object)apolice, new JsonSerializerSettings { ReferenceLoopHandling = (ReferenceLoopHandling)1 }), EntidadeId = ((DomainBase)apolice).Id, Tela = (TipoTela)2, NomeMaquina = Environment.MachineName, UsuarioMaquina = Environment.UserName, Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString() }; await Task.Run(delegate { UnitOfWork commited = Instancia.Commited; try { commited.RegistroLogRepository.SaveOrUpdate(registroLog); ((GenericUnitOfWork)commited).Commit(); } finally { ((IDisposable)commited)?.Dispose(); } }); } return parcela; } public static void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0006: Unknown result type (might be due to invalid IL or missing references) DatePicker val = (DatePicker)sender; val.Text = ValidationHelper.FormatDate(val.Text); } public static void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e) { //IL_0001: Unknown result type (might be due to invalid IL or missing references) //IL_0007: Invalid comparison between Unknown and I4 //IL_000b: Unknown result type (might be due to invalid IL or missing references) if ((int)e.Key == 6) { ((DatePicker)sender).Text = GetNetworkTime().Date.ToString("dd/MM/yyyy"); } } public static async Task OrganizarDocumentos(long id) { ApoliceServico servico = new ApoliceServico(); Controle val = await servico.BuscarControleAsync(id); int ordem = 1; (from x in val.Documentos where !x.Excluido orderby x.Vigencia1 select x).ToList().ForEach(delegate(Documento x) { if (x.Tipo == 0) { x.Ordem = 0; } else { x.Ordem = ordem; ordem++; } }); await servico.UpdateRange(val); } public static async Task ReativarItens(List ids) { ItemServico servico = new ItemServico(); List list = await servico.BuscarItems(ids); list.ForEach(delegate(Item x) { x.Substituido = null; x.Cancelado = false; x.Status = x.StatusInclusao; }); await servico.SaveRange(list); return servico.Sucesso; } public static async Task InativarItens(long id, long ramo, bool delete = true) { ItemServico servico = new ItemServico(); ObservableCollection itens = await servico.BuscarItens(id); if (!(await ReativarItens((from x in itens where x.Substituicao.HasValue select x.Substituicao.Value).ToList()))) { return false; } if (delete) { await servico.DeleteRange(itens.ToList(), ramo); } else { itens.ToList().ForEach(delegate(Item x) { x.Cancelado = true; }); await servico.SaveRange(itens.ToList()); } return servico.Sucesso; } public static string ExportarHtml(TipoRelatorio tipo, string dados, string porcentagem = "60", string orientation = "landscape", bool search = false, string grafico = "") { string newValue = $"DATA DE EMISSÃO DO RELATÓRIO EM {GetNetworkTime():G}"; if (tipo.Inicio != DateTime.MinValue && tipo.Nome != "RELATÓRIO DE CLIENTE") { newValue = $"PERÍODO DE {tipo.Inicio:d} ATÉ {tipo.Fim:d}. DATA DE EMISSÃO DO RELATÓRIO EM {GetNetworkTime():G}"; } string newValue2 = ((!search) ? "" : ""); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Resources.RelatorioTemplate.Replace("{style}", newValue2).Replace("Orientation", orientation).Replace("{NomeRelatorio}", Recursos.Empresa.NomeSocial + " - " + tipo.Nome) .Replace("{EmissaoRelatorio}", newValue) .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 newValue = $"DATA DE EMISSÃO DO RELATÓRIO EM {GetNetworkTime():G}"; if (tipo.Inicio != DateTime.MinValue && tipo.Nome != "RELATÓRIO DE CLIENTE") { newValue = $"PERÍODO DE {tipo.Inicio:d} ATÉ {tipo.Fim:d}. DATA DE EMISSÃO DO RELATÓRIO EM {GetNetworkTime():G}"; } string newValue2 = ((!search) ? "" : ""); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(Resources.RelatorioMultipleTemplate.Replace("{style}", newValue2).Replace("Orientation", orientation).Replace("{NomeRelatorio}", Recursos.Empresa.NomeSocial + " - " + tipo.Nome) .Replace("{EmissaoRelatorio}", newValue) .Replace("{Grafico}", grafico) .Replace("{DadosRelatorio}", dados)); return stringBuilder.ToString(); } public static string CriarRecibo(Vendedor vendedor, decimal valor, Filtros filtro, bool segundavia) { string text = (segundavia ? " acima listados" : $" no periodo de {filtro.Inicio:d} até {filtro.Fim:d}"); string text2 = "CPF"; if (vendedor.Documento != null && ValidationHelper.OnlyNumber(vendedor.Documento).Length > 12) { text2 = "CNPJ"; } return $"
\r\n
RECIBO DE PAGAMENTO
\r\n
\r\n
Declaração de recebimento de Comissão
\r\n

Eu {vendedor.Nome}, portador(a) do {text2} {vendedor.Documento} declaro que recebi de {Recursos.Empresa.Nome} o valor de {valor:c} referente a comissão dos seguros{text}.

\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

_____________________________________________________________
{GetNetworkTime().Date:d}

\r\n
\r\n
"; } public static string CreateCard(string title, string body, bool pageBreak = false) { StringBuilder stringBuilder = new StringBuilder(); stringBuilder.Append(pageBreak ? "
" : "
"); stringBuilder.Append("
"); stringBuilder.Append("
" + title + "
"); stringBuilder.Append(body); stringBuilder.Append("
"); stringBuilder.Append("
"); return stringBuilder.ToString(); } public static async Task GenerateTableSintetic(List sintetic, int fontSize = 0) { if (sintetic == null || sintetic.Count == 0) { return ""; } string classSize = ((fontSize == 0) ? "" : $"fs-{fontSize}'"); return await Task.Run(delegate { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder headerContent = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); StringBuilder content = new StringBuilder(); sintetic.ForEach(delegate(SinteticModel x) { headerContent.Append(Resources.HeaderTemplate.Replace("{Align}", "text-center").Replace("{Size}", classSize).Replace("{FontWeight}", "fw-bold") .Replace("{Content}", x.Hint)); content.Append(Resources.ColumnTemplate.Replace("{Align}", "text-center").Replace("{Size}", classSize).Replace("{FontWeight}", "") .Replace("{Content}", (x.Value == null) ? "" : x.Value.ToString())); }); stringBuilder2.Append(Resources.RowTemplate.Replace("{Content}", headerContent.ToString()).Replace("{Color}", "")); stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", content.ToString()).Replace("{Color}", "")); stringBuilder.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder2.ToString()).Replace("{Body}", stringBuilder3.ToString()).Replace("{Footer}", "")); return stringBuilder.ToString(); }); } public static async Task GenerateTableSintetic(List sintetic, int fontSize = 0) { if (sintetic == null || sintetic.Count == 0) { return ""; } string classSize = ((fontSize == 0) ? "" : $"fs-{fontSize}'"); return await Task.Run(delegate { StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder headerContent = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); sintetic.ForEach(delegate(SinteticModelList x) { headerContent.Append(Resources.HeaderTemplate.Replace("{Align}", "text-center").Replace("{Size}", classSize).Replace("{FontWeight}", "fw-bold") .Replace("{Content}", x.Hint)); }); stringBuilder2.Append(Resources.RowTemplate.Replace("{Content}", headerContent.ToString()).Replace("{Color}", "")); for (int i = 0; i < sintetic.First().Value.Count; i++) { StringBuilder stringBuilder4 = new StringBuilder(); bool flag = false; foreach (SinteticModelList item in sintetic) { flag = flag || (item.Value[0] != null && item.Value[i].ToString() == "TOTAL"); stringBuilder4.Append(Resources.ColumnTemplate.Replace("{Align}", "text-center").Replace("{Size}", classSize).Replace("{FontWeight}", flag ? "fw-bold" : "") .Replace("{Content}", $"{item.Value[i]}")); } stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", "")); } stringBuilder.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder2.ToString()).Replace("{Body}", stringBuilder3.ToString()).Replace("{Footer}", "")); return stringBuilder.ToString(); }); } public static async Task GenerateTable(List analitico, List colunasOcultas, bool grafico = false, bool propertyName = false, string footer = "", ConfiguracaoImpressao config = null) { if (analitico == null) { return ""; } if (analitico.Count == 0) { return ""; } int num = 0; if (config != null) { num = config.TamanhoFonte; } string classSize = ((num == 0) ? "" : $"fs-{num}'"); return await Task.Run(delegate { //IL_0112: Unknown result type (might be due to invalid IL or missing references) StringBuilder stringBuilder = new StringBuilder(); StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder rowContent = new StringBuilder(); Type type = analitico[0].GetType(); PropertyInfo[] properties = type.GetProperties(); int num2 = 0; PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if (!(propertyInfo.Name == "ValidationEvent")) { object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); if (obj != null) { string description = ((DescriptionAttribute)obj).Description; if ((!propertyName || !colunasOcultas.Contains(propertyInfo.Name)) && (propertyName || !colunasOcultas.Contains(description))) { object obj2 = propertyInfo.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault(); string text = ""; if (obj2 != null) { text = ((TipoAttribute)obj2).Description; } string newValue = "text-start"; switch (text) { case "PERCENTUAL": case "VALOR": newValue = "text-center"; break; case "QUANTIDADE": case "DATA": newValue = "text-end"; break; } stringBuilder2.Append(Resources.HeaderTemplate.Replace("{Align}", newValue).Replace("{Size}", classSize).Replace("{FontWeight}", "fw-bold") .Replace("{Content}", description)); num2++; } } } } stringBuilder.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder2.ToString()).Replace("{Color}", "")); analitico.ForEach(delegate(T x) { //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Invalid comparison between Unknown and I4 //IL_01d8: Unknown result type (might be due to invalid IL or missing references) type = x.GetType(); properties = type.GetProperties(); PropertyInfo propertyInfo2 = properties.FirstOrDefault((PropertyInfo b) => b.Name == "Bold"); bool flag = propertyInfo2 != null && (bool)propertyInfo2.GetValue(x); PropertyInfo propertyInfo3 = properties.FirstOrDefault((PropertyInfo b) => b.Name == "Sinal"); Sinal result; string text2 = ((propertyInfo3 != null && propertyInfo3.GetValue(x) != null && Enum.TryParse(propertyInfo3.GetValue(x).ToString(), ignoreCase: true, out result) && (int)result == 1) ? "color: red;" : "color: black;"); if (!flag) { _ = ""; } else { _ = ""; } StringBuilder stringBuilder4 = new StringBuilder(); PropertyInfo[] array2 = properties; foreach (PropertyInfo propertyInfo4 in array2) { if (!(propertyInfo4.Name == "ValidationEvent")) { object obj3 = propertyInfo4.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); if (obj3 != null) { string description2 = ((DescriptionAttribute)obj3).Description; if ((!propertyName || !colunasOcultas.Contains(propertyInfo4.Name)) && (propertyName || !colunasOcultas.Contains(description2))) { object obj4 = propertyInfo4.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault(); string text3 = ""; if (obj4 != null) { text3 = ((TipoAttribute)obj4).Description; } string newValue2 = "text-start"; string newValue3; switch (text3) { default: newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{propertyInfo4.GetValue(x)}" : ""); break; case "PERCENTUAL": newValue2 = "text-end"; newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{(decimal)propertyInfo4.GetValue(x) * 0.01m:p2}" : ""); break; case "VALOR": newValue2 = "text-end"; newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{(decimal)propertyInfo4.GetValue(x):c2}" : ""); break; case "VALORDECIMAL2": newValue2 = "text-end"; newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{(decimal)propertyInfo4.GetValue(x):n2}" : ""); break; case "DATA": newValue2 = "text-center"; newValue3 = ((propertyInfo4.GetValue(x) == null || (DateTime)propertyInfo4.GetValue(x) == DateTime.MinValue) ? "" : $"{(DateTime)propertyInfo4.GetValue(x):d}"); break; case "QUANTIDADE": newValue2 = "text-center"; newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{propertyInfo4.GetValue(x)}" : ""); break; case "ENUM": newValue3 = ((propertyInfo4.GetValue(x) != null) ? (ValidationHelper.GetDescription((Enum)propertyInfo4.GetValue(x)) ?? "") : ""); break; case "DATA/TIME?": case "DATA/TIME": newValue2 = "text-center"; newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{(DateTime?)propertyInfo4.GetValue(x):G}" : ""); break; case "DATA?": newValue2 = "text-center"; newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{(DateTime?)propertyInfo4.GetValue(x):d}" : ""); break; case "VALOR?": newValue2 = "text-end"; newValue3 = ((propertyInfo4.GetValue(x) != null) ? $"{(decimal?)propertyInfo4.GetValue(x):c2}" : ""); break; } stringBuilder4.Append(Resources.ColumnTemplate.Replace("{Align}", newValue2).Replace("{Size}", classSize).Replace("{FontWeight}", flag ? "fw-bold" : "") .Replace("{Content}", newValue3)); } } } } rowContent.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", "style='" + text2 + "'")); }); StringBuilder stringBuilder3 = new StringBuilder(); if (grafico) { rowContent.Append(""); rowContent.Append("
"); rowContent.Append("
*VALORES NEGATIVOS NÃO SÃO REPRESENTADOS NO GRÁFICO DE PIZZA.
"); rowContent.Append(""); } stringBuilder3.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder.ToString()).Replace("{Body}", rowContent.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer)) ? Resources.FooterTemplate.Replace("{Content}", $"{footer}") : "")); return stringBuilder3.ToString(); }); } public static async Task GenerateMultipleTable(List> analiticos, List colunasOcultas, bool grafico = false, bool propertyName = false, string footer = "", ConfiguracaoImpressao config = null) { if (analiticos == null) { return ""; } if (analiticos.Count == 0) { return ""; } int num = 0; if (config != null) { num = config.TamanhoFonte; } string classSize = ((num == 0) ? "" : $"fs-{num}'"); return await Task.Run(delegate { StringBuilder stringBuilder = new StringBuilder(); int num2 = 0; foreach (List analitico in analiticos) { StringBuilder stringBuilder2 = new StringBuilder(); StringBuilder stringBuilder3 = new StringBuilder(); StringBuilder stringBuilder4 = new StringBuilder(); int num3 = 0; stringBuilder3.Append(Resources.HeaderTemplate.Replace("{Align}", "text-start").Replace("{Size}", "").Replace("{FontWeight}", "fw-bold") .Replace("{Content}", analitico[0].NomeRelatorio)); stringBuilder2.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder3.ToString()).Replace("{Color}", "")); analitico.ForEach(delegate(Listagem x) { //IL_0098: Unknown result type (might be due to invalid IL or missing references) //IL_009b: Invalid comparison between Unknown and I4 //IL_018c: Unknown result type (might be due to invalid IL or missing references) PropertyInfo[] properties = ((object)x).GetType().GetProperties(); PropertyInfo propertyInfo = properties.FirstOrDefault((PropertyInfo b) => b.Name == "Bold"); bool flag = propertyInfo != null && (bool)propertyInfo.GetValue(x); PropertyInfo propertyInfo2 = properties.FirstOrDefault((PropertyInfo b) => b.Name == "Sinal"); Sinal result; string text = ((propertyInfo2 != null && propertyInfo2.GetValue(x) != null && Enum.TryParse(propertyInfo2.GetValue(x).ToString(), ignoreCase: true, out result) && (int)result == 1) ? "color: red;" : "color: black;"); if (!flag) { _ = ""; } else { _ = ""; } StringBuilder stringBuilder6 = new StringBuilder(); PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo3 in array) { if (!(propertyInfo3.Name == "ValidationEvent")) { object obj = propertyInfo3.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); if (obj != null) { string description = ((DescriptionAttribute)obj).Description; if ((!propertyName || !colunasOcultas.Contains(propertyInfo3.Name)) && (propertyName || !colunasOcultas.Contains(description))) { object obj2 = propertyInfo3.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault(); string text2 = ""; if (obj2 != null) { text2 = ((TipoAttribute)obj2).Description; } string newValue = "text-start"; string newValue2; switch (text2) { default: newValue2 = ((propertyInfo3.GetValue(x) != null) ? $"{propertyInfo3.GetValue(x)}" : ""); break; case "PERCENTUAL": newValue = "text-end"; newValue2 = ((propertyInfo3.GetValue(x) != null) ? $"{(decimal)propertyInfo3.GetValue(x) * 0.01m:p2}" : ""); break; case "VALOR": newValue = "text-end"; newValue2 = ((propertyInfo3.GetValue(x) != null) ? $"{(decimal)propertyInfo3.GetValue(x):c2}" : ""); break; case "DATA": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(x) == null || (DateTime)propertyInfo3.GetValue(x) == DateTime.MinValue) ? "" : $"{(DateTime)propertyInfo3.GetValue(x):d}"); break; case "QUANTIDADE": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(x) != null) ? $"{propertyInfo3.GetValue(x)}" : ""); break; case "ENUM": newValue2 = ((propertyInfo3.GetValue(x) != null) ? (ValidationHelper.GetDescription((Enum)propertyInfo3.GetValue(x)) ?? "") : ""); break; case "DATA/TIME?": case "DATA/TIME": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(x) != null) ? $"{(DateTime?)propertyInfo3.GetValue(x):G}" : ""); break; case "DATA?": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(x) != null) ? $"{(DateTime?)propertyInfo3.GetValue(x):d}" : ""); break; case "VALOR?": newValue = "text-end"; newValue2 = ((propertyInfo3.GetValue(x) != null) ? $"{(decimal?)propertyInfo3.GetValue(x):c2}" : ""); break; } stringBuilder6.Append(Resources.ColumnTemplate.Replace("{Align}", newValue).Replace("{Size}", classSize).Replace("{FontWeight}", flag ? "fw-bold" : "") .Replace("{Content}", newValue2)); } } } } }); StringBuilder stringBuilder5 = new StringBuilder(); if (grafico) { stringBuilder4.Append($"
"); } num2++; stringBuilder5.Append(Resources.TableMultipleTemplate.Replace("{Head}", stringBuilder2.ToString()).Replace("{Body}", stringBuilder4.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer)) ? Resources.FooterTemplate.Replace("{Content}", $"{footer}") : "")); stringBuilder.Append(stringBuilder5.ToString()); } return stringBuilder.ToString(); }); } public static async Task GerarXlsSintetico(XLWorkbook xlWorkbook, string nome, List sintetic) { return await Task.Run((Func)delegate { try { nome = nome.ValidaNomePlanilha(); IXLWorksheet xlWorksheet = xlWorkbook.Worksheets.Add(nome); int indexColumn = 1; sintetic.ForEach(delegate(SinteticModel x) { xlWorksheet.Cell(1, indexColumn).Value = x.Hint; xlWorksheet.Cell(2, indexColumn).Value = x.Value; indexColumn++; }); ((IXLFontBase)((IXLRangeBase)xlWorksheet.Row(1)).Style.Font).Bold = true; xlWorksheet.Columns().AdjustToContents(); return xlWorkbook; } catch (Exception) { return (XLWorkbook)null; } }); } public static async Task GenerateTable(List analitico, Relatorio relatorio, bool grafico = false, bool verificarColunas = true, string footer = "", ConfiguracaoImpressao config = null) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) int fontSize = 0; List parametros; if (config == null) { List list = ((!verificarColunas) ? null : (await new ConfuguracoesServico().BuscarParametros(relatorio))); parametros = list; if (parametros == null || parametros.Count == 0) { PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public); parametros = ((IEnumerable)properties).Select((Func)((PropertyInfo x) => new ParametrosRelatorio { Campo = x.Name, Header = x.GetDescriptionAttribute(), Tipo = x.GetTypeAttribute(), Relatorio = relatorio, Width = 0, Ordem = 0 })).ToList(); } } else { parametros = config.Campos; fontSize = config.TamanhoFonte; } string classSize = ((fontSize == 0) ? "" : $"fs-{fontSize}'"); parametros = await GetRestricoesColunas(parametros); if (analitico == null) { return ""; } if (analitico.Count == 0) { return ""; } return await Task.Run(delegate { StringBuilder stringBuilder = new StringBuilder(); StringBuilder headerContent = new StringBuilder(); StringBuilder rowContent = new StringBuilder(); Type type = analitico[0].GetType(); PropertyInfo[] properties2 = type.GetProperties(); int columnsCount = 0; ExtensionMethods.ForEach((IEnumerable)(from x in parametros orderby x.Ordem, x.Header select x), (Action)delegate(ParametrosRelatorio x) { if (!(x.Tipo == "INVALID")) { PropertyInfo propertyInfo4 = properties2.FirstOrDefault((PropertyInfo p) => p.Name == x.Campo); if (!(propertyInfo4 == null)) { string descriptionAttribute = propertyInfo4.GetDescriptionAttribute(); string newValue3 = "text-start"; switch (x.Tipo) { case "PERCENTUAL": case "VALOR": newValue3 = "text-center"; break; case "QUANTIDADE": case "DATA": newValue3 = "text-end"; break; } headerContent.Append(Resources.HeaderTemplate.Replace("{Align}", newValue3).Replace("{Size}", classSize).Replace("{FontWeight}", "fw-bold") .Replace("{Content}", descriptionAttribute)); columnsCount++; } } }); stringBuilder.Append(Resources.RowTemplate.Replace("{Content}", headerContent.ToString()).Replace("{Color}", "")); analitico.ForEach(delegate(T a) { //IL_0101: Unknown result type (might be due to invalid IL or missing references) //IL_0104: Invalid comparison between Unknown and I4 StringBuilder content = new StringBuilder(); type = a.GetType(); properties2 = type.GetProperties(); PropertyInfo propertyInfo = properties2.FirstOrDefault((PropertyInfo b) => b.Name == "Bold"); bool bold = propertyInfo != null && (bool)propertyInfo.GetValue(a); PropertyInfo propertyInfo2 = properties2.FirstOrDefault((PropertyInfo b) => b.Name == "Sinal"); Sinal result; string text = ((propertyInfo2 != null && propertyInfo2.GetValue(a) != null && Enum.TryParse(propertyInfo2.GetValue(a).ToString(), ignoreCase: true, out result) && (int)result == 1) ? "color: red;" : "color: black;"); if (!bold) { _ = ""; } else { _ = ""; } ExtensionMethods.ForEach((IEnumerable)(from x in parametros orderby x.Ordem, x.Header select x), (Action)delegate(ParametrosRelatorio x) { if (!(x.Tipo == "INVALID")) { PropertyInfo propertyInfo3 = properties2.FirstOrDefault((PropertyInfo p) => p.Name == x.Campo); if (!(propertyInfo3 == null)) { string newValue = "text-start"; string newValue2; switch (x.Tipo) { default: newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{propertyInfo3.GetValue(a)}" : ""); break; case "PERCENTUAL": newValue = "text-end"; newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{(decimal)propertyInfo3.GetValue(a) * 0.01m:p2}" : ""); break; case "VALOR": newValue = "text-end"; newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{(decimal)propertyInfo3.GetValue(a):c2}" : ""); break; case "VALORDECIMAL2": newValue = "text-end"; newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{(decimal)propertyInfo3.GetValue(a):n2}" : ""); break; case "DATA": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(a) == null || (DateTime)propertyInfo3.GetValue(a) == DateTime.MinValue) ? "" : $"{(DateTime)propertyInfo3.GetValue(a):d}"); break; case "QUANTIDADE": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{propertyInfo3.GetValue(a)}" : ""); break; case "ENUM": newValue2 = ((propertyInfo3.GetValue(a) != null && Convert.ToInt32(propertyInfo3.GetValue(a)) != 0) ? (ValidationHelper.GetDescription((Enum)propertyInfo3.GetValue(a)) ?? "") : ""); break; case "DATA/TIME?": case "DATA/TIME": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{(DateTime?)propertyInfo3.GetValue(a):G}" : ""); break; case "DATA?": newValue = "text-center"; newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{(DateTime?)propertyInfo3.GetValue(a):d}" : ""); break; case "VALOR?": newValue = "text-end"; newValue2 = ((propertyInfo3.GetValue(a) != null) ? $"{(decimal?)propertyInfo3.GetValue(a):c2}" : ""); break; } content.Append(Resources.ColumnTemplate.Replace("{Align}", newValue).Replace("{Size}", classSize).Replace("{FontWeight}", bold ? "fw-bold" : "") .Replace("{Content}", newValue2)); } } }); rowContent.Append(Resources.RowTemplate.Replace("{Content}", content.ToString()).Replace("{Color}", "style='" + text + "'")); }); StringBuilder stringBuilder2 = new StringBuilder(); stringBuilder2.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder.ToString()).Replace("{Body}", rowContent.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer)) ? Resources.FooterTemplate.Replace("{Content}", $"{footer}") : "")); return stringBuilder2.ToString(); }); } public static async Task GerarXls(XLWorkbook xlWorkbook, string nome, List analitico, Relatorio relatorio, bool verificarColunas = true) { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0027: Unknown result type (might be due to invalid IL or missing references) nome = nome.ValidaNomePlanilha(); List list = ((!verificarColunas) ? null : (await new ConfuguracoesServico().BuscarParametros(relatorio))); List parametros = list; if (parametros == null || parametros.Count == 0) { PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public); parametros = ((IEnumerable)properties).Select((Func)((PropertyInfo x) => new ParametrosRelatorio { Campo = x.Name, Header = x.GetDescriptionAttribute(), Tipo = x.GetTypeAttribute(), Relatorio = relatorio, Width = 0, Ordem = 0 })).ToList(); } parametros = await GetRestricoesColunas(parametros); return await Task.Run((Func)delegate { try { IXLWorksheet xlWorksheet = xlWorkbook.Worksheets.Add(nome); Type type = analitico[0].GetType(); PropertyInfo[] properties2 = type.GetProperties(); int indexColumn = 1; ExtensionMethods.ForEach((IEnumerable)(from x in parametros orderby x.Ordem, x.Header select x), (Action)delegate(ParametrosRelatorio x) { if (!(x.Tipo == "INVALID")) { PropertyInfo propertyInfo2 = properties2.FirstOrDefault((PropertyInfo p) => p.Name == x.Campo || (p.Name.ToUpper().Equals("NOME") && x.Campo.ToUpper().Equals("VENDEDOR") && nome.Equals("SINTÉTICO POR VENDEDOR") && (int)relatorio == 7) || (p.Name.ToUpper().Equals("NOME") && x.Campo.ToUpper().Equals("SEGURADORA") && nome.Equals("SINTÉTICO POR SEGURADORA") && (int)relatorio == 7) || (p.Name.ToUpper().Equals("NOME") && x.Campo.ToUpper().Equals("RAMO") && nome.Equals("SINTÉTICO POR RAMO") && (int)relatorio == 7)); if (!(propertyInfo2 == null)) { xlWorksheet.Cell(1, indexColumn).Value = propertyInfo2.GetDescriptionAttribute(); indexColumn++; } } }); int indexRow = 2; analitico.ForEach(delegate(T a) { indexColumn = 1; int row = indexRow; ExtensionMethods.ForEach((IEnumerable)(from x in parametros orderby x.Ordem, x.Header select x), (Action)delegate(ParametrosRelatorio x) { if (!(x.Tipo == "INVALID")) { PropertyInfo propertyInfo = properties2.FirstOrDefault((PropertyInfo p) => p.Name == x.Campo || (p.Name.ToUpper().Equals("NOME") && x.Campo.ToUpper().Equals("VENDEDOR") && nome.Equals("SINTÉTICO POR VENDEDOR") && (int)relatorio == 7) || (p.Name.ToUpper().Equals("NOME") && x.Campo.ToUpper().Equals("SEGURADORA") && nome.Equals("SINTÉTICO POR SEGURADORA") && (int)relatorio == 7) || (p.Name.ToUpper().Equals("NOME") && x.Campo.ToUpper().Equals("RAMO") && nome.Equals("SINTÉTICO POR RAMO") && (int)relatorio == 7)); if (!(propertyInfo == null)) { Regex regex = new Regex("\\<[^\\>]*\\>"); object obj = propertyInfo.GetValue(a); if (obj != null && obj.ToString().Contains(">") && obj.ToString().Contains("<")) { obj = regex.Replace(obj.ToString(), ""); } switch (x.Tipo) { default: ((IXLNumberFormatBase)xlWorksheet.Cell(row, indexColumn).Style.NumberFormat).Format = "@"; xlWorksheet.Cell(row, indexColumn).Value = $"{obj}"; break; case "DATA/TIME?": case "DATA/TIME": ((IXLNumberFormatBase)xlWorksheet.Cell(row, indexColumn).Style.NumberFormat).Format = "dd/MM/yyyy HH:mm:ss"; xlWorksheet.Cell(row, indexColumn).Value = $"{obj}"; break; case "DATA?": case "DATA": ((IXLNumberFormatBase)xlWorksheet.Cell(row, indexColumn).Style.NumberFormat).Format = "dd/MM/yyyy"; xlWorksheet.Cell(row, indexColumn).Value = $"{obj}"; break; case "VALOR": xlWorksheet.Cell(row, indexColumn).Style.NumberFormat.SetNumberFormatId(2); xlWorksheet.Cell(row, indexColumn).Value = ((decimal?)obj).GetValueOrDefault(); break; case "QUANTIDADE": xlWorksheet.Cell(row, indexColumn).Style.NumberFormat.SetNumberFormatId(1); xlWorksheet.Cell(row, indexColumn).Value = obj; break; case "PERCENTUAL": xlWorksheet.Cell(row, indexColumn).Style.NumberFormat.SetNumberFormatId(10); xlWorksheet.Cell(row, indexColumn).Value = ((decimal?)obj).GetValueOrDefault() * 0.01m; break; } int num = indexColumn; indexColumn = num + 1; } } }); indexRow++; }); ((IXLFontBase)((IXLRangeBase)xlWorksheet.Row(1)).Style.Font).Bold = true; xlWorksheet.Columns().AdjustToContents(); return xlWorkbook; } catch (Exception) { return (XLWorkbook)null; } }); } public static async Task GerarXls(XLWorkbook xlWorkbook, string nome, List analitico, List colunasOcultas = null) { return await Task.Run((Func)delegate { try { nome = nome.ValidaNomePlanilha(); IXLWorksheet xlWorksheet = xlWorkbook.Worksheets.Add(nome); Type type = analitico[0].GetType(); PropertyInfo[] properties = type.GetProperties(); int indexColumn = 1; PropertyInfo[] array = properties; foreach (PropertyInfo propertyInfo in array) { if (!(propertyInfo.Name == "ValidationEvent")) { object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); if (obj != null) { string description = ((DescriptionAttribute)obj).Description; if (colunasOcultas == null || !colunasOcultas.Contains(description)) { xlWorksheet.Cell(1, indexColumn).Value = description; indexColumn++; } } } } int indexRow = 2; analitico.ForEach(delegate(T x) { indexColumn = 1; type = x.GetType(); properties = type.GetProperties(); PropertyInfo[] array2 = properties; foreach (PropertyInfo propertyInfo2 in array2) { if (propertyInfo2.Name == "ValidationEvent") { continue; } object obj2 = propertyInfo2.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); if (obj2 == null) { continue; } string description2 = ((DescriptionAttribute)obj2).Description; if (colunasOcultas != null && colunasOcultas.Contains(description2)) { continue; } string name = propertyInfo2.Name; if (!name.Contains("Fipe")) { switch (name) { case "NumeroProposta": case "NumeroApolice": case "NumeroPedidoEndosso": break; default: goto IL_010f; } } ((IXLNumberFormatBase)xlWorksheet.Cell(indexRow, indexColumn).Style.NumberFormat).Format = "@"; goto IL_010f; IL_010f: xlWorksheet.Cell(indexRow, indexColumn).Value = propertyInfo2.GetValue(x); indexColumn++; } indexRow++; }); ((IXLFontBase)((IXLRangeBase)xlWorksheet.Row(1)).Style.Font).Bold = true; xlWorksheet.Columns().AdjustToContents(); return xlWorkbook; } catch (Exception) { return (XLWorkbook)null; } }); } public static bool IsWindowOpen(string title) where T : Window { return ((IEnumerable)Application.Current.Windows).OfType().Any((T x) => ((Window)x).Title == title); } public static void Destroy() where T : Window { object obj = ((IEnumerable)Application.Current.Windows).OfType().FirstOrDefault(); if (obj != null) { ((Window)obj).Close(); } } public static void Destroy(string title) where T : Window { object obj = ((IEnumerable)Application.Current.Windows).OfType().FirstOrDefault((T x) => ((Window)x).Title == title); if (obj != null) { ((Window)obj).Close(); } } public static T GetValueFromType(this object objeto) { Type typeFromHandle = typeof(T); PropertyInfo[] properties = objeto.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo propertyInfo in properties) { if (!(propertyInfo.PropertyType != typeFromHandle)) { return (T)propertyInfo.GetValue(objeto); } } return default(T); } private static async Task> GetRestricoesColunas(List parametros) { List restricoes = await new RestricaoUsuarioServico().BuscarRestricoesCamposRelatorios(((DomainBase)Recursos.Usuario).Id); restricoes = restricoes.Where((RestricaoUsuarioCamposRelatorios x) => x.Restricao).ToList(); return parametros.Where((ParametrosRelatorio x) => restricoes.Where((RestricaoUsuarioCamposRelatorios y) => x.Relatorio == y.Relatorio).All((RestricaoUsuarioCamposRelatorios y) => x.Header != y.Campo)).ToList(); } public static async Task ContruirLista(this DataGrid grid, Relatorio relatorio) { //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0017: Unknown result type (might be due to invalid IL or missing references) List list = await new ConfuguracoesServico().BuscarParametros(relatorio); if (list == null || list.Count == 0) { list = ((IEnumerable)typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public)).Select((Func)((PropertyInfo x) => new ParametrosRelatorio { Campo = x.Name, Header = x.GetDescriptionAttribute(), Tipo = x.GetTypeAttribute(), Relatorio = relatorio, Width = 0, Ordem = 0 })).ToList(); } if (!Recursos.Usuario.Administrador) { list = await GetRestricoesColunas(list); } (from x in list orderby x.Ordem, x.Header select x).ToList().ForEach(delegate(ParametrosRelatorio x) { //IL_0077: Unknown result type (might be due to invalid IL or missing references) //IL_007d: Expected O, but got Unknown //IL_0091: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected O, but got Unknown //IL_0335: Unknown result type (might be due to invalid IL or missing references) //IL_033a: Unknown result type (might be due to invalid IL or missing references) //IL_021a: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0234: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Expected O, but got Unknown //IL_01db: Unknown result type (might be due to invalid IL or missing references) //IL_01e1: Expected O, but got Unknown //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_01fb: Expected O, but got Unknown //IL_0361: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0367: Unknown result type (might be due to invalid IL or missing references) //IL_0373: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Expected O, but got Unknown //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0384: Unknown result type (might be due to invalid IL or missing references) //IL_038b: Unknown result type (might be due to invalid IL or missing references) //IL_0397: Expected O, but got Unknown //IL_0397: Unknown result type (might be due to invalid IL or missing references) //IL_02d4: Unknown result type (might be due to invalid IL or missing references) //IL_02da: Expected O, but got Unknown //IL_02ee: Unknown result type (might be due to invalid IL or missing references) //IL_02f4: Expected O, but got Unknown //IL_03b8: Unknown result type (might be due to invalid IL or missing references) //IL_03a7: Unknown result type (might be due to invalid IL or missing references) //IL_0298: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Expected O, but got Unknown //IL_02b2: Unknown result type (might be due to invalid IL or missing references) //IL_02b8: Expected O, but got Unknown //IL_0259: Unknown result type (might be due to invalid IL or missing references) //IL_025f: Expected O, but got Unknown //IL_0273: Unknown result type (might be due to invalid IL or missing references) //IL_0279: Expected O, but got Unknown //IL_03c2: Unknown result type (might be due to invalid IL or missing references) //IL_03c9: Unknown result type (might be due to invalid IL or missing references) //IL_03d5: Expected O, but got Unknown //IL_030a: Unknown result type (might be due to invalid IL or missing references) //IL_0310: Expected O, but got Unknown //IL_0324: Unknown result type (might be due to invalid IL or missing references) //IL_032a: Expected O, but got Unknown if (!(x.Tipo == "INVALID") && (!(x.Campo == "DataControle") || Recursos.Usuario.Administrador || !Recursos.Configuracoes.Any((ConfiguracaoSistema c) => (int)c.Configuracao == 33))) { string stringFormat = ""; Style elementStyle = (Style)Application.Current.Resources[(object)"VerticalCenterStyle3"]; Style headerStyle = (Style)Application.Current.Resources[(object)"MaterialDesignDataGridColumnHeaderNew"]; switch (x.Tipo) { case "DATA/TIME?": case "DATA/TIME": stringFormat = "G"; elementStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterStyle2"]; headerStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterHeaderStyleNew"]; break; case "DATA?": case "DATA": stringFormat = "d"; elementStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterStyle2"]; headerStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterHeaderStyleNew"]; break; case "PERCENTUAL": stringFormat = "{0:0.00}%"; elementStyle = (Style)Application.Current.Resources[(object)"HorizontalRightStyle"]; headerStyle = (Style)Application.Current.Resources[(object)"HorizontalRightHeaderStyleNew"]; break; case "VALOR": stringFormat = "c"; elementStyle = (Style)Application.Current.Resources[(object)"HorizontalRightStyle"]; headerStyle = (Style)Application.Current.Resources[(object)"HorizontalRightHeaderStyleNew"]; break; case "VALORDECIMAL2": stringFormat = "n2"; elementStyle = (Style)Application.Current.Resources[(object)"HorizontalRightStyle"]; headerStyle = (Style)Application.Current.Resources[(object)"HorizontalRightHeaderStyleNew"]; break; case "QUANTIDADE": elementStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterStyle2"]; headerStyle = (Style)Application.Current.Resources[(object)"HorizontalCenterHeaderStyleNew"]; break; } grid.Columns.Add((DataGridColumn)new MaterialDataGridTextColumn { Header = (x.Header?.ToUpper() ?? x.Campo.ToUpper()), Binding = (BindingBase)new Binding { Path = new PropertyPath(x.Campo, Array.Empty()), StringFormat = stringFormat, Mode = (BindingMode)0, UpdateSourceTrigger = (UpdateSourceTrigger)1 }, Width = (DataGridLength)((x.Width == 0) ? new DataGridLength(1.0, (DataGridLengthUnitType)0) : DataGridLength.op_Implicit((double)x.Width)), ElementStyle = elementStyle, HeaderStyle = headerStyle }); } }); } public static List ConstruirSintetico(this List sintetico, Relatorio relatorio) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (sintetico == null) { return null; } List sintetics = new List(); typeof(Sintetico).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList().ForEach(delegate(PropertyInfo props) { //IL_0744: Unknown result type (might be due to invalid IL or missing references) //IL_0724: Unknown result type (might be due to invalid IL or missing references) //IL_078d: Unknown result type (might be due to invalid IL or missing references) //IL_0792: Unknown result type (might be due to invalid IL or missing references) //IL_0799: Unknown result type (might be due to invalid IL or missing references) //IL_07a9: Expected O, but got Unknown if (props.GetValue(sintetico.First()) != null) { string descriptionAttribute = props.GetDescriptionAttribute(); TipoRestricao? val = null; switch (descriptionAttribute) { case "PRÊMIO TOTAL": val = (TipoRestricao)65; break; case "TOTAL DE CLIENTES": case "TOTAL DE CLIENTES ATIVOS": case "TOTAL DE CLIENTES INATIVOS": val = (TipoRestricao)66; break; case "PRÊMIO LÍQUIDO": val = (TipoRestricao)67; break; case "MÉDIA DE COMISSÃO GERADA": case "MÉDIA DE COMISSÃO PONDERADA": case "MÉDIA DE COMISSÃO FECHADA": val = (TipoRestricao)68; break; case "QUANTIDADE DE NOVOS NEGÓCIOS": case "QUANTIDADE DE NEGÓCIOS PRÓPRIOS": val = (TipoRestricao)69; break; case "QUANTIDADE DE RENOVAÇÕES": case "QUANTIDADE DE SEGUROS NOVOS": val = (TipoRestricao)70; break; case "QUANTIDADE DE CANCELAMENTOS": val = (TipoRestricao)71; break; case "QUANTIDADE DE APÓLICES": val = (TipoRestricao)72; break; case "QUANTIDADE DE ENDOSSOS": val = (TipoRestricao)73; break; case "QUANTIDADE DE FATURAS": val = (TipoRestricao)74; break; case "TOTAL GERAL": val = (TipoRestricao)75; break; case "TOTAL DE LÍQUIDO": val = (TipoRestricao)76; break; case "QUANTIDADE DE PROSPECÇÕES": val = (TipoRestricao)77; break; case "TOTAL DE COMISSÃO GERADA": val = (TipoRestricao)78; break; case "COMISSÃO RECEBIDA BRUTA": val = (TipoRestricao)79; break; case "COMISSÃO RECEBIDA LÍQUIDA": val = (TipoRestricao)92; break; case "IMPOSTOS": val = (TipoRestricao)93; break; case "COMISSÃO PREVISTA": val = (TipoRestricao)80; break; case "REPASSE": val = (TipoRestricao)81; break; case "TOTAL PREVISTO": val = (TipoRestricao)82; break; case "TOTAL DE TERCEIROS": val = (TipoRestricao)83; break; case "QUANTIDADE LIQUIDADO": val = (TipoRestricao)84; break; case "QUANTIDADE PENDENTE": val = (TipoRestricao)85; break; case "VALOR LIQUIDADO": val = (TipoRestricao)86; break; case "VALOR": val = (TipoRestricao)100; break; case "VALOR ORÇADO": val = (TipoRestricao)101; break; case "VALOR LIBERADO": val = (TipoRestricao)103; break; case "VALOR PAGO": val = (TipoRestricao)104; break; case "VALOR SALVADO": val = (TipoRestricao)105; break; case "VALOR FRANQUIA": val = (TipoRestricao)106; break; case "COMISSÃO PENDENTE": val = (TipoRestricao)87; break; case "META ATINGIR": val = (TipoRestricao)88; break; case "META CUMPRIDA": val = (TipoRestricao)89; break; case "TOTAL PARCELAS": val = (TipoRestricao)102; break; } if (val.HasValue) { RestricaoUsuario val2 = new RestricaoUsuarioServico().BuscarRestricao(Recursos.Usuario, val.Value); if (val2 != null && val2.Restricao) { return; } } List list = new ConfuguracoesServico().BuscarParametroTotalizacao(relatorio); if (list == null || list.Count <= 0 || !list.All((ParametrosTotalizacao y) => y.Campo != props.Name) || props.Name.ToUpperInvariant().Contains("AGRUPAMENTO")) { SinteticModelList sintetic = new SinteticModelList { Hint = descriptionAttribute, Value = new List() }; string tipo = props.GetTypeAttribute(); sintetico.ForEach(delegate(Sintetico s) { object item; switch (tipo) { default: item = $"{props.GetValue(s)}"; break; case "DATA/TIME": case "DATA/TIME?": item = ((DateTime?)props.GetValue(s))?.ToString("G"); break; case "DATA": case "DATA?": item = ((DateTime?)props.GetValue(s))?.ToString("d"); break; case "PERCENTUAL": item = $"{props.GetValue(s):n2} %"; break; case "VALOR": item = ((decimal)props.GetValue(s)).ToString("c2"); break; } sintetic.Value.Add(item); }); sintetics.Add(sintetic); } } }); return sintetics; } public static List ConstruirSintetico(this Sintetico sintetico, Relatorio relatorio) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) if (sintetico == null) { return null; } List sintetics = new List(); typeof(Sintetico).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList().ForEach(delegate(PropertyInfo x) { //IL_074d: Unknown result type (might be due to invalid IL or missing references) //IL_072d: Unknown result type (might be due to invalid IL or missing references) //IL_077d: Unknown result type (might be due to invalid IL or missing references) //IL_0782: Unknown result type (might be due to invalid IL or missing references) //IL_0789: Unknown result type (might be due to invalid IL or missing references) //IL_0792: Expected O, but got Unknown if (x.GetValue(sintetico) != null) { string descriptionAttribute = x.GetDescriptionAttribute(); TipoRestricao? val = null; string descriptionField = null; switch (descriptionAttribute) { case "PRÊMIO TOTAL": val = (TipoRestricao)65; break; case "TOTAL DE CLIENTES": case "TOTAL DE CLIENTES ATIVOS": case "TOTAL DE CLIENTES INATIVOS": val = (TipoRestricao)66; break; case "PRÊMIO LÍQUIDO": val = (TipoRestricao)67; break; case "MÉDIA DE COMISSÃO GERADA": case "MÉDIA DE COMISSÃO PONDERADA": case "MÉDIA DE COMISSÃO FECHADA": val = (TipoRestricao)68; break; case "QUANTIDADE DE NOVOS NEGÓCIOS": case "QUANTIDADE DE NEGÓCIOS PRÓPRIOS": val = (TipoRestricao)69; break; case "QUANTIDADE DE RENOVAÇÕES": case "QUANTIDADE DE SEGUROS NOVOS": val = (TipoRestricao)70; break; case "QUANTIDADE DE CANCELAMENTOS": val = (TipoRestricao)71; break; case "QUANTIDADE DE APÓLICES": val = (TipoRestricao)72; break; case "QUANTIDADE DE ENDOSSOS": val = (TipoRestricao)73; break; case "QUANTIDADE DE FATURAS": val = (TipoRestricao)74; break; case "TOTAL GERAL": val = (TipoRestricao)75; descriptionField = "CONTAGEM GERAL DE DOCUMENTOS"; break; case "TOTAL DE LÍQUIDO": val = (TipoRestricao)76; descriptionField = "CONTAGEM GERAL DOS DOCUMENTOS ATIVOS"; break; case "QUANTIDADE DE PROSPECÇÕES": val = (TipoRestricao)77; break; case "TOTAL DE COMISSÃO GERADA": val = (TipoRestricao)78; break; case "COMISSÃO RECEBIDA BRUTA": val = (TipoRestricao)79; break; case "COMISSÃO RECEBIDA LÍQUIDA": val = (TipoRestricao)92; break; case "IMPOSTOS": val = (TipoRestricao)93; break; case "COMISSÃO PREVISTA": val = (TipoRestricao)80; break; case "REPASSE": val = (TipoRestricao)81; break; case "TOTAL PREVISTO": val = (TipoRestricao)82; break; case "TOTAL DE TERCEIROS": val = (TipoRestricao)83; break; case "QUANTIDADE LIQUIDADO": val = (TipoRestricao)84; break; case "QUANTIDADE PENDENTE": val = (TipoRestricao)85; break; case "VALOR LIQUIDADO": val = (TipoRestricao)86; break; case "VALOR": val = (TipoRestricao)100; break; case "VALOR ORÇADO": val = (TipoRestricao)101; break; case "VALOR LIBERADO": val = (TipoRestricao)103; break; case "VALOR PAGO": val = (TipoRestricao)104; break; case "VALOR SALVADO": val = (TipoRestricao)105; break; case "VALOR FRANQUIA": val = (TipoRestricao)106; break; case "COMISSÃO PENDENTE": val = (TipoRestricao)87; break; case "META ATINGIR": val = (TipoRestricao)88; break; case "META CUMPRIDA": val = (TipoRestricao)89; break; case "TOTAL PARCELAS": val = (TipoRestricao)102; break; } if (val.HasValue) { RestricaoUsuario val2 = new RestricaoUsuarioServico().BuscarRestricao(Recursos.Usuario, val.Value); if (val2 != null && val2.Restricao) { return; } } List list = new ConfuguracoesServico().BuscarParametroTotalizacao(relatorio); if (list == null || list.Count <= 0 || !list.All((ParametrosTotalizacao y) => y.Campo != x.Name)) { SinteticModel val3 = new SinteticModel { Hint = descriptionAttribute, DescriptionField = descriptionField }; switch (x.GetTypeAttribute()) { default: val3.Value = $"{x.GetValue(sintetico)}"; break; case "DATA/TIME?": case "DATA/TIME": val3.Value = ((DateTime?)x.GetValue(sintetico))?.ToString("G"); break; case "DATA?": case "DATA": val3.Value = ((DateTime?)x.GetValue(sintetico))?.ToString("d"); break; case "PERCENTUAL": val3.Value = $"{x.GetValue(sintetico)} %"; break; case "VALOR": val3.Value = ((decimal)x.GetValue(sintetico)).ToString("c2"); break; case "VALORDECIMAL2": val3.Value = ((decimal)x.GetValue(sintetico)).ToString("n2"); break; } sintetics.Add(val3); } } }); return sintetics; } public static string GetTypeAttribute(this PropertyInfo pi) { //IL_0021: Unknown result type (might be due to invalid IL or missing references) object obj = pi.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault(); if (obj == null) { return ""; } return ((TipoAttribute)obj).Description; } public static string GetDescriptionAttribute(this PropertyInfo pi) { object obj = pi.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); if (obj == null) { return pi.Name.ToUpper(); } return ((DescriptionAttribute)obj).Description; } public static List OcultarColunasDescricao(Type type, string categoria) { List list = new List(); PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propertyInfo in properties) { if (propertyInfo.Name == "ValidationEvent") { continue; } object obj = propertyInfo.GetCustomAttributes(typeof(CategoryAttribute), inherit: true).FirstOrDefault(); if (obj != null && !(((CategoryAttribute)obj).Category == categoria)) { object obj2 = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), inherit: true).FirstOrDefault(); if (obj2 != null) { string description = ((DescriptionAttribute)obj2).Description; list.Add(description); } } } return list; } public static string SubstituirVariaveis(string corpo, MalaDireta envio) { //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002d: Unknown result type (might be due to invalid IL or missing references) //IL_0097: Expected I4, but got Unknown //IL_009d: Unknown result type (might be due to invalid IL or missing references) //IL_00c6: Unknown result type (might be due to invalid IL or missing references) //IL_0108: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Unknown result type (might be due to invalid IL or missing references) //IL_05ce: Unknown result type (might be due to invalid IL or missing references) //IL_0655: Unknown result type (might be due to invalid IL or missing references) //IL_068d: Unknown result type (might be due to invalid IL or missing references) //IL_06c5: Unknown result type (might be due to invalid IL or missing references) //IL_070e: Unknown result type (might be due to invalid IL or missing references) //IL_078a: Unknown result type (might be due to invalid IL or missing references) //IL_023a: Unknown result type (might be due to invalid IL or missing references) //IL_0268: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Unknown result type (might be due to invalid IL or missing references) //IL_0415: Unknown result type (might be due to invalid IL or missing references) //IL_0451: Unknown result type (might be due to invalid IL or missing references) //IL_047f: Unknown result type (might be due to invalid IL or missing references) //IL_04ad: Unknown result type (might be due to invalid IL or missing references) //IL_018a: Unknown result type (might be due to invalid IL or missing references) //IL_01e9: Unknown result type (might be due to invalid IL or missing references) //IL_050d: Unknown result type (might be due to invalid IL or missing references) //IL_05f0: Unknown result type (might be due to invalid IL or missing references) //IL_06f2: Unknown result type (might be due to invalid IL or missing references) //IL_02d0: Unknown result type (might be due to invalid IL or missing references) //IL_0314: Unknown result type (might be due to invalid IL or missing references) //IL_063b: Unknown result type (might be due to invalid IL or missing references) //IL_0753: Unknown result type (might be due to invalid IL or missing references) //IL_0759: Invalid comparison between Unknown and I4 //IL_058f: Unknown result type (might be due to invalid IL or missing references) //IL_07e6: Unknown result type (might be due to invalid IL or missing references) //IL_07ec: Invalid comparison between Unknown and I4 DateTime networkTime = GetNetworkTime(); VariaveisMalaDireta[] array = (VariaveisMalaDireta[])Enum.GetValues(typeof(VariaveisMalaDireta)); foreach (VariaveisMalaDireta val in array) { switch ((int)val) { case 0: corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), networkTime.ToString(new CultureInfo("pt-BR"))); break; case 1: corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), ValidationHelper.IsNotNullOrEmpty(envio.Cliente.NomeSocialRg) ? envio.Cliente.NomeSocialRg : envio.Cliente.Nome); break; case 2: corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Cliente.Documento); break; case 16: corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Cliente.VencimentoHabilitacao?.ToString("d")); break; case 14: if (envio.Cliente.Nascimento.HasValue) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Cliente.Nascimento?.ToString("dd/MM")); } break; case 15: if (envio.Cliente.Nascimento.HasValue) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Cliente.Nascimento?.ToString("d")); } break; case 3: if (envio.Apolice != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Apolice.Proposta); } break; case 4: if (envio.Apolice != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Apolice.Apolice + ((envio.Apolice.Tipo != 0) ? (", endosso de número: " + envio.Apolice.Endosso) : "")); } break; case 5: { Documento apolice9 = envio.Apolice; if (((apolice9 != null) ? apolice9.Controle : null) != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Apolice.Controle.Ramo.Nome); } break; } case 6: { Documento apolice3 = envio.Apolice; if (((apolice3 != null) ? apolice3.Controle : null) != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Apolice.Controle.Seguradora.Nome); } break; } case 7: if (envio.Apolice != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Apolice.Vigencia1.ToString("d")); } break; case 8: if (envio.Apolice != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Apolice.Vigencia2?.ToString("d")); } break; case 9: if (envio.Parcela != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Parcela.Vencimento.ToString("d")); } break; case 10: if (envio.Parcela != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Parcela.Valor.ToString("c2")); } break; case 11: if (envio.Item != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Item.Descricao); } break; case 12: if (envio.Sinistro != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Sinistro.Numero); } break; case 13: if (envio.Parcela != null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), envio.Parcela.NumeroParcela.ToString()); } break; case 17: { if (envio.ArquivoDigital == null || envio.ArquivoDigital.All((IndiceArquivoDigital x) => string.IsNullOrWhiteSpace(x.UrlAssinatura))) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), string.Empty); break; } string links = ""; envio.ArquivoDigital.Where((IndiceArquivoDigital x) => !string.IsNullOrWhiteSpace(x.UrlAssinatura)).ToList().ForEach(delegate(IndiceArquivoDigital x) { links = links + ""; }); links += "
ABAIXO OS DOCUMENTOS PARA ASSINATURA
" + x.Descricao + "
"; corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), links); break; } case 18: { string newValue3 = $"ABAIXO O LINK PARA MEU CARTÃO DE VISITA.
CARTÃO DE VISITA ELETRÔNICO"; corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), newValue3); break; } case 19: { if (envio.Apolice == null) { corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), string.Empty); break; } Uri assistance = Address.Assistance; object arg; if (envio == null) { arg = null; } else { Documento apolice7 = envio.Apolice; arg = ((apolice7 != null) ? ((DomainBase)apolice7).Id.GeraAssistencia() : null); } string newValue2 = $"ABAIXO O LINK PARA O SEU CARTÃO ASSISTÊNCIA.
CARTÃO ASSISTÊNCIA"; corpo = corpo.Replace(ValidationHelper.GetEntity((Enum)(object)val), newValue2); break; } case 20: { string text3 = corpo; string entity3 = ValidationHelper.GetEntity((Enum)(object)val); Documento apolice4 = envio.Apolice; corpo = text3.Replace(entity3, (apolice4 != null) ? apolice4.PremioLiquido.ToString("c") : null); break; } case 21: { string text2 = corpo; string entity2 = ValidationHelper.GetEntity((Enum)(object)val); Documento apolice2 = envio.Apolice; corpo = text2.Replace(entity2, (apolice2 != null) ? apolice2.PremioTotal.ToString("c") : null); break; } case 22: { string text5 = corpo; string entity5 = ValidationHelper.GetEntity((Enum)(object)val); Documento apolice8 = envio.Apolice; object newValue4; if (apolice8 == null) { newValue4 = null; } else { FormaPagamento? formaPagamento = apolice8.FormaPagamento; newValue4 = (formaPagamento.HasValue ? ValidationHelper.GetDescription((Enum)(object)formaPagamento.GetValueOrDefault()) : null); } corpo = text5.Replace(entity5, (string?)newValue4); break; } case 23: { string text4 = corpo; string entity4 = ValidationHelper.GetEntity((Enum)(object)val); Documento apolice5 = envio.Apolice; object newValue; if (((apolice5 != null) ? new decimal?(apolice5.NumeroParcelas) : null).HasValue && (int)envio.Apolice.TipoRecebimento.GetValueOrDefault() != 2) { Documento apolice6 = envio.Apolice; newValue = ((apolice6 != null) ? apolice6.NumeroParcelas.ToString() : null); } else { newValue = "Indefinido"; } corpo = text4.Replace(entity4, (string?)newValue); break; } case 24: { string text = corpo; string entity = ValidationHelper.GetEntity((Enum)(object)val); Documento apolice = envio.Apolice; corpo = text.Replace(entity, (!((apolice != null) ? new decimal?(apolice.NumeroParcelas) : null).HasValue || envio.Apolice.NumeroParcelas == 0m || (int)envio.Apolice.TipoRecebimento.GetValueOrDefault() == 2) ? "Verificar documento anexado" : (envio.Apolice.PremioTotal / envio.Apolice.NumeroParcelas).ToString()); break; } } } return corpo; } public static string GetText(string html) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) HtmlDocument val = new HtmlDocument(); val.LoadHtml(html); return NodeText(val.DocumentNode); } private static string NodeText(HtmlNode node) { //IL_0056: Unknown result type (might be due to invalid IL or missing references) //IL_005c: Invalid comparison between Unknown and I4 //IL_0025: Unknown result type (might be due to invalid IL or missing references) //IL_002b: Invalid comparison between Unknown and I4 string text = ""; if (node.HasChildNodes) { foreach (HtmlNode item in (IEnumerable)node.ChildNodes) { text += (((int)item.NodeType == 3) ? item.InnerText : NodeText(item)); } } else if ((int)node.NodeType == 3) { text = node.InnerText; } return text; } public static string AdicionarLog(string html) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) HtmlDocument val = new HtmlDocument(); val.LoadHtml(html); DateTime networkTime = GetNetworkTime(); foreach (HtmlNode item in (IEnumerable)val.DocumentNode.ChildNodes) { if (!(item.Name != "body")) { item.InnerHtml = $"

{Recursos.Usuario.Nome} ID-{((DomainBase)Recursos.Usuario).Id} {networkTime:g}

{item.InnerHtml}
"; return item.InnerHtml; } } return ""; } public static List PopularFiltroPersonalizado() { //IL_0062: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Unknown result type (might be due to invalid IL or missing references) //IL_0073: Unknown result type (might be due to invalid IL or missing references) //IL_0080: Expected O, but got Unknown List list = new List(); foreach (PropertyInfo item in from x in typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public) orderby ValidationHelper.DescriptionAttribute(x) select x) { if (item.Name == "ValidationEvent") { continue; } FiltroPersonalizado val = new FiltroPersonalizado { Propriedade = item.Name, Nome = item.GetDescriptionAttribute() }; if (!(item.GetTypeAttribute() == "INVALID")) { Type type = item.PropertyType; if (type.IsGenericType && type.GetGenericTypeDefinition() == typeof(Nullable<>)) { type = type.GetGenericArguments()[0]; } val.Tipo = ((type.BaseType == typeof(Enum)) ? type.BaseType : type); list.Add(val); } } return list; } public static List PopularFiltroFinanceiro() { //IL_0006: Unknown result type (might be due to invalid IL or missing references) //IL_000b: Unknown result type (might be due to invalid IL or missing references) //IL_0016: Unknown result type (might be due to invalid IL or missing references) //IL_0021: Unknown result type (might be due to invalid IL or missing references) //IL_0036: Expected O, but got Unknown //IL_0037: Unknown result type (might be due to invalid IL or missing references) //IL_003c: Unknown result type (might be due to invalid IL or missing references) //IL_0047: Unknown result type (might be due to invalid IL or missing references) //IL_0052: Unknown result type (might be due to invalid IL or missing references) //IL_0067: Expected O, but got Unknown //IL_0068: Unknown result type (might be due to invalid IL or missing references) //IL_006d: Unknown result type (might be due to invalid IL or missing references) //IL_0078: Unknown result type (might be due to invalid IL or missing references) //IL_0083: Unknown result type (might be due to invalid IL or missing references) //IL_0098: Expected O, but got Unknown //IL_0099: Unknown result type (might be due to invalid IL or missing references) //IL_009e: Unknown result type (might be due to invalid IL or missing references) //IL_00a9: Unknown result type (might be due to invalid IL or missing references) //IL_00b4: Unknown result type (might be due to invalid IL or missing references) //IL_00c9: Expected O, but got Unknown //IL_00ca: Unknown result type (might be due to invalid IL or missing references) //IL_00cf: Unknown result type (might be due to invalid IL or missing references) //IL_00da: Unknown result type (might be due to invalid IL or missing references) //IL_00e5: Unknown result type (might be due to invalid IL or missing references) //IL_00fa: Expected O, but got Unknown //IL_00fb: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_010b: Unknown result type (might be due to invalid IL or missing references) //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_012b: Expected O, but got Unknown //IL_012c: Unknown result type (might be due to invalid IL or missing references) //IL_0131: Unknown result type (might be due to invalid IL or missing references) //IL_013c: Unknown result type (might be due to invalid IL or missing references) //IL_0147: Unknown result type (might be due to invalid IL or missing references) //IL_015c: Expected O, but got Unknown //IL_015d: Unknown result type (might be due to invalid IL or missing references) //IL_0162: Unknown result type (might be due to invalid IL or missing references) //IL_016d: Unknown result type (might be due to invalid IL or missing references) //IL_0178: Unknown result type (might be due to invalid IL or missing references) //IL_018d: Expected O, but got Unknown //IL_018e: Unknown result type (might be due to invalid IL or missing references) //IL_0193: Unknown result type (might be due to invalid IL or missing references) //IL_019e: Unknown result type (might be due to invalid IL or missing references) //IL_01a9: Unknown result type (might be due to invalid IL or missing references) //IL_01be: Expected O, but got Unknown //IL_01bf: Unknown result type (might be due to invalid IL or missing references) //IL_01c4: Unknown result type (might be due to invalid IL or missing references) //IL_01cf: Unknown result type (might be due to invalid IL or missing references) //IL_01da: Unknown result type (might be due to invalid IL or missing references) //IL_01ef: Expected O, but got Unknown //IL_01f0: Unknown result type (might be due to invalid IL or missing references) //IL_01f5: Unknown result type (might be due to invalid IL or missing references) //IL_0200: Unknown result type (might be due to invalid IL or missing references) //IL_020b: Unknown result type (might be due to invalid IL or missing references) //IL_0220: Expected O, but got Unknown //IL_0221: Unknown result type (might be due to invalid IL or missing references) //IL_0226: Unknown result type (might be due to invalid IL or missing references) //IL_0231: Unknown result type (might be due to invalid IL or missing references) //IL_023c: Unknown result type (might be due to invalid IL or missing references) //IL_0251: Expected O, but got Unknown //IL_0252: Unknown result type (might be due to invalid IL or missing references) //IL_0257: Unknown result type (might be due to invalid IL or missing references) //IL_0262: Unknown result type (might be due to invalid IL or missing references) //IL_026d: Unknown result type (might be due to invalid IL or missing references) //IL_0282: Expected O, but got Unknown //IL_0283: Unknown result type (might be due to invalid IL or missing references) //IL_0288: Unknown result type (might be due to invalid IL or missing references) //IL_0293: Unknown result type (might be due to invalid IL or missing references) //IL_029e: Unknown result type (might be due to invalid IL or missing references) //IL_02b3: Expected O, but got Unknown //IL_02b4: Unknown result type (might be due to invalid IL or missing references) //IL_02b9: Unknown result type (might be due to invalid IL or missing references) //IL_02c4: Unknown result type (might be due to invalid IL or missing references) //IL_02cf: Unknown result type (might be due to invalid IL or missing references) //IL_02e4: Expected O, but got Unknown //IL_02e5: Unknown result type (might be due to invalid IL or missing references) //IL_02ea: Unknown result type (might be due to invalid IL or missing references) //IL_02f5: Unknown result type (might be due to invalid IL or missing references) //IL_0300: Unknown result type (might be due to invalid IL or missing references) //IL_0315: Expected O, but got Unknown //IL_0316: Unknown result type (might be due to invalid IL or missing references) //IL_031b: Unknown result type (might be due to invalid IL or missing references) //IL_0326: Unknown result type (might be due to invalid IL or missing references) //IL_0331: Unknown result type (might be due to invalid IL or missing references) //IL_0346: Expected O, but got Unknown //IL_0347: Unknown result type (might be due to invalid IL or missing references) //IL_034c: Unknown result type (might be due to invalid IL or missing references) //IL_0357: Unknown result type (might be due to invalid IL or missing references) //IL_0362: Unknown result type (might be due to invalid IL or missing references) //IL_0377: Expected O, but got Unknown //IL_0378: Unknown result type (might be due to invalid IL or missing references) //IL_037d: Unknown result type (might be due to invalid IL or missing references) //IL_0388: Unknown result type (might be due to invalid IL or missing references) //IL_0393: Unknown result type (might be due to invalid IL or missing references) //IL_03a8: Expected O, but got Unknown //IL_03a9: Unknown result type (might be due to invalid IL or missing references) //IL_03ae: Unknown result type (might be due to invalid IL or missing references) //IL_03b9: Unknown result type (might be due to invalid IL or missing references) //IL_03c4: Unknown result type (might be due to invalid IL or missing references) //IL_03d9: Expected O, but got Unknown return new List { new FiltroPersonalizado { Propriedade = "Id", Nome = "ID", Tipo = typeof(long) }, new FiltroPersonalizado { Propriedade = "Controle.Fornecedor.NomeSocial", Nome = "FORNECEDOR", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Controle.Fornecedor.Ativo", Nome = "FORNECEDOR ATIVO", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Historico", Nome = "HISTÓRICO", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Parcela", Nome = "PARCELA", Tipo = typeof(int) }, new FiltroPersonalizado { Propriedade = "Documento", Nome = "DOCUMENTO", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Competencia", Nome = "COMPETÊNCIA", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Complemento", Nome = "COMPLEMENTO", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Vencimento", Nome = "VENCIMENTO", Tipo = typeof(DateTime) }, new FiltroPersonalizado { Propriedade = "Valor", Nome = "VALOR", Tipo = typeof(decimal) }, new FiltroPersonalizado { Propriedade = "Baixa", Nome = "DATA BAIXA", Tipo = typeof(DateTime) }, new FiltroPersonalizado { Propriedade = "ValorPago", Nome = "VALOR PAGO", Tipo = typeof(decimal) }, new FiltroPersonalizado { Propriedade = "Pagamento", Nome = "PAGAMENTO", Tipo = typeof(DateTime) }, new FiltroPersonalizado { Propriedade = "Conta.Descricao", Nome = "CONTA", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Controle.Plano.Descricao", Nome = "PLANO DE CONTAS", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Controle.Centro.Descricao", Nome = "CENTRO DE CUSTO", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Sinal", Nome = "SINAL", Tipo = typeof(Enum) }, new FiltroPersonalizado { Propriedade = "TipoPagamento", Nome = "FORMA PAGAMENTO", Tipo = typeof(Enum) }, new FiltroPersonalizado { Propriedade = "Observacao", Nome = "OBSERVAÇÃO", Tipo = typeof(string) }, new FiltroPersonalizado { Propriedade = "Controle.Plano.Nome", Nome = "PLANO", Tipo = typeof(string) } }; } public static List ColunasRelatorio(Relatorio relatorio, List parametrosAdicionados) { //IL_00a3: Unknown result type (might be due to invalid IL or missing references) //IL_00a8: Unknown result type (might be due to invalid IL or missing references) //IL_00cd: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Unknown result type (might be due to invalid IL or missing references) //IL_00ef: Unknown result type (might be due to invalid IL or missing references) //IL_00ff: Unknown result type (might be due to invalid IL or missing references) //IL_0100: Unknown result type (might be due to invalid IL or missing references) //IL_0106: Unknown result type (might be due to invalid IL or missing references) //IL_0117: Unknown result type (might be due to invalid IL or missing references) //IL_011e: Unknown result type (might be due to invalid IL or missing references) //IL_0143: Expected O, but got Unknown List list = new List(); foreach (PropertyInfo pi in from x in typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public) orderby x.GetDescriptionAttribute() select x) { if (!(pi.Name == "ValidationEvent") && !(pi.GetTypeAttribute() == "INVALID") && !parametrosAdicionados.Any((ParametrosRelatorio x) => x.Campo == pi.Name)) { ParametrosRelatorio val = new ParametrosRelatorio(); ParametrosRelatorio? obj = ((IEnumerable)parametrosAdicionados).FirstOrDefault((Func)((ParametrosRelatorio x) => x.IdUsuario != 0L && x.Campo == pi.Name)); val.Id = ((obj != null) ? obj.Id : 0); val.Campo = pi.Name; val.Header = pi.GetDescriptionAttribute(); val.IdUsuario = ((DomainBase)Recursos.Usuario).Id; val.Relatorio = relatorio; val.Tipo = pi.GetTypeAttribute(); val.Width = 0; ParametrosRelatorio? obj2 = ((IEnumerable)parametrosAdicionados).FirstOrDefault((Func)((ParametrosRelatorio x) => x.Campo == pi.Name)); val.Ordem = ((obj2 != null) ? obj2.Ordem : 0); ParametrosRelatorio item = val; list.Add(item); } } return list; } public static List TotalizacoesRelatorio(Relatorio relatorio, List parametrosAdicionados) { //IL_000c: Unknown result type (might be due to invalid IL or missing references) //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0050: Expected I4, but got Unknown //IL_0395: Unknown result type (might be due to invalid IL or missing references) //IL_039a: Unknown result type (might be due to invalid IL or missing references) //IL_03bf: Unknown result type (might be due to invalid IL or missing references) //IL_03d0: Unknown result type (might be due to invalid IL or missing references) //IL_03e1: Unknown result type (might be due to invalid IL or missing references) //IL_03f1: Unknown result type (might be due to invalid IL or missing references) //IL_03f2: Unknown result type (might be due to invalid IL or missing references) //IL_03fa: Expected O, but got Unknown List list = new List(); List list2 = new List(); switch (relatorio - 2) { case 0: case 1: list2.Add("PremioTotal"); list2.Add("PremioLiquido"); list2.Add("MediaComissao"); list2.Add("ComissaoGerada"); list2.Add("Cancelamentos"); list2.Add("Novos"); list2.Add("NegociosProprios"); list2.Add("Renovacoes"); list2.Add("SegurosNovos"); list2.Add("Apolices"); list2.Add("Endossos"); list2.Add("Faturas"); list2.Add("TotalGeral"); list2.Add("MediaPonderada"); break; case 2: list2.Add("Cancelamentos"); list2.Add("Novos"); list2.Add("Renovacoes"); list2.Add("Apolices"); list2.Add("Endossos"); list2.Add("Faturas"); list2.Add("TotalProspeccao"); list2.Add("TotalGeral"); list2.Add("PremioTotal"); list2.Add("PremioLiquido"); list2.Add("ComissaoGerada"); break; case 3: list2.Add("ComissaoRecebidaBruta"); list2.Add("ComissaoRecebidaLiquida"); list2.Add("ComissaoPrevista"); list2.Add("Repasse"); list2.Add("Impostos"); list2.Add("PremioTotal"); list2.Add("PremioLiquido"); break; case 4: case 14: list2.Add("ComissaoPrevista"); list2.Add("TotalPrevista"); list2.Add("TotalGeral"); list2.Add("TotalParcela"); break; case 7: case 8: list2.Add("Liquidado"); list2.Add("ValorLiquidado"); list2.Add("Pendente"); list2.Add("TotalGeral"); list2.Add("TotalClientes"); list2.Add("TotalTerceiros"); break; case 6: list2.Add("PremioTotal"); list2.Add("PremioLiquido"); list2.Add("ComissaoRecebidaBruta"); list2.Add("MediaComissao"); list2.Add("TotalPrevista"); list2.Add("ComissaoGerada"); list2.Add("Cancelamentos"); list2.Add("Novos"); list2.Add("Renovacoes"); list2.Add("Apolices"); list2.Add("Endossos"); list2.Add("Faturas"); list2.Add("TotalGeral"); break; } foreach (PropertyInfo pi in from x in typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public) orderby x.GetDescriptionAttribute() select x) { if (!(pi.Name == "ValidationEvent") && !(pi.GetTypeAttribute() == "INVALID") && list2.Contains(pi.Name) && !(pi.Name == "Agrupamento") && !parametrosAdicionados.Any((ParametrosTotalizacao x) => x.Campo == pi.Name)) { ParametrosTotalizacao val = new ParametrosTotalizacao(); ParametrosTotalizacao? obj = ((IEnumerable)parametrosAdicionados).FirstOrDefault((Func)((ParametrosTotalizacao x) => x.IdUsuario != 0L && x.Campo == pi.Name)); val.Id = ((obj != null) ? obj.Id : 0); val.Campo = pi.Name; val.Header = pi.GetDescriptionAttribute(); val.IdUsuario = ((DomainBase)Recursos.Usuario).Id; val.Relatorio = relatorio; ParametrosTotalizacao item = val; list.Add(item); } } return list; } public static async Task> OcultarColunas(Relatorio relatorio) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_000f: Unknown result type (might be due to invalid IL or missing references) List filtros = new List(); List list = await new ConfuguracoesServico().BuscarParametros(relatorio); if (list == null || list.Count == 0) { return filtros; } list = await GetRestricoesColunas(list); PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public); foreach (PropertyInfo pi in properties) { object obj = pi.GetCustomAttributes(typeof(TipoAttribute), inherit: true).FirstOrDefault(); string text = ""; if (obj != null) { text = ((TipoAttribute)obj).Description; } string descriptionAttribute = pi.GetDescriptionAttribute(); if (text == "INVALID") { filtros.Add(descriptionAttribute); } if (!list.Any((ParametrosRelatorio x) => x.Campo == pi.Name) && !(pi.Name == "ValidationEvent")) { filtros.Add(descriptionAttribute); } } return filtros; } public static async Task ExcluirPagamento(VendedorParcela pagamento) { pagamento.DataPagamento = null; ParcelaServico servico = new ParcelaServico { Sucesso = true }; await servico.Save(pagamento); return servico.Sucesso; } public static TipoTela? ConvertTela(string name) { //IL_0032: Unknown result type (might be due to invalid IL or missing references) return ((IEnumerable)((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList()).FirstOrDefault((Func)((TipoTela x) => ValidationHelper.GetEntity((Enum)(object)x) == name)); } public static string PlacaVencimento(string placa, Categoria? categoria) { //IL_007b: Unknown result type (might be due to invalid IL or missing references) //IL_0081: Invalid comparison between Unknown and I4 //IL_009a: Unknown result type (might be due to invalid IL or missing references) //IL_00a0: Invalid comparison between Unknown and I4 //IL_00b9: Unknown result type (might be due to invalid IL or missing references) //IL_00bf: Invalid comparison between Unknown and I4 //IL_00d8: Unknown result type (might be due to invalid IL or missing references) //IL_00de: Invalid comparison between Unknown and I4 //IL_00f7: Unknown result type (might be due to invalid IL or missing references) //IL_00fd: Invalid comparison between Unknown and I4 //IL_0116: Unknown result type (might be due to invalid IL or missing references) //IL_011c: Invalid comparison between Unknown and I4 //IL_0135: Unknown result type (might be due to invalid IL or missing references) //IL_013b: Invalid comparison between Unknown and I4 //IL_0154: Unknown result type (might be due to invalid IL or missing references) //IL_015a: Invalid comparison between Unknown and I4 //IL_0173: Unknown result type (might be due to invalid IL or missing references) //IL_0179: Invalid comparison between Unknown and I4 if (string.IsNullOrEmpty(placa)) { return ""; } switch (placa.Substring(placa.Length - 1, 1)) { case "1": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "ABRIL"; } return "SETEMBRO"; case "2": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "MAIO"; } return "SETEMBRO"; case "3": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "JUNHO"; } return "OUTUBRO"; case "4": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "JULHO"; } return "OUTUBRO"; case "5": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "AGOSTO"; } return "OUTUBRO"; case "6": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "AGOSTO"; } return "NOVEMBRO"; case "7": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "SETEMBRO"; } return "NOVEMBRO"; case "8": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "OUTUBRO"; } return "NOVEMBRO"; case "9": if (!categoria.HasValue || (int)categoria.GetValueOrDefault() != 4) { return "NOVEMBRO"; } return "DEZEMBRO"; case "0": return "DEZEMBRO"; default: return ""; } } public static ParentescoVinculo? ParentescoInverso(ParentescoVinculo? parentesco) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) //IL_0013: Unknown result type (might be due to invalid IL or missing references) //IL_0014: Unknown result type (might be due to invalid IL or missing references) //IL_0076: Expected I4, but got Unknown return parentesco switch { 0L => (ParentescoVinculo)1, 1L => (ParentescoVinculo)0, 3L => (ParentescoVinculo)4, 4L => (ParentescoVinculo)3, 5L => (ParentescoVinculo)6, 6L => (ParentescoVinculo)5, 7L => (ParentescoVinculo)8, 8L => (ParentescoVinculo)7, 10L => (ParentescoVinculo)11, 11L => (ParentescoVinculo)10, 13L => (ParentescoVinculo)14, 14L => (ParentescoVinculo)13, 19L => (ParentescoVinculo)20, 20L => (ParentescoVinculo)19, 22L => (ParentescoVinculo)21, 21L => (ParentescoVinculo)22, _ => parentesco, }; } public static string DiaDaSemana(this int? dia) { if (!dia.HasValue) { return ""; } return (DayOfWeek)dia.Value switch { DayOfWeek.Sunday => "DOMINGO", DayOfWeek.Monday => "SEGUNDA-FEIRA", DayOfWeek.Tuesday => "TERÇA-FEIRA", DayOfWeek.Wednesday => "QUARTA-FEIRA", DayOfWeek.Thursday => "QUINTA-FEIRA", DayOfWeek.Friday => "SEXTA-FEIRA", DayOfWeek.Saturday => "SABADO", _ => "", }; } public static string GetBody(this string html) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0005: Unknown result type (might be due to invalid IL or missing references) HtmlDocument val = new HtmlDocument(); val.LoadHtml(html); HtmlNode obj = val.DocumentNode.SelectSingleNode("//body"); if (obj == null) { return null; } return obj.InnerHtml; } public static string GerarGrafico(List sinteticoLista) { string rows = "['NOME', 'VALOR'], "; sinteticoLista.ForEach(delegate(ValorSintetico x) { if (x.Indice != "TOTAL" && x.Valor > 0m) { rows = rows + "[`" + x.Indice + " " + x.Porcentagem + "`, " + x.Valor.ToString("F2", CultureInfo.InvariantCulture) + "], "; } }); 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(); } [IteratorStateMachine(typeof(_003CDistinctBy_003Ed__55<, >))] public static IEnumerable DistinctBy(this IEnumerable source, Func keySelector) { //yield-return decompiler failed: Unexpected instruction in Iterator.Dispose() return new _003CDistinctBy_003Ed__55(-2) { _003C_003E3__source = source, _003C_003E3__keySelector = keySelector }; } public static string Clear(this string stringToClean) { if (stringToClean != null) { return Regex.Replace(stringToClean, "[^\\d]", string.Empty); } return null; } public static string RemoverAcentos(string text) { string source = text.Normalize(NormalizationForm.FormD); StringBuilder stringBuilder = new StringBuilder(); foreach (char item in from c in source let unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c) where unicodeCategory != UnicodeCategory.NonSpacingMark select c) { stringBuilder.Append(item); } return stringBuilder.ToString().Normalize(NormalizationForm.FormC); } public static Cor? GetCor(string text) { //IL_0031: Unknown result type (might be due to invalid IL or missing references) if (text.Contains("outro")) { return (Cor)16; } if (Enum.TryParse(text, ignoreCase: true, out Cor _)) { return (Cor)Enum.Parse(typeof(Cor), text, ignoreCase: true); } return null; } public static Correcao? GetCorrecao(string text) { if (text.Contains("mercado")) { return (Correcao)0; } if (text.Contains("determinado")) { return (Correcao)1; } return null; } public static TabelaReferencia? GetTabelaReferencia(string text) { //IL_001c: Unknown result type (might be due to invalid IL or missing references) if (Enum.TryParse(text, ignoreCase: true, out TabelaReferencia _)) { return (TabelaReferencia)Enum.Parse(typeof(TabelaReferencia), text, ignoreCase: true); } return null; } public static Categoria? GetCategoria(string text) { //IL_0094: Unknown result type (might be due to invalid IL or missing references) if (text.Contains("caminhao") || text.Contains("caminhão")) { return (Categoria)4; } if (text.Contains("onibus") || text.Contains("ônibus")) { return (Categoria)6; } if (text.Contains("utilitario") || text.Contains("utilitário")) { return (Categoria)6; } if (text.Contains("moto")) { return (Categoria)9; } if (Enum.TryParse(text, ignoreCase: true, out Categoria _)) { return (Categoria)Enum.Parse(typeof(Categoria), text, ignoreCase: true); } return null; } public static TipoCobertura? GetTipoCobertura(string text) { //IL_0086: Unknown result type (might be due to invalid IL or missing references) if (text.Contains("incendio") || text.Contains("incêndio")) { return (TipoCobertura)2; } if (text.Contains("roubo") && text.Contains("furto")) { return (TipoCobertura)5; } if (text.Contains("terceiros")) { return (TipoCobertura)3; } if (text.Contains("compreensiva")) { return (TipoCobertura)1; } if (Enum.TryParse(text, ignoreCase: true, out TipoCobertura _)) { return (TipoCobertura)Enum.Parse(typeof(TipoCobertura), text, ignoreCase: true); } return null; } public static Isencao? GetIsencao(string text) { if (text.Contains("sem")) { return (Isencao)0; } if (text.Contains("ipi") && text.Contains("icms")) { return (Isencao)3; } if (text.Contains("ipi")) { return (Isencao)2; } if (text.Contains("icms")) { return (Isencao)1; } return null; } public static Combustivel? GetCombustivel(string text) { //IL_015d: Unknown result type (might be due to invalid IL or missing references) if (text.Contains("flex")) { return (Combustivel)4; } if (text.Contains("gasolina") && (text.Contains("alcool") || text.Contains("álcool"))) { if (text.Contains("gnv")) { return (Combustivel)8; } if (text.Contains("eletrico") || text.Contains("elétrico")) { return (Combustivel)12; } return (Combustivel)4; } if (text.Contains("gasolina") && text.Contains("gnv")) { return (Combustivel)7; } if (text.Contains("gasolina") && (text.Contains("eletrico") || text.Contains("elétrico"))) { return (Combustivel)9; } if (text.Contains("eletrico") || text.Contains("elétrico")) { return (Combustivel)11; } if (text.Contains("alcool") || text.Contains("álcool")) { return (Combustivel)1; } if (text.Contains("hibrido") || text.Contains("híbrido")) { return (Combustivel)10; } if (text.Contains("outro")) { return (Combustivel)6; } if (Enum.TryParse(text, ignoreCase: true, out Combustivel _)) { return (Combustivel)Enum.Parse(typeof(Combustivel), text, ignoreCase: true); } return null; } public static async Task GetFabricante(string text) { List list = await new BaseServico().BuscarFabricante(text); return (list.Count < 1) ? null : list.First(); } 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 = $"{index} {nome}"; } if (nome.Length > 30) { nome = nome.Substring(0, 30); } return nome; } public static bool IsEmpty(this string html) { int count = Regex.Matches(html, "").Count; bool flag = true; int startIndex = 0; for (int i = 0; i < count; i++) { int num = html.IndexOf("", startIndex, StringComparison.Ordinal) + 6; if (num == 5) { break; } int num2 = html.IndexOf("", startIndex, StringComparison.Ordinal); startIndex = num2 + 7; flag = string.IsNullOrWhiteSpace(html.Substring(num, num2 - num)); if (!flag) { break; } } return flag; } public static Window IsHosterOpen(string name) { return (Window)(object)((IEnumerable)Application.Current.Windows).OfType().ToList().FirstOrDefault(delegate(HosterWindow x) { ContentControl? obj = Extentions.FindVisualChildren((DependencyObject)(object)x).FirstOrDefault(); return ((obj != null) ? ((FrameworkElement)obj).Tag.ToString() : null) == name; }); } public static DateTime GetNetworkTime() { try { if (StartTime.HasValue) { return StartTime.Value.AddMilliseconds(Stopwatch.ElapsedMilliseconds); } byte[] array = new byte[48]; array[0] = 27; IPEndPoint remoteEP = new IPEndPoint(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(remoteEP); socket.ReceiveTimeout = 3000; socket.Send(array); socket.Receive(array); socket.Close(); } ulong num = ((ulong)array[40] << 24) | ((ulong)array[41] << 16) | ((ulong)array[42] << 8) | array[43]; ulong num2 = ((ulong)array[44] << 24) | ((ulong)array[45] << 16) | ((ulong)array[46] << 8) | array[47]; ulong num3 = num * 1000 + num2 * 1000 / 4294967296L; DateTime value = new DateTime(1900, 1, 1).AddMilliseconds((long)num3).ToLocalTime(); StartTime = value; Stopwatch = Stopwatch.StartNew(); return StartTime.Value; } catch (Exception) { StartTime = DateTime.Now; Stopwatch = Stopwatch.StartNew(); return StartTime.Value; } } public static TipoPagamento ParseTransactionType(this OfxTransactionType type) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0042: Expected I4, but got Unknown switch ((int)type) { default: return (TipoPagamento)12; case 0: return (TipoPagamento)5; case 1: case 4: return (TipoPagamento)7; case 11: return (TipoPagamento)15; case 6: case 13: return (TipoPagamento)8; case 7: case 12: return (TipoPagamento)10; case 14: return (TipoPagamento)6; case 10: return (TipoPagamento)4; } } public static string GeraCartaoVisita(this long id) { try { return HttpUtility.UrlEncode($"{DateTime.Now.Ticks}:{ApplicationHelper.IdFornecedor}:V:{id}".Base64Encode()); } catch { } return ""; } public static string GeraAssistencia(this long id) { try { return HttpUtility.UrlEncode($"{DateTime.Now.Ticks}:{ApplicationHelper.IdFornecedor}:A:{id}".Base64Encode()); } catch { } return ""; } public static long UnixTimeStamp() { return (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds; } public static async Task CriarCartao(this Card card) { return await Connection.Post("Card", card); } public static async Task AtualizarCartao(this Card card, string id) { return (await Connection.Put("Card/" + id, card) == null) ? id : null; } public static async Task CriarAssistencia(this Assistance assistance) { return await Connection.Post("Assistance", assistance); } public static async Task Criarlogo(this Logo logo) { return await Connection.Post("Card/Logo", logo); } public static async Task Atualizarlogo(this Logo logo, string id) { return await Connection.Put("Card/Logo/" + id, logo); } public static async Task CriarSeguradora(this AssistenciaCia cia) { return await Connection.Post("Assistance/Seguradora", cia); } public static async Task AtualizarSeguradora(this AssistenciaCia cia, string id) { return await Connection.Put("Assistance/Seguradora/" + id, cia); } public static async Task AtualizarAssistencia(this Assistance assistance, string id) { return (await Connection.Put("Assistance/" + id, assistance) == null) ? id : null; } public static bool EnviarWhatsapp(this string numero, string anotacoes = null) { Uri uri = (string.IsNullOrEmpty(anotacoes) ? Recursos.WhatsAppLink.SetQuery("phone", numero) : Recursos.WhatsAppLink.AddQuery("phone", numero).SetQuery("text", anotacoes)); try { Process.Start(new ProcessStartInfo(uri.AbsoluteUri)); return true; } catch (Exception) { uri.AbsoluteUri.CopyToClipboard(); return false; } } public static bool ProgramaEmExecucao(this string programName) { return Process.GetProcessesByName(programName).Length != 0; } [DllImport("user32.dll")] private static extern bool SetForegroundWindow(IntPtr hWnd); [DllImport("user32.dll")] private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow); public static void BringToFront(this string programName) { try { Process[] processesByName = Process.GetProcessesByName(programName); if (processesByName.Length != 0) { IntPtr mainWindowHandle = processesByName[0].MainWindowHandle; ShowWindow(mainWindowHandle, 5); ShowWindow(mainWindowHandle, 9); SetForegroundWindow(mainWindowHandle); } } catch (Exception) { } } public static List LogList(this List valores, bool restricaoComissao = false) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown List> tuples = new List>(); valores.ForEach(delegate(ValorOriginal x) { if (!restricaoComissao || !x.Campo.ToUpper().Contains("COMISSÃO")) { tuples.Add(new Tuple(x.Descricao, string.IsNullOrEmpty(x.ValorAtual) ? "NÃO PREENCHIDO" : ((x.ValorAtual == "True") ? "SIM" : ((x.ValorAtual == "False") ? "NÃO" : x.ValorAtual)), "")); } }); return new List { new TupleList { Tuples = new ObservableCollection>(tuples) } }; } public static List LogList(this List valores, bool restricaoComissao = false) { //IL_0030: Unknown result type (might be due to invalid IL or missing references) //IL_0035: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown List> tuples = new List>(); valores.ForEach(delegate(Diferenca x) { if (!restricaoComissao || !x.Campo.ToUpper().Contains("COMISSÃO")) { tuples.Add(new Tuple(x.Descricao, string.IsNullOrEmpty(x.ValorAtual) ? "NÃO PREENCHIDO" : ((x.ValorAtual == "True") ? "SIM" : ((x.ValorAtual == "False") ? "NÃO" : x.ValorAtual)), string.IsNullOrEmpty(x.ValorAnterior) ? "NÃO PREENCHIDO" : ((x.ValorAnterior == "True") ? "SIM" : ((x.ValorAnterior == "False") ? "NÃO" : x.ValorAnterior)))); } }); return new List { new TupleList { Tuples = new ObservableCollection>(tuples) } }; } public static void CopyToClipboard(this string text) { try { Clipboard.SetText(text); } catch (Exception) { } } public static async Task GerarCsv(List Conteudo, IEnumerable colunasExportacao) { PropertyInfo[] source = (from p in typeof(T).GetProperties() where colunasExportacao.Contains(p.Name) select p).ToArray(); StringBuilder stringBuilder = new StringBuilder(); stringBuilder.AppendLine(string.Join(";", source.Select((PropertyInfo p) => p.Name))); foreach (T item in Conteudo) { IEnumerable values = source.Select((PropertyInfo p) => p.GetValue(item, null)?.ToString() ?? string.Empty); stringBuilder.AppendLine(string.Join(";", values)); } return stringBuilder.ToString(); } public static UsoVeiculo? GetUsoveiculo(string text) { //IL_000e: Unknown result type (might be due to invalid IL or missing references) UsoVeiculo result; return (UsoVeiculo)(Enum.TryParse(text, ignoreCase: true, out result) ? ((int)result) : 0); } public static string BoolToString(this bool boolean) { if (!boolean) { return "0"; } return "1"; } public static string ConvertGaragemTrabalhoEstudoCalculo(this GaragemTrabalhoEstudo garagemTrabalhoEstudo) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_001e: Expected I4, but got Unknown switch ((int)garagemTrabalhoEstudo) { case 0: return "0"; case 1: return "1"; case 2: return "2"; case 4: case 5: return "3"; default: return string.Empty; } } public static string ConvertTipoSeguroCalculo(this TipoSeguro tipoSeguro) { //IL_0000: Unknown result type (might be due to invalid IL or missing references) //IL_0002: Unknown result type (might be due to invalid IL or missing references) //IL_0004: Invalid comparison between Unknown and I4 if (tipoSeguro - 1 <= 1) { return "1"; } return "0"; } public static string ConvertTempoHabilitacaoCalculo(this DateTime tempoHabilitacao) { if (tempoHabilitacao == DateTime.MinValue) { return "0"; } int num = DateTime.Now.Year - tempoHabilitacao.Year; if (num >= 11) { return "11"; } return num.ToString(); } public static TempoHabilitacao ConvertTempoHabilitacao(int tempoHabilitacao = 0) { if (tempoHabilitacao != 1) { if (tempoHabilitacao != 2) { if (tempoHabilitacao != 3) { if (tempoHabilitacao != 4) { if (tempoHabilitacao != 5) { if (tempoHabilitacao != 6) { if (tempoHabilitacao != 7) { if (tempoHabilitacao != 8) { if (tempoHabilitacao != 9) { if (tempoHabilitacao != 10) { if (tempoHabilitacao < 11) { return (TempoHabilitacao)0; } return (TempoHabilitacao)10; } return (TempoHabilitacao)9; } return (TempoHabilitacao)8; } return (TempoHabilitacao)7; } return (TempoHabilitacao)6; } return (TempoHabilitacao)5; } return (TempoHabilitacao)4; } return (TempoHabilitacao)3; } return (TempoHabilitacao)2; } return (TempoHabilitacao)1; } return (TempoHabilitacao)0; } }