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 _arquivos = new ObservableCollection(); public ObservableCollection 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(); ((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 Importar(List 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) { } }); } }