From 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 Mon Sep 17 00:00:00 2001 From: Lucas Faria Mendes Date: Mon, 30 Mar 2026 10:38:18 -0300 Subject: chore: location --- .../ViewModels/Generic/BaseFinanceiroViewModel.cs | 512 --------------------- 1 file changed, 512 deletions(-) delete mode 100644 Gestor.Application/ViewModels/Generic/BaseFinanceiroViewModel.cs (limited to 'Gestor.Application/ViewModels/Generic/BaseFinanceiroViewModel.cs') diff --git a/Gestor.Application/ViewModels/Generic/BaseFinanceiroViewModel.cs b/Gestor.Application/ViewModels/Generic/BaseFinanceiroViewModel.cs deleted file mode 100644 index 3e5561d..0000000 --- a/Gestor.Application/ViewModels/Generic/BaseFinanceiroViewModel.cs +++ /dev/null @@ -1,512 +0,0 @@ -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 System; -using System.Collections.Generic; -using System.Diagnostics; -using System.IO; -using System.Linq; -using System.Runtime.CompilerServices; -using System.Text; -using System.Text.RegularExpressions; -using System.Threading.Tasks; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Forms; -using Xceed.Wpf.AvalonDock.Controls; - -namespace Gestor.Application.ViewModels.Generic -{ - public abstract class BaseFinanceiroViewModel : BaseViewModel - { - public AutoCompleteFilterPredicate BancoItemFilter - { - get - { - AutoCompleteFilterPredicate u003cu003e9_140 = BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__14_0; - if (u003cu003e9_140 == null) - { - u003cu003e9_140 = new AutoCompleteFilterPredicate(BaseFinanceiroViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => ((Banco)obj).get_Nome().ToUpper().Contains(searchText.ToUpper())); - BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__14_0 = u003cu003e9_140; - } - return u003cu003e9_140; - } - } - - public AutoCompleteFilterPredicate BancosContasItemFilter - { - get - { - AutoCompleteFilterPredicate u003cu003e9_20 = BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__2_0; - if (u003cu003e9_20 == null) - { - u003cu003e9_20 = new AutoCompleteFilterPredicate(BaseFinanceiroViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => ((BancosContas)obj).get_Descricao().ToUpper().Contains(searchText.ToUpper())); - BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__2_0 = u003cu003e9_20; - } - return u003cu003e9_20; - } - } - - public AutoCompleteFilterPredicate FornecedorItemFilter - { - get - { - AutoCompleteFilterPredicate u003cu003e9_60 = BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__6_0; - if (u003cu003e9_60 == null) - { - u003cu003e9_60 = new AutoCompleteFilterPredicate(BaseFinanceiroViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => { - if (((Fornecedor)obj).get_Nome() != null && ((Fornecedor)obj).get_Nome().ToUpper().Contains(searchText.ToUpper()) || ((Fornecedor)obj).get_Documento() != null && ((Fornecedor)obj).get_Documento().ToString().Contains(searchText.ToUpper()) || ((Fornecedor)obj).get_Telefone1() != null && ((Fornecedor)obj).get_Telefone1().ToString().Contains(searchText.ToUpper()) || ((Fornecedor)obj).get_Telefone2() != null && ((Fornecedor)obj).get_Telefone2().ToString().Contains(searchText.ToUpper())) - { - return true; - } - if (((Fornecedor)obj).get_Email() == null) - { - return false; - } - return ((Fornecedor)obj).get_Email().ToString().Contains(searchText.ToUpper()); - }); - BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__6_0 = u003cu003e9_60; - } - return u003cu003e9_60; - } - } - - public AutoCompleteFilterPredicate LancamentoItemFilter - { - get - { - AutoCompleteFilterPredicate u003cu003e9_80 = BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__8_0; - if (u003cu003e9_80 == null) - { - u003cu003e9_80 = new AutoCompleteFilterPredicate(BaseFinanceiroViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => { - bool historico; - bool plano; - bool centro; - bool fornecedor; - if ((((Lancamento)obj).get_Historico() == null || !((Lancamento)obj).get_Historico().ToUpper().Contains(searchText.ToUpper())) && !((Lancamento)obj).get_Vencimento().ToString().ToUpper().Contains(searchText.ToUpper()) && (!((Lancamento)obj).get_Baixa().HasValue || !((Lancamento)obj).get_Baixa().ToString().ToUpper().Contains(searchText.ToUpper())) && (!((Lancamento)obj).get_Pagamento().HasValue || !((Lancamento)obj).get_Pagamento().ToString().ToUpper().Contains(searchText.ToUpper())) && (((Lancamento)obj).get_Conta() == null || !((Lancamento)obj).get_Conta().get_Descricao().ToString().ToUpper().Contains(searchText.ToUpper()))) - { - ControleFinanceiro controle = ((Lancamento)obj).get_Controle(); - if (controle != null) - { - historico = controle.get_Historico(); - } - else - { - historico = false; - } - if (!historico || !((Lancamento)obj).get_Controle().get_Historico().ToString().ToUpper().Contains(searchText.ToUpper())) - { - ControleFinanceiro controleFinanceiro = ((Lancamento)obj).get_Controle(); - if (controleFinanceiro != null) - { - plano = controleFinanceiro.get_Plano(); - } - else - { - plano = false; - } - if (!plano || !((Lancamento)obj).get_Controle().get_Plano().get_Descricao().ToString().ToUpper().Contains(searchText.ToUpper())) - { - ControleFinanceiro controle1 = ((Lancamento)obj).get_Controle(); - if (controle1 != null) - { - centro = controle1.get_Centro(); - } - else - { - centro = false; - } - if (!centro || !((Lancamento)obj).get_Controle().get_Centro().get_Descricao().ToString().ToUpper().Contains(searchText.ToUpper())) - { - ControleFinanceiro controleFinanceiro1 = ((Lancamento)obj).get_Controle(); - if (controleFinanceiro1 != null) - { - fornecedor = controleFinanceiro1.get_Fornecedor(); - } - else - { - fornecedor = false; - } - if (!fornecedor) - { - return false; - } - return ((Lancamento)obj).get_Controle().get_Fornecedor().get_Nome().ToString().ToUpper().Contains(searchText.ToUpper()); - } - } - } - } - return true; - }); - BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__8_0 = u003cu003e9_80; - } - return u003cu003e9_80; - } - } - - public AutoCompleteFilterPredicate PlanoItemFilter - { - get - { - AutoCompleteFilterPredicate u003cu003e9_100 = BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__10_0; - if (u003cu003e9_100 == null) - { - u003cu003e9_100 = new AutoCompleteFilterPredicate(BaseFinanceiroViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => { - if (((Plano)obj).get_Descricao().ToUpper().Contains(searchText.ToUpper())) - { - return true; - } - return ((Plano)obj).get_Descricao().ToString().Contains(searchText.ToUpper()); - }); - BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__10_0 = u003cu003e9_100; - } - return u003cu003e9_100; - } - } - - public AutoCompleteFilterPredicate PlanosItemFilter - { - get - { - AutoCompleteFilterPredicate u003cu003e9_120 = BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__12_0; - if (u003cu003e9_120 == null) - { - u003cu003e9_120 = new AutoCompleteFilterPredicate(BaseFinanceiroViewModel.u003cu003ec.u003cu003e9, (string searchText, object obj) => { - if (((Planos)obj).get_Descricao().ToUpper().Contains(searchText.ToUpper())) - { - return true; - } - return ((Planos)obj).get_Descricao().ToString().Contains(searchText.ToUpper()); - }); - BaseFinanceiroViewModel.u003cu003ec.u003cu003e9__12_0 = u003cu003e9_120; - } - return u003cu003e9_120; - } - } - - protected BaseFinanceiroViewModel() - { - } - - internal async Task> BuscarBancosContas(string value) - { - List bancosContas = await Task.Run>(() => (new BaseServico()).BuscarBancosContas(value)); - return bancosContas; - } - - internal async Task> BuscarFornecedor(string value) - { - List fornecedors = await Task.Run>(() => (new BaseServico()).BuscarFornecedor(value, false)); - return fornecedors; - } - - internal async Task> BuscarFornecedorAtivo(string value) - { - List fornecedors = await Task.Run>(() => (new BaseServico()).BuscarFornecedor(value, true)); - return fornecedors; - } - - private string DetectEncodingAndRead(string arquivo) - { - return File.ReadAllText(arquivo, BaseFinanceiroViewModel.DetectTextFileEncoding(arquivo)); - } - - public static Encoding DetectTextFileEncoding(string filePath) - { - byte[] numArray; - using (FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read)) - { - int num = (int)Math.Min(fileStream.Length, (long)4096); - numArray = new byte[num]; - fileStream.Read(numArray, 0, num); - } - if ((int)numArray.Length >= 2) - { - if ((int)numArray.Length >= 3 && numArray[0] == 239 && numArray[1] == 187 && numArray[2] == 191) - { - return Encoding.UTF8; - } - if (numArray[0] == 255 && numArray[1] == 254) - { - return Encoding.Unicode; - } - if (numArray[0] == 254 && numArray[1] == 255) - { - return Encoding.BigEndianUnicode; - } - if ((int)numArray.Length >= 4 && numArray[0] == 255 && numArray[1] == 254 && numArray[2] == 0 && numArray[3] == 0) - { - return Encoding.UTF32; - } - if ((int)numArray.Length >= 4 && numArray[0] == 0 && numArray[1] == 0 && numArray[2] == 254 && numArray[3] == 255) - { - return new UTF32Encoding(true, true); - } - } - bool flag = true; - int num1 = 0; - int num2 = 0; - for (int i = 0; i < (int)numArray.Length; i++) - { - if (numArray[i] <= 127) - { - num2++; - } - else if (numArray[i] >= 194 && numArray[i] <= 223 && i + 1 < (int)numArray.Length && numArray[i + 1] >= 128 && numArray[i + 1] <= 191) - { - num1++; - i++; - } - else if (numArray[i] >= 224 && numArray[i] <= 239 && i + 2 < (int)numArray.Length && numArray[i + 1] >= 128 && numArray[i + 1] <= 191 && numArray[i + 2] >= 128 && numArray[i + 2] <= 191) - { - num1++; - i += 2; - } - else if (numArray[i] < 240 || numArray[i] > 244 || i + 3 >= (int)numArray.Length || numArray[i + 1] < 128 || numArray[i + 1] > 191 || numArray[i + 2] < 128 || numArray[i + 2] > 191 || numArray[i + 3] < 128 || numArray[i + 3] > 191) - { - flag = false; - break; - } - else - { - num1++; - i += 3; - } - } - int num3 = 0; - for (int j = 0; j < (int)numArray.Length - 1; j += 2) - { - if (numArray[j] == 0 || numArray[j + 1] == 0) - { - num3++; - } - } - if (flag && num1 > 0) - { - return Encoding.UTF8; - } - if ((double)num2 > (double)((int)numArray.Length) * 0.95) - { - return Encoding.ASCII; - } - if ((double)num3 <= (double)((int)numArray.Length) * 0.4) - { - return Encoding.GetEncoding(1252); - } - int num4 = 0; - int num5 = 0; - for (int k = 0; k < (int)numArray.Length - 1; k += 2) - { - if (numArray[k] == 0 && numArray[k + 1] != 0) - { - num5++; - } - if (numArray[k] != 0 && numArray[k + 1] == 0) - { - num4++; - } - } - if (num4 > num5) - { - return Encoding.Unicode; - } - return Encoding.BigEndianUnicode; - } - - public async Task ExecuteRunExtendedDialogContas(System.Windows.Controls.UserControl dialogControl, string hostName) - { - BancosContas bancosConta; - IEnumerable windows = System.Windows.Application.Current.Windows.OfType(); - List list = Extentions.FindVisualChildren(windows.SingleOrDefault((Window x) => x.IsActive)).ToList(); - list.ForEach((WebEditor x) => x.Visibility = Visibility.Collapsed); - object obj = await DialogHost.Show(dialogControl, hostName, new DialogOpenedEventHandler(this, BaseViewModel.ExtendedOpenedEventHandler), new DialogClosingEventHandler(this, BaseViewModel.ExtendedClosingEventHandler)); - if (!(obj is bool)) - { - bancosConta = (BancosContas)obj; - } - else - { - bancosConta = null; - } - return bancosConta; - } - - public async Task ExecuteRunExtendedDialogTransferencia(System.Windows.Controls.UserControl dialogControl, string hostName) - { - Transferencia transferencium; - IEnumerable windows = System.Windows.Application.Current.Windows.OfType(); - List list = Extentions.FindVisualChildren(windows.SingleOrDefault((Window x) => x.IsActive)).ToList(); - list.ForEach((WebEditor x) => x.Visibility = Visibility.Collapsed); - object obj = await DialogHost.Show(dialogControl, hostName, new DialogOpenedEventHandler(this, BaseViewModel.ExtendedOpenedEventHandler), new DialogClosingEventHandler(this, BaseViewModel.ExtendedClosingEventHandler)); - if (!(obj is bool)) - { - transferencium = (Transferencia)obj; - } - else - { - transferencium = null; - } - return transferencium; - } - - public async Task ExecuteRunExtendedDialogVinculo(System.Windows.Controls.UserControl dialogControl, string hostName) - { - Lancamento lancamento; - IEnumerable windows = System.Windows.Application.Current.Windows.OfType(); - List list = Extentions.FindVisualChildren(windows.SingleOrDefault((Window x) => x.IsActive)).ToList(); - list.ForEach((WebEditor x) => x.Visibility = Visibility.Collapsed); - object obj = await DialogHost.Show(dialogControl, hostName, new DialogOpenedEventHandler(this, BaseViewModel.ExtendedOpenedEventHandler), new DialogClosingEventHandler(this, BaseViewModel.ExtendedClosingEventHandler)); - if (!(obj is bool)) - { - lancamento = (Lancamento)obj; - } - else - { - lancamento = null; - } - return lancamento; - } - - public Encoding GetEncoding(string filename) - { - byte[] numArray = new byte[4]; - using (FileStream fileStream = new FileStream(filename, FileMode.Open, FileAccess.Read)) - { - fileStream.Read(numArray, 0, 4); - } - if (numArray[0] == 43 && numArray[1] == 47 && numArray[2] == 118) - { - return Encoding.UTF7; - } - if (numArray[0] == 239 && numArray[1] == 187 && numArray[2] == 191) - { - return Encoding.UTF8; - } - if (numArray[0] == 255 && numArray[1] == 254 && numArray[2] == 0 && numArray[3] == 0) - { - return Encoding.UTF32; - } - if (numArray[0] == 255 && numArray[1] == 254) - { - return Encoding.Unicode; - } - if (numArray[0] == 254 && numArray[1] == 255) - { - return Encoding.BigEndianUnicode; - } - if (numArray[0] != 0 || numArray[1] != 0 || numArray[2] != 254 || numArray[3] != 255) - { - return Encoding.ASCII; - } - return new UTF32Encoding(true, true); - } - - public async Task> ImportarOfx() - { - List ofxDocuments; - BaseFinanceiroViewModel.u003cu003ec__DisplayClass22_0 variable; - List ofxDocuments1 = new List(); - bool flag = false; - List strs = new List(); - using (OpenFileDialog openFileDialog = new OpenFileDialog()) - { - openFileDialog.Multiselect = true; - openFileDialog.Filter = "Arquivos OFX|*.ofx"; - openFileDialog.InitialDirectory = Environment.SpecialFolder.Desktop.ToString(); - if (DialogResult.OK == openFileDialog.ShowDialog()) - { - strs.AddRange(openFileDialog.FileNames); - } - else - { - ofxDocuments = null; - variable = null; - return ofxDocuments; - } - } - await Task.Run(() => { - OfxDocumentParser ofxDocumentParser = new OfxDocumentParser(); - strs.ForEach((string x) => { - try - { - string str = DateTime.Now.Date.ToString("yyyyMMddHHmmss"); - string str1 = this.DetectEncodingAndRead(x).Replace("00000000", string.Concat("", str)).Replace("00000000000000", string.Concat("", str)).Replace(",", ".").Replace(" ", "."); - if (str1.Contains("336") && !str1.Contains("")) - { - str1 = str1.Replace("UTF - 8", "USASCII").Replace("", "\r\n\r\n0\r\n00000000\r\n").Replace("00000000", string.Concat("", str)).Replace(": ", ":").Replace(" ", "").Replace("", "0"); - } - if (str1.Contains("0403") && !str1.Contains("CHARSET:1252") && str1.Contains("ENCODING:UTF-8")) - { - str1 = str1.Replace("UTF-8", "USASCII\nCHARSET:1252").Replace("00000000", string.Concat("", str)).Replace("[0:GMT]", "").Replace(": ", ":").Replace(" ", ""); - } - if (str1.Contains("260")) - { - str1 = str1.Replace("UTF-8", "USASCII").Replace("CHARSET:NONE", "CHARSET:1252"); - } - if (str1.Contains("")) - { - str1 = str1.Replace("", "SEM INFORMAÇÃO"); - } - if (Regex.IsMatch(str1, "\\s*")) - { - str1 = str1.Replace("\n", "SEM NOME").Replace("", "SEM NOME"); - } - OfxDocument ofxDocument = ofxDocumentParser.Import(str1); - ofxDocuments1.Add(ofxDocument); - } - catch (Exception exception) - { - flag = true; - } - }); - }); - if (flag) - { - await base.ShowMessage("HOUVE PROBLEMAS AO IMPORTAR O OFX, BAIXE-O NOVAMENTE COM UM PERÍODO MENOR.", "OK", "", false); - } - ofxDocuments = ofxDocuments1; - variable = null; - return ofxDocuments; - } - - internal async Task ShowContas(List contas) - { - string str; - IEnumerable windows = System.Windows.Application.Current.Windows.OfType(); - DialogHost dialogHost = Extentions.FindVisualChildren(windows.SingleOrDefault((Window x) => x.IsActive)).FirstOrDefault(); - ContasDialog contasDialog = new ContasDialog(contas); - BaseFinanceiroViewModel baseFinanceiroViewModel = this; - ContasDialog contasDialog1 = contasDialog; - str = (dialogHost != null ? dialogHost.get_Identifier().ToString() : "RootDialog"); - return await baseFinanceiroViewModel.ExecuteRunExtendedDialogContas(contasDialog1, str); - } - - internal async Task ShowTransferencia(Transferencia transferencia) - { - string str; - IEnumerable windows = System.Windows.Application.Current.Windows.OfType(); - DialogHost dialogHost = Extentions.FindVisualChildren(windows.SingleOrDefault((Window x) => x.IsActive)).FirstOrDefault(); - DialogTransferencia dialogTransferencium = new DialogTransferencia(transferencia); - BaseFinanceiroViewModel baseFinanceiroViewModel = this; - DialogTransferencia dialogTransferencium1 = dialogTransferencium; - str = (dialogHost != null ? dialogHost.get_Identifier().ToString() : "RootDialog"); - return await baseFinanceiroViewModel.ExecuteRunExtendedDialogTransferencia(dialogTransferencium1, str); - } - - internal async Task ShowVinculo(FinanceiroViewModel viewModel) - { - string str; - IEnumerable windows = System.Windows.Application.Current.Windows.OfType(); - DialogHost dialogHost = Extentions.FindVisualChildren(windows.SingleOrDefault((Window x) => x.IsActive)).FirstOrDefault(); - VincularLancamentoDialog vincularLancamentoDialog = new VincularLancamentoDialog(viewModel); - BaseFinanceiroViewModel baseFinanceiroViewModel = this; - VincularLancamentoDialog vincularLancamentoDialog1 = vincularLancamentoDialog; - str = (dialogHost != null ? dialogHost.get_Identifier().ToString() : "RootDialog"); - return await baseFinanceiroViewModel.ExecuteRunExtendedDialogVinculo(vincularLancamentoDialog1, str); - } - } -} \ No newline at end of file -- cgit v1.2.3