summaryrefslogtreecommitdiff
path: root/Gestor.Application/Helpers/Funcoes.cs
diff options
context:
space:
mode:
authorLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
committerLucas Faria Mendes <lucas.fariamo08@gmail.com>2026-03-30 13:38:18 +0000
commit1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (patch)
treee1c3b20ea08f0cf71122a1e73f0d395f8fd83874 /Gestor.Application/Helpers/Funcoes.cs
parent674ca83ba9243a9e95a7568c797668dab6aee26a (diff)
downloadgestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.tar.gz
gestor-1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1.zip
chore: location
Diffstat (limited to 'Gestor.Application/Helpers/Funcoes.cs')
-rw-r--r--Gestor.Application/Helpers/Funcoes.cs6825
1 files changed, 0 insertions, 6825 deletions
diff --git a/Gestor.Application/Helpers/Funcoes.cs b/Gestor.Application/Helpers/Funcoes.cs
deleted file mode 100644
index 786f217..0000000
--- a/Gestor.Application/Helpers/Funcoes.cs
+++ /dev/null
@@ -1,6825 +0,0 @@
-using Agger.Registro;
-using ClosedXML.Excel;
-using CsQuery.ExtensionMethods;
-using Gestor.Application;
-using Gestor.Application.Actions;
-using Gestor.Application.Properties;
-using Gestor.Application.Servicos;
-using Gestor.Application.Servicos.Configuracoes;
-using Gestor.Application.Servicos.Ferramentas;
-using Gestor.Application.Servicos.Generic;
-using Gestor.Application.Servicos.Seguros;
-using Gestor.Application.Servicos.Seguros.Itens;
-using Gestor.Application.ViewModels.Generic;
-using Gestor.Application.Views.Generic;
-using Gestor.Common.Validation;
-using Gestor.Infrastructure.Repository.Interface;
-using Gestor.Infrastructure.UnitOfWork.Generic;
-using Gestor.Infrastructure.UnitOfWork.Logic;
-using Gestor.Model.API;
-using Gestor.Model.Attributes;
-using Gestor.Model.Common;
-using Gestor.Model.Domain.Card;
-using Gestor.Model.Domain.Common;
-using Gestor.Model.Domain.Configuracoes;
-using Gestor.Model.Domain.Generic;
-using Gestor.Model.Domain.MalaDireta;
-using Gestor.Model.Domain.Relatorios;
-using Gestor.Model.Domain.Seguros;
-using HtmlAgilityPack;
-using MaterialDesignThemes.Wpf;
-using Newtonsoft.Json;
-using OfxSharpLib;
-using System;
-using System.Collections;
-using System.Collections.Generic;
-using System.Collections.ObjectModel;
-using System.ComponentModel;
-using System.Diagnostics;
-using System.Globalization;
-using System.Linq;
-using System.Net;
-using System.Net.Sockets;
-using System.Reflection;
-using System.Runtime.CompilerServices;
-using System.Runtime.InteropServices;
-using System.Text;
-using System.Text.RegularExpressions;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Web;
-using System.Windows;
-using System.Windows.Controls;
-using System.Windows.Data;
-using System.Windows.Input;
-using System.Windows.Threading;
-using Xceed.Wpf.AvalonDock.Controls;
-
-namespace Gestor.Application.Helpers
-{
- public static class Funcoes
- {
- public static System.Diagnostics.Stopwatch Stopwatch;
-
- public static DateTime? StartTime;
-
- public static string AdicionarLog(string html)
- {
- string innerHtml;
- HtmlDocument htmlDocument = new HtmlDocument();
- htmlDocument.LoadHtml(html);
- DateTime networkTime = Funcoes.GetNetworkTime();
- using (IEnumerator<HtmlNode> enumerator = htmlDocument.get_DocumentNode().get_ChildNodes().GetEnumerator())
- {
- while (enumerator.MoveNext())
- {
- HtmlNode current = enumerator.Current;
- if (current.get_Name() != "body")
- {
- continue;
- }
- current.set_InnerHtml(string.Format("<p>{0} ID-{1} {2:g} </p>{3}<hr>", new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), networkTime, current.get_InnerHtml() }));
- innerHtml = current.get_InnerHtml();
- return innerHtml;
- }
- return "";
- }
- return innerHtml;
- }
-
- public static async Task<string> AtualizarAssistencia(Assistance assistance, string id)
- {
- string str;
- if (await Gestor.Application.Helpers.Connection.Put<string>(string.Concat("Assistance/", id), assistance) == null)
- {
- str = id;
- }
- else
- {
- str = null;
- }
- return str;
- }
-
- public static async Task<string> AtualizarCartao(Gestor.Model.Domain.Card.Card card, string id)
- {
- string str;
- if (await Gestor.Application.Helpers.Connection.Put<string>(string.Concat("Card/", id), card) == null)
- {
- str = id;
- }
- else
- {
- str = null;
- }
- return str;
- }
-
- public static async Task<string> Atualizarlogo(Logo logo, string id)
- {
- string str = await Gestor.Application.Helpers.Connection.Put<string>(string.Concat("Card/Logo/", id), logo);
- return str;
- }
-
- public static async Task<string> AtualizarSeguradora(AssistenciaCia cia, string id)
- {
- string str = await Gestor.Application.Helpers.Connection.Put<string>(string.Concat("Assistance/Seguradora/", id), cia);
- return str;
- }
-
- public static async Task<Parcela> BaixarComissao(Parcela parcela, List<Parcela> parcelas, List<VendedorParcela> repasses, [DecimalConstant(0, 0, 0, 0, 2)] decimal tolerancia = default(decimal), bool comissaoAuto = false)
- {
- Parcela parcela1;
- long? nullable1;
- Parcela parcela2;
- decimal num1;
- decimal num2;
- bool flag;
- object nome;
- object apolice;
- long? nullable2;
- bool flag1;
- object empty;
- string str;
- string proposta;
- Funcoes.u003cu003ec__DisplayClass2_0 variable;
- Parcela parcela3 = parcela;
- ParcelaServico parcelaServico = new ParcelaServico();
- Parcela parcela4 = parcela3;
- num1 = (!(parcela3.get_ValorComDesconto() == decimal.Zero) || !(Math.Abs(parcela3.get_ValorComDesconto()) < Math.Abs(parcela3.get_ValorComissao())) ? parcela3.get_ValorComDesconto() : parcela3.get_ValorComissao());
- parcela4.set_ValorComDesconto(num1);
- List<VendedorParcela> vendedorParcelas = repasses;
- var groupings =
- from x in vendedorParcelas
- group x by new { Id = x.get_Parcela().get_Id(), vendedor = x.get_Vendedor().get_Id(), tipovendedor = x.get_TipoVendedor().get_Id() };
- BaseDialogViewModel baseDialogViewModel = new BaseDialogViewModel();
- if (!groupings.Any((g) => g.Count<VendedorParcela>() > 1))
- {
- DateTime networkTime = Funcoes.GetNetworkTime();
- if (parcela3.get_SubTipo() != 1 || parcela3.get_Documento().get_TipoRecebimento().GetValueOrDefault() != 1)
- {
- List<VendedorParcela> vendedorParcelas1 = repasses.Where<VendedorParcela>((VendedorParcela x) => {
- FormaRepasse? nullable;
- FormaRepasse? forma;
- if (x.get_Parcela().get_Id() != parcela3.get_Id() || x.get_DataPagamento().HasValue)
- {
- return false;
- }
- if (x == null)
- {
- return false;
- }
- Repasse repasse = x.get_Repasse();
- if (repasse != null)
- {
- forma = repasse.get_Forma();
- }
- else
- {
- nullable = null;
- forma = nullable;
- }
- nullable = forma;
- return nullable.GetValueOrDefault() == 1;
- }).ToList<VendedorParcela>();
- vendedorParcelas1.ForEach((VendedorParcela x) => {
- x.set_DataPrePagamento(parcela3.get_DataRecebimento());
- x.set_ValorRepasse(new decimal?(Funcoes.CalculaRepasse(x.get_Repasse(), parcela3, false)));
- });
- parcela2 = await parcelaServico.Save(parcela3, parcelas, vendedorParcelas1, false);
- parcela3 = parcela2;
- if (!parcelaServico.Sucesso)
- {
- await Funcoes.MostrarErro(24);
- parcela1 = parcela3;
- variable = null;
- parcelaServico = null;
- baseDialogViewModel = null;
- return parcela1;
- }
- }
- else
- {
- num2 = (parcela3.get_Documento().get_AdicionalComiss() ? parcela3.get_Documento().get_PremioLiquido() + parcela3.get_Documento().get_PremioAdicional() : parcela3.get_Documento().get_PremioLiquido());
- decimal num3 = num2;
- decimal comissao = (num3 * parcela3.get_Documento().get_Comissao()) * new decimal(1, 0, 0, false, 2);
- List<Parcela> parcelas1 = parcelas;
- IEnumerable<Parcela> parcelas2 = parcelas1.Where<Parcela>((Parcela x) => {
- if (x.get_SubTipo() != 1)
- {
- return false;
- }
- return x.get_DataRecebimento().HasValue;
- });
- decimal num4 = parcelas2.Sum<Parcela>((Parcela x) => x.get_ValorComissao());
- decimal num5 = Math.Abs(comissao) - Math.Abs(num4);
- flag = (num5 <= tolerancia ? true : num5 < new decimal(1, 0, 0, false, 2));
- bool flag2 = flag;
- TipoRecebimento? tipoRecebimento = parcela3.get_Documento().get_TipoRecebimento();
- bool flag3 = tipoRecebimento.GetValueOrDefault() == 1 & flag2;
- bool flag4 = true;
- if (flag3)
- {
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- if (configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema c) => c.get_Configuracao() == 54))
- {
- Parcela parcela5 = parcela3;
- if (parcela5 != null)
- {
- Documento documento = parcela5.get_Documento();
- if (documento != null)
- {
- Controle controle = documento.get_Controle();
- if (controle != null)
- {
- Cliente cliente = controle.get_Cliente();
- if (cliente != null)
- {
- nome = cliente.get_Nome();
- }
- else
- {
- nome = null;
- }
- }
- else
- {
- nome = null;
- }
- }
- else
- {
- nome = null;
- }
- }
- else
- {
- nome = null;
- }
- if (nome == null)
- {
- nome = string.Empty;
- }
- string str1 = (string)nome;
- if (string.IsNullOrEmpty(str1))
- {
- Documento documento1 = parcela3.get_Documento();
- if (documento1 != null)
- {
- Controle controle1 = documento1.get_Controle();
- if (controle1 != null)
- {
- Cliente cliente1 = controle1.get_Cliente();
- if (cliente1 != null)
- {
- nullable2 = new long?(cliente1.get_Id());
- }
- else
- {
- nullable1 = null;
- nullable2 = nullable1;
- }
- }
- else
- {
- nullable1 = null;
- nullable2 = nullable1;
- }
- long? nullable3 = nullable2;
- long num6 = (long)0;
- flag1 = nullable3.GetValueOrDefault() > num6 & nullable3.HasValue;
- }
- else
- {
- flag1 = false;
- }
- if (flag1)
- {
- Cliente cliente2 = await (new ClienteServico()).BuscarClienteAsync(parcela3.get_Documento().get_Controle().get_Cliente().get_Id());
- if (cliente2 != null)
- {
- empty = cliente2.get_Nome();
- }
- else
- {
- empty = null;
- }
- if (empty == null)
- {
- empty = string.Empty;
- }
- str1 = (string)empty;
- }
- }
- if (!string.IsNullOrEmpty(str1))
- {
- str1 = string.Concat(", DO CLIENTE ", str1);
- }
- Parcela parcela6 = parcela3;
- if (parcela6 != null)
- {
- Documento documento2 = parcela6.get_Documento();
- if (documento2 != null)
- {
- apolice = documento2.get_Apolice();
- }
- else
- {
- apolice = null;
- }
- }
- else
- {
- apolice = null;
- }
- if (apolice == null)
- {
- apolice = string.Empty;
- }
- string str2 = (string)apolice;
- if (!string.IsNullOrEmpty(str2))
- {
- str2 = string.Concat(" - APÓLICE ", str2);
- }
- if (parcela3.get_Documento().get_NumeroParcelas() != parcela3.get_NumeroParcela())
- {
- bool flag5 = await baseDialogViewModel.ShowMessage(string.Format("AINDA RESTA {0:c}{1}{2} QUE NÃO SERÁ REPASSADO, CONTINUAR A BAIXA POR ESGOTAMENTO?", num5, str1, str2), "SIM, BAIXAR POR ESGOMENTO", "NÃO", false);
- bool flag6 = flag5;
- flag3 = flag5;
- flag4 = flag6;
- }
- }
- }
- List<VendedorParcela> vendedorParcelas2 = repasses.Where<VendedorParcela>((VendedorParcela x) => {
- bool valueOrDefault;
- if (x.get_Parcela().get_Id() == this.parcela.get_Id())
- {
- Repasse repasse = x.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false);
- if (valueOrDefault)
- {
- return !x.get_DataPagamento().HasValue;
- }
- }
- return false;
- }).ToList<VendedorParcela>();
- List<VendedorParcela> vendedorParcelas3 = new List<VendedorParcela>();
- Parcela parcela7 = parcelas.FirstOrDefault<Parcela>((Parcela x) => {
- if (x.get_SubTipo() != 1)
- {
- return false;
- }
- return x.get_NumeroParcela() == this.parcela.get_NumeroParcela() + 1;
- });
- Parcela parcela8 = parcela3;
- List<VendedorParcela> vendedorParcelas4 = vendedorParcelas2;
- ExtensionMethods.ForEach(
- from g in vendedorParcelas4
- group g by new { Id = g.get_Parcela().get_Id(), vendedor = g.get_Vendedor().get_Id(), tipovendedor = g.get_TipoVendedor().get_Id() }, (x) => {
- if (x.First<VendedorParcela>().get_CoCorretagem())
- {
- return;
- }
- decimal valueOrDefault = x.First<VendedorParcela>().get_ValorRepasse().GetValueOrDefault();
- decimal num = Funcoes.CalculaPagamento(x.First<VendedorParcela>(), parcela8, comissao);
- x.First<VendedorParcela>().set_ValorRepasse(new decimal?((Math.Abs(valueOrDefault) > Math.Abs(num) ? num : valueOrDefault)));
- x.First<VendedorParcela>().set_DataPrePagamento(parcela8.get_DataRecebimento());
- if (flag4 && (Math.Abs(comissao) - Math.Abs(num4)) <= Math.Abs(tolerancia) || parcela7 == null)
- {
- return;
- }
- VendedorParcela vendedorParcela = new VendedorParcela();
- vendedorParcela.set_Repasse(x.First<VendedorParcela>().get_Repasse());
- vendedorParcela.set_Parcela(parcela7);
- vendedorParcela.set_Documento(parcela8.get_Documento());
- vendedorParcela.set_ValorRepasse(new decimal?(valueOrDefault - num));
- vendedorParcela.set_Vendedor(x.First<VendedorParcela>().get_Vendedor());
- vendedorParcela.set_ValorTotal(x.First<VendedorParcela>().get_ValorTotal());
- vendedorParcela.set_PorcentagemRepasse(x.First<VendedorParcela>().get_PorcentagemRepasse());
- vendedorParcela.set_TipoVendedor(x.First<VendedorParcela>().get_TipoVendedor());
- vendedorParcela.set_CoCorretagem(x.First<VendedorParcela>().get_CoCorretagem());
- vendedorParcelas3.Add(vendedorParcela);
- });
- if (vendedorParcelas3.Count > 0)
- {
- vendedorParcelas2.AddRange(vendedorParcelas3);
- }
- if (await parcelaServico.SaveRange(vendedorParcelas2))
- {
- parcela2 = await parcelaServico.Save(parcela3, parcelas, null, false);
- parcela3 = parcela2;
- if (parcelaServico.Sucesso)
- {
- if (flag3)
- {
- List<Parcela> parcelas3 = parcelas;
- List<Parcela> parcelas4 = parcelas3.Where<Parcela>((Parcela x) => {
- if (x.get_DataRecebimento().HasValue)
- {
- return false;
- }
- return x.get_SubTipo() == 1;
- }).ToList<Parcela>();
- List<VendedorParcela> vendedorParcelas5 = new List<VendedorParcela>();
- parcelas4.ForEach((Parcela x) => {
- x.set_Documento(parcela3.get_Documento());
- x.set_DataRecebimento(parcela3.get_DataRecebimento());
- x.set_DataCredito(parcela3.get_DataRecebimento());
- x.set_ValorRealizado(decimal.Zero);
- x.set_ValorComissao(decimal.Zero);
- x.set_ValorComDesconto(decimal.Zero);
- x.set_Irr(decimal.Zero);
- x.set_Iss(decimal.Zero);
- List<VendedorParcela> list = repasses.Where<VendedorParcela>((VendedorParcela p) => {
- bool valueOrDefault;
- if (p.get_Parcela().get_Id() == x.get_Id())
- {
- Repasse repasse = p.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false);
- if (valueOrDefault)
- {
- Repasse repasse1 = p.get_Repasse();
- if (repasse1 == null)
- {
- return true;
- }
- return repasse1.get_Tipo().GetValueOrDefault() != 3;
- }
- }
- return false;
- }).ToList<VendedorParcela>();
- list.ForEach((VendedorParcela p) => {
- decimal? nullable;
- p.set_Parcela(x);
- p.set_Documento(parcela3.get_Documento());
- p.set_DataPrePagamento(new DateTime?(networkTime));
- VendedorParcela vendedorParcela = p;
- decimal? valorRepasse = p.get_ValorRepasse();
- decimal cSu0024u003cu003e8_locals1 = tolerancia;
- if ((valorRepasse.GetValueOrDefault() > cSu0024u003cu003e8_locals1) & valorRepasse.HasValue)
- {
- cSu0024u003cu003e8_locals1 = new decimal();
- nullable = new decimal?(cSu0024u003cu003e8_locals1);
- }
- else
- {
- nullable = p.get_ValorRepasse();
- }
- vendedorParcela.set_ValorRepasse(nullable);
- });
- vendedorParcelas5.AddRange(list);
- });
- await parcelaServico.SaveRange(parcelas);
- if (!parcelaServico.Sucesso)
- {
- await Funcoes.MostrarErro(24);
- parcela1 = parcela3;
- variable = null;
- parcelaServico = null;
- baseDialogViewModel = null;
- return parcela1;
- }
- else if (await parcelaServico.SaveRange(vendedorParcelas5))
- {
- }
- else
- {
- await Funcoes.MostrarErro(24);
- parcela1 = parcela3;
- variable = null;
- parcelaServico = null;
- baseDialogViewModel = null;
- return parcela1;
- }
- }
- }
- else
- {
- await Funcoes.MostrarErro(24);
- parcela1 = parcela3;
- variable = null;
- parcelaServico = null;
- baseDialogViewModel = null;
- return parcela1;
- }
- }
- else
- {
- await Funcoes.MostrarErro(24);
- parcela1 = parcela3;
- variable = null;
- parcelaServico = null;
- baseDialogViewModel = null;
- return parcela1;
- }
- }
- if (!comissaoAuto)
- {
- Funcoes.RegistrarLogBaixa(parcela3.get_Documento().get_Id(), networkTime);
- }
- parcela1 = parcela3;
- }
- else
- {
- Documento documento3 = parcela3.get_Documento();
- if (documento3 != null)
- {
- str = documento3.get_Apolice();
- }
- else
- {
- str = null;
- }
- if (string.IsNullOrWhiteSpace(str))
- {
- Documento documento4 = parcela3.get_Documento();
- if (documento4 != null)
- {
- proposta = documento4.get_Apolice();
- }
- else
- {
- proposta = null;
- }
- }
- else
- {
- Documento documento5 = parcela3.get_Documento();
- if (documento5 != null)
- {
- proposta = documento5.get_Proposta();
- }
- else
- {
- proposta = null;
- }
- }
- string str3 = proposta;
- await baseDialogViewModel.ShowMessage(string.Format("HÁ VENDEDORES DUPLICADOS PARA A PARCELA {0} DO DOCUMENTO {1}, BAIXA DE COMISSÃO INTERROMPIDA.{2}REALIZE A CORREÇÃO DOS VENDEDORES E TENTE NOVAMENTE.", parcela3.get_NumeroParcela(), str3, Environment.NewLine), "OK", "", false);
- parcela3.set_DataRecebimento(null);
- parcela3.set_ValorComissao(decimal.Zero);
- parcela3.set_ValorComDesconto(decimal.Zero);
- parcela3.set_Irr(decimal.Zero);
- parcela3.set_Iss(decimal.Zero);
- parcela3.set_Outros(decimal.Zero);
- parcela3.set_Desconto(decimal.Zero);
- parcela1 = parcela3;
- }
- variable = null;
- parcelaServico = null;
- baseDialogViewModel = null;
- return parcela1;
- }
-
- public static string BoolToString(this bool boolean)
- {
- if (!boolean)
- {
- return "0";
- }
- return "1";
- }
-
- public static void BringToFront(this string programName)
- {
- try
- {
- Process[] processesByName = Process.GetProcessesByName(programName);
- if (processesByName.Length != 0)
- {
- IntPtr mainWindowHandle = processesByName[0].MainWindowHandle;
- Funcoes.ShowWindow(mainWindowHandle, 5);
- Funcoes.ShowWindow(mainWindowHandle, 9);
- Funcoes.SetForegroundWindow(mainWindowHandle);
- }
- }
- catch (Exception exception)
- {
- }
- }
-
- public static decimal CalculaPagamento(VendedorParcela pagamento, Parcela parcela, decimal comissaoPrevista)
- {
- TipoRepasse? tipo;
- bool valueOrDefault;
- bool flag;
- bool valueOrDefault1;
- bool flag1;
- decimal num;
- decimal num1 = pagamento.get_PorcentagemRepasse().GetValueOrDefault();
- decimal valueOrDefault2 = pagamento.get_ValorRepasse().GetValueOrDefault();
- decimal valorComDesconto = parcela.get_ValorComDesconto();
- Repasse repasse = pagamento.get_Repasse();
- if (repasse != null)
- {
- valueOrDefault = repasse.get_Incidencia().GetValueOrDefault() == 2;
- }
- else
- {
- valueOrDefault = false;
- }
- if (valueOrDefault)
- {
- decimal comissao = (parcela.get_Documento().get_Comissao() * parcela.get_Documento().get_PremioLiquido()) * new decimal(1, 0, 0, false, 2);
- num = (parcela.get_ValorComissao() != decimal.Zero ? parcela.get_ValorComissao() / comissao : decimal.Zero);
- valorComDesconto = parcela.get_Documento().get_PremioLiquido() * num;
- }
- Repasse repasse1 = pagamento.get_Repasse();
- if (repasse1 != null)
- {
- tipo = repasse1.get_Tipo();
- flag = tipo.GetValueOrDefault() != 1;
- }
- else
- {
- flag = true;
- }
- if (flag)
- {
- decimal? porcentagemRepasse = pagamento.get_PorcentagemRepasse();
- num1 = (valorComDesconto * porcentagemRepasse.GetValueOrDefault()) * new decimal(1, 0, 0, false, 2);
- }
- Repasse repasse2 = pagamento.get_Repasse();
- if (repasse2 != null)
- {
- tipo = repasse2.get_Tipo();
- valueOrDefault1 = tipo.GetValueOrDefault() == 1;
- }
- else
- {
- valueOrDefault1 = false;
- }
- if (valueOrDefault1)
- {
- Repasse repasse3 = pagamento.get_Repasse();
- if (repasse3 != null)
- {
- flag1 = repasse3.get_Forma().GetValueOrDefault() == 1;
- }
- else
- {
- flag1 = false;
- }
- if (flag1)
- {
- if (Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 25))
- {
- num1 *= (comissaoPrevista == decimal.Zero ? decimal.One : parcela.get_ValorComissao() / comissaoPrevista);
- }
- }
- }
- if (Math.Abs(num1) <= Math.Abs(valueOrDefault2))
- {
- return num1;
- }
- return valueOrDefault2;
- }
-
- public static decimal CalculaRepasse(Repasse repasse, Parcela parcela, bool apolice = true)
- {
- decimal num;
- decimal num1;
- decimal num2;
- decimal comissao;
- decimal num3;
- if (repasse == null)
- {
- return decimal.Zero;
- }
- NegocioCorretora? negocioCorretora = parcela.get_Documento().get_NegocioCorretora();
- bool valueOrDefault = negocioCorretora.GetValueOrDefault() == 1;
- if (!apolice || parcela.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2 || parcela.get_SubTipo() != 1)
- {
- decimal num4 = (parcela.get_Documento().get_TipoRecebimento().GetValueOrDefault() == 2 ? parcela.get_ValorLiquidoFatura() : parcela.get_Valor());
- if (repasse.get_Incidencia().GetValueOrDefault() == 2)
- {
- num3 = num4;
- }
- else
- {
- num3 = (parcela.get_ValorComDesconto() == decimal.Zero ? num4 : parcela.get_ValorComDesconto());
- }
- num1 = num3;
- num2 = num1;
- comissao = (parcela.get_ValorComDesconto() == decimal.Zero ? parcela.get_Comissao() * new decimal(1, 0, 0, false, 2) : decimal.One);
- }
- else
- {
- num1 = (parcela.get_Documento().get_AdicionalComiss() ? parcela.get_Documento().get_PremioLiquido() + parcela.get_Documento().get_PremioAdicional() : parcela.get_Documento().get_PremioLiquido());
- num2 = (parcela.get_Documento().get_AdicionalComiss() ? parcela.get_Documento().get_PremioLiquido() + parcela.get_Documento().get_PremioAdicional() : parcela.get_Documento().get_PremioLiquido());
- comissao = parcela.get_Documento().get_Comissao() * new decimal(1, 0, 0, false, 2);
- }
- num1 = (repasse.get_Incidencia().GetValueOrDefault() == 2 ? num1 : num1 * comissao);
- num1 = (repasse.get_Tipo().GetValueOrDefault() == 1 ? num1 : (num1 * (valueOrDefault ? repasse.get_ValorRenovacao() : repasse.get_ValorNovo())) * new decimal(1, 0, 0, false, 2));
- decimal num5 = (repasse.get_Incidencia().GetValueOrDefault() == 2 ? num2 : num2 * comissao);
- if (repasse.get_Tipo().GetValueOrDefault() != 1)
- {
- num = (num5 * (valueOrDefault ? repasse.get_ValorRenovacao() : repasse.get_ValorNovo())) * new decimal(1, 0, 0, false, 2);
- }
- else
- {
- num = (valueOrDefault ? repasse.get_ValorRenovacao() : repasse.get_ValorNovo());
- if (Recursos.Configuracoes.Any<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() == 24) && parcela.get_Valor() < decimal.Zero)
- {
- num = -num;
- }
- }
- if (parcela.get_Documento().get_TipoRecebimento().GetValueOrDefault() != 2 && parcela.get_SubTipo() == 1 && parcela.get_Documento().get_TipoEndosso().GetValueOrDefault() != 2)
- {
- if (Math.Abs(num) > Math.Abs(num1))
- {
- (new BaseDialogViewModel()).ShowMessage("OS VALORES DE REPASSE ULTRAPASSARAM O VALOR DE COMISSÃO FECHADA. REVEJA OS VALORES.", "OK", "", false);
- }
- if (Math.Abs(num) <= Math.Abs(num1))
- {
- return num;
- }
- return num1;
- }
- if (parcela.get_ValorComDesconto() != decimal.Zero && Math.Abs(num) > Math.Abs(parcela.get_ValorComDesconto()))
- {
- if (Recursos.Configuracoes.All<ConfiguracaoSistema>((ConfiguracaoSistema x) => x.get_Configuracao() != 15))
- {
- return parcela.get_ValorComDesconto();
- }
- }
- return num;
- }
-
- public static string Clear(this string stringToClean)
- {
- if (stringToClean == null)
- {
- return null;
- }
- return Regex.Replace(stringToClean, "[^\\d]", string.Empty);
- }
-
- private static void CloseSlackBar()
- {
- Thread.Sleep(5000);
- Dispatcher dispatcher = App.ProgressRing.Dispatcher;
- if (dispatcher == null)
- {
- return;
- }
- dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => Funcoes.ToggleSnackBar("", false)));
- }
-
- public static List<ParametrosRelatorio> ColunasRelatorio<T>(Relatorio relatorio, List<ParametrosRelatorio> parametrosAdicionados)
- {
- long id;
- int ordem;
- List<ParametrosRelatorio> parametrosRelatorios = new List<ParametrosRelatorio>();
- foreach (PropertyInfo propertyInfo in
- from in (IEnumerable<PropertyInfo>)typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public)
- orderby x.GetDescriptionAttribute()
- select )
- {
- if (propertyInfo.Name == "ValidationEvent" || propertyInfo.GetTypeAttribute() == "INVALID" || parametrosAdicionados.Any<ParametrosRelatorio>((ParametrosRelatorio x) => x.get_Campo() == propertyInfo.Name))
- {
- continue;
- }
- ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio();
- ParametrosRelatorio parametrosRelatorio1 = parametrosAdicionados.FirstOrDefault<ParametrosRelatorio>((ParametrosRelatorio x) => {
- if (x.get_IdUsuario() == 0)
- {
- return false;
- }
- return x.get_Campo() == propertyInfo.Name;
- });
- if (parametrosRelatorio1 != null)
- {
- id = parametrosRelatorio1.get_Id();
- }
- else
- {
- id = (long)0;
- }
- parametrosRelatorio.set_Id(id);
- parametrosRelatorio.set_Campo(propertyInfo.Name);
- parametrosRelatorio.set_Header(propertyInfo.GetDescriptionAttribute());
- parametrosRelatorio.set_IdUsuario(Recursos.Usuario.get_Id());
- parametrosRelatorio.set_Relatorio(relatorio);
- parametrosRelatorio.set_Tipo(propertyInfo.GetTypeAttribute());
- parametrosRelatorio.set_Width(0);
- ParametrosRelatorio parametrosRelatorio2 = parametrosAdicionados.FirstOrDefault<ParametrosRelatorio>((ParametrosRelatorio x) => x.get_Campo() == propertyInfo.Name);
- if (parametrosRelatorio2 != null)
- {
- ordem = parametrosRelatorio2.get_Ordem();
- }
- else
- {
- ordem = 0;
- }
- parametrosRelatorio.set_Ordem(ordem);
- parametrosRelatorios.Add(parametrosRelatorio);
- }
- return parametrosRelatorios;
- }
-
- public static List<SinteticModelList> ConstruirSintetico(this List<Sintetico> sintetico, Relatorio relatorio)
- {
- if (sintetico == null)
- {
- return null;
- }
- List<SinteticModelList> sinteticModelLists = new List<SinteticModelList>();
- typeof(Sintetico).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList<PropertyInfo>().ForEach((PropertyInfo props) => {
- char chr;
- if (props.GetValue(sintetico.First<Sintetico>()) == null)
- {
- return;
- }
- string descriptionAttribute = props.GetDescriptionAttribute();
- TipoRestricao? nullable = null;
- if (descriptionAttribute != null)
- {
- switch (descriptionAttribute.Length)
- {
- case 5:
- {
- if (descriptionAttribute == "VALOR")
- {
- nullable = new TipoRestricao?(100);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 7:
- {
- if (descriptionAttribute == "REPASSE")
- {
- nullable = new TipoRestricao?(81);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 8:
- {
- if (descriptionAttribute == "IMPOSTOS")
- {
- nullable = new TipoRestricao?(93);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 10:
- {
- if (descriptionAttribute == "VALOR PAGO")
- {
- nullable = new TipoRestricao?(104);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 11:
- {
- if (descriptionAttribute == "TOTAL GERAL")
- {
- nullable = new TipoRestricao?(75);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 12:
- {
- chr = descriptionAttribute[0];
- if (chr == 'M')
- {
- if (descriptionAttribute == "META ATINGIR")
- {
- nullable = new TipoRestricao?(88);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'P')
- {
- if (descriptionAttribute == "PRÊMIO TOTAL")
- {
- nullable = new TipoRestricao?(65);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'V')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "VALOR ORÇADO")
- {
- nullable = new TipoRestricao?(101);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 13:
- {
- chr = descriptionAttribute[0];
- if (chr == 'M')
- {
- if (descriptionAttribute == "META CUMPRIDA")
- {
- nullable = new TipoRestricao?(89);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'V')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "VALOR SALVADO")
- {
- nullable = new TipoRestricao?(105);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 14:
- {
- chr = descriptionAttribute[8];
- switch (chr)
- {
- case 'A':
- {
- if (descriptionAttribute == "VALOR FRANQUIA")
- {
- nullable = new TipoRestricao?(106);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 'B':
- {
- if (descriptionAttribute == "VALOR LIBERADO")
- {
- nullable = new TipoRestricao?(103);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 'C':
- case 'D':
- {
- goto Label0;
- }
- case 'E':
- {
- if (descriptionAttribute == "TOTAL PREVISTO")
- {
- nullable = new TipoRestricao?(82);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- default:
- {
- if (chr == 'R')
- {
- if (descriptionAttribute == "TOTAL PARCELAS")
- {
- nullable = new TipoRestricao?(102);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'Í')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "PRÊMIO LÍQUIDO")
- {
- nullable = new TipoRestricao?(67);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- }
- break;
- }
- case 15:
- {
- if (descriptionAttribute == "VALOR LIQUIDADO")
- {
- nullable = new TipoRestricao?(86);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 16:
- {
- if (descriptionAttribute == "TOTAL DE LÍQUIDO")
- {
- nullable = new TipoRestricao?(76);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 17:
- {
- chr = descriptionAttribute[10];
- if (chr == 'E')
- {
- if (descriptionAttribute == "COMISSÃO PENDENTE")
- {
- nullable = new TipoRestricao?(87);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'L')
- {
- if (descriptionAttribute == "TOTAL DE CLIENTES")
- {
- goto Label1;
- }
- goto Label0;
- }
- else if (chr != 'R')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "COMISSÃO PREVISTA")
- {
- nullable = new TipoRestricao?(80);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 18:
- {
- if (descriptionAttribute == "TOTAL DE TERCEIROS")
- {
- nullable = new TipoRestricao?(83);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 19:
- {
- if (descriptionAttribute == "QUANTIDADE PENDENTE")
- {
- nullable = new TipoRestricao?(85);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 20:
- {
- if (descriptionAttribute == "QUANTIDADE LIQUIDADO")
- {
- nullable = new TipoRestricao?(84);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 21:
- {
- if (descriptionAttribute == "QUANTIDADE DE FATURAS")
- {
- nullable = new TipoRestricao?(74);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 22:
- {
- chr = descriptionAttribute[14];
- if (chr == 'A')
- {
- if (descriptionAttribute == "QUANTIDADE DE APÓLICES")
- {
- nullable = new TipoRestricao?(72);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'E')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "QUANTIDADE DE ENDOSSOS")
- {
- nullable = new TipoRestricao?(73);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 23:
- {
- if (descriptionAttribute == "COMISSÃO RECEBIDA BRUTA")
- {
- nullable = new TipoRestricao?(79);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 24:
- {
- chr = descriptionAttribute[0];
- if (chr == 'M')
- {
- if (descriptionAttribute == "MÉDIA DE COMISSÃO GERADA")
- {
- break;
- }
- goto Label0;
- }
- else if (chr == 'Q')
- {
- if (descriptionAttribute == "QUANTIDADE DE RENOVAÇÕES")
- {
- goto Label2;
- }
- goto Label0;
- }
- else if (chr == 'T')
- {
- if (descriptionAttribute == "TOTAL DE CLIENTES ATIVOS")
- {
- goto Label1;
- }
- if (descriptionAttribute == "TOTAL DE COMISSÃO GERADA")
- {
- nullable = new TipoRestricao?(78);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else
- {
- goto Label0;
- }
- }
- case 25:
- {
- chr = descriptionAttribute[0];
- if (chr == 'C')
- {
- if (descriptionAttribute == "COMISSÃO RECEBIDA LÍQUIDA")
- {
- nullable = new TipoRestricao?(92);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'M')
- {
- if (descriptionAttribute == "MÉDIA DE COMISSÃO FECHADA")
- {
- break;
- }
- goto Label0;
- }
- else if (chr != 'Q')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "QUANTIDADE DE PROSPECÇÕES")
- {
- nullable = new TipoRestricao?(77);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 26:
- {
- if (descriptionAttribute == "TOTAL DE CLIENTES INATIVOS")
- {
- goto Label1;
- }
- goto Label0;
- }
- case 27:
- {
- chr = descriptionAttribute[15];
- if (chr == 'A')
- {
- if (descriptionAttribute == "QUANTIDADE DE CANCELAMENTOS")
- {
- nullable = new TipoRestricao?(71);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'E')
- {
- if (descriptionAttribute == "QUANTIDADE DE SEGUROS NOVOS")
- {
- goto Label2;
- }
- goto Label0;
- }
- else if (chr == 'Ã')
- {
- if (descriptionAttribute == "MÉDIA DE COMISSÃO PONDERADA")
- {
- break;
- }
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 28:
- {
- if (descriptionAttribute == "QUANTIDADE DE NOVOS NEGÓCIOS")
- {
- goto Label3;
- }
- goto Label0;
- }
- case 31:
- {
- if (descriptionAttribute == "QUANTIDADE DE NEGÓCIOS PRÓPRIOS")
- {
- goto Label3;
- }
- goto Label0;
- }
- default:
- {
- goto Label0;
- }
- }
- nullable = new TipoRestricao?(68);
- }
- Label0:
- if (nullable.HasValue)
- {
- RestricaoUsuario restricaoUsuario = (new RestricaoUsuarioServico()).BuscarRestricao(Recursos.Usuario, nullable.Value);
- if (restricaoUsuario != null && restricaoUsuario.get_Restricao())
- {
- return;
- }
- }
- List<ParametrosTotalizacao> parametrosTotalizacaos = (new ConfuguracoesServico()).BuscarParametroTotalizacao(relatorio);
- if (parametrosTotalizacaos != null && parametrosTotalizacaos.Count > 0 && parametrosTotalizacaos.All<ParametrosTotalizacao>((ParametrosTotalizacao y) => y.get_Campo() != props.Name) && !props.Name.ToUpperInvariant().Contains("AGRUPAMENTO"))
- {
- return;
- }
- SinteticModelList sinteticModelList = new SinteticModelList();
- sinteticModelList.set_Hint(descriptionAttribute);
- sinteticModelList.set_Value(new List<object>());
- SinteticModelList sinteticModelList1 = sinteticModelList;
- string typeAttribute = props.GetTypeAttribute();
- sintetico.ForEach((Sintetico s) => {
- object obj;
- DateTime? value;
- DateTime valueOrDefault;
- object str;
- object str1;
- string str2 = typeAttribute;
- if (str2 == "DATA/TIME" || str2 == "DATA/TIME?")
- {
- value = (DateTime?)props.GetValue(s);
- if (value.HasValue)
- {
- valueOrDefault = value.GetValueOrDefault();
- str = valueOrDefault.ToString("G");
- }
- else
- {
- str = null;
- }
- obj = str;
- }
- else if (str2 == "DATA" || str2 == "DATA?")
- {
- value = (DateTime?)props.GetValue(s);
- if (value.HasValue)
- {
- valueOrDefault = value.GetValueOrDefault();
- str1 = valueOrDefault.ToString("d");
- }
- else
- {
- str1 = null;
- }
- obj = str1;
- }
- else
- {
- obj = (str2 == "PERCENTUAL" ? string.Format("{0:n2} %", props.GetValue(s)) : (str2 == "VALOR" ? ((decimal)props.GetValue(s)).ToString("c2") : string.Format("{0}", props.GetValue(s))));
- }
- sinteticModelList1.get_Value().Add(obj);
- });
- sinteticModelLists.Add(sinteticModelList1);
- return;
- Label1:
- nullable = new TipoRestricao?(66);
- goto Label0;
- Label2:
- nullable = new TipoRestricao?(70);
- goto Label0;
- Label3:
- nullable = new TipoRestricao?(69);
- goto Label0;
- });
- return sinteticModelLists;
- }
-
- public static List<SinteticModel> ConstruirSintetico(this Sintetico sintetico, Relatorio relatorio)
- {
- if (sintetico == null)
- {
- return null;
- }
- List<SinteticModel> sinteticModels = new List<SinteticModel>();
- typeof(Sintetico).GetProperties(BindingFlags.Instance | BindingFlags.Public).ToList<PropertyInfo>().ForEach((PropertyInfo x) => {
- int length;
- char chr;
- DateTime? value;
- DateTime valueOrDefault;
- decimal num;
- object str;
- SinteticModel sinteticModel;
- object obj;
- if (x.GetValue(sintetico) == null)
- {
- return;
- }
- string descriptionAttribute = x.GetDescriptionAttribute();
- TipoRestricao? nullable = null;
- string str1 = null;
- if (descriptionAttribute != null)
- {
- length = descriptionAttribute.Length;
- switch (length)
- {
- case 5:
- {
- if (descriptionAttribute == "VALOR")
- {
- nullable = new TipoRestricao?(100);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 7:
- {
- if (descriptionAttribute == "REPASSE")
- {
- nullable = new TipoRestricao?(81);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 8:
- {
- if (descriptionAttribute == "IMPOSTOS")
- {
- nullable = new TipoRestricao?(93);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 10:
- {
- if (descriptionAttribute == "VALOR PAGO")
- {
- nullable = new TipoRestricao?(104);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 11:
- {
- if (descriptionAttribute == "TOTAL GERAL")
- {
- nullable = new TipoRestricao?(75);
- str1 = "CONTAGEM GERAL DE DOCUMENTOS";
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 12:
- {
- chr = descriptionAttribute[0];
- if (chr == 'M')
- {
- if (descriptionAttribute == "META ATINGIR")
- {
- nullable = new TipoRestricao?(88);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'P')
- {
- if (descriptionAttribute == "PRÊMIO TOTAL")
- {
- nullable = new TipoRestricao?(65);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'V')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "VALOR ORÇADO")
- {
- nullable = new TipoRestricao?(101);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 13:
- {
- chr = descriptionAttribute[0];
- if (chr == 'M')
- {
- if (descriptionAttribute == "META CUMPRIDA")
- {
- nullable = new TipoRestricao?(89);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'V')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "VALOR SALVADO")
- {
- nullable = new TipoRestricao?(105);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 14:
- {
- chr = descriptionAttribute[8];
- switch (chr)
- {
- case 'A':
- {
- if (descriptionAttribute == "VALOR FRANQUIA")
- {
- nullable = new TipoRestricao?(106);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 'B':
- {
- if (descriptionAttribute == "VALOR LIBERADO")
- {
- nullable = new TipoRestricao?(103);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 'C':
- case 'D':
- {
- goto Label0;
- }
- case 'E':
- {
- if (descriptionAttribute == "TOTAL PREVISTO")
- {
- nullable = new TipoRestricao?(82);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- default:
- {
- if (chr == 'R')
- {
- if (descriptionAttribute == "TOTAL PARCELAS")
- {
- nullable = new TipoRestricao?(102);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'Í')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "PRÊMIO LÍQUIDO")
- {
- nullable = new TipoRestricao?(67);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- }
- break;
- }
- case 15:
- {
- if (descriptionAttribute == "VALOR LIQUIDADO")
- {
- nullable = new TipoRestricao?(86);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 16:
- {
- if (descriptionAttribute == "TOTAL DE LÍQUIDO")
- {
- nullable = new TipoRestricao?(76);
- str1 = "CONTAGEM GERAL DOS DOCUMENTOS ATIVOS";
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 17:
- {
- chr = descriptionAttribute[10];
- if (chr == 'E')
- {
- if (descriptionAttribute == "COMISSÃO PENDENTE")
- {
- nullable = new TipoRestricao?(87);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'L')
- {
- if (descriptionAttribute == "TOTAL DE CLIENTES")
- {
- goto Label1;
- }
- goto Label0;
- }
- else if (chr != 'R')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "COMISSÃO PREVISTA")
- {
- nullable = new TipoRestricao?(80);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 18:
- {
- if (descriptionAttribute == "TOTAL DE TERCEIROS")
- {
- nullable = new TipoRestricao?(83);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 19:
- {
- if (descriptionAttribute == "QUANTIDADE PENDENTE")
- {
- nullable = new TipoRestricao?(85);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 20:
- {
- if (descriptionAttribute == "QUANTIDADE LIQUIDADO")
- {
- nullable = new TipoRestricao?(84);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 21:
- {
- if (descriptionAttribute == "QUANTIDADE DE FATURAS")
- {
- nullable = new TipoRestricao?(74);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 22:
- {
- chr = descriptionAttribute[14];
- if (chr == 'A')
- {
- if (descriptionAttribute == "QUANTIDADE DE APÓLICES")
- {
- nullable = new TipoRestricao?(72);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr != 'E')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "QUANTIDADE DE ENDOSSOS")
- {
- nullable = new TipoRestricao?(73);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 23:
- {
- if (descriptionAttribute == "COMISSÃO RECEBIDA BRUTA")
- {
- nullable = new TipoRestricao?(79);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 24:
- {
- chr = descriptionAttribute[0];
- if (chr == 'M')
- {
- if (descriptionAttribute == "MÉDIA DE COMISSÃO GERADA")
- {
- break;
- }
- goto Label0;
- }
- else if (chr == 'Q')
- {
- if (descriptionAttribute == "QUANTIDADE DE RENOVAÇÕES")
- {
- goto Label2;
- }
- goto Label0;
- }
- else if (chr == 'T')
- {
- if (descriptionAttribute == "TOTAL DE CLIENTES ATIVOS")
- {
- goto Label1;
- }
- if (descriptionAttribute == "TOTAL DE COMISSÃO GERADA")
- {
- nullable = new TipoRestricao?(78);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else
- {
- goto Label0;
- }
- }
- case 25:
- {
- chr = descriptionAttribute[0];
- if (chr == 'C')
- {
- if (descriptionAttribute == "COMISSÃO RECEBIDA LÍQUIDA")
- {
- nullable = new TipoRestricao?(92);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'M')
- {
- if (descriptionAttribute == "MÉDIA DE COMISSÃO FECHADA")
- {
- break;
- }
- goto Label0;
- }
- else if (chr != 'Q')
- {
- goto Label0;
- }
- else if (descriptionAttribute == "QUANTIDADE DE PROSPECÇÕES")
- {
- nullable = new TipoRestricao?(77);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 26:
- {
- if (descriptionAttribute == "TOTAL DE CLIENTES INATIVOS")
- {
- goto Label1;
- }
- goto Label0;
- }
- case 27:
- {
- chr = descriptionAttribute[15];
- if (chr == 'A')
- {
- if (descriptionAttribute == "QUANTIDADE DE CANCELAMENTOS")
- {
- nullable = new TipoRestricao?(71);
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- else if (chr == 'E')
- {
- if (descriptionAttribute == "QUANTIDADE DE SEGUROS NOVOS")
- {
- goto Label2;
- }
- goto Label0;
- }
- else if (chr == 'Ã')
- {
- if (descriptionAttribute == "MÉDIA DE COMISSÃO PONDERADA")
- {
- break;
- }
- goto Label0;
- }
- else
- {
- goto Label0;
- }
- }
- case 28:
- {
- if (descriptionAttribute == "QUANTIDADE DE NOVOS NEGÓCIOS")
- {
- goto Label3;
- }
- goto Label0;
- }
- case 31:
- {
- if (descriptionAttribute == "QUANTIDADE DE NEGÓCIOS PRÓPRIOS")
- {
- goto Label3;
- }
- goto Label0;
- }
- default:
- {
- goto Label0;
- }
- }
- nullable = new TipoRestricao?(68);
- }
- Label0:
- if (nullable.HasValue)
- {
- RestricaoUsuario restricaoUsuario = (new RestricaoUsuarioServico()).BuscarRestricao(Recursos.Usuario, nullable.Value);
- if (restricaoUsuario != null && restricaoUsuario.get_Restricao())
- {
- return;
- }
- }
- List<ParametrosTotalizacao> parametrosTotalizacaos = (new ConfuguracoesServico()).BuscarParametroTotalizacao(relatorio);
- if (parametrosTotalizacaos != null && parametrosTotalizacaos.Count > 0 && parametrosTotalizacaos.All<ParametrosTotalizacao>((ParametrosTotalizacao y) => y.get_Campo() != x.Name))
- {
- return;
- }
- SinteticModel sinteticModel1 = new SinteticModel();
- sinteticModel1.set_Hint(descriptionAttribute);
- sinteticModel1.set_DescriptionField(str1);
- SinteticModel sinteticModel2 = sinteticModel1;
- string typeAttribute = x.GetTypeAttribute();
- if (typeAttribute != null)
- {
- length = typeAttribute.Length;
- switch (length)
- {
- case 4:
- {
- if (typeAttribute == "DATA")
- {
- break;
- }
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- case 5:
- {
- chr = typeAttribute[0];
- if (chr == 'D')
- {
- if (typeAttribute == "DATA?")
- {
- break;
- }
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- else if (chr != 'V')
- {
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- else if (typeAttribute == "VALOR")
- {
- num = (decimal)x.GetValue(sintetico);
- sinteticModel2.set_Value(num.ToString("c2"));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- else
- {
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- }
- case 6:
- case 7:
- case 8:
- {
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- case 9:
- {
- if (typeAttribute == "DATA/TIME")
- {
- sinteticModel = sinteticModel2;
- value = (DateTime?)x.GetValue(sintetico);
- if (value.HasValue)
- {
- valueOrDefault = value.GetValueOrDefault();
- obj = valueOrDefault.ToString("G");
- }
- else
- {
- obj = null;
- }
- sinteticModel.set_Value(obj);
- sinteticModels.Add(sinteticModel2);
- return;
- }
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- case 10:
- {
- chr = typeAttribute[0];
- if (chr == 'D')
- {
- if (typeAttribute == "DATA/TIME?")
- {
- sinteticModel = sinteticModel2;
- value = (DateTime?)x.GetValue(sintetico);
- if (value.HasValue)
- {
- valueOrDefault = value.GetValueOrDefault();
- obj = valueOrDefault.ToString("G");
- }
- else
- {
- obj = null;
- }
- sinteticModel.set_Value(obj);
- sinteticModels.Add(sinteticModel2);
- return;
- }
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- else if (chr != 'P')
- {
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- else if (typeAttribute == "PERCENTUAL")
- {
- sinteticModel2.set_Value(string.Format("{0} %", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- else
- {
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- }
- default:
- {
- if (length == 13)
- {
- if (typeAttribute != "VALORDECIMAL2")
- {
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- num = (decimal)x.GetValue(sintetico);
- sinteticModel2.set_Value(num.ToString("n2"));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- else
- {
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- }
- }
- }
- SinteticModel sinteticModel3 = sinteticModel2;
- value = (DateTime?)x.GetValue(sintetico);
- if (value.HasValue)
- {
- valueOrDefault = value.GetValueOrDefault();
- str = valueOrDefault.ToString("d");
- }
- else
- {
- str = null;
- }
- sinteticModel3.set_Value(str);
- sinteticModels.Add(sinteticModel2);
- return;
- }
- sinteticModel2.set_Value(string.Format("{0}", x.GetValue(sintetico)));
- sinteticModels.Add(sinteticModel2);
- return;
- Label1:
- nullable = new TipoRestricao?(66);
- goto Label0;
- Label2:
- nullable = new TipoRestricao?(70);
- goto Label0;
- Label3:
- nullable = new TipoRestricao?(69);
- goto Label0;
- });
- return sinteticModels;
- }
-
- public static async Task ContruirLista<T>(DataGrid grid, Relatorio relatorio)
- {
- List<ParametrosRelatorio> list = await (new ConfuguracoesServico()).BuscarParametros(relatorio);
- if (list == null || list.Count == 0)
- {
- list = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public).Select<PropertyInfo, ParametrosRelatorio>((PropertyInfo x) => {
- ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio();
- parametrosRelatorio.set_Campo(x.Name);
- parametrosRelatorio.set_Header(x.GetDescriptionAttribute());
- parametrosRelatorio.set_Tipo(x.GetTypeAttribute());
- parametrosRelatorio.set_Relatorio(relatorio);
- parametrosRelatorio.set_Width(0);
- parametrosRelatorio.set_Ordem(0);
- return parametrosRelatorio;
- }).ToList<ParametrosRelatorio>();
- }
- if (!Recursos.Usuario.get_Administrador())
- {
- list = await Funcoes.GetRestricoesColunas(list);
- }
- List<ParametrosRelatorio> parametrosRelatorios = list;
- IOrderedEnumerable<ParametrosRelatorio> ordem =
- from in parametrosRelatorios
- orderby x.get_Ordem()
- select ;
- ordem.ThenBy<ParametrosRelatorio, string>((ParametrosRelatorio x) => x.get_Header()).ToList<ParametrosRelatorio>().ForEach((ParametrosRelatorio x) => {
- char chr;
- object upper;
- if (x.get_Tipo() == "INVALID")
- {
- return;
- }
- if (x.get_Campo() == "DataControle" && !Recursos.Usuario.get_Administrador())
- {
- List<ConfiguracaoSistema> configuracoes = Recursos.Configuracoes;
- Func<ConfiguracaoSistema, bool> u003cu003e9_324 = Funcoes.u003cu003ec__32<T>.u003cu003e9__32_4;
- if (u003cu003e9_324 == null)
- {
- u003cu003e9_324 = (ConfiguracaoSistema c) => c.get_Configuracao() == 33;
- Funcoes.u003cu003ec__32<T>.u003cu003e9__32_4 = u003cu003e9_324;
- }
- if (configuracoes.Any<ConfiguracaoSistema>(u003cu003e9_324))
- {
- return;
- }
- }
- string str = "";
- Style item = (Style)System.Windows.Application.Current.Resources["VerticalCenterStyle3"];
- Style style = (Style)System.Windows.Application.Current.Resources["MaterialDesignDataGridColumnHeaderNew"];
- string tipo = x.get_Tipo();
- if (tipo != null)
- {
- int length = tipo.Length;
- switch (length)
- {
- case 4:
- {
- if (tipo == "DATA")
- {
- break;
- }
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- case 5:
- {
- chr = tipo[0];
- if (chr == 'D')
- {
- if (tipo == "DATA?")
- {
- break;
- }
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else if (chr != 'V')
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else if (tipo == "VALOR")
- {
- str = "c";
- item = (Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"];
- style = (Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyleNew"];
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- }
- case 6:
- case 7:
- case 8:
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- case 9:
- {
- if (tipo == "DATA/TIME")
- {
- goto Label1;
- }
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- case 10:
- {
- chr = tipo[0];
- if (chr == 'D')
- {
- if (tipo == "DATA/TIME?")
- {
- goto Label1;
- }
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else if (chr == 'P')
- {
- if (tipo == "PERCENTUAL")
- {
- str = "{0:0.00}%";
- item = (Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"];
- style = (Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyleNew"];
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- }
- else if (chr != 'Q')
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else if (tipo == "QUANTIDADE")
- {
- item = (Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"];
- style = (Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyleNew"];
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- }
- default:
- {
- if (length != 13)
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else if (tipo == "VALORDECIMAL2")
- {
- str = "n2";
- item = (Style)System.Windows.Application.Current.Resources["HorizontalRightStyle"];
- style = (Style)System.Windows.Application.Current.Resources["HorizontalRightHeaderStyleNew"];
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- else
- {
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- }
- }
- }
- str = "d";
- item = (Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"];
- style = (Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyleNew"];
- }
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- Label1:
- str = "G";
- item = (Style)System.Windows.Application.Current.Resources["HorizontalCenterStyle2"];
- style = (Style)System.Windows.Application.Current.Resources["HorizontalCenterHeaderStyleNew"];
- ObservableCollection<DataGridColumn> columns = grid.Columns;
- MaterialDataGridTextColumn materialDataGridTextColumn = new MaterialDataGridTextColumn();
- string header = x.get_Header();
- if (header != null)
- {
- upper = header.ToUpper();
- }
- else
- {
- upper = null;
- }
- if (upper == null)
- {
- upper = x.get_Campo().ToUpper();
- }
- materialDataGridTextColumn.Header = upper;
- materialDataGridTextColumn.Binding = new Binding()
- {
- Path = new PropertyPath(x.get_Campo(), Array.Empty<object>()),
- StringFormat = str,
- Mode = BindingMode.TwoWay,
- UpdateSourceTrigger = UpdateSourceTrigger.PropertyChanged
- };
- materialDataGridTextColumn.Width = (x.get_Width() == 0 ? new DataGridLength(1, DataGridLengthUnitType.Auto) : (double)x.get_Width());
- materialDataGridTextColumn.ElementStyle = item;
- materialDataGridTextColumn.HeaderStyle = style;
- columns.Add(materialDataGridTextColumn);
- return;
- });
- }
-
- public static string ConvertGaragemTrabalhoEstudoCalculo(this GaragemTrabalhoEstudo garagemTrabalhoEstudo)
- {
- switch (garagemTrabalhoEstudo)
- {
- case 0:
- {
- return "0";
- }
- case 1:
- {
- return "1";
- }
- case 2:
- {
- return "2";
- }
- case 3:
- {
- return string.Empty;
- }
- case 4:
- case 5:
- {
- return "3";
- }
- default:
- {
- return string.Empty;
- }
- }
- }
-
- public static TipoTela? ConvertTela(string name)
- {
- return new TipoTela?(((TipoTela[])Enum.GetValues(typeof(TipoTela))).ToList<TipoTela>().FirstOrDefault<TipoTela>((TipoTela x) => Gestor.Common.Validation.ValidationHelper.GetEntity(x) == name));
- }
-
- public static TempoHabilitacao ConvertTempoHabilitacao(int tempoHabilitacao = 0)
- {
- if (tempoHabilitacao == 1)
- {
- return 0;
- }
- if (tempoHabilitacao == 2)
- {
- return 1;
- }
- if (tempoHabilitacao == 3)
- {
- return 2;
- }
- if (tempoHabilitacao == 4)
- {
- return 3;
- }
- if (tempoHabilitacao == 5)
- {
- return 4;
- }
- if (tempoHabilitacao == 6)
- {
- return 5;
- }
- if (tempoHabilitacao == 7)
- {
- return 6;
- }
- if (tempoHabilitacao == 8)
- {
- return 7;
- }
- if (tempoHabilitacao == 9)
- {
- return 8;
- }
- if (tempoHabilitacao == 10)
- {
- return 9;
- }
- if (tempoHabilitacao >= 11)
- {
- return 10;
- }
- return 0;
- }
-
- public static string ConvertTempoHabilitacaoCalculo(this DateTime tempoHabilitacao)
- {
- if (tempoHabilitacao == DateTime.MinValue)
- {
- return "0";
- }
- int year = DateTime.Now.Year - tempoHabilitacao.Year;
- if (year >= 11)
- {
- return "11";
- }
- return year.ToString();
- }
-
- public static string ConvertTipoSeguroCalculo(this TipoSeguro tipoSeguro)
- {
- if (tipoSeguro - 1 <= 1)
- {
- return "1";
- }
- return "0";
- }
-
- public static void CopyToClipboard(this string text)
- {
- try
- {
- Clipboard.SetText(text);
- }
- catch (Exception exception)
- {
- }
- }
-
- public static string CreateCard(string title, string body, bool pageBreak = false)
- {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append((pageBreak ? "<div class='card p-0' style='page-break-after:always;'>" : "<div class='card p-0'>"));
- stringBuilder.Append("<div class='card-body'>");
- stringBuilder.Append(string.Concat("<h5 class='card-title'>", title, "</h5>"));
- stringBuilder.Append(body);
- stringBuilder.Append("</div>");
- stringBuilder.Append("</div>");
- return stringBuilder.ToString();
- }
-
- public static async Task<string> CriarAssistencia(Assistance assistance)
- {
- return await Gestor.Application.Helpers.Connection.Post<string>("Assistance", assistance);
- }
-
- public static async Task<string> CriarCartao(Gestor.Model.Domain.Card.Card card)
- {
- return await Gestor.Application.Helpers.Connection.Post<string>("Card", card);
- }
-
- public static async Task<string> Criarlogo(Logo logo)
- {
- return await Gestor.Application.Helpers.Connection.Post<string>("Card/Logo", logo);
- }
-
- public static string CriarRecibo(Vendedor vendedor, decimal valor, Filtros filtro, bool segundavia)
- {
- string str = (segundavia ? " acima listados" : string.Format(" no periodo de {0:d} até {1:d}", filtro.get_Inicio(), filtro.get_Fim()));
- string str1 = "CPF";
- if (vendedor.get_Documento() != null && Gestor.Common.Validation.ValidationHelper.OnlyNumber(vendedor.get_Documento()).Length > 12)
- {
- str1 = "CNPJ";
- }
- object[] nome = new object[] { vendedor.get_Nome(), str1, vendedor.get_Documento(), Recursos.Empresa.get_Nome(), valor, str, null };
- nome[6] = Funcoes.GetNetworkTime().Date;
- return string.Format(" <div class='card'>\r\n <h5 class='card-header'>RECIBO DE PAGAMENTO</h5>\r\n <div class='card-body'>\r\n <h5 class='card-title'>Declaração de recebimento de Comissão</h5>\r\n <p class='card-text'>Eu {0}, portador(a) do {1} {2} declaro que recebi de {3} o valor de {4:c} referente a comissão dos seguros{5}.</p>\r\n\r\n <p class='card-text'>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.</p>\r\n\r\n <p class='card-text'>_____________________________________________________________ </br> {6:d}</p>\r\n </div>\r\n </div>", nome);
- }
-
- public static async Task<string> CriarSeguradora(AssistenciaCia cia)
- {
- return await Gestor.Application.Helpers.Connection.Post<string>("Assistance/Seguradora", cia);
- }
-
- public static void DatePicker_OnLostKeyboardFocus(object sender, KeyboardFocusChangedEventArgs e)
- {
- DatePicker datePicker = (DatePicker)sender;
- datePicker.Text = Gestor.Common.Validation.ValidationHelper.FormatDate(datePicker.Text);
- }
-
- public static void DatePicker_PreviewKeyDown(object sender, KeyEventArgs e)
- {
- if (e.Key != Key.Return)
- {
- return;
- }
- DatePicker str = (DatePicker)sender;
- DateTime date = Funcoes.GetNetworkTime().Date;
- str.Text = date.ToString("dd/MM/yyyy");
- }
-
- public static void Destroy<T>()
- where T : Window
- {
- object obj = System.Windows.Application.Current.Windows.OfType<T>().FirstOrDefault<T>();
- if (obj == null)
- {
- return;
- }
- ((Window)obj).Close();
- }
-
- public static void Destroy<T>(string title)
- where T : Window
- {
- object obj = System.Windows.Application.Current.Windows.OfType<T>().FirstOrDefault<T>((T x) => x.Title == title);
- if (obj == null)
- {
- return;
- }
- ((Window)obj).Close();
- }
-
- public static string DiaDaSemana(this int? dia)
- {
- if (!dia.HasValue)
- {
- return "";
- }
- switch (dia.Value)
- {
- case 0:
- {
- return "DOMINGO";
- }
- case 1:
- {
- return "SEGUNDA-FEIRA";
- }
- case 2:
- {
- return "TERÇA-FEIRA";
- }
- case 3:
- {
- return "QUARTA-FEIRA";
- }
- case 4:
- {
- return "QUINTA-FEIRA";
- }
- case 5:
- {
- return "SEXTA-FEIRA";
- }
- case 6:
- {
- return "SABADO";
- }
- }
- return "";
- }
-
- public static IEnumerable<TSource> DistinctBy<TSource, TKey>(IEnumerable<TSource> source, Func<TSource, TKey> keySelector)
- {
- HashSet<TKey> tKeys = new HashSet<TKey>();
- foreach (TSource tSource in source)
- {
- if (!tKeys.Add(keySelector(tSource)))
- {
- continue;
- }
- yield return tSource;
- }
- }
-
- public static bool EnviarWhatsapp(this string numero, string anotacoes = null)
- {
- bool flag;
- Uri uri = (string.IsNullOrEmpty(anotacoes) ? Recursos.WhatsAppLink.SetQuery("phone", numero, true) : Recursos.WhatsAppLink.AddQuery<string>("phone", numero).SetQuery("text", anotacoes, true));
- try
- {
- Process.Start(new ProcessStartInfo(uri.AbsoluteUri));
- flag = true;
- }
- catch (Exception exception)
- {
- uri.AbsoluteUri.CopyToClipboard();
- flag = false;
- }
- return flag;
- }
-
- public static async Task<Parcela> ExcluirBaixa(Parcela parcela, List<VendedorParcela> repasses, List<Parcela> parcelas = null)
- {
- Parcela parcela1;
- string str;
- decimal num1;
- List<Parcela> parcelas1;
- List<Parcela> parcelas2;
- Funcoes.u003cu003ec__DisplayClass9_0 variable;
- ParcelaServico parcelaServico;
- VendedorServico vendedorServico;
- Parcela parcela2 = parcela;
- ParcelaServico parcelaServico1 = new ParcelaServico();
- if (parcela2.get_SubTipo() != 1 || parcela2.get_Documento().get_TipoRecebimento().GetValueOrDefault() != 1)
- {
- List<VendedorParcela> list = repasses.Where<VendedorParcela>((VendedorParcela x) => {
- if (x.get_Parcela().get_Id() != parcela2.get_Id())
- {
- return false;
- }
- return !x.get_DataPagamento().HasValue;
- }).ToList<VendedorParcela>();
- List<VendedorParcela> vendedorParcelas1 = list;
- vendedorParcelas1.ForEach((VendedorParcela x) => {
- x.set_DataPrePagamento(null);
- VendedorParcela vendedorParcela = x;
- decimal? valorTotal = x.get_ValorTotal();
- vendedorParcela.set_ValorRepasse(new decimal?((valorTotal.HasValue ? valorTotal.GetValueOrDefault() : Funcoes.CalculaPagamento(x, x.get_Parcela(), decimal.Zero))));
- });
- parcela2.set_ValorComissao(decimal.Zero);
- parcela2.set_ValorComDesconto(decimal.Zero);
- DateTime? nullable1 = null;
- parcela2.set_DataRecebimento(nullable1);
- nullable1 = null;
- parcela2.set_DataCredito(nullable1);
- parcela2.set_ValorRealizado(decimal.Zero);
- Parcela parcela3 = await parcelaServico1.Save(parcela2, parcelas, list, false);
- parcela2 = parcela3;
- if (!parcelaServico1.Sucesso)
- {
- await Funcoes.MostrarErro(191);
- parcela1 = parcela2;
- variable = null;
- parcelaServico1 = null;
- parcelaServico = null;
- vendedorServico = null;
- return parcela1;
- }
- }
- else
- {
- List<VendedorParcela> list1 = repasses.Where<VendedorParcela>((VendedorParcela x) => {
- bool valueOrDefault;
- if (x.get_Parcela().get_SubTipo() == 1)
- {
- Repasse repasse = x.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false);
- if (valueOrDefault)
- {
- if (x.get_Parcela().get_Id() == this.parcela.get_Id())
- {
- return true;
- }
- return !x.get_DataPrePagamento().HasValue;
- }
- }
- return false;
- }).ToList<VendedorParcela>();
- decimal premioLiquido = parcela2.get_Documento().get_PremioLiquido();
- num1 = (parcela2.get_Documento().get_AdicionalComiss() ? parcela2.get_Documento().get_PremioAdicional() : decimal.Zero);
- decimal comissao = ((premioLiquido + num1) * parcela2.get_Documento().get_Comissao()) * new decimal(1, 0, 0, false, 2);
- List<VendedorParcela> vendedorParcelas2 = list1;
- List<VendedorParcela> list2 = (
- from x in vendedorParcelas2
- group x by x.get_Vendedor().get_Id()).Select<IGrouping<long, VendedorParcela>, VendedorParcela>((IGrouping<long, VendedorParcela> x) => {
- TipoRepasse? nullable;
- decimal? valorTotal;
- decimal num;
- TipoRepasse? tipo;
- bool valueOrDefault;
- bool hasValue;
- decimal? valorRepasse;
- bool flag;
- VendedorParcela vendedorParcela = new VendedorParcela();
- vendedorParcela.set_Repasse(x.First<VendedorParcela>().get_Repasse());
- vendedorParcela.set_Parcela(parcela2);
- vendedorParcela.set_Documento(parcela2.get_Documento());
- VendedorParcela vendedorParcela1 = x.First<VendedorParcela>();
- if (vendedorParcela1 != null)
- {
- Repasse repasse = vendedorParcela1.get_Repasse();
- if (repasse != null)
- {
- tipo = repasse.get_Tipo();
- }
- else
- {
- nullable = null;
- tipo = nullable;
- }
- nullable = tipo;
- valueOrDefault = nullable.GetValueOrDefault() != 3;
- }
- else
- {
- valueOrDefault = true;
- }
- if (valueOrDefault)
- {
- VendedorParcela vendedorParcela2 = x.First<VendedorParcela>();
- if (vendedorParcela2 != null)
- {
- valorTotal = vendedorParcela2.get_ValorTotal();
- hasValue = valorTotal.HasValue;
- }
- else
- {
- hasValue = false;
- }
- if (hasValue)
- {
- VendedorParcela vendedorParcela3 = x.First<VendedorParcela>();
- if (vendedorParcela3 != null)
- {
- valorTotal = vendedorParcela3.get_ValorTotal();
- num = new decimal();
- flag = !((valorTotal.GetValueOrDefault() == num) & valorTotal.HasValue);
- }
- else
- {
- flag = true;
- }
- if (!flag)
- {
- goto Label1;
- }
- VendedorParcela vendedorParcela4 = x.First<VendedorParcela>();
- if (vendedorParcela4 != null)
- {
- valorRepasse = vendedorParcela4.get_ValorTotal();
- vendedorParcela.set_ValorTotal(valorRepasse);
- vendedorParcela.set_Vendedor(x.First<VendedorParcela>().get_Vendedor());
- vendedorParcela.set_PorcentagemRepasse(x.First<VendedorParcela>().get_PorcentagemRepasse());
- vendedorParcela.set_TipoVendedor(x.First<VendedorParcela>().get_TipoVendedor());
- vendedorParcela.set_CoCorretagem(x.First<VendedorParcela>().get_CoCorretagem());
- return vendedorParcela;
- }
- else
- {
- valorTotal = null;
- valorRepasse = valorTotal;
- vendedorParcela.set_ValorTotal(valorRepasse);
- vendedorParcela.set_Vendedor(x.First<VendedorParcela>().get_Vendedor());
- vendedorParcela.set_PorcentagemRepasse(x.First<VendedorParcela>().get_PorcentagemRepasse());
- vendedorParcela.set_TipoVendedor(x.First<VendedorParcela>().get_TipoVendedor());
- vendedorParcela.set_CoCorretagem(x.First<VendedorParcela>().get_CoCorretagem());
- return vendedorParcela;
- }
- }
- Label1:
- num = comissao;
- valorTotal = x.First<VendedorParcela>().get_PorcentagemRepasse();
- valorRepasse = (valorTotal.HasValue ? new decimal?((num * valorTotal.GetValueOrDefault()) * new decimal(1, 0, 0, false, 2)) : null);
- }
- else
- {
- valorRepasse = x.First<VendedorParcela>().get_ValorRepasse();
- }
- vendedorParcela.set_ValorTotal(valorRepasse);
- vendedorParcela.set_Vendedor(x.First<VendedorParcela>().get_Vendedor());
- vendedorParcela.set_PorcentagemRepasse(x.First<VendedorParcela>().get_PorcentagemRepasse());
- vendedorParcela.set_TipoVendedor(x.First<VendedorParcela>().get_TipoVendedor());
- vendedorParcela.set_CoCorretagem(x.First<VendedorParcela>().get_CoCorretagem());
- return vendedorParcela;
- }).ToList<VendedorParcela>();
- parcelas1 = (parcelas != null ? parcelas.Where<Parcela>((Parcela x) => {
- if (x.get_SubTipo() != 1)
- {
- return false;
- }
- return x.get_NumeroParcela() < this.parcela.get_NumeroParcela();
- }).ToList<Parcela>() : new List<Parcela>());
- List<Parcela> parcelas3 = parcelas1;
- list2.ForEach((VendedorParcela y) => {
- VendedorParcela vendedorParcela = y;
- decimal? valorTotal = y.get_ValorTotal();
- IEnumerable<VendedorParcela> vendedorParcelas = repasses.Where<VendedorParcela>((VendedorParcela x) => {
- bool valueOrDefault;
- if (x.get_Parcela().get_SubTipo() == 1)
- {
- Repasse repasse = x.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false);
- if (valueOrDefault && x.get_Vendedor().get_Id() == y.get_Vendedor().get_Id())
- {
- List<Parcela> cSu0024u003cu003e8_locals2 = parcelas3;
- Func<Parcela, long> u003cu003e9_912 = Funcoes.u003cu003ec.u003cu003e9__9_12;
- if (u003cu003e9_912 == null)
- {
- u003cu003e9_912 = (Parcela z) => z.get_Id();
- Funcoes.u003cu003ec.u003cu003e9__9_12 = u003cu003e9_912;
- }
- return cSu0024u003cu003e8_locals2.Select<Parcela, long>(u003cu003e9_912).ToList<long>().Contains(x.get_Parcela().get_Id());
- }
- }
- return false;
- });
- Func<VendedorParcela, decimal?> u003cu003e9_911 = Funcoes.u003cu003ec.u003cu003e9__9_11;
- if (u003cu003e9_911 == null)
- {
- u003cu003e9_911 = (VendedorParcela x) => x.get_ValorRepasse();
- Funcoes.u003cu003ec.u003cu003e9__9_11 = u003cu003e9_911;
- }
- decimal? nullable = vendedorParcelas.Sum<VendedorParcela>(u003cu003e9_911);
- vendedorParcela.set_ValorRepasse((valorTotal.HasValue & nullable.HasValue ? new decimal?(valorTotal.GetValueOrDefault() - nullable.GetValueOrDefault()) : null));
- });
- parcelas2 = (parcelas != null ? parcelas.Where<Parcela>((Parcela x) => {
- if (x.get_SubTipo() != 1)
- {
- return false;
- }
- return x.get_NumeroParcela() > this.parcela.get_NumeroParcela();
- }).ToList<Parcela>() : new List<Parcela>());
- List<Parcela> list3 = parcelas2;
- list3.Add(parcela2);
- List<VendedorParcela> vendedorParcelas3 = repasses.Where<VendedorParcela>((VendedorParcela x) => {
- bool valueOrDefault;
- if (x.get_Parcela().get_SubTipo() == 1)
- {
- Repasse repasse = x.get_Repasse();
- valueOrDefault = (repasse != null ? repasse.get_Forma().GetValueOrDefault() == 1 : false);
- if (valueOrDefault)
- {
- if (x.get_Parcela().get_NumeroParcela() >= this.parcela.get_NumeroParcela())
- {
- return true;
- }
- return !x.get_DataPrePagamento().HasValue;
- }
- }
- return false;
- }).ToList<VendedorParcela>();
- if (!await parcelaServico1.DeletePagamentoRange(vendedorParcelas3))
- {
- await Funcoes.MostrarErro(191);
- parcela1 = parcela2;
- variable = null;
- parcelaServico1 = null;
- parcelaServico = null;
- vendedorServico = null;
- return parcela1;
- }
- else if (await parcelaServico1.SaveRange(list2))
- {
- List<Parcela> parcelas4 = list3;
- list3 = parcelas4.Where<Parcela>((Parcela dParcela) => {
- if (dParcela.get_ValorComissao() != decimal.Zero || dParcela.get_ValorComissao() != decimal.Zero || dParcela.get_DataRecebimento().HasValue || dParcela.get_DataCredito().HasValue)
- {
- return true;
- }
- return dParcela.get_ValorRealizado() != decimal.Zero;
- }).ToList<Parcela>();
- if (list3 != null && list3.Count > 0)
- {
- list3.ForEach((Parcela dParcela) => {
- dParcela.set_Documento(this.parcela.get_Documento());
- dParcela.set_ValorComissao(decimal.Zero);
- dParcela.set_ValorComDesconto(decimal.Zero);
- DateTime? nullable = null;
- dParcela.set_DataRecebimento(nullable);
- nullable = null;
- dParcela.set_DataCredito(nullable);
- dParcela.set_ValorRealizado(decimal.Zero);
- });
- list3 = await parcelaServico1.UpdateRange(list3);
- if (parcelaServico1.Sucesso)
- {
- parcela2 = list3.FirstOrDefault<Parcela>((Parcela x) => x.get_Id() == this.parcela.get_Id());
- }
- else
- {
- await Funcoes.MostrarErro(191);
- parcela1 = parcela2;
- variable = null;
- parcelaServico1 = null;
- parcelaServico = null;
- vendedorServico = null;
- return parcela1;
- }
- }
- list2 = null;
- list3 = null;
- }
- else
- {
- await Funcoes.MostrarErro(191);
- parcela1 = parcela2;
- variable = null;
- parcelaServico1 = null;
- parcelaServico = null;
- vendedorServico = null;
- return parcela1;
- }
- }
- ApoliceServico apoliceServico = new ApoliceServico();
- parcelaServico = new ParcelaServico();
- vendedorServico = new VendedorServico();
- if (parcela2 != null)
- {
- Documento documento = await apoliceServico.BuscarApoliceAsync(parcela2.get_Documento().get_Id(), false, false);
- Documento documento1 = documento;
- ObservableCollection<Parcela> observableCollection = await parcelaServico.BuscarParcelasAsync(documento.get_Id());
- documento1.set_Parcelas(observableCollection);
- documento1 = null;
- List<VendedorParcela> vendedorParcelas4 = await vendedorServico.BuscaRepasse(documento.get_Id());
- foreach (Parcela parcela4 in documento.get_Parcelas())
- {
- foreach (VendedorParcela vendedorParcela5 in vendedorParcelas4)
- {
- if (vendedorParcela5.get_Parcela().get_Id() != parcela4.get_Id())
- {
- continue;
- }
- if (parcela4.get_Vendedores() == null)
- {
- parcela4.set_Vendedores(new ObservableCollection<VendedorParcela>());
- }
- parcela4.get_Vendedores().Add(vendedorParcela5);
- }
- }
- IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
- RegistroLog registroLog = new RegistroLog();
- registroLog.set_Acao(2);
- registroLog.set_Usuario(Recursos.Usuario);
- registroLog.set_DataHora(Funcoes.GetNetworkTime());
- Documento documento2 = documento;
- JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
- jsonSerializerSetting.set_ReferenceLoopHandling(1);
- registroLog.set_Descricao(JsonConvert.SerializeObject(documento2, jsonSerializerSetting));
- registroLog.set_EntidadeId(documento.get_Id());
- registroLog.set_Tela(2);
- registroLog.set_NomeMaquina(Environment.MachineName);
- registroLog.set_UsuarioMaquina(Environment.UserName);
- IPAddress[] addressList = hostEntry.AddressList;
- IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
- if (pAddress != null)
- {
- str = pAddress.ToString();
- }
- else
- {
- str = null;
- }
- registroLog.set_Ip(str);
- RegistroLog registroLog1 = registroLog;
- await Task.Run(() => {
- using (UnitOfWork commited = Instancia.Commited)
- {
- commited.get_RegistroLogRepository().SaveOrUpdate(registroLog1);
- commited.Commit();
- }
- });
- documento = null;
- }
- parcela1 = parcela2;
- variable = null;
- parcelaServico1 = null;
- parcelaServico = null;
- vendedorServico = null;
- return parcela1;
- }
-
- public static async Task<bool> ExcluirPagamento(VendedorParcela pagamento)
- {
- pagamento.set_DataPagamento(null);
- ParcelaServico parcelaServico = new ParcelaServico()
- {
- Sucesso = true
- };
- await parcelaServico.Save(pagamento);
- bool sucesso = parcelaServico.Sucesso;
- parcelaServico = null;
- return sucesso;
- }
-
- public static string ExportarHtml(TipoRelatorio tipo, string dados, string porcentagem = "60", string orientation = "landscape", bool search = false, string grafico = "")
- {
- string str = string.Format("DATA DE EMISSÃO DO RELATÓRIO EM {0:G}", Funcoes.GetNetworkTime());
- if (tipo.get_Inicio() != DateTime.MinValue && tipo.get_Nome() != "RELATÓRIO DE CLIENTE")
- {
- str = string.Format("PERÍODO DE {0:d} ATÉ {1:d}. DATA DE EMISSÃO DO RELATÓRIO EM {2:G}", tipo.get_Inicio(), tipo.get_Fim(), Funcoes.GetNetworkTime());
- }
- string str1 = (!search ? "<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css' integrity='sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC' crossorigin='anonymous'>" : "<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' integrity='sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm' crossorigin='anonymous'>");
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append(Resources.RelatorioTemplate.Replace("{style}", str1).Replace("Orientation", orientation).Replace("{NomeRelatorio}", string.Concat(Recursos.Empresa.get_NomeSocial(), " - ", tipo.get_Nome())).Replace("{EmissaoRelatorio}", str).Replace("{Grafico}", grafico).Replace("{DadosRelatorio}", dados));
- return stringBuilder.ToString();
- }
-
- public static string ExportarMultipleHtml(TipoRelatorio tipo, string dados, string porcentagem = "60", string orientation = "landscape", bool search = false, string grafico = "")
- {
- string str = string.Format("DATA DE EMISSÃO DO RELATÓRIO EM {0:G}", Funcoes.GetNetworkTime());
- if (tipo.get_Inicio() != DateTime.MinValue && tipo.get_Nome() != "RELATÓRIO DE CLIENTE")
- {
- str = string.Format("PERÍODO DE {0:d} ATÉ {1:d}. DATA DE EMISSÃO DO RELATÓRIO EM {2:G}", tipo.get_Inicio(), tipo.get_Fim(), Funcoes.GetNetworkTime());
- }
- string str1 = (!search ? "<link rel='stylesheet' href='https://cdn.jsdelivr.net/npm/bootstrap@5.0.2/dist/css/bootstrap.min.css' integrity='sha384-EVSTQN3/azprG1Anm3QDgpJLIm9Nao0Yz1ztcQTwFspd3yD65VohhpuuCOmLASjC' crossorigin='anonymous'>" : "<link rel='stylesheet' href='https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0/css/bootstrap.min.css' integrity='sha384-Gn5384xqQ1aoWXA+058RXPxPg6fy4IWvTNh0E263XmFcJlSAwiGgFAW/dAiS6JXm' crossorigin='anonymous'>");
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append(Resources.RelatorioMultipleTemplate.Replace("{style}", str1).Replace("Orientation", orientation).Replace("{NomeRelatorio}", string.Concat(Recursos.Empresa.get_NomeSocial(), " - ", tipo.get_Nome())).Replace("{EmissaoRelatorio}", str).Replace("{Grafico}", grafico).Replace("{DadosRelatorio}", dados));
- return stringBuilder.ToString();
- }
-
- public static async Task<string> GenerateMultipleTable(List<List<Listagem>> analiticos, List<string> colunasOcultas, bool grafico = false, bool propertyName = false, string footer = "", ConfiguracaoImpressao config = null)
- {
- string str4;
- string str5;
- Action<Listagem> action2 = null;
- if (analiticos == null)
- {
- str4 = "";
- }
- else if (analiticos.Count != 0)
- {
- int tamanhoFonte = 0;
- if (config != null)
- {
- tamanhoFonte = config.get_TamanhoFonte();
- }
- str5 = (tamanhoFonte == 0 ? "" : string.Format("fs-{0}'", tamanhoFonte));
- string str6 = str5;
- str4 = await Task.Run<string>(() => {
- StringBuilder stringBuilder2 = new StringBuilder();
- int num = 0;
- foreach (List<Listagem> analitico in analiticos)
- {
- StringBuilder stringBuilder3 = new StringBuilder();
- StringBuilder stringBuilder4 = new StringBuilder();
- StringBuilder stringBuilder5 = new StringBuilder();
- int num1 = 0;
- stringBuilder4.Append(Resources.HeaderTemplate.Replace("{Align}", "text-start").Replace("{Size}", "").Replace("{FontWeight}", "fw-bold").Replace("{Content}", analitico[0].get_NomeRelatorio()));
- stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", ""));
- List<Listagem> listagems = analitico;
- Action<Listagem> u003cu003e9_1 = action2;
- if (u003cu003e9_1 == null)
- {
- Action<Listagem> action = (Listagem x) => {
- Sinal sinal;
- string str;
- char chr;
- string str1;
- PropertyInfo[] properties = x.GetType().GetProperties();
- Func<PropertyInfo, bool> u003cu003e9_222 = Funcoes.u003cu003ec.u003cu003e9__22_2;
- if (u003cu003e9_222 == null)
- {
- u003cu003e9_222 = (PropertyInfo b) => b.Name == "Bold";
- Funcoes.u003cu003ec.u003cu003e9__22_2 = u003cu003e9_222;
- }
- PropertyInfo propertyInfo = ((IEnumerable<PropertyInfo>)properties).FirstOrDefault<PropertyInfo>(u003cu003e9_222);
- bool flag = (propertyInfo == null ? false : (bool)propertyInfo.GetValue(x));
- Func<PropertyInfo, bool> u003cu003e9_223 = Funcoes.u003cu003ec.u003cu003e9__22_3;
- if (u003cu003e9_223 == null)
- {
- u003cu003e9_223 = (PropertyInfo b) => b.Name == "Sinal";
- Funcoes.u003cu003ec.u003cu003e9__22_3 = u003cu003e9_223;
- }
- PropertyInfo propertyInfo1 = ((IEnumerable<PropertyInfo>)properties).FirstOrDefault<PropertyInfo>(u003cu003e9_223);
- string str2 = (!(propertyInfo1 != null) || propertyInfo1.GetValue(x) == null || !Enum.TryParse<Sinal>(propertyInfo1.GetValue(x).ToString(), true, out sinal) || sinal != 1 ? "color: black;" : "color: red;");
- if (flag)
- {
- string.Concat("<tr style='font-weight: bold; ", str2, "'>");
- }
- else
- {
- string.Concat("<tr style='", str2, "'>");
- }
- StringBuilder stringBuilder = new StringBuilder();
- PropertyInfo[] propertyInfoArray = properties;
- for (int i = 0; i < (int)propertyInfoArray.Length; i++)
- {
- PropertyInfo propertyInfo2 = propertyInfoArray[i];
- if (propertyInfo2.Name != "ValidationEvent")
- {
- object obj = propertyInfo2.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
- if (obj != null)
- {
- string description = ((DescriptionAttribute)obj).Description;
- if ((!propertyName || !colunasOcultas.Contains(propertyInfo2.Name)) && (propertyName || !colunasOcultas.Contains(description)))
- {
- object obj1 = propertyInfo2.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault<object>();
- string description1 = "";
- if (obj1 != null)
- {
- description1 = ((TipoAttribute)obj1).get_Description();
- }
- string str3 = "text-start";
- if (description1 != null)
- {
- switch (description1.Length)
- {
- case 4:
- {
- chr = description1[0];
- if (chr == 'D')
- {
- if (description1 == "DATA")
- {
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) == null || (DateTime)propertyInfo2.GetValue(x) == DateTime.MinValue ? "" : string.Format("{0:d}", (DateTime)propertyInfo2.GetValue(x)));
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- else if (chr != 'E')
- {
- goto Label1;
- }
- else if (description1 == "ENUM")
- {
- str = (propertyInfo2.GetValue(x) != null ? Gestor.Common.Validation.ValidationHelper.GetDescription((Enum)propertyInfo2.GetValue(x)) ?? "" : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- case 5:
- {
- chr = description1[0];
- if (chr == 'D')
- {
- if (description1 == "DATA?")
- {
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:d}", (DateTime?)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- else if (chr != 'V')
- {
- goto Label1;
- }
- else if (description1 == "VALOR")
- {
- str3 = "text-end";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- case 6:
- {
- if (description1 != "VALOR?")
- {
- goto Label1;
- }
- str3 = "text-end";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal?)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- case 9:
- {
- if (description1 == "DATA/TIME")
- {
- break;
- }
- goto Label1;
- }
- case 10:
- {
- chr = description1[0];
- if (chr == 'D')
- {
- if (description1 == "DATA/TIME?")
- {
- break;
- }
- goto Label1;
- }
- else if (chr == 'P')
- {
- if (description1 == "PERCENTUAL")
- {
- str3 = "text-end";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:p2}", (decimal)propertyInfo2.GetValue(x) * new decimal(1, 0, 0, false, 2)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- else if (chr != 'Q')
- {
- goto Label1;
- }
- else if (description1 == "QUANTIDADE")
- {
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- default:
- {
- goto Label1;
- }
- }
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:G}", (DateTime?)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- Label1:
- str1 = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : "");
- str = str1;
- Label0:
- StringBuilder stringBuilder1 = stringBuilder;
- stringBuilder1.Append(Resources.ColumnTemplate.Replace("{Align}", str3).Replace("{Size}", str6).Replace("{FontWeight}", (flag ? "fw-bold" : "")).Replace("{Content}", str));
- }
- }
- }
- }
- };
- Action<Listagem> action1 = action;
- action2 = action;
- u003cu003e9_1 = action1;
- }
- listagems.ForEach(u003cu003e9_1);
- StringBuilder stringBuilder6 = new StringBuilder();
- if (grafico)
- {
- stringBuilder5.Append(string.Format("<div id=\"donutchart{0}\" style=\"width: 70%; height: 125px;\"></div>", num));
- }
- num++;
- stringBuilder6.Append(Resources.TableMultipleTemplate.Replace("{Head}", stringBuilder3.ToString()).Replace("{Body}", stringBuilder5.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer) ? Resources.FooterTemplate.Replace("{Content}", string.Format("<tr><td colspan='{0}' style='color:gray'>{1}</td></tr>", num1, footer)) : "")));
- stringBuilder2.Append(stringBuilder6.ToString());
- }
- return stringBuilder2.ToString();
- });
- }
- else
- {
- str4 = "";
- }
- return str4;
- }
-
- public static async Task<string> GenerateTable<T>(List<T> analitico, List<string> colunasOcultas, bool grafico = false, bool propertyName = false, string footer = "", ConfiguracaoImpressao config = null)
- {
- string str7;
- string str8;
- if (analitico == null)
- {
- str7 = "";
- }
- else if (analitico.Count != 0)
- {
- int tamanhoFonte = 0;
- if (config != null)
- {
- tamanhoFonte = config.get_TamanhoFonte();
- }
- str8 = (tamanhoFonte == 0 ? "" : string.Format("fs-{0}'", tamanhoFonte));
- string str9 = str8;
- str7 = await Task.Run<string>(() => {
- StringBuilder stringBuilder2 = new StringBuilder();
- StringBuilder stringBuilder3 = new StringBuilder();
- StringBuilder stringBuilder4 = new StringBuilder();
- Type type = analitico[0].GetType();
- PropertyInfo[] properties = type.GetProperties();
- int num = 0;
- PropertyInfo[] propertyInfoArray3 = properties;
- for (int i1 = 0; i1 < (int)propertyInfoArray3.Length; i1++)
- {
- PropertyInfo propertyInfo3 = propertyInfoArray3[i1];
- if (propertyInfo3.Name != "ValidationEvent")
- {
- object obj2 = propertyInfo3.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
- if (obj2 != null)
- {
- string str4 = ((DescriptionAttribute)obj2).Description;
- if ((!propertyName || !colunasOcultas.Contains(propertyInfo3.Name)) && (propertyName || !colunasOcultas.Contains(str4)))
- {
- object obj3 = propertyInfo3.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault<object>();
- string str5 = "";
- if (obj3 != null)
- {
- str5 = ((TipoAttribute)obj3).get_Description();
- }
- string str6 = "text-start";
- if (str5 == "PERCENTUAL" || str5 == "VALOR")
- {
- str6 = "text-center";
- }
- else if (str5 == "QUANTIDADE" || str5 == "DATA")
- {
- str6 = "text-end";
- }
- stringBuilder3.Append(Resources.HeaderTemplate.Replace("{Align}", str6).Replace("{Size}", str9).Replace("{FontWeight}", "fw-bold").Replace("{Content}", str4));
- num++;
- }
- }
- }
- }
- stringBuilder2.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder3.ToString()).Replace("{Color}", ""));
- analitico.ForEach((T x) => {
- Sinal sinal;
- string str;
- char chr;
- string str1;
- type = x.GetType();
- properties = type.GetProperties();
- PropertyInfo[] propertyInfoArray = properties;
- Func<PropertyInfo, bool> u003cu003e9_212 = Funcoes.u003cu003ec__21<T>.u003cu003e9__21_2;
- if (u003cu003e9_212 == null)
- {
- u003cu003e9_212 = (PropertyInfo b) => b.Name == "Bold";
- Funcoes.u003cu003ec__21<T>.u003cu003e9__21_2 = u003cu003e9_212;
- }
- PropertyInfo propertyInfo = ((IEnumerable<PropertyInfo>)propertyInfoArray).FirstOrDefault<PropertyInfo>(u003cu003e9_212);
- bool flag = (propertyInfo == null ? false : (bool)propertyInfo.GetValue(x));
- PropertyInfo[] propertyInfoArray1 = properties;
- Func<PropertyInfo, bool> u003cu003e9_213 = Funcoes.u003cu003ec__21<T>.u003cu003e9__21_3;
- if (u003cu003e9_213 == null)
- {
- u003cu003e9_213 = (PropertyInfo b) => b.Name == "Sinal";
- Funcoes.u003cu003ec__21<T>.u003cu003e9__21_3 = u003cu003e9_213;
- }
- PropertyInfo propertyInfo1 = ((IEnumerable<PropertyInfo>)propertyInfoArray1).FirstOrDefault<PropertyInfo>(u003cu003e9_213);
- string str2 = (!(propertyInfo1 != null) || propertyInfo1.GetValue(x) == null || !Enum.TryParse<Sinal>(propertyInfo1.GetValue(x).ToString(), true, out sinal) || sinal != 1 ? "color: black;" : "color: red;");
- if (flag)
- {
- string.Concat("<tr style='font-weight: bold; ", str2, "'>");
- }
- else
- {
- string.Concat("<tr style='", str2, "'>");
- }
- StringBuilder stringBuilder = new StringBuilder();
- PropertyInfo[] propertyInfoArray2 = properties;
- for (int i = 0; i < (int)propertyInfoArray2.Length; i++)
- {
- PropertyInfo propertyInfo2 = propertyInfoArray2[i];
- if (propertyInfo2.Name != "ValidationEvent")
- {
- object obj = propertyInfo2.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
- if (obj != null)
- {
- string description = ((DescriptionAttribute)obj).Description;
- if ((!propertyName || !colunasOcultas.Contains(propertyInfo2.Name)) && (propertyName || !colunasOcultas.Contains(description)))
- {
- object obj1 = propertyInfo2.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault<object>();
- string description1 = "";
- if (obj1 != null)
- {
- description1 = ((TipoAttribute)obj1).get_Description();
- }
- string str3 = "text-start";
- if (description1 != null)
- {
- switch (description1.Length)
- {
- case 4:
- {
- chr = description1[0];
- if (chr == 'D')
- {
- if (description1 == "DATA")
- {
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) == null || (DateTime)propertyInfo2.GetValue(x) == DateTime.MinValue ? "" : string.Format("{0:d}", (DateTime)propertyInfo2.GetValue(x)));
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- else if (chr != 'E')
- {
- goto Label1;
- }
- else if (description1 == "ENUM")
- {
- str = (propertyInfo2.GetValue(x) != null ? Gestor.Common.Validation.ValidationHelper.GetDescription((Enum)propertyInfo2.GetValue(x)) ?? "" : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- case 5:
- {
- chr = description1[0];
- if (chr == 'D')
- {
- if (description1 == "DATA?")
- {
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:d}", (DateTime?)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- else if (chr != 'V')
- {
- goto Label1;
- }
- else if (description1 == "VALOR")
- {
- str3 = "text-end";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- case 6:
- {
- if (description1 != "VALOR?")
- {
- goto Label1;
- }
- str3 = "text-end";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:c2}", (decimal?)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- case 9:
- {
- if (description1 == "DATA/TIME")
- {
- break;
- }
- goto Label1;
- }
- case 10:
- {
- chr = description1[0];
- if (chr == 'D')
- {
- if (description1 == "DATA/TIME?")
- {
- break;
- }
- goto Label1;
- }
- else if (chr == 'P')
- {
- if (description1 == "PERCENTUAL")
- {
- str3 = "text-end";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:p2}", (decimal)propertyInfo2.GetValue(x) * new decimal(1, 0, 0, false, 2)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- else if (chr != 'Q')
- {
- goto Label1;
- }
- else if (description1 == "QUANTIDADE")
- {
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- case 13:
- {
- if (description1 == "VALORDECIMAL2")
- {
- str3 = "text-end";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:n2}", (decimal)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- else
- {
- goto Label1;
- }
- }
- default:
- {
- goto Label1;
- }
- }
- str3 = "text-center";
- str = (propertyInfo2.GetValue(x) != null ? string.Format("{0:G}", (DateTime?)propertyInfo2.GetValue(x)) : "");
- goto Label0;
- }
- Label1:
- str1 = (propertyInfo2.GetValue(x) != null ? string.Format("{0}", propertyInfo2.GetValue(x)) : "");
- str = str1;
- Label0:
- StringBuilder stringBuilder1 = stringBuilder;
- stringBuilder1.Append(Resources.ColumnTemplate.Replace("{Align}", str3).Replace("{Size}", str9).Replace("{FontWeight}", (flag ? "fw-bold" : "")).Replace("{Content}", str));
- }
- }
- }
- }
- stringBuilder4.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder.ToString()).Replace("{Color}", string.Concat("style='", str2, "'")));
- });
- StringBuilder stringBuilder5 = new StringBuilder();
- if (grafico)
- {
- stringBuilder4.Append("<td>");
- stringBuilder4.Append("<div id=\"donutchart\" style=\"width: 500px; height: 300px;\"></div>");
- stringBuilder4.Append("<h6 style='text-align:center'>*VALORES NEGATIVOS NÃO SÃO REPRESENTADOS NO GRÁFICO DE PIZZA.</h6>");
- stringBuilder4.Append("</td>");
- }
- stringBuilder5.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder2.ToString()).Replace("{Body}", stringBuilder4.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer) ? Resources.FooterTemplate.Replace("{Content}", string.Format("<tr><td colspan='{0}' style='color:gray'>{1}</td></tr>", num, footer)) : "")));
- return stringBuilder5.ToString();
- });
- }
- else
- {
- str7 = "";
- }
- return str7;
- }
-
- public static async Task<string> GenerateTable<T>(List<T> analitico, Relatorio relatorio, bool grafico = false, bool verificarColunas = true, string footer = "", ConfiguracaoImpressao config = null)
- {
- string str6;
- List<ParametrosRelatorio> restricoesColunas;
- string str7;
- List<ParametrosRelatorio> campos;
- int tamanhoFonte = 0;
- if (config != null)
- {
- campos = config.get_Campos();
- tamanhoFonte = config.get_TamanhoFonte();
- }
- else
- {
- if (!verificarColunas)
- {
- restricoesColunas = null;
- }
- else
- {
- restricoesColunas = await (new ConfuguracoesServico()).BuscarParametros(relatorio);
- }
- campos = restricoesColunas;
- if (campos == null || campos.Count == 0)
- {
- PropertyInfo[] propertyInfoArray2 = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public);
- campos = propertyInfoArray2.Select<PropertyInfo, ParametrosRelatorio>((PropertyInfo x) => {
- ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio();
- parametrosRelatorio.set_Campo(x.Name);
- parametrosRelatorio.set_Header(x.GetDescriptionAttribute());
- parametrosRelatorio.set_Tipo(x.GetTypeAttribute());
- parametrosRelatorio.set_Relatorio(relatorio);
- parametrosRelatorio.set_Width(0);
- parametrosRelatorio.set_Ordem(0);
- return parametrosRelatorio;
- }).ToList<ParametrosRelatorio>();
- }
- }
- str7 = (tamanhoFonte == 0 ? "" : string.Format("fs-{0}'", tamanhoFonte));
- string str8 = str7;
- restricoesColunas = await Funcoes.GetRestricoesColunas(campos);
- campos = restricoesColunas;
- if (analitico == null)
- {
- str6 = "";
- }
- else if (analitico.Count != 0)
- {
- str6 = await Task.Run<string>(() => {
- StringBuilder stringBuilder3 = new StringBuilder();
- StringBuilder stringBuilder4 = new StringBuilder();
- StringBuilder stringBuilder5 = new StringBuilder();
- Type type = analitico[0].GetType();
- PropertyInfo[] properties = type.GetProperties();
- int num = 0;
- List<ParametrosRelatorio> parametrosRelatorios1 = campos;
- Func<ParametrosRelatorio, int> u003cu003e9_242 = Funcoes.u003cu003ec__24<T>.u003cu003e9__24_2;
- if (u003cu003e9_242 == null)
- {
- u003cu003e9_242 = (ParametrosRelatorio x) => x.get_Ordem();
- Funcoes.u003cu003ec__24<T>.u003cu003e9__24_2 = u003cu003e9_242;
- }
- IOrderedEnumerable<ParametrosRelatorio> parametrosRelatorios2 = parametrosRelatorios1.OrderBy<ParametrosRelatorio, int>(u003cu003e9_242);
- Func<ParametrosRelatorio, string> u003cu003e9_243 = Funcoes.u003cu003ec__24<T>.u003cu003e9__24_3;
- if (u003cu003e9_243 == null)
- {
- u003cu003e9_243 = (ParametrosRelatorio x) => x.get_Header();
- Funcoes.u003cu003ec__24<T>.u003cu003e9__24_3 = u003cu003e9_243;
- }
- ExtensionMethods.ForEach<ParametrosRelatorio>(parametrosRelatorios2.ThenBy<ParametrosRelatorio, string>(u003cu003e9_243), (ParametrosRelatorio x) => {
- if (x.get_Tipo() == "INVALID")
- {
- return;
- }
- PropertyInfo propertyInfo = properties.FirstOrDefault<PropertyInfo>((PropertyInfo p) => p.Name == x.get_Campo());
- if (propertyInfo == null)
- {
- return;
- }
- string descriptionAttribute = propertyInfo.GetDescriptionAttribute();
- string str = "text-start";
- string tipo = x.get_Tipo();
- if (tipo == "PERCENTUAL" || tipo == "VALOR")
- {
- str = "text-center";
- }
- else if (tipo == "QUANTIDADE" || tipo == "DATA")
- {
- str = "text-end";
- }
- stringBuilder4.Append(Resources.HeaderTemplate.Replace("{Align}", str).Replace("{Size}", str8).Replace("{FontWeight}", "fw-bold").Replace("{Content}", descriptionAttribute));
- num++;
- });
- stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", ""));
- analitico.ForEach((T a) => {
- Sinal sinal;
- StringBuilder stringBuilder2 = new StringBuilder();
- type = a.GetType();
- properties = type.GetProperties();
- PropertyInfo[] propertyInfoArray = properties;
- Func<PropertyInfo, bool> u003cu003e9_247 = Funcoes.u003cu003ec__24<T>.u003cu003e9__24_7;
- if (u003cu003e9_247 == null)
- {
- u003cu003e9_247 = (PropertyInfo b) => b.Name == "Bold";
- Funcoes.u003cu003ec__24<T>.u003cu003e9__24_7 = u003cu003e9_247;
- }
- PropertyInfo propertyInfo1 = ((IEnumerable<PropertyInfo>)propertyInfoArray).FirstOrDefault<PropertyInfo>(u003cu003e9_247);
- bool flag = (propertyInfo1 == null ? false : (bool)propertyInfo1.GetValue(a));
- PropertyInfo[] propertyInfoArray1 = properties;
- Func<PropertyInfo, bool> u003cu003e9_248 = Funcoes.u003cu003ec__24<T>.u003cu003e9__24_8;
- if (u003cu003e9_248 == null)
- {
- u003cu003e9_248 = (PropertyInfo b) => b.Name == "Sinal";
- Funcoes.u003cu003ec__24<T>.u003cu003e9__24_8 = u003cu003e9_248;
- }
- PropertyInfo propertyInfo2 = ((IEnumerable<PropertyInfo>)propertyInfoArray1).FirstOrDefault<PropertyInfo>(u003cu003e9_248);
- string str5 = (!(propertyInfo2 != null) || propertyInfo2.GetValue(a) == null || !Enum.TryParse<Sinal>(propertyInfo2.GetValue(a).ToString(), true, out sinal) || sinal != 1 ? "color: black;" : "color: red;");
- if (flag)
- {
- string.Concat("<tr class='fw-bold' style='", str5, "'>");
- }
- else
- {
- string.Concat("<tr style='", str5, "'>");
- }
- List<ParametrosRelatorio> cSu0024u003cu003e8_locals1 = campos;
- Func<ParametrosRelatorio, int> u003cu003e9_249 = Funcoes.u003cu003ec__24<T>.u003cu003e9__24_9;
- if (u003cu003e9_249 == null)
- {
- u003cu003e9_249 = (ParametrosRelatorio x) => x.get_Ordem();
- Funcoes.u003cu003ec__24<T>.u003cu003e9__24_9 = u003cu003e9_249;
- }
- IOrderedEnumerable<ParametrosRelatorio> parametrosRelatorios = cSu0024u003cu003e8_locals1.OrderBy<ParametrosRelatorio, int>(u003cu003e9_249);
- Func<ParametrosRelatorio, string> u003cu003e9_2410 = Funcoes.u003cu003ec__24<T>.u003cu003e9__24_10;
- if (u003cu003e9_2410 == null)
- {
- u003cu003e9_2410 = (ParametrosRelatorio x) => x.get_Header();
- Funcoes.u003cu003ec__24<T>.u003cu003e9__24_10 = u003cu003e9_2410;
- }
- ExtensionMethods.ForEach<ParametrosRelatorio>(parametrosRelatorios.ThenBy<ParametrosRelatorio, string>(u003cu003e9_2410), (ParametrosRelatorio x) => {
- string str;
- char chr;
- string str1;
- string str2;
- string str3;
- StringBuilder stringBuilder;
- StringBuilder stringBuilder1;
- if (x.get_Tipo() == "INVALID")
- {
- return;
- }
- PropertyInfo propertyInfo = properties.FirstOrDefault<PropertyInfo>((PropertyInfo p) => p.Name == x.get_Campo());
- if (propertyInfo == null)
- {
- return;
- }
- string str4 = "text-start";
- string tipo = x.get_Tipo();
- if (tipo != null)
- {
- switch (tipo.Length)
- {
- case 4:
- {
- chr = tipo[0];
- if (chr == 'D')
- {
- if (tipo == "DATA")
- {
- str4 = "text-center";
- str = (propertyInfo.GetValue(a) == null || (DateTime)propertyInfo.GetValue(a) == DateTime.MinValue ? "" : string.Format("{0:d}", (DateTime)propertyInfo.GetValue(a)));
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- else if (chr != 'E')
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else if (tipo == "ENUM")
- {
- str = (propertyInfo.GetValue(a) == null || Convert.ToInt32(propertyInfo.GetValue(a)) == 0 ? "" : Gestor.Common.Validation.ValidationHelper.GetDescription((Enum)propertyInfo.GetValue(a)) ?? "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- case 5:
- {
- chr = tipo[0];
- if (chr == 'D')
- {
- if (tipo == "DATA?")
- {
- str4 = "text-center";
- str = (propertyInfo.GetValue(a) != null ? string.Format("{0:d}", (DateTime?)propertyInfo.GetValue(a)) : "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- else if (chr != 'V')
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else if (tipo == "VALOR")
- {
- str4 = "text-end";
- str = (propertyInfo.GetValue(a) != null ? string.Format("{0:c2}", (decimal)propertyInfo.GetValue(a)) : "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- case 6:
- {
- if (tipo != "VALOR?")
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- str4 = "text-end";
- str = (propertyInfo.GetValue(a) != null ? string.Format("{0:c2}", (decimal?)propertyInfo.GetValue(a)) : "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- case 7:
- case 8:
- case 11:
- case 12:
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- case 9:
- {
- if (tipo == "DATA/TIME")
- {
- break;
- }
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- case 10:
- {
- chr = tipo[0];
- if (chr == 'D')
- {
- if (tipo == "DATA/TIME?")
- {
- break;
- }
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else if (chr == 'P')
- {
- if (tipo == "PERCENTUAL")
- {
- str4 = "text-end";
- str = (propertyInfo.GetValue(a) != null ? string.Format("{0:p2}", (decimal)propertyInfo.GetValue(a) * new decimal(1, 0, 0, false, 2)) : "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- else if (chr != 'Q')
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else if (tipo == "QUANTIDADE")
- {
- str4 = "text-center";
- str = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- case 13:
- {
- if (tipo == "VALORDECIMAL2")
- {
- str4 = "text-end";
- str = (propertyInfo.GetValue(a) != null ? string.Format("{0:n2}", (decimal)propertyInfo.GetValue(a)) : "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- else
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- default:
- {
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- }
- str4 = "text-center";
- str = (propertyInfo.GetValue(a) != null ? string.Format("{0:G}", (DateTime?)propertyInfo.GetValue(a)) : "");
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- return;
- }
- str1 = (propertyInfo.GetValue(a) != null ? string.Format("{0}", propertyInfo.GetValue(a)) : "");
- str = str1;
- stringBuilder = stringBuilder2;
- str2 = Resources.ColumnTemplate.Replace("{Align}", str4).Replace("{Size}", str8);
- str3 = (flag ? "fw-bold" : "");
- stringBuilder1 = stringBuilder.Append(str2.Replace("{FontWeight}", str3).Replace("{Content}", str));
- });
- stringBuilder5.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder2.ToString()).Replace("{Color}", string.Concat("style='", str5, "'")));
- });
- StringBuilder stringBuilder6 = new StringBuilder();
- stringBuilder6.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder3.ToString()).Replace("{Body}", stringBuilder5.ToString()).Replace("{Footer}", (!string.IsNullOrEmpty(footer) ? Resources.FooterTemplate.Replace("{Content}", string.Format("<tr><td colspan='{0}' style='color:gray'>{1}</td></tr>", num, footer)) : "")));
- return stringBuilder6.ToString();
- });
- }
- else
- {
- str6 = "";
- }
- return str6;
- }
-
- public static async Task<string> GenerateTableSintetic(List<SinteticModel> sintetic, int fontSize = 0)
- {
- string str;
- string str1;
- if (sintetic == null || sintetic.Count == 0)
- {
- str = "";
- }
- else
- {
- str1 = (fontSize == 0 ? "" : string.Format("fs-{0}'", fontSize));
- string str2 = str1;
- str = await Task.Run<string>(() => {
- StringBuilder stringBuilder = new StringBuilder();
- StringBuilder stringBuilder1 = new StringBuilder();
- StringBuilder stringBuilder2 = new StringBuilder();
- StringBuilder stringBuilder3 = new StringBuilder();
- StringBuilder stringBuilder4 = new StringBuilder();
- sintetic.ForEach((SinteticModel x) => {
- stringBuilder2.Append(Resources.HeaderTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", "fw-bold").Replace("{Content}", x.get_Hint()));
- stringBuilder4.Append(Resources.ColumnTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", "").Replace("{Content}", (x.get_Value() == null ? "" : x.get_Value().ToString())));
- });
- stringBuilder1.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder2.ToString()).Replace("{Color}", ""));
- stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", ""));
- stringBuilder.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder1.ToString()).Replace("{Body}", stringBuilder3.ToString()).Replace("{Footer}", ""));
- return stringBuilder.ToString();
- });
- }
- return str;
- }
-
- public static async Task<string> GenerateTableSintetic(List<SinteticModelList> sintetic, int fontSize = 0)
- {
- string str;
- string str1;
- if (sintetic == null || sintetic.Count == 0)
- {
- str = "";
- }
- else
- {
- str1 = (fontSize == 0 ? "" : string.Format("fs-{0}'", fontSize));
- string str2 = str1;
- str = await Task.Run<string>(() => {
- StringBuilder stringBuilder = new StringBuilder();
- StringBuilder stringBuilder1 = new StringBuilder();
- StringBuilder stringBuilder2 = new StringBuilder();
- StringBuilder stringBuilder3 = new StringBuilder();
- sintetic.ForEach((SinteticModelList x) => stringBuilder2.Append(Resources.HeaderTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", "fw-bold").Replace("{Content}", x.get_Hint())));
- stringBuilder1.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder2.ToString()).Replace("{Color}", ""));
- for (int i = 0; i < sintetic.First<SinteticModelList>().get_Value().Count; i++)
- {
- StringBuilder stringBuilder4 = new StringBuilder();
- bool flag = false;
- foreach (SinteticModelList sinteticModelList in sintetic)
- {
- flag = (flag ? true : (sinteticModelList.get_Value()[0] == null ? false : sinteticModelList.get_Value()[i].ToString() == "TOTAL"));
- stringBuilder4.Append(Resources.ColumnTemplate.Replace("{Align}", "text-center").Replace("{Size}", str2).Replace("{FontWeight}", (flag ? "fw-bold" : "")).Replace("{Content}", string.Format("{0}", sinteticModelList.get_Value()[i])));
- }
- stringBuilder3.Append(Resources.RowTemplate.Replace("{Content}", stringBuilder4.ToString()).Replace("{Color}", ""));
- }
- stringBuilder.Append(Resources.TableTemplate.Replace("{Head}", stringBuilder1.ToString()).Replace("{Body}", stringBuilder3.ToString()).Replace("{Footer}", ""));
- return stringBuilder.ToString();
- });
- }
- return str;
- }
-
- public static string GeraAssistencia(this long id)
- {
- string str;
- try
- {
- DateTime now = DateTime.Now;
- str = HttpUtility.UrlEncode(string.Format("{0}:{1}:A:{2}", now.Ticks, ApplicationHelper.IdFornecedor, id).Base64Encode());
- }
- catch
- {
- return "";
- }
- return str;
- }
-
- public static string GeraCartaoVisita(this long id)
- {
- string str;
- try
- {
- DateTime now = DateTime.Now;
- str = HttpUtility.UrlEncode(string.Format("{0}:{1}:V:{2}", now.Ticks, ApplicationHelper.IdFornecedor, id).Base64Encode());
- }
- catch
- {
- return "";
- }
- return str;
- }
-
- public static async Task<string> GerarCsv<T>(List<T> Conteudo, IEnumerable<string> colunasExportacao)
- {
- PropertyInfo[] array = (
- from in typeof(T).GetProperties()
- where colunasExportacao.Contains<string>(p.Name)
- select ).ToArray<PropertyInfo>();
- StringBuilder stringBuilder = new StringBuilder();
- StringBuilder stringBuilder1 = stringBuilder;
- PropertyInfo[] propertyInfoArray = array;
- stringBuilder1.AppendLine(string.Join(";",
- from in (IEnumerable<PropertyInfo>)propertyInfoArray
- select p.Name));
- foreach (T conteudo in Conteudo)
- {
- IEnumerable<string> strs = array.Select<PropertyInfo, string>((PropertyInfo p) => {
- object str;
- object value = p.GetValue(conteudo, null);
- if (value != null)
- {
- str = value.ToString();
- }
- else
- {
- str = null;
- }
- if (str == null)
- {
- str = string.Empty;
- }
- return str;
- });
- stringBuilder.AppendLine(string.Join(";", strs));
- }
- return stringBuilder.ToString();
- }
-
- public static string GerarGrafico(List<ValorSintetico> sinteticoLista)
- {
- string str = "['NOME', 'VALOR'], ";
- sinteticoLista.ForEach((ValorSintetico x) => {
- if (x.get_Indice() != "TOTAL" && x.get_Valor() > decimal.Zero)
- {
- string[] indice = new string[] { str, "[`", x.get_Indice(), " ", x.get_Porcentagem(), "`, ", null, null };
- indice[6] = x.get_Valor().ToString("F2", CultureInfo.InvariantCulture);
- indice[7] = "], ";
- str = string.Concat(indice);
- }
- });
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append("<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>");
- stringBuilder.Append("<script type=\"text/javascript\">");
- stringBuilder.Append("google.charts.load(\"current\", {packages:[\"corechart\"]});");
- stringBuilder.Append("google.charts.setOnLoadCallback(drawChart);");
- stringBuilder.Append("function drawChart() {");
- stringBuilder.Append(string.Concat("var data = google.visualization.arrayToDataTable([", str, "]);"));
- stringBuilder.Append("var options = { pieHole:0.4, chartArea:{top:100,width:'100%',height:'100%'}, pieSliceText:'none', enableInteractivity:false, legend:{alignment:'center', position:'top', maxLines:6}, pieStartAngle: 50 };");
- stringBuilder.Append("var chart = new google.visualization.PieChart(document.getElementById('donutchart'));");
- stringBuilder.Append("chart.draw(data, options); }");
- stringBuilder.Append("</script>");
- return stringBuilder.ToString();
- }
-
- public static string GerarGraficoUnico(List<List<ValorSintetico>> sinteticosListas)
- {
- StringBuilder stringBuilder = new StringBuilder();
- stringBuilder.Append("<script type=\"text/javascript\" src=\"https://www.gstatic.com/charts/loader.js\"></script>");
- stringBuilder.Append("<script type=\"text/javascript\">");
- stringBuilder.Append("google.charts.load(\"current\", {packages:[\"corechart\"]});");
- stringBuilder.Append("google.charts.setOnLoadCallback(drawAllCharts);");
- stringBuilder.Append("function drawAllCharts() {");
- stringBuilder.Append("var data;");
- stringBuilder.Append("var chart;");
- stringBuilder.Append("var options = { pieHole:0.4, chartArea:{left: 0,width:'100%',height:'100%'}, pieSliceText:'none', enableInteractivity:false, legend:{alignment:'center'}, pieStartAngle: 50 };");
- int num = 0;
- foreach (List<ValorSintetico> sinteticosLista in sinteticosListas)
- {
- string str1 = "['NOME', 'VALOR'], ";
- sinteticosLista.ForEach((ValorSintetico x) => {
- if (x.get_Indice() != "TOTAL")
- {
- string str = string.Format("{0}", x.get_Valor());
- if (x.get_Unidate() != null && x.get_Unidate().Equals("R$"))
- {
- str = string.Format("{0:c2}", x.get_Valor());
- }
- string[] indice = new string[] { str1, "[`", x.get_Indice(), " \n", str, "\n", x.get_Porcentagem(), "`, ", null, null };
- indice[8] = x.get_Valor().ToString("F2", CultureInfo.InvariantCulture);
- indice[9] = "], ";
- str1 = string.Concat(indice);
- }
- });
- stringBuilder.Append(string.Concat("data = google.visualization.arrayToDataTable([", str1, "]);"));
- stringBuilder.Append(string.Format("chart = new google.visualization.PieChart(document.getElementById('donutchart{0}'));", num));
- stringBuilder.Append("chart.draw(data, options);");
- num++;
- }
- stringBuilder.Append("}");
- stringBuilder.Append("</script>");
- return stringBuilder.ToString();
- }
-
- public static async Task<XLWorkbook> GerarXls<T>(XLWorkbook xlWorkbook, string nome, List<T> analitico, Relatorio relatorio, bool verificarColunas = true)
- {
- List<ParametrosRelatorio> restricoesColunas;
- string str = nome;
- str = str.ValidaNomePlanilha("", 0);
- if (!verificarColunas)
- {
- restricoesColunas = null;
- }
- else
- {
- restricoesColunas = await (new ConfuguracoesServico()).BuscarParametros(relatorio);
- }
- List<ParametrosRelatorio> list = restricoesColunas;
- if (list == null || list.Count == 0)
- {
- PropertyInfo[] propertyInfoArray = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public);
- list = propertyInfoArray.Select<PropertyInfo, ParametrosRelatorio>((PropertyInfo x) => {
- ParametrosRelatorio parametrosRelatorio = new ParametrosRelatorio();
- parametrosRelatorio.set_Campo(x.Name);
- parametrosRelatorio.set_Header(x.GetDescriptionAttribute());
- parametrosRelatorio.set_Tipo(x.GetTypeAttribute());
- parametrosRelatorio.set_Relatorio(relatorio);
- parametrosRelatorio.set_Width(0);
- parametrosRelatorio.set_Ordem(0);
- return parametrosRelatorio;
- }).ToList<ParametrosRelatorio>();
- }
- restricoesColunas = await Funcoes.GetRestricoesColunas(list);
- list = restricoesColunas;
- XLWorkbook xLWorkbook1 = await Task.Run<XLWorkbook>(() => {
- XLWorkbook xLWorkbook;
- try
- {
- IXLWorksheet xLWorksheet = xlWorkbook.get_Worksheets().Add(str);
- PropertyInfo[] properties = analitico[0].GetType().GetProperties();
- int num1 = 1;
- List<ParametrosRelatorio> parametrosRelatorios1 = list;
- Func<ParametrosRelatorio, int> u003cu003e9_252 = Funcoes.u003cu003ec__25<T>.u003cu003e9__25_2;
- if (u003cu003e9_252 == null)
- {
- u003cu003e9_252 = (ParametrosRelatorio x) => x.get_Ordem();
- Funcoes.u003cu003ec__25<T>.u003cu003e9__25_2 = u003cu003e9_252;
- }
- IOrderedEnumerable<ParametrosRelatorio> parametrosRelatorios2 = parametrosRelatorios1.OrderBy<ParametrosRelatorio, int>(u003cu003e9_252);
- Func<ParametrosRelatorio, string> u003cu003e9_253 = Funcoes.u003cu003ec__25<T>.u003cu003e9__25_3;
- if (u003cu003e9_253 == null)
- {
- u003cu003e9_253 = (ParametrosRelatorio x) => x.get_Header();
- Funcoes.u003cu003ec__25<T>.u003cu003e9__25_3 = u003cu003e9_253;
- }
- ExtensionMethods.ForEach<ParametrosRelatorio>(parametrosRelatorios2.ThenBy<ParametrosRelatorio, string>(u003cu003e9_253), (ParametrosRelatorio x) => {
- if (x.get_Tipo() == "INVALID")
- {
- return;
- }
- PropertyInfo propertyInfo = properties.FirstOrDefault<PropertyInfo>((PropertyInfo p) => {
- if (p.Name == x.get_Campo() || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("VENDEDOR") && str.Equals("SINTÉTICO POR VENDEDOR") && relatorio == 7 || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("SEGURADORA") && str.Equals("SINTÉTICO POR SEGURADORA") && relatorio == 7)
- {
- return true;
- }
- if (!p.Name.ToUpper().Equals("NOME") || !x.get_Campo().ToUpper().Equals("RAMO") || !str.Equals("SINTÉTICO POR RAMO"))
- {
- return false;
- }
- return relatorio == 7;
- });
- if (propertyInfo == null)
- {
- return;
- }
- xLWorksheet.Cell(1, num1).set_Value(propertyInfo.GetDescriptionAttribute());
- num1++;
- });
- int num2 = 2;
- analitico.ForEach((T a) => {
- num1 = 1;
- int num = num2;
- List<ParametrosRelatorio> cSu0024u003cu003e8_locals1 = list;
- Func<ParametrosRelatorio, int> u003cu003e9_257 = Funcoes.u003cu003ec__25<T>.u003cu003e9__25_7;
- if (u003cu003e9_257 == null)
- {
- u003cu003e9_257 = (ParametrosRelatorio x) => x.get_Ordem();
- Funcoes.u003cu003ec__25<T>.u003cu003e9__25_7 = u003cu003e9_257;
- }
- IOrderedEnumerable<ParametrosRelatorio> parametrosRelatorios = cSu0024u003cu003e8_locals1.OrderBy<ParametrosRelatorio, int>(u003cu003e9_257);
- Func<ParametrosRelatorio, string> u003cu003e9_258 = Funcoes.u003cu003ec__25<T>.u003cu003e9__25_8;
- if (u003cu003e9_258 == null)
- {
- u003cu003e9_258 = (ParametrosRelatorio x) => x.get_Header();
- Funcoes.u003cu003ec__25<T>.u003cu003e9__25_8 = u003cu003e9_258;
- }
- ExtensionMethods.ForEach<ParametrosRelatorio>(parametrosRelatorios.ThenBy<ParametrosRelatorio, string>(u003cu003e9_258), (ParametrosRelatorio x) => {
- int cSu0024u003cu003e8_locals3;
- char chr;
- if (x.get_Tipo() == "INVALID")
- {
- return;
- }
- PropertyInfo propertyInfo = properties.FirstOrDefault<PropertyInfo>((PropertyInfo p) => {
- if (p.Name == x.get_Campo() || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("VENDEDOR") && str.Equals("SINTÉTICO POR VENDEDOR") && relatorio == 7 || p.Name.ToUpper().Equals("NOME") && x.get_Campo().ToUpper().Equals("SEGURADORA") && str.Equals("SINTÉTICO POR SEGURADORA") && relatorio == 7)
- {
- return true;
- }
- if (!p.Name.ToUpper().Equals("NOME") || !x.get_Campo().ToUpper().Equals("RAMO") || !str.Equals("SINTÉTICO POR RAMO"))
- {
- return false;
- }
- return relatorio == 7;
- });
- if (propertyInfo == null)
- {
- return;
- }
- Regex regex = new Regex("\\<[^\\>]*\\>");
- object value = propertyInfo.GetValue(a);
- if (value != null && value.ToString().Contains(">") && value.ToString().Contains("<"))
- {
- value = regex.Replace(value.ToString(), "");
- }
- string tipo = x.get_Tipo();
- if (tipo != null)
- {
- switch (tipo.Length)
- {
- case 4:
- {
- if (tipo == "DATA")
- {
- break;
- }
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- case 5:
- {
- chr = tipo[0];
- if (chr == 'D')
- {
- if (tipo == "DATA?")
- {
- break;
- }
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- else if (chr == 'V')
- {
- if (tipo != "VALOR")
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().SetNumberFormatId(2);
- xLWorksheet.Cell(num, num1).set_Value(((decimal?)value).GetValueOrDefault());
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- else
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- }
- case 6:
- case 7:
- case 8:
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- case 9:
- {
- if (tipo == "DATA/TIME")
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("dd/MM/yyyy HH:mm:ss");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- case 10:
- {
- chr = tipo[0];
- if (chr == 'D')
- {
- if (tipo == "DATA/TIME?")
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("dd/MM/yyyy HH:mm:ss");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- else if (chr == 'P')
- {
- if (tipo == "PERCENTUAL")
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().SetNumberFormatId(10);
- xLWorksheet.Cell(num, num1).set_Value(((decimal?)value).GetValueOrDefault() * new decimal(1, 0, 0, false, 2));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- else
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- }
- else if (chr != 'Q')
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- else if (tipo == "QUANTIDADE")
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().SetNumberFormatId(1);
- xLWorksheet.Cell(num, num1).set_Value(value);
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- else
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- }
- default:
- {
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- }
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("dd/MM/yyyy");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- return;
- }
- xLWorksheet.Cell(num, num1).get_Style().get_NumberFormat().set_Format("@");
- xLWorksheet.Cell(num, num1).set_Value(string.Format("{0}", value));
- cSu0024u003cu003e8_locals3 = num1;
- num1 = cSu0024u003cu003e8_locals3 + 1;
- });
- num2++;
- });
- xLWorksheet.Row(1).get_Style().get_Font().set_Bold(true);
- xLWorksheet.Columns().AdjustToContents();
- xLWorkbook = xlWorkbook;
- }
- catch (Exception exception)
- {
- xLWorkbook = null;
- }
- return xLWorkbook;
- });
- return xLWorkbook1;
- }
-
- public static async Task<XLWorkbook> GerarXls<T>(XLWorkbook xlWorkbook, string nome, List<T> analitico, List<string> colunasOcultas = null)
- {
- XLWorkbook xLWorkbook1 = await Task.Run<XLWorkbook>(() => {
- XLWorkbook xLWorkbook;
- try
- {
- nome = nome.ValidaNomePlanilha("", 0);
- IXLWorksheet xLWorksheet = xlWorkbook.get_Worksheets().Add(nome);
- Type type = analitico[0].GetType();
- PropertyInfo[] properties = type.GetProperties();
- int num = 1;
- PropertyInfo[] propertyInfoArray1 = properties;
- for (int i1 = 0; i1 < (int)propertyInfoArray1.Length; i1++)
- {
- PropertyInfo propertyInfo1 = propertyInfoArray1[i1];
- if (propertyInfo1.Name != "ValidationEvent")
- {
- object obj1 = propertyInfo1.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
- if (obj1 != null)
- {
- string str = ((DescriptionAttribute)obj1).Description;
- if (colunasOcultas == null || !colunasOcultas.Contains(str))
- {
- xLWorksheet.Cell(1, num).set_Value(str);
- num++;
- }
- }
- }
- }
- int num1 = 2;
- analitico.ForEach((T x) => {
- int i;
- num = 1;
- type = x.GetType();
- properties = type.GetProperties();
- PropertyInfo[] propertyInfoArray = properties;
- for (i = 0; i < (int)propertyInfoArray.Length; i++)
- {
- PropertyInfo propertyInfo = propertyInfoArray[i];
- if (propertyInfo.Name != "ValidationEvent")
- {
- object obj = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
- if (obj != null)
- {
- string description = ((DescriptionAttribute)obj).Description;
- if (colunasOcultas == null || !colunasOcultas.Contains(description))
- {
- string name = propertyInfo.Name;
- if (name.Contains("Fipe") || name == "NumeroProposta" || name == "NumeroApolice" || name == "NumeroPedidoEndosso")
- {
- xLWorksheet.Cell(num1, num).get_Style().get_NumberFormat().set_Format("@");
- }
- xLWorksheet.Cell(num1, num).set_Value(propertyInfo.GetValue(x));
- num++;
- }
- }
- }
- }
- i = num1;
- num1 = i + 1;
- });
- xLWorksheet.Row(1).get_Style().get_Font().set_Bold(true);
- xLWorksheet.Columns().AdjustToContents();
- xLWorkbook = xlWorkbook;
- }
- catch (Exception exception)
- {
- xLWorkbook = null;
- }
- return xLWorkbook;
- });
- return xLWorkbook1;
- }
-
- public static async Task<XLWorkbook> GerarXlsSintetico(XLWorkbook xlWorkbook, string nome, List<SinteticModel> sintetic)
- {
- XLWorkbook xLWorkbook1 = await Task.Run<XLWorkbook>(() => {
- XLWorkbook xLWorkbook;
- try
- {
- nome = nome.ValidaNomePlanilha("", 0);
- IXLWorksheet xLWorksheet = xlWorkbook.get_Worksheets().Add(nome);
- int num = 1;
- sintetic.ForEach((SinteticModel x) => {
- xLWorksheet.Cell(1, num).set_Value(x.get_Hint());
- xLWorksheet.Cell(2, num).set_Value(x.get_Value());
- num++;
- });
- xLWorksheet.Row(1).get_Style().get_Font().set_Bold(true);
- xLWorksheet.Columns().AdjustToContents();
- xLWorkbook = xlWorkbook;
- }
- catch (Exception exception)
- {
- xLWorkbook = null;
- }
- return xLWorkbook;
- });
- return xLWorkbook1;
- }
-
- public static string GetBody(this string html)
- {
- HtmlDocument htmlDocument = new HtmlDocument();
- htmlDocument.LoadHtml(html);
- HtmlNode htmlNode = htmlDocument.get_DocumentNode().SelectSingleNode("//body");
- if (htmlNode != null)
- {
- return htmlNode.get_InnerHtml();
- }
- return null;
- }
-
- public static Categoria? GetCategoria(string text)
- {
- Categoria categorium;
- if (text.Contains("caminhao") || text.Contains("caminhão"))
- {
- return new Categoria?(4);
- }
- if (text.Contains("onibus") || text.Contains("ônibus"))
- {
- return new Categoria?(6);
- }
- if (text.Contains("utilitario") || text.Contains("utilitário"))
- {
- return new Categoria?(6);
- }
- if (text.Contains("moto"))
- {
- return new Categoria?(9);
- }
- if (!Enum.TryParse<Categoria>(text, true, out categorium))
- {
- return null;
- }
- return new Categoria?((Categoria)Enum.Parse(typeof(Categoria), text, true));
- }
-
- public static Combustivel? GetCombustivel(string text)
- {
- Combustivel combustivel;
- if (text.Contains("flex"))
- {
- return new Combustivel?(4);
- }
- if (text.Contains("gasolina") && (text.Contains("alcool") || text.Contains("álcool")))
- {
- if (text.Contains("gnv"))
- {
- return new Combustivel?(8);
- }
- if (!text.Contains("eletrico") && !text.Contains("elétrico"))
- {
- return new Combustivel?(4);
- }
- return new Combustivel?(12);
- }
- if (text.Contains("gasolina") && text.Contains("gnv"))
- {
- return new Combustivel?(7);
- }
- if (text.Contains("gasolina") && (text.Contains("eletrico") || text.Contains("elétrico")))
- {
- return new Combustivel?(9);
- }
- if (text.Contains("eletrico") || text.Contains("elétrico"))
- {
- return new Combustivel?(11);
- }
- if (text.Contains("alcool") || text.Contains("álcool"))
- {
- return new Combustivel?(1);
- }
- if (text.Contains("hibrido") || text.Contains("híbrido"))
- {
- return new Combustivel?(10);
- }
- if (text.Contains("outro"))
- {
- return new Combustivel?(6);
- }
- if (!Enum.TryParse<Combustivel>(text, true, out combustivel))
- {
- return null;
- }
- return new Combustivel?((Combustivel)Enum.Parse(typeof(Combustivel), text, true));
- }
-
- public static Cor? GetCor(string text)
- {
- Cor cor;
- if (text.Contains("outro"))
- {
- return new Cor?(16);
- }
- if (!Enum.TryParse<Cor>(text, true, out cor))
- {
- return null;
- }
- return new Cor?((Cor)Enum.Parse(typeof(Cor), text, true));
- }
-
- public static Correcao? GetCorrecao(string text)
- {
- if (text.Contains("mercado"))
- {
- return new Correcao?(0);
- }
- if (text.Contains("determinado"))
- {
- return new Correcao?(1);
- }
- return null;
- }
-
- public static string GetDescriptionAttribute(this PropertyInfo pi)
- {
- object obj = pi.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
- if (obj == null)
- {
- return pi.Name.ToUpper();
- }
- return ((DescriptionAttribute)obj).Description;
- }
-
- public static async Task<Fabricante> GetFabricante(string text)
- {
- Fabricante fabricante;
- List<Fabricante> fabricantes = await (new BaseServico()).BuscarFabricante(text);
- if (fabricantes.Count < 1)
- {
- fabricante = null;
- }
- else
- {
- fabricante = fabricantes.First<Fabricante>();
- }
- return fabricante;
- }
-
- public static Isencao? GetIsencao(string text)
- {
- if (text.Contains("sem"))
- {
- return new Isencao?(0);
- }
- if (text.Contains("ipi") && text.Contains("icms"))
- {
- return new Isencao?(3);
- }
- if (text.Contains("ipi"))
- {
- return new Isencao?(2);
- }
- if (text.Contains("icms"))
- {
- return new Isencao?(1);
- }
- return null;
- }
-
- public static DateTime GetNetworkTime()
- {
- DateTime value;
- try
- {
- if (!Funcoes.StartTime.HasValue)
- {
- byte[] numArray = new byte[48];
- numArray[0] = 27;
- IPEndPoint pEndPoint = new IPEndPoint(((IEnumerable<IPAddress>)Dns.GetHostEntry("time.google.com").AddressList).First<IPAddress>((IPAddress a) => a.AddressFamily == AddressFamily.InterNetwork), 123);
- using (Socket socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp))
- {
- socket.Connect(pEndPoint);
- socket.ReceiveTimeout = 3000;
- socket.Send(numArray);
- socket.Receive(numArray);
- socket.Close();
- }
- ulong num = (ulong)numArray[40] << 24 | (ulong)numArray[41] << 16 | (ulong)numArray[42] << 8 | (ulong)numArray[43];
- ulong num1 = (ulong)numArray[44] << 24 | (ulong)numArray[45] << 16 | (ulong)numArray[46] << 8 | (ulong)numArray[47];
- ulong num2 = num * (long)1000 + num1 * (long)1000 / 4294967296L;
- DateTime dateTime = new DateTime(1900, 1, 1);
- dateTime = dateTime.AddMilliseconds((double)num2);
- Funcoes.StartTime = new DateTime?(dateTime.ToLocalTime());
- Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
- value = Funcoes.StartTime.Value;
- }
- else
- {
- value = Funcoes.StartTime.Value;
- value = value.AddMilliseconds((double)Funcoes.Stopwatch.ElapsedMilliseconds);
- }
- }
- catch (Exception exception)
- {
- Funcoes.StartTime = new DateTime?(DateTime.Now);
- Funcoes.Stopwatch = System.Diagnostics.Stopwatch.StartNew();
- value = Funcoes.StartTime.Value;
- }
- return value;
- }
-
- private static async Task<List<ParametrosRelatorio>> GetRestricoesColunas(List<ParametrosRelatorio> parametros)
- {
- List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios = await (new RestricaoUsuarioServico()).BuscarRestricoesCamposRelatorios(Recursos.Usuario.get_Id());
- List<RestricaoUsuarioCamposRelatorios> list = restricaoUsuarioCamposRelatorios;
- List<RestricaoUsuarioCamposRelatorios> restricaoUsuarioCamposRelatorios1 = list;
- list = (
- from x in restricaoUsuarioCamposRelatorios1
- where x.get_Restricao()
- select x).ToList<RestricaoUsuarioCamposRelatorios>();
- List<ParametrosRelatorio> parametrosRelatorios = (
- from x in parametros
- where (
- from y in list
- where x.get_Relatorio() == y.get_Relatorio()
- select y).All<RestricaoUsuarioCamposRelatorios>((RestricaoUsuarioCamposRelatorios y) => x.get_Header() != y.get_Campo())
- select x).ToList<ParametrosRelatorio>();
- return parametrosRelatorios;
- }
-
- public static TabelaReferencia? GetTabelaReferencia(string text)
- {
- TabelaReferencia tabelaReferencium;
- if (!Enum.TryParse<TabelaReferencia>(text, true, out tabelaReferencium))
- {
- return null;
- }
- return new TabelaReferencia?((TabelaReferencia)Enum.Parse(typeof(TabelaReferencia), text, true));
- }
-
- public static string GetText(string html)
- {
- HtmlDocument htmlDocument = new HtmlDocument();
- htmlDocument.LoadHtml(html);
- return Funcoes.NodeText(htmlDocument.get_DocumentNode());
- }
-
- public static TipoCobertura? GetTipoCobertura(string text)
- {
- TipoCobertura tipoCobertura;
- if (text.Contains("incendio") || text.Contains("incêndio"))
- {
- return new TipoCobertura?(2);
- }
- if (text.Contains("roubo") && text.Contains("furto"))
- {
- return new TipoCobertura?(5);
- }
- if (text.Contains("terceiros"))
- {
- return new TipoCobertura?(3);
- }
- if (text.Contains("compreensiva"))
- {
- return new TipoCobertura?(1);
- }
- if (!Enum.TryParse<TipoCobertura>(text, true, out tipoCobertura))
- {
- return null;
- }
- return new TipoCobertura?((TipoCobertura)Enum.Parse(typeof(TipoCobertura), text, true));
- }
-
- public static string GetTypeAttribute(this PropertyInfo pi)
- {
- object obj = pi.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault<object>();
- if (obj == null)
- {
- return "";
- }
- return ((TipoAttribute)obj).get_Description();
- }
-
- public static UsoVeiculo? GetUsoveiculo(string text)
- {
- UsoVeiculo usoVeiculo;
- UsoVeiculo usoVeiculo1;
- if (Enum.TryParse<UsoVeiculo>(text, true, out usoVeiculo))
- {
- usoVeiculo1 = usoVeiculo;
- }
- else
- {
- usoVeiculo1 = 0;
- }
- return new UsoVeiculo?(usoVeiculo1);
- }
-
- public static T GetValueFromType<T>(this object objeto)
- {
- Type type = typeof(T);
- PropertyInfo[] properties = objeto.GetType().GetProperties(BindingFlags.Instance | BindingFlags.Public);
- for (int i = 0; i < (int)properties.Length; i++)
- {
- PropertyInfo propertyInfo = properties[i];
- if (propertyInfo.PropertyType == type)
- {
- return (T)propertyInfo.GetValue(objeto);
- }
- }
- return default(T);
- }
-
- public static async Task<bool> InativarItens(long id, long ramo, bool delete = true)
- {
- bool sucesso;
- ItemServico itemServico = new ItemServico();
- ObservableCollection<Item> observableCollection = await itemServico.BuscarItens(id);
- ObservableCollection<Item> observableCollection1 = observableCollection;
- IEnumerable<Item> hasValue =
- from x in observableCollection1
- where x.get_Substituicao().HasValue
- select x;
- if (await Funcoes.ReativarItens((
- from x in hasValue
- select x.get_Substituicao().Value).ToList<long>()))
- {
- if (!delete)
- {
- List<Item> list = observableCollection.ToList<Item>();
- list.ForEach((Item x) => x.set_Cancelado(true));
- await itemServico.SaveRange(observableCollection.ToList<Item>());
- }
- else
- {
- await itemServico.DeleteRange(observableCollection.ToList<Item>(), ramo);
- }
- sucesso = itemServico.Sucesso;
- }
- else
- {
- sucesso = false;
- }
- itemServico = null;
- observableCollection = null;
- return sucesso;
- }
-
- public static bool IsEmpty(this string html)
- {
- int count = Regex.Matches(html, "<body>").Count;
- bool flag = true;
- int num = 0;
- for (int i = 0; i < count; i++)
- {
- int num1 = html.IndexOf("<body>", num, StringComparison.Ordinal) + 6;
- if (num1 == 5)
- {
- break;
- }
- int num2 = html.IndexOf("</body>", num, StringComparison.Ordinal);
- num = num2 + 7;
- flag = string.IsNullOrWhiteSpace(html.Substring(num1, num2 - num1));
- if (!flag)
- {
- break;
- }
- }
- return flag;
- }
-
- public static Window IsHosterOpen(string name)
- {
- return System.Windows.Application.Current.Windows.OfType<HosterWindow>().ToList<HosterWindow>().FirstOrDefault<HosterWindow>((HosterWindow x) => {
- string str;
- ContentControl contentControl = Extentions.FindVisualChildren<ContentControl>(x).FirstOrDefault<ContentControl>();
- if (contentControl != null)
- {
- str = contentControl.Tag.ToString();
- }
- else
- {
- str = null;
- }
- return str == name;
- });
- }
-
- public static bool IsWindowOpen<T>(string title)
- where T : Window
- {
- return System.Windows.Application.Current.Windows.OfType<T>().Any<T>((T x) => x.Title == title);
- }
-
- public static List<TupleList> LogList(this List<ValorOriginal> valores, bool restricaoComissao = false)
- {
- List<Tuple<string, string, string>> tuples = new List<Tuple<string, string, string>>();
- valores.ForEach((ValorOriginal x) => {
- if (restricaoComissao && x.get_Campo().ToUpper().Contains("COMISSÃO"))
- {
- return;
- }
- tuples.Add(new Tuple<string, string, string>(x.get_Descricao(), (string.IsNullOrEmpty(x.get_ValorAtual()) ? "NÃO PREENCHIDO" : (x.get_ValorAtual() == "True" ? "SIM" : (x.get_ValorAtual() == "False" ? "NÃO" : x.get_ValorAtual()))), ""));
- });
- List<TupleList> tupleLists = new List<TupleList>();
- TupleList tupleList = new TupleList();
- tupleList.set_Tuples(new ObservableCollection<Tuple<string, string, string>>(tuples));
- tupleLists.Add(tupleList);
- return tupleLists;
- }
-
- public static List<TupleList> LogList(this List<Diferenca> valores, bool restricaoComissao = false)
- {
- List<Tuple<string, string, string>> tuples = new List<Tuple<string, string, string>>();
- valores.ForEach((Diferenca x) => {
- if (restricaoComissao && x.get_Campo().ToUpper().Contains("COMISSÃO"))
- {
- return;
- }
- tuples.Add(new Tuple<string, string, string>(x.get_Descricao(), (string.IsNullOrEmpty(x.get_ValorAtual()) ? "NÃO PREENCHIDO" : (x.get_ValorAtual() == "True" ? "SIM" : (x.get_ValorAtual() == "False" ? "NÃO" : x.get_ValorAtual()))), (string.IsNullOrEmpty(x.get_ValorAnterior()) ? "NÃO PREENCHIDO" : (x.get_ValorAnterior() == "True" ? "SIM" : (x.get_ValorAnterior() == "False" ? "NÃO" : x.get_ValorAnterior())))));
- });
- List<TupleList> tupleLists = new List<TupleList>();
- TupleList tupleList = new TupleList();
- tupleList.set_Tuples(new ObservableCollection<Tuple<string, string, string>>(tuples));
- tupleLists.Add(tupleList);
- return tupleLists;
- }
-
- public static async Task MostrarErro(TipoErro erro)
- {
- await System.Windows.Application.Current.Dispatcher.BeginInvoke(DispatcherPriority.Background, new Action(() => (new ErrorWindow(erro, true)).ShowDialog()));
- }
-
- private static string NodeText(HtmlNode node)
- {
- string innerText = "";
- if (node.get_HasChildNodes())
- {
- foreach (HtmlNode childNode in node.get_ChildNodes())
- {
- innerText = string.Concat(innerText, (childNode.get_NodeType() == 3 ? childNode.get_InnerText() : Funcoes.NodeText(childNode)));
- }
- }
- else if (node.get_NodeType() == 3)
- {
- innerText = node.get_InnerText();
- }
- return innerText;
- }
-
- public static async Task<List<string>> OcultarColunas<T>(Relatorio relatorio)
- {
- List<string> strs;
- List<string> strs1 = new List<string>();
- List<ParametrosRelatorio> restricoesColunas = await (new ConfuguracoesServico()).BuscarParametros(relatorio);
- if (restricoesColunas == null || restricoesColunas.Count == 0)
- {
- strs = strs1;
- }
- else
- {
- restricoesColunas = await Funcoes.GetRestricoesColunas(restricoesColunas);
- PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public);
- for (int i = 0; i < (int)properties.Length; i++)
- {
- PropertyInfo propertyInfo = properties[i];
- object obj = propertyInfo.GetCustomAttributes(typeof(TipoAttribute), true).FirstOrDefault<object>();
- string description = "";
- if (obj != null)
- {
- description = ((TipoAttribute)obj).get_Description();
- }
- string descriptionAttribute = propertyInfo.GetDescriptionAttribute();
- if (description == "INVALID")
- {
- strs1.Add(descriptionAttribute);
- }
- if (!restricoesColunas.Any<ParametrosRelatorio>((ParametrosRelatorio x) => x.get_Campo() == propertyInfo.Name) && !(propertyInfo.Name == "ValidationEvent"))
- {
- strs1.Add(descriptionAttribute);
- }
- }
- strs = strs1;
- }
- strs1 = null;
- return strs;
- }
-
- public static List<string> OcultarColunasDescricao(Type type, string categoria)
- {
- List<string> strs = new List<string>();
- PropertyInfo[] properties = type.GetProperties();
- for (int i = 0; i < (int)properties.Length; i++)
- {
- PropertyInfo propertyInfo = properties[i];
- if (propertyInfo.Name != "ValidationEvent")
- {
- object obj = propertyInfo.GetCustomAttributes(typeof(CategoryAttribute), true).FirstOrDefault<object>();
- if (obj != null && !(((CategoryAttribute)obj).Category == categoria))
- {
- object obj1 = propertyInfo.GetCustomAttributes(typeof(DescriptionAttribute), true).FirstOrDefault<object>();
- if (obj1 != null)
- {
- strs.Add(((DescriptionAttribute)obj1).Description);
- }
- }
- }
- }
- return strs;
- }
-
- public static async Task OrganizarDocumentos(long id)
- {
- ApoliceServico apoliceServico = new ApoliceServico();
- Controle controle = await apoliceServico.BuscarControleAsync(id);
- int num = 1;
- IList<Documento> documentos = controle.get_Documentos();
- IEnumerable<Documento> excluido =
- from x in documentos
- where !x.get_Excluido()
- select x;
- (
- from x in excluido
- orderby x.get_Vigencia1()
- select x).ToList<Documento>().ForEach((Documento x) => {
- if (x.get_Tipo() == 0)
- {
- x.set_Ordem(0);
- return;
- }
- x.set_Ordem(num);
- num++;
- });
- await apoliceServico.UpdateRange(controle);
- apoliceServico = null;
- }
-
- public static ParentescoVinculo? ParentescoInverso(ParentescoVinculo? parentesco)
- {
- if (parentesco.HasValue)
- {
- switch (parentesco.GetValueOrDefault())
- {
- case 0:
- {
- return new ParentescoVinculo?(1);
- }
- case 1:
- {
- return new ParentescoVinculo?(0);
- }
- case 3:
- {
- return new ParentescoVinculo?(4);
- }
- case 4:
- {
- return new ParentescoVinculo?(3);
- }
- case 5:
- {
- return new ParentescoVinculo?(6);
- }
- case 6:
- {
- return new ParentescoVinculo?(5);
- }
- case 7:
- {
- return new ParentescoVinculo?(8);
- }
- case 8:
- {
- return new ParentescoVinculo?(7);
- }
- case 10:
- {
- return new ParentescoVinculo?(11);
- }
- case 11:
- {
- return new ParentescoVinculo?(10);
- }
- case 13:
- {
- return new ParentescoVinculo?(14);
- }
- case 14:
- {
- return new ParentescoVinculo?(13);
- }
- case 19:
- {
- return new ParentescoVinculo?(20);
- }
- case 20:
- {
- return new ParentescoVinculo?(19);
- }
- case 21:
- {
- return new ParentescoVinculo?(22);
- }
- case 22:
- {
- return new ParentescoVinculo?(21);
- }
- }
- }
- return parentesco;
- }
-
- public static TipoPagamento ParseTransactionType(this OfxTransactionType type)
- {
- switch (type)
- {
- case 0:
- {
- return 5;
- }
- case 1:
- case 4:
- {
- return 7;
- }
- case 6:
- case 13:
- {
- return 8;
- }
- case 7:
- case 12:
- {
- return 10;
- }
- case 10:
- {
- return 4;
- }
- case 11:
- {
- return 15;
- }
- case 14:
- {
- return 6;
- }
- default:
- {
- return 12;
- }
- }
- }
-
- public static string PlacaVencimento(string placa, Categoria? categoria)
- {
- if (string.IsNullOrEmpty(placa))
- {
- return "";
- }
- string str = placa.Substring(placa.Length - 1, 1);
- if (str != null && str.Length == 1)
- {
- switch (str[0])
- {
- case '0':
- {
- return "DEZEMBRO";
- }
- case '1':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "SETEMBRO";
- }
- return "ABRIL";
- }
- case '2':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "SETEMBRO";
- }
- return "MAIO";
- }
- case '3':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "OUTUBRO";
- }
- return "JUNHO";
- }
- case '4':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "OUTUBRO";
- }
- return "JULHO";
- }
- case '5':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "OUTUBRO";
- }
- return "AGOSTO";
- }
- case '6':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "NOVEMBRO";
- }
- return "AGOSTO";
- }
- case '7':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "NOVEMBRO";
- }
- return "SETEMBRO";
- }
- case '8':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "NOVEMBRO";
- }
- return "OUTUBRO";
- }
- case '9':
- {
- if (categoria.HasValue && categoria.GetValueOrDefault() == 4)
- {
- return "DEZEMBRO";
- }
- return "NOVEMBRO";
- }
- }
- }
- return "";
- }
-
- public static List<FiltroPersonalizado> PopularFiltroFinanceiro()
- {
- List<FiltroPersonalizado> filtroPersonalizados = new List<FiltroPersonalizado>();
- FiltroPersonalizado filtroPersonalizado = new FiltroPersonalizado();
- filtroPersonalizado.set_Propriedade("Id");
- filtroPersonalizado.set_Nome("ID");
- filtroPersonalizado.set_Tipo(typeof(long));
- filtroPersonalizados.Add(filtroPersonalizado);
- FiltroPersonalizado filtroPersonalizado1 = new FiltroPersonalizado();
- filtroPersonalizado1.set_Propriedade("Controle.Fornecedor.NomeSocial");
- filtroPersonalizado1.set_Nome("FORNECEDOR");
- filtroPersonalizado1.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado1);
- FiltroPersonalizado filtroPersonalizado2 = new FiltroPersonalizado();
- filtroPersonalizado2.set_Propriedade("Controle.Fornecedor.Ativo");
- filtroPersonalizado2.set_Nome("FORNECEDOR ATIVO");
- filtroPersonalizado2.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado2);
- FiltroPersonalizado filtroPersonalizado3 = new FiltroPersonalizado();
- filtroPersonalizado3.set_Propriedade("Historico");
- filtroPersonalizado3.set_Nome("HISTÓRICO");
- filtroPersonalizado3.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado3);
- FiltroPersonalizado filtroPersonalizado4 = new FiltroPersonalizado();
- filtroPersonalizado4.set_Propriedade("Parcela");
- filtroPersonalizado4.set_Nome("PARCELA");
- filtroPersonalizado4.set_Tipo(typeof(int));
- filtroPersonalizados.Add(filtroPersonalizado4);
- FiltroPersonalizado filtroPersonalizado5 = new FiltroPersonalizado();
- filtroPersonalizado5.set_Propriedade("Documento");
- filtroPersonalizado5.set_Nome("DOCUMENTO");
- filtroPersonalizado5.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado5);
- FiltroPersonalizado filtroPersonalizado6 = new FiltroPersonalizado();
- filtroPersonalizado6.set_Propriedade("Competencia");
- filtroPersonalizado6.set_Nome("COMPETÊNCIA");
- filtroPersonalizado6.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado6);
- FiltroPersonalizado filtroPersonalizado7 = new FiltroPersonalizado();
- filtroPersonalizado7.set_Propriedade("Complemento");
- filtroPersonalizado7.set_Nome("COMPLEMENTO");
- filtroPersonalizado7.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado7);
- FiltroPersonalizado filtroPersonalizado8 = new FiltroPersonalizado();
- filtroPersonalizado8.set_Propriedade("Vencimento");
- filtroPersonalizado8.set_Nome("VENCIMENTO");
- filtroPersonalizado8.set_Tipo(typeof(DateTime));
- filtroPersonalizados.Add(filtroPersonalizado8);
- FiltroPersonalizado filtroPersonalizado9 = new FiltroPersonalizado();
- filtroPersonalizado9.set_Propriedade("Valor");
- filtroPersonalizado9.set_Nome("VALOR");
- filtroPersonalizado9.set_Tipo(typeof(decimal));
- filtroPersonalizados.Add(filtroPersonalizado9);
- FiltroPersonalizado filtroPersonalizado10 = new FiltroPersonalizado();
- filtroPersonalizado10.set_Propriedade("Baixa");
- filtroPersonalizado10.set_Nome("DATA BAIXA");
- filtroPersonalizado10.set_Tipo(typeof(DateTime));
- filtroPersonalizados.Add(filtroPersonalizado10);
- FiltroPersonalizado filtroPersonalizado11 = new FiltroPersonalizado();
- filtroPersonalizado11.set_Propriedade("ValorPago");
- filtroPersonalizado11.set_Nome("VALOR PAGO");
- filtroPersonalizado11.set_Tipo(typeof(decimal));
- filtroPersonalizados.Add(filtroPersonalizado11);
- FiltroPersonalizado filtroPersonalizado12 = new FiltroPersonalizado();
- filtroPersonalizado12.set_Propriedade("Pagamento");
- filtroPersonalizado12.set_Nome("PAGAMENTO");
- filtroPersonalizado12.set_Tipo(typeof(DateTime));
- filtroPersonalizados.Add(filtroPersonalizado12);
- FiltroPersonalizado filtroPersonalizado13 = new FiltroPersonalizado();
- filtroPersonalizado13.set_Propriedade("Conta.Descricao");
- filtroPersonalizado13.set_Nome("CONTA");
- filtroPersonalizado13.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado13);
- FiltroPersonalizado filtroPersonalizado14 = new FiltroPersonalizado();
- filtroPersonalizado14.set_Propriedade("Controle.Plano.Descricao");
- filtroPersonalizado14.set_Nome("PLANO DE CONTAS");
- filtroPersonalizado14.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado14);
- FiltroPersonalizado filtroPersonalizado15 = new FiltroPersonalizado();
- filtroPersonalizado15.set_Propriedade("Controle.Centro.Descricao");
- filtroPersonalizado15.set_Nome("CENTRO DE CUSTO");
- filtroPersonalizado15.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado15);
- FiltroPersonalizado filtroPersonalizado16 = new FiltroPersonalizado();
- filtroPersonalizado16.set_Propriedade("Sinal");
- filtroPersonalizado16.set_Nome("SINAL");
- filtroPersonalizado16.set_Tipo(typeof(Enum));
- filtroPersonalizados.Add(filtroPersonalizado16);
- FiltroPersonalizado filtroPersonalizado17 = new FiltroPersonalizado();
- filtroPersonalizado17.set_Propriedade("TipoPagamento");
- filtroPersonalizado17.set_Nome("FORMA PAGAMENTO");
- filtroPersonalizado17.set_Tipo(typeof(Enum));
- filtroPersonalizados.Add(filtroPersonalizado17);
- FiltroPersonalizado filtroPersonalizado18 = new FiltroPersonalizado();
- filtroPersonalizado18.set_Propriedade("Observacao");
- filtroPersonalizado18.set_Nome("OBSERVAÇÃO");
- filtroPersonalizado18.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado18);
- FiltroPersonalizado filtroPersonalizado19 = new FiltroPersonalizado();
- filtroPersonalizado19.set_Propriedade("Controle.Plano.Nome");
- filtroPersonalizado19.set_Nome("PLANO");
- filtroPersonalizado19.set_Tipo(typeof(string));
- filtroPersonalizados.Add(filtroPersonalizado19);
- return filtroPersonalizados;
- }
-
- public static List<FiltroPersonalizado> PopularFiltroPersonalizado<T>()
- {
- List<FiltroPersonalizado> filtroPersonalizados = new List<FiltroPersonalizado>();
- foreach (PropertyInfo propertyInfo in
- from in (IEnumerable<PropertyInfo>)typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public)
- orderby Gestor.Common.Validation.ValidationHelper.DescriptionAttribute(x)
- select )
- {
- if (propertyInfo.Name == "ValidationEvent")
- {
- continue;
- }
- FiltroPersonalizado filtroPersonalizado = new FiltroPersonalizado();
- filtroPersonalizado.set_Propriedade(propertyInfo.Name);
- filtroPersonalizado.set_Nome(propertyInfo.GetDescriptionAttribute());
- FiltroPersonalizado filtroPersonalizado1 = filtroPersonalizado;
- if (propertyInfo.GetTypeAttribute() == "INVALID")
- {
- continue;
- }
- Type propertyType = propertyInfo.PropertyType;
- if (propertyType.IsGenericType && propertyType.GetGenericTypeDefinition() == typeof(Nullable<>))
- {
- propertyType = propertyType.GetGenericArguments()[0];
- }
- filtroPersonalizado1.set_Tipo((propertyType.BaseType == typeof(Enum) ? propertyType.BaseType : propertyType));
- filtroPersonalizados.Add(filtroPersonalizado1);
- }
- return filtroPersonalizados;
- }
-
- public static bool ProgramaEmExecucao(this string programName)
- {
- return Process.GetProcessesByName(programName).Length != 0;
- }
-
- public static async Task<bool> ReativarItens(List<long> ids)
- {
- ItemServico itemServico = new ItemServico();
- List<Item> items = await itemServico.BuscarItems(ids);
- List<Item> items1 = items;
- items1.ForEach((Item x) => {
- x.set_Substituido(null);
- x.set_Cancelado(false);
- x.set_Status(x.get_StatusInclusao());
- });
- await itemServico.SaveRange(items);
- bool sucesso = itemServico.Sucesso;
- itemServico = null;
- return sucesso;
- }
-
- public static async Task RecusarApolice(Documento documento, string motivo, bool estorno)
- {
- bool flag;
- string str;
- NegocioCorretora negocioCorretora;
- NegocioCorretora negocioCorretora1;
- ApoliceServico apoliceServico = new ApoliceServico();
- CriticaApoliceServico criticaApoliceServico = new CriticaApoliceServico();
- if (documento.get_Tipo() != 0 || !string.IsNullOrEmpty(documento.get_Apolice()))
- {
- str = (documento.get_Tipo() != 0 || string.IsNullOrEmpty(documento.get_Apolice()) ? "ENDOSSO RECUSADO" : "APÓLICE RECUSADA");
- }
- else
- {
- str = "PROPOSTA RECUSADA";
- }
- string str1 = str;
- if (!string.IsNullOrWhiteSpace(motivo))
- {
- Documento documento1 = documento;
- object[] nome = new object[] { Recursos.Usuario.get_Nome(), Recursos.Usuario.get_Id(), Funcoes.GetNetworkTime(), Environment.NewLine, motivo, Environment.NewLine, Environment.NewLine, documento.get_Observacao() };
- documento1.set_Observacao(string.Format("{0}, ID: {1}, {2:g}{3}RECUSA: {4}{5}{6}{7}", nome));
- }
- if (documento.get_Tipo() != 0)
- {
- if (!documento.get_NegocioCorretora().HasValue)
- {
- Documento documento2 = documento;
- negocioCorretora = (!documento.get_Negocio().HasValue || documento.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1);
- documento2.set_NegocioCorretora(new NegocioCorretora?(negocioCorretora));
- }
- documento.set_Situacao(7);
- documento.set_Apolice("RECUSADA");
- documento.set_Endosso("RECUSADA");
- flag = await apoliceServico.BaixarParcelasCancelamento(documento, estorno);
- if (!flag)
- {
- Action<TipoTela, string> acessaTela = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela != null)
- {
- acessaTela(21, "");
- }
- else
- {
- }
- }
- await apoliceServico.Save(documento, false, false);
- if (!apoliceServico.Sucesso)
- {
- Action<TipoTela, string> action = Gestor.Application.Actions.Actions.AcessaTela;
- if (action != null)
- {
- action(21, "");
- }
- else
- {
- }
- }
- if (!apoliceServico.Sucesso)
- {
- Action<TipoTela, string> acessaTela1 = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela1 != null)
- {
- acessaTela1(21, "");
- }
- else
- {
- }
- }
- flag = await Funcoes.InativarItens(documento.get_Id(), documento.get_Controle().get_Ramo().get_Id(), false);
- if (!flag)
- {
- Action<TipoTela, string> action1 = Gestor.Application.Actions.Actions.AcessaTela;
- if (action1 != null)
- {
- action1(21, "");
- }
- else
- {
- }
- }
- }
- else
- {
- await apoliceServico.Save(documento, false, false);
- Controle controle = await apoliceServico.BuscarControleAsync(documento.get_Controle().get_Id());
- if (controle.get_Id() != 0)
- {
- foreach (Documento documento3 in controle.get_Documentos())
- {
- if (!documento3.get_NegocioCorretora().HasValue)
- {
- Documento documento4 = documento3;
- negocioCorretora1 = (!documento3.get_Negocio().HasValue || documento3.get_Negocio().GetValueOrDefault() != 1 ? 0 : 1);
- documento4.set_NegocioCorretora(new NegocioCorretora?(negocioCorretora1));
- }
- documento3.set_Situacao(7);
- documento3.set_Apolice("RECUSADA");
- flag = await apoliceServico.BaixarParcelasCancelamento(documento3, estorno);
- if (flag)
- {
- continue;
- }
- Action<TipoTela, string> acessaTela2 = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela2 != null)
- {
- acessaTela2(21, "");
- }
- else
- {
- }
- }
- flag = await apoliceServico.UpdateRange(controle);
- controle = null;
- }
- else
- {
- apoliceServico = null;
- criticaApoliceServico = null;
- str1 = null;
- return;
- }
- }
- if (!flag)
- {
- Action<TipoTela, string> action2 = Gestor.Application.Actions.Actions.AcessaTela;
- if (action2 != null)
- {
- action2(21, "");
- }
- else
- {
- }
- }
- List<CriticaApolice> criticaApolices = await criticaApoliceServico.BuscarCritica(documento.get_Id());
- if (criticaApolices != null)
- {
- foreach (CriticaApolice criticaApolouse in criticaApolices)
- {
- criticaApolouse.set_Critica(new bool?(true));
- await criticaApoliceServico.Save(criticaApolouse);
- }
- }
- Action<TipoTela, string> acessaTela3 = Gestor.Application.Actions.Actions.AcessaTela;
- if (acessaTela3 != null)
- {
- acessaTela3(21, "");
- }
- else
- {
- }
- Funcoes.ToggleSnackBar(string.Concat(str1, " COM SUCESSO"), true);
- apoliceServico = null;
- criticaApoliceServico = null;
- str1 = null;
- }
-
- private static async void RegistrarLogBaixa(long id, DateTime now)
- {
- string str;
- ApoliceServico apoliceServico = new ApoliceServico();
- ParcelaServico parcelaServico = new ParcelaServico();
- VendedorServico vendedorServico = new VendedorServico();
- Documento documento = await apoliceServico.BuscarApoliceAsync(id, false, false);
- Documento documento1 = documento;
- ObservableCollection<Parcela> observableCollection = await parcelaServico.BuscarParcelasAsync(documento.get_Id());
- documento1.set_Parcelas(observableCollection);
- documento1 = null;
- List<VendedorParcela> vendedorParcelas = await vendedorServico.BuscaRepasse(documento.get_Id());
- foreach (Parcela parcela in documento.get_Parcelas())
- {
- foreach (VendedorParcela vendedorParcela in vendedorParcelas)
- {
- if (vendedorParcela.get_Parcela().get_Id() != parcela.get_Id())
- {
- continue;
- }
- if (parcela.get_Vendedores() == null)
- {
- parcela.set_Vendedores(new ObservableCollection<VendedorParcela>());
- }
- parcela.get_Vendedores().Add(vendedorParcela);
- }
- }
- IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
- RegistroLog registroLog = new RegistroLog();
- registroLog.set_Acao(1);
- registroLog.set_Usuario(Recursos.Usuario);
- registroLog.set_DataHora(now);
- Documento documento2 = documento;
- JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
- jsonSerializerSetting.set_ReferenceLoopHandling(1);
- registroLog.set_Descricao(JsonConvert.SerializeObject(documento2, jsonSerializerSetting));
- registroLog.set_EntidadeId(documento.get_Id());
- registroLog.set_Tela(2);
- registroLog.set_NomeMaquina(Environment.MachineName);
- registroLog.set_UsuarioMaquina(Environment.UserName);
- IPAddress[] addressList = hostEntry.AddressList;
- IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork);
- if (pAddress != null)
- {
- str = pAddress.ToString();
- }
- else
- {
- str = null;
- }
- registroLog.set_Ip(str);
- RegistroLog registroLog1 = registroLog;
- using (UnitOfWork commited = Instancia.Commited)
- {
- commited.get_RegistroLogRepository().SaveOrUpdate(registroLog1);
- commited.Commit();
- }
- parcelaServico = null;
- vendedorServico = null;
- documento = null;
- }
-
- public static string RemoverAcentos(string text)
- {
- string str = text.Normalize(NormalizationForm.FormD);
- StringBuilder stringBuilder = new StringBuilder();
- foreach (char chr in
- from c in str
- let unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c)
- where unicodeCategory != UnicodeCategory.NonSpacingMark
- select c)
- {
- stringBuilder.Append(chr);
- }
- return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
- }
-
- [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
- private static extern bool SetForegroundWindow(IntPtr hWnd);
-
- [DllImport("user32.dll", CharSet=CharSet.None, ExactSpelling=false)]
- private static extern bool ShowWindow(IntPtr hWnd, int nCmdShow);
-
- public static string SubstituirVariaveis(string corpo, MalaDireta envio)
- {
- DateTime? vigencia2;
- DateTime vigencia1;
- decimal valor;
- decimal? nullable;
- bool controle;
- bool flag;
- string str;
- string str1;
- string str2;
- string str3;
- object obj;
- string str4;
- string str5;
- string description;
- decimal? nullable1;
- string str6;
- decimal? nullable2;
- string str7;
- DateTime networkTime = Funcoes.GetNetworkTime();
- VariaveisMalaDireta[] values = (VariaveisMalaDireta[])Enum.GetValues(typeof(VariaveisMalaDireta));
- for (int i = 0; i < (int)values.Length; i++)
- {
- VariaveisMalaDireta variaveisMalaDiretum = values[i];
- switch (variaveisMalaDiretum)
- {
- case 0:
- {
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), networkTime.ToString(new CultureInfo("pt-BR")));
- break;
- }
- case 1:
- {
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), (Gestor.Common.Validation.ValidationHelper.IsNotNullOrEmpty(envio.get_Cliente().get_NomeSocialRg()) ? envio.get_Cliente().get_NomeSocialRg() : envio.get_Cliente().get_Nome()));
- break;
- }
- case 2:
- {
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Cliente().get_Documento());
- break;
- }
- case 3:
- {
- if (envio.get_Apolice() == null)
- {
- break;
- }
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Apolice().get_Proposta());
- break;
- }
- case 4:
- {
- if (envio.get_Apolice() == null)
- {
- break;
- }
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), string.Concat(envio.get_Apolice().get_Apolice(), (envio.get_Apolice().get_Tipo() != 0 ? string.Concat(", endosso de número: ", envio.get_Apolice().get_Endosso()) : "")));
- break;
- }
- case 5:
- {
- Documento apolice = envio.get_Apolice();
- if (apolice != null)
- {
- controle = apolice.get_Controle();
- }
- else
- {
- controle = false;
- }
- if (!controle)
- {
- break;
- }
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Apolice().get_Controle().get_Ramo().get_Nome());
- break;
- }
- case 6:
- {
- Documento documento = envio.get_Apolice();
- if (documento != null)
- {
- flag = documento.get_Controle();
- }
- else
- {
- flag = false;
- }
- if (!flag)
- {
- break;
- }
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Apolice().get_Controle().get_Seguradora().get_Nome());
- break;
- }
- case 7:
- {
- if (envio.get_Apolice() == null)
- {
- break;
- }
- string entity = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- vigencia1 = envio.get_Apolice().get_Vigencia1();
- corpo = corpo.Replace(entity, vigencia1.ToString("d"));
- break;
- }
- case 8:
- {
- if (envio.get_Apolice() == null)
- {
- break;
- }
- string str8 = corpo;
- string entity1 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- vigencia2 = envio.get_Apolice().get_Vigencia2();
- if (vigencia2.HasValue)
- {
- vigencia1 = vigencia2.GetValueOrDefault();
- str = vigencia1.ToString("d");
- }
- else
- {
- str = null;
- }
- corpo = str8.Replace(entity1, str);
- break;
- }
- case 9:
- {
- if (envio.get_Parcela() == null)
- {
- break;
- }
- string entity2 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- vigencia1 = envio.get_Parcela().get_Vencimento();
- corpo = corpo.Replace(entity2, vigencia1.ToString("d"));
- break;
- }
- case 10:
- {
- if (envio.get_Parcela() == null)
- {
- break;
- }
- string entity3 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- valor = envio.get_Parcela().get_Valor();
- corpo = corpo.Replace(entity3, valor.ToString("c2"));
- break;
- }
- case 11:
- {
- if (envio.get_Item() == null)
- {
- break;
- }
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Item().get_Descricao());
- break;
- }
- case 12:
- {
- if (envio.get_Sinistro() == null)
- {
- break;
- }
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), envio.get_Sinistro().get_Numero());
- break;
- }
- case 13:
- {
- if (envio.get_Parcela() == null)
- {
- break;
- }
- string entity4 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- int numeroParcela = envio.get_Parcela().get_NumeroParcela();
- corpo = corpo.Replace(entity4, numeroParcela.ToString());
- break;
- }
- case 14:
- {
- vigencia2 = envio.get_Cliente().get_Nascimento();
- if (!vigencia2.HasValue)
- {
- break;
- }
- string str9 = corpo;
- string entity5 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- vigencia2 = envio.get_Cliente().get_Nascimento();
- if (vigencia2.HasValue)
- {
- vigencia1 = vigencia2.GetValueOrDefault();
- str1 = vigencia1.ToString("dd/MM");
- }
- else
- {
- str1 = null;
- }
- corpo = str9.Replace(entity5, str1);
- break;
- }
- case 15:
- {
- vigencia2 = envio.get_Cliente().get_Nascimento();
- if (!vigencia2.HasValue)
- {
- break;
- }
- string str10 = corpo;
- string entity6 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- vigencia2 = envio.get_Cliente().get_Nascimento();
- if (vigencia2.HasValue)
- {
- vigencia1 = vigencia2.GetValueOrDefault();
- str2 = vigencia1.ToString("d");
- }
- else
- {
- str2 = null;
- }
- corpo = str10.Replace(entity6, str2);
- break;
- }
- case 16:
- {
- string str11 = corpo;
- string entity7 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- vigencia2 = envio.get_Cliente().get_VencimentoHabilitacao();
- if (vigencia2.HasValue)
- {
- vigencia1 = vigencia2.GetValueOrDefault();
- str3 = vigencia1.ToString("d");
- }
- else
- {
- str3 = null;
- }
- corpo = str11.Replace(entity7, str3);
- break;
- }
- case 17:
- {
- if (envio.get_ArquivoDigital() != null)
- {
- if (!envio.get_ArquivoDigital().All<IndiceArquivoDigital>((IndiceArquivoDigital x) => string.IsNullOrWhiteSpace(x.get_UrlAssinatura())))
- {
- string str12 = "<table><thead><tr><th>ABAIXO OS DOCUMENTOS PARA ASSINATURA</th></thead><tbody>";
- (
- from x in envio.get_ArquivoDigital()
- where !string.IsNullOrWhiteSpace(x.get_UrlAssinatura())
- select x).ToList<IndiceArquivoDigital>().ForEach((IndiceArquivoDigital x) => str12 = string.Concat(new string[] { str12, "<tr><td><a href='", x.get_UrlAssinatura(), "'>", x.get_Descricao(), "</a></td></tr>" }));
- str12 = string.Concat(str12, "</tbody></table>");
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), str12);
- break;
- }
- }
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), string.Empty);
- break;
- }
- case 18:
- {
- string str13 = string.Format("<strong>ABAIXO O LINK PARA MEU CARTÃO DE VISITA.</strong><br><a target='_blank' href='{0}{1}'>CARTÃO DE VISITA ELETRÔNICO</a>", Address.get_Card(), Recursos.Usuario.get_Id().GeraCartaoVisita());
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), str13);
- break;
- }
- case 19:
- {
- if (envio.get_Apolice() != null)
- {
- Uri assistance = Address.get_Assistance();
- if (envio != null)
- {
- Documento apolice1 = envio.get_Apolice();
- if (apolice1 != null)
- {
- obj = apolice1.get_Id().GeraAssistencia();
- }
- else
- {
- obj = null;
- }
- }
- else
- {
- obj = null;
- }
- string str14 = string.Format("<strong>ABAIXO O LINK PARA O SEU CARTÃO ASSISTÊNCIA.</strong><br><a target='_blank' href='{0}{1}'>CARTÃO ASSISTÊNCIA</a>", assistance, obj);
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), str14);
- break;
- }
- else
- {
- corpo = corpo.Replace(Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum), string.Empty);
- break;
- }
- }
- case 20:
- {
- string str15 = corpo;
- string entity8 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- Documento documento1 = envio.get_Apolice();
- if (documento1 != null)
- {
- str4 = documento1.get_PremioLiquido().ToString("c");
- }
- else
- {
- str4 = null;
- }
- corpo = str15.Replace(entity8, str4);
- break;
- }
- case 21:
- {
- string str16 = corpo;
- string entity9 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- Documento apolice2 = envio.get_Apolice();
- if (apolice2 != null)
- {
- str5 = apolice2.get_PremioTotal().ToString("c");
- }
- else
- {
- str5 = null;
- }
- corpo = str16.Replace(entity9, str5);
- break;
- }
- case 22:
- {
- string str17 = corpo;
- string entity10 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- Documento documento2 = envio.get_Apolice();
- if (documento2 != null)
- {
- FormaPagamento? formaPagamento = documento2.get_FormaPagamento();
- if (formaPagamento.HasValue)
- {
- description = Gestor.Common.Validation.ValidationHelper.GetDescription(formaPagamento.GetValueOrDefault());
- }
- else
- {
- description = null;
- }
- }
- else
- {
- description = null;
- }
- corpo = str17.Replace(entity10, description);
- break;
- }
- case 23:
- {
- string str18 = corpo;
- string entity11 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- Documento apolice3 = envio.get_Apolice();
- if (apolice3 != null)
- {
- nullable1 = new decimal?(apolice3.get_NumeroParcelas());
- }
- else
- {
- nullable = null;
- nullable1 = nullable;
- }
- if (!nullable1.HasValue || envio.get_Apolice().get_TipoRecebimento().GetValueOrDefault() == 2)
- {
- str6 = "Indefinido";
- }
- else
- {
- Documento documento3 = envio.get_Apolice();
- if (documento3 != null)
- {
- str6 = documento3.get_NumeroParcelas().ToString();
- }
- else
- {
- str6 = null;
- }
- }
- corpo = str18.Replace(entity11, str6);
- break;
- }
- case 24:
- {
- string str19 = corpo;
- string entity12 = Gestor.Common.Validation.ValidationHelper.GetEntity(variaveisMalaDiretum);
- Documento apolice4 = envio.get_Apolice();
- if (apolice4 != null)
- {
- nullable2 = new decimal?(apolice4.get_NumeroParcelas());
- }
- else
- {
- nullable = null;
- nullable2 = nullable;
- }
- if (!nullable2.HasValue || envio.get_Apolice().get_NumeroParcelas() == decimal.Zero || envio.get_Apolice().get_TipoRecebimento().GetValueOrDefault() == 2)
- {
- str7 = "Verificar documento anexado";
- }
- else
- {
- valor = envio.get_Apolice().get_PremioTotal() / envio.get_Apolice().get_NumeroParcelas();
- str7 = valor.ToString();
- }
- corpo = str19.Replace(entity12, str7);
- break;
- }
- }
- }
- return corpo;
- }
-
- public static void ToggleSnackBar(string message, bool active = true)
- {
- App.SnackBar.get_Message().Content = message;
- App.SnackBar.set_IsActive(active);
- if (!active)
- {
- return;
- }
- Task.Factory.StartNew(new Action(Funcoes.CloseSlackBar));
- }
-
- public static List<ParametrosTotalizacao> TotalizacoesRelatorio<T>(Relatorio relatorio, List<ParametrosTotalizacao> parametrosAdicionados)
- {
- long id;
- List<ParametrosTotalizacao> parametrosTotalizacaos = new List<ParametrosTotalizacao>();
- List<string> strs = new List<string>();
- switch (relatorio)
- {
- case 2:
- case 3:
- {
- strs.Add("PremioTotal");
- strs.Add("PremioLiquido");
- strs.Add("MediaComissao");
- strs.Add("ComissaoGerada");
- strs.Add("Cancelamentos");
- strs.Add("Novos");
- strs.Add("NegociosProprios");
- strs.Add("Renovacoes");
- strs.Add("SegurosNovos");
- strs.Add("Apolices");
- strs.Add("Endossos");
- strs.Add("Faturas");
- strs.Add("TotalGeral");
- strs.Add("MediaPonderada");
- goto case 15;
- }
- case 4:
- {
- strs.Add("Cancelamentos");
- strs.Add("Novos");
- strs.Add("Renovacoes");
- strs.Add("Apolices");
- strs.Add("Endossos");
- strs.Add("Faturas");
- strs.Add("TotalProspeccao");
- strs.Add("TotalGeral");
- strs.Add("PremioTotal");
- strs.Add("PremioLiquido");
- strs.Add("ComissaoGerada");
- goto case 15;
- }
- case 5:
- {
- strs.Add("ComissaoRecebidaBruta");
- strs.Add("ComissaoRecebidaLiquida");
- strs.Add("ComissaoPrevista");
- strs.Add("Repasse");
- strs.Add("Impostos");
- strs.Add("PremioTotal");
- strs.Add("PremioLiquido");
- goto case 15;
- }
- case 6:
- case 16:
- {
- strs.Add("ComissaoPrevista");
- strs.Add("TotalPrevista");
- strs.Add("TotalGeral");
- strs.Add("TotalParcela");
- goto case 15;
- }
- case 7:
- case 11:
- case 12:
- case 13:
- case 14:
- case 15:
- {
- PropertyInfo[] properties = typeof(T).GetProperties(BindingFlags.Instance | BindingFlags.Public);
- foreach (PropertyInfo propertyInfo in
- from in (IEnumerable<PropertyInfo>)properties
- orderby x.GetDescriptionAttribute()
- select )
- {
- if (propertyInfo.Name == "ValidationEvent" || propertyInfo.GetTypeAttribute() == "INVALID" || !strs.Contains(propertyInfo.Name) || propertyInfo.Name == "Agrupamento" || parametrosAdicionados.Any<ParametrosTotalizacao>((ParametrosTotalizacao x) => x.get_Campo() == propertyInfo.Name))
- {
- continue;
- }
- ParametrosTotalizacao parametrosTotalizacao = new ParametrosTotalizacao();
- ParametrosTotalizacao parametrosTotalizacao1 = parametrosAdicionados.FirstOrDefault<ParametrosTotalizacao>((ParametrosTotalizacao x) => {
- if (x.get_IdUsuario() == 0)
- {
- return false;
- }
- return x.get_Campo() == propertyInfo.Name;
- });
- if (parametrosTotalizacao1 != null)
- {
- id = parametrosTotalizacao1.get_Id();
- }
- else
- {
- id = (long)0;
- }
- parametrosTotalizacao.set_Id(id);
- parametrosTotalizacao.set_Campo(propertyInfo.Name);
- parametrosTotalizacao.set_Header(propertyInfo.GetDescriptionAttribute());
- parametrosTotalizacao.set_IdUsuario(Recursos.Usuario.get_Id());
- parametrosTotalizacao.set_Relatorio(relatorio);
- parametrosTotalizacaos.Add(parametrosTotalizacao);
- }
- return parametrosTotalizacaos;
- }
- case 8:
- {
- strs.Add("PremioTotal");
- strs.Add("PremioLiquido");
- strs.Add("ComissaoRecebidaBruta");
- strs.Add("MediaComissao");
- strs.Add("TotalPrevista");
- strs.Add("ComissaoGerada");
- strs.Add("Cancelamentos");
- strs.Add("Novos");
- strs.Add("Renovacoes");
- strs.Add("Apolices");
- strs.Add("Endossos");
- strs.Add("Faturas");
- strs.Add("TotalGeral");
- goto case 15;
- }
- case 9:
- case 10:
- {
- strs.Add("Liquidado");
- strs.Add("ValorLiquidado");
- strs.Add("Pendente");
- strs.Add("TotalGeral");
- strs.Add("TotalClientes");
- strs.Add("TotalTerceiros");
- goto case 15;
- }
- default:
- {
- goto case 15;
- }
- }
- }
-
- public static long UnixTimeStamp()
- {
- DateTime utcNow = DateTime.UtcNow;
- TimeSpan timeSpan = utcNow.Subtract(new DateTime(1970, 1, 1));
- return (long)timeSpan.TotalSeconds;
- }
-
- public static string ValidaNomePlanilha(this string nome, string agrupamento = "", int index = 0)
- {
- if (string.IsNullOrWhiteSpace(nome))
- {
- nome = agrupamento;
- }
- nome = nome.Replace("/", "_").Replace(":", " ").Replace("*", " ").Replace("?", "").Trim();
- if (index > 0)
- {
- nome = string.Format("{0} {1}", index, nome);
- }
- if (nome.Length > 30)
- {
- nome = nome.Substring(0, 30);
- }
- return nome;
- }
-
- public static async Task<bool[]> VerificarPagamento(long id)
- {
- bool[] flagArray = new bool[2];
- List<Parcela> parcelas = await (new ParcelaServico()).BuscarParcelas(id);
- if (parcelas.Any<Parcela>((Parcela x) => x.get_DataRecebimento().HasValue))
- {
- flagArray[0] = true;
- }
- List<VendedorParcela> vendedorParcelas = await (new VendedorServico()).BuscaRepasse(id);
- if (vendedorParcelas.Any<VendedorParcela>((VendedorParcela x) => x.get_DataPagamento().HasValue))
- {
- flagArray[1] = true;
- }
- bool[] flagArray1 = flagArray;
- flagArray = null;
- return flagArray1;
- }
- }
-} \ No newline at end of file