diff options
| author | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
|---|---|---|
| committer | Lucas Faria Mendes <lucas.fariamo08@gmail.com> | 2026-03-30 15:29:41 +0000 |
| commit | 225aa1499e37faf9d38257caabbadc68d78b427e (patch) | |
| tree | 102bb7a40c58595348ae9d3c7076201759fe0720 /Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs | |
| parent | 1f4e14b2e973ee7de337fd4866d9a5ceff5cb6d1 (diff) | |
| download | gestor-225aa1499e37faf9d38257caabbadc68d78b427e.tar.gz gestor-225aa1499e37faf9d38257caabbadc68d78b427e.zip | |
decompiler.com
Diffstat (limited to 'Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs')
| -rw-r--r-- | Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs | 103 |
1 files changed, 103 insertions, 0 deletions
diff --git a/Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs b/Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs new file mode 100644 index 0000000..34daacf --- /dev/null +++ b/Decompiler/Gestor.Application.ViewModels/ImportViewModel.cs @@ -0,0 +1,103 @@ +using System; +using System.Collections.Generic; +using System.Collections.ObjectModel; +using System.Diagnostics; +using System.Linq; +using System.Threading.Tasks; +using Gestor.Application.Helpers; +using Gestor.Application.ViewModels.Generic; +using Gestor.Model.Domain.Generic; +using Microsoft.Win32; + +namespace Gestor.Application.ViewModels; + +public class ImportViewModel : BaseViewModel +{ + private ObservableCollection<Arquivo> _arquivos = new ObservableCollection<Arquivo>(); + + public ObservableCollection<Arquivo> Arquivos + { + get + { + return _arquivos; + } + set + { + _arquivos = value; + OnPropertyChanged("Arquivos"); + } + } + + public void CarregarArquivos() + { + //IL_0000: Unknown result type (might be due to invalid IL or missing references) + //IL_0005: Unknown result type (might be due to invalid IL or missing references) + //IL_0010: Unknown result type (might be due to invalid IL or missing references) + //IL_001b: Unknown result type (might be due to invalid IL or missing references) + //IL_0023: Expected O, but got Unknown + OpenFileDialog val = new OpenFileDialog + { + Title = "Selecione o PDF", + Filter = "Arquivos PDF|*.pdf", + Multiselect = true + }; + if (((CommonDialog)val).ShowDialog().GetValueOrDefault()) + { + Arquivos = new ObservableCollection<Arquivo>(); + ((FileDialog)val).FileNames.ToList().ForEach(delegate(string x) + { + Arquivos.Add(new Arquivo + { + Nome = x, + Processo = 0 + }); + }); + } + } + + public void Importar() + { + new TaskFactory().StartNew(() => Importar(Arquivos.ToList())); + } + + public async Task<bool> Importar(List<Arquivo> arquivos) + { + arquivos.ForEach(async delegate(Arquivo x) + { + await Import(x); + }); + return true; + } + + public async Task Import(Arquivo arquivo) + { + await Task.Run(delegate + { + try + { + Process process = new Process + { + StartInfo = new ProcessStartInfo + { + FileName = "C:\\AggerSeguros\\Agger.Import201911261630\\Agger.ImportPDF.exe", + Arguments = $" {((DomainBase)Recursos.Empresa).Id} {((DomainBase)Recursos.Usuario).Id} NOVOGESTOR {arquivo.Nome}", + UseShellExecute = false, + RedirectStandardOutput = true, + CreateNoWindow = true + } + }; + process.Start(); + process.WaitForExit(); + string text = process.StandardError.ReadToEnd(); + string text2 = process.StandardOutput.ReadToEnd(); + if (process.ExitCode != 0) + { + throw new Exception("netsh exit code: " + process.ExitCode + " " + ((!string.IsNullOrEmpty(text)) ? (" " + text) : "") + " " + ((!string.IsNullOrEmpty(text2)) ? (" " + text2) : "")); + } + } + catch (Exception) + { + } + }); + } +} |