From 225aa1499e37faf9d38257caabbadc68d78b427e Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 12:29:41 -0300 Subject: decompiler.com --- .../BaseFinanceiroViewModel.cs | 371 +++++++++++++++++++++ 1 file changed, 371 insertions(+) create mode 100644 Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs (limited to 'Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs') diff --git a/Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs b/Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs new file mode 100644 index 0000000..abe8a24 --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels.Generic/BaseFinanceiroViewModel.cs @@ -0,0 +1,371 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Text; +using System.Text.RegularExpressions; +using System.Threading.Tasks; +using System.Windows; +using System.Windows.Controls; +using System.Windows.Forms; +using Gestor.Application.Componentes; +using Gestor.Application.Servicos.Generic; +using Gestor.Application.ViewModels.Financeiro; +using Gestor.Model.Domain.Common; +using Gestor.Model.Domain.Financeiro; +using MaterialDesignThemes.Wpf; +using OfxSharpLib; +using Xceed.Wpf.AvalonDock.Controls; + +namespace Gestor.Application.ViewModels.Generic; + +public abstract class BaseFinanceiroViewModel : BaseViewModel +{ + public AutoCompleteFilterPredicate BancosContasItemFilter => (string searchText, object obj) => ((BancosContas)obj).Descricao.ToUpper().Contains(searchText.ToUpper()); + + public AutoCompleteFilterPredicate FornecedorItemFilter => (string searchText, object obj) => (((Fornecedor)obj).Nome != null && ((Fornecedor)obj).Nome.ToUpper().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Documento != null && ((Fornecedor)obj).Documento.ToString().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Telefone1 != null && ((Fornecedor)obj).Telefone1.ToString().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Telefone2 != null && ((Fornecedor)obj).Telefone2.ToString().Contains(searchText.ToUpper())) || (((Fornecedor)obj).Email != null && ((Fornecedor)obj).Email.ToString().Contains(searchText.ToUpper())); + + public AutoCompleteFilterPredicate LancamentoItemFilter => delegate(string searchText, object obj) + { + //IL_0001: Unknown result type (might be due to invalid IL or missing references) + //IL_002e: Unknown result type (might be due to invalid IL or missing references) + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0056: Unknown result type (might be due to invalid IL or missing references) + //IL_0099: Unknown result type (might be due to invalid IL or missing references) + //IL_006b: Unknown result type (might be due to invalid IL or missing references) + //IL_00dc: Unknown result type (might be due to invalid IL or missing references) + //IL_00ae: Unknown result type (might be due to invalid IL or missing references) + //IL_0113: Unknown result type (might be due to invalid IL or missing references) + //IL_00e9: Unknown result type (might be due to invalid IL or missing references) + //IL_0156: Unknown result type (might be due to invalid IL or missing references) + //IL_012c: Unknown result type (might be due to invalid IL or missing references) + //IL_019e: Unknown result type (might be due to invalid IL or missing references) + //IL_016f: Unknown result type (might be due to invalid IL or missing references) + //IL_01e3: Unknown result type (might be due to invalid IL or missing references) + //IL_01b7: Unknown result type (might be due to invalid IL or missing references) + //IL_01fc: Unknown result type (might be due to invalid IL or missing references) + if ((((Lancamento)obj).Historico == null || !((Lancamento)obj).Historico.ToUpper().Contains(searchText.ToUpper())) && !((Lancamento)obj).Vencimento.ToString().ToUpper().Contains(searchText.ToUpper()) && (!((Lancamento)obj).Baixa.HasValue || !((Lancamento)obj).Baixa.ToString().ToUpper().Contains(searchText.ToUpper())) && (!((Lancamento)obj).Pagamento.HasValue || !((Lancamento)obj).Pagamento.ToString().ToUpper().Contains(searchText.ToUpper())) && (((Lancamento)obj).Conta == null || !((Lancamento)obj).Conta.Descricao.ToString().ToUpper().Contains(searchText.ToUpper()))) + { + ControleFinanceiro controle = ((Lancamento)obj).Controle; + if (((controle != null) ? controle.Historico : null) == null || !((Lancamento)obj).Controle.Historico.ToString().ToUpper().Contains(searchText.ToUpper())) + { + ControleFinanceiro controle2 = ((Lancamento)obj).Controle; + if (((controle2 != null) ? controle2.Plano : null) == null || !((Lancamento)obj).Controle.Plano.Descricao.ToString().ToUpper().Contains(searchText.ToUpper())) + { + ControleFinanceiro controle3 = ((Lancamento)obj).Controle; + if (((controle3 != null) ? controle3.Centro : null) == null || !((Lancamento)obj).Controle.Centro.Descricao.ToString().ToUpper().Contains(searchText.ToUpper())) + { + ControleFinanceiro controle4 = ((Lancamento)obj).Controle; + if (((controle4 != null) ? controle4.Fornecedor : null) != null) + { + return ((Lancamento)obj).Controle.Fornecedor.Nome.ToString().ToUpper().Contains(searchText.ToUpper()); + } + return false; + } + } + } + } + return true; + }; + + public AutoCompleteFilterPredicate PlanoItemFilter => (string searchText, object obj) => ((Plano)obj).Descricao.ToUpper().Contains(searchText.ToUpper()) || ((Plano)obj).Descricao.ToString().Contains(searchText.ToUpper()); + + public AutoCompleteFilterPredicate PlanosItemFilter => (string searchText, object obj) => ((Planos)obj).Descricao.ToUpper().Contains(searchText.ToUpper()) || ((Planos)obj).Descricao.ToString().Contains(searchText.ToUpper()); + + public AutoCompleteFilterPredicate BancoItemFilter => (string searchText, object obj) => ((Banco)obj).Nome.ToUpper().Contains(searchText.ToUpper()); + + internal async Task> BuscarBancosContas(string value) + { + return await Task.Run(() => new BaseServico().BuscarBancosContas(value)); + } + + internal async Task> BuscarFornecedor(string value) + { + return await Task.Run(() => new BaseServico().BuscarFornecedor(value)); + } + + internal async Task> BuscarFornecedorAtivo(string value) + { + return await Task.Run(() => new BaseServico().BuscarFornecedor(value, ativo: true)); + } + + internal async Task ShowTransferencia(Transferencia transferencia) + { + DialogHost val = Extentions.FindVisualChildren((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType().SingleOrDefault((Func)((Window x) => x.IsActive))).FirstOrDefault(); + DialogTransferencia dialogControl = new DialogTransferencia(transferencia); + return await ExecuteRunExtendedDialogTransferencia((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog"); + } + + public async Task ExecuteRunExtendedDialogTransferencia(UserControl dialogControl, string hostName) + { + Extentions.FindVisualChildren((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType().SingleOrDefault((Func)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x) + { + ((UIElement)x).Visibility = (Visibility)2; + }); + object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler)); + if (obj is bool) + { + return null; + } + return (Transferencia)obj; + } + + internal async Task ShowVinculo(FinanceiroViewModel viewModel) + { + DialogHost val = Extentions.FindVisualChildren((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType().SingleOrDefault((Func)((Window x) => x.IsActive))).FirstOrDefault(); + VincularLancamentoDialog dialogControl = new VincularLancamentoDialog(viewModel); + return await ExecuteRunExtendedDialogVinculo((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog"); + } + + public async Task ExecuteRunExtendedDialogVinculo(UserControl dialogControl, string hostName) + { + Extentions.FindVisualChildren((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType().SingleOrDefault((Func)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x) + { + ((UIElement)x).Visibility = (Visibility)2; + }); + object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler)); + if (obj is bool) + { + return null; + } + return (Lancamento)obj; + } + + internal async Task ShowContas(List contas) + { + DialogHost val = Extentions.FindVisualChildren((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType().SingleOrDefault((Func)((Window x) => x.IsActive))).FirstOrDefault(); + ContasDialog dialogControl = new ContasDialog(contas); + return await ExecuteRunExtendedDialogContas((UserControl)(object)dialogControl, (val != null) ? val.Identifier.ToString() : "RootDialog"); + } + + public async Task ExecuteRunExtendedDialogContas(UserControl dialogControl, string hostName) + { + Extentions.FindVisualChildren((DependencyObject)(object)((IEnumerable)Application.Current.Windows).OfType().SingleOrDefault((Func)((Window x) => x.IsActive))).ToList().ForEach(delegate(WebEditor x) + { + ((UIElement)x).Visibility = (Visibility)2; + }); + object obj = await DialogHost.Show((object)dialogControl, (object)hostName, new DialogOpenedEventHandler(base.ExtendedOpenedEventHandler), new DialogClosingEventHandler(base.ExtendedClosingEventHandler)); + if (obj is bool) + { + return null; + } + return (BancosContas)obj; + } + + public Encoding GetEncoding(string filename) + { + byte[] array = new byte[4]; + using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read)) + { + fileStream.Read(array, 0, 4); + } + if (array[0] == 43 && array[1] == 47 && array[2] == 118) + { + return Encoding.UTF7; + } + if (array[0] == 239 && array[1] == 187 && array[2] == 191) + { + return Encoding.UTF8; + } + if (array[0] == byte.MaxValue && array[1] == 254 && array[2] == 0 && array[3] == 0) + { + return Encoding.UTF32; + } + if (array[0] == byte.MaxValue && array[1] == 254) + { + return Encoding.Unicode; + } + if (array[0] == 254 && array[1] == byte.MaxValue) + { + return Encoding.BigEndianUnicode; + } + if (array[0] == 0 && array[1] == 0 && array[2] == 254 && array[3] == byte.MaxValue) + { + return new UTF32Encoding(bigEndian: true, byteOrderMark: true); + } + return Encoding.ASCII; + } + + public async Task> ImportarOfx() + { + List ofxDocuments = new List(); + bool error = false; + List files = new List(); + OpenFileDialog val = new OpenFileDialog(); + try + { + val.Multiselect = true; + ((FileDialog)val).Filter = "Arquivos OFX|*.ofx"; + ((FileDialog)val).InitialDirectory = Environment.SpecialFolder.Desktop.ToString(); + if (1 != (int)((CommonDialog)val).ShowDialog()) + { + return null; + } + files.AddRange(((FileDialog)val).FileNames); + } + finally + { + ((IDisposable)val)?.Dispose(); + } + await Task.Run(delegate + { + //IL_000e: Unknown result type (might be due to invalid IL or missing references) + //IL_0018: Expected O, but got Unknown + OfxDocumentParser parser = new OfxDocumentParser(); + files.ForEach(delegate(string x) + { + try + { + string text = DateTime.Now.Date.ToString("yyyyMMddHHmmss"); + string text2 = DetectEncodingAndRead(x).Replace("00000000", "" + text).Replace("00000000000000", "" + text).Replace(",", ".") + .Replace(" ", "."); + if (text2.Contains("336") && !text2.Contains("")) + { + text2 = text2.Replace("UTF - 8", "USASCII").Replace("", "\r\n\r\n0\r\n00000000\r\n").Replace("00000000", "" + text) + .Replace(": ", ":") + .Replace(" ", "") + .Replace("", "0"); + } + if (text2.Contains("0403") && !text2.Contains("CHARSET:1252") && text2.Contains("ENCODING:UTF-8")) + { + text2 = text2.Replace("UTF-8", "USASCII\nCHARSET:1252").Replace("00000000", "" + text).Replace("[0:GMT]", "") + .Replace(": ", ":") + .Replace(" ", ""); + } + if (text2.Contains("260")) + { + text2 = text2.Replace("UTF-8", "USASCII").Replace("CHARSET:NONE", "CHARSET:1252"); + } + if (text2.Contains("")) + { + text2 = text2.Replace("", "SEM INFORMAÇÃO"); + } + if (Regex.IsMatch(text2, "\\s*")) + { + text2 = text2.Replace("\n", "SEM NOME").Replace("", "SEM NOME"); + } + OfxDocument item = parser.Import(text2); + ofxDocuments.Add(item); + } + catch (Exception) + { + error = true; + } + }); + }); + if (error) + { + await ShowMessage("HOUVE PROBLEMAS AO IMPORTAR O OFX, BAIXE-O NOVAMENTE COM UM PERÍODO MENOR."); + } + return ofxDocuments; + } + + private string DetectEncodingAndRead(string arquivo) + { + return File.ReadAllText(arquivo, DetectTextFileEncoding(arquivo)); + } + + public static Encoding DetectTextFileEncoding(string filePath) + { + byte[] array; + using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) + { + int num = (int)Math.Min(fileStream.Length, 4096L); + array = new byte[num]; + fileStream.Read(array, 0, num); + } + if (array.Length >= 2) + { + if (array.Length >= 3 && array[0] == 239 && array[1] == 187 && array[2] == 191) + { + return Encoding.UTF8; + } + if (array[0] == byte.MaxValue && array[1] == 254) + { + return Encoding.Unicode; + } + if (array[0] == 254 && array[1] == byte.MaxValue) + { + return Encoding.BigEndianUnicode; + } + if (array.Length >= 4 && array[0] == byte.MaxValue && array[1] == 254 && array[2] == 0 && array[3] == 0) + { + return Encoding.UTF32; + } + if (array.Length >= 4 && array[0] == 0 && array[1] == 0 && array[2] == 254 && array[3] == byte.MaxValue) + { + return new UTF32Encoding(bigEndian: true, byteOrderMark: true); + } + } + bool flag = true; + int num2 = 0; + int num3 = 0; + for (int i = 0; i < array.Length; i++) + { + if (array[i] <= 127) + { + num3++; + continue; + } + if (array[i] >= 194 && array[i] <= 223 && i + 1 < array.Length && array[i + 1] >= 128 && array[i + 1] <= 191) + { + num2++; + i++; + continue; + } + if (array[i] >= 224 && array[i] <= 239 && i + 2 < array.Length && array[i + 1] >= 128 && array[i + 1] <= 191 && array[i + 2] >= 128 && array[i + 2] <= 191) + { + num2++; + i += 2; + continue; + } + if (array[i] >= 240 && array[i] <= 244 && i + 3 < array.Length && array[i + 1] >= 128 && array[i + 1] <= 191 && array[i + 2] >= 128 && array[i + 2] <= 191 && array[i + 3] >= 128 && array[i + 3] <= 191) + { + num2++; + i += 3; + continue; + } + flag = false; + break; + } + int num4 = 0; + for (int j = 0; j < array.Length - 1; j += 2) + { + if (array[j] == 0 || array[j + 1] == 0) + { + num4++; + } + } + if (flag && num2 > 0) + { + return Encoding.UTF8; + } + if ((double)num3 > (double)array.Length * 0.95) + { + return Encoding.ASCII; + } + if ((double)num4 > (double)array.Length * 0.4) + { + int num5 = 0; + int num6 = 0; + for (int k = 0; k < array.Length - 1; k += 2) + { + if (array[k] == 0 && array[k + 1] != 0) + { + num6++; + } + if (array[k] != 0 && array[k + 1] == 0) + { + num5++; + } + } + if (num5 > num6) + { + return Encoding.Unicode; + } + return Encoding.BigEndianUnicode; + } + return Encoding.GetEncoding(1252); + } +} -- cgit v1.2.3