blob: 34daacf497e56df27c39e10ffe10e7445685a28d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
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)
{
}
});
}
}
|