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
104
105
106
107
108
109
|
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using Gestor.Application.Helpers;
using Gestor.Application.Model.Ajuda;
using Gestor.Application.Servicos.Ajuda;
using Gestor.Application.ViewModels.Generic;
using Gestor.Common.Validation;
using Gestor.Model.Domain.Generic;
using Gestor.Model.License;
namespace Gestor.Application.ViewModels.Drawer.Ajuda;
public class ContratosViewModel : BaseViewModel
{
private readonly AjudaServico _ajudaServico;
private bool _carregando;
private List<Licenca> _contratos;
private Licenca _selectedContrato;
public bool Carregando
{
get
{
return _carregando;
}
set
{
_carregando = value;
base.IsEnabled = !value;
base.EnableMenu = !value;
OnPropertyChanged("Carregando");
}
}
public List<Licenca> Contratos
{
get
{
return _contratos;
}
set
{
_contratos = value;
OnPropertyChanged("Contratos");
}
}
public Licenca SelectedContrato
{
get
{
return _selectedContrato;
}
set
{
_selectedContrato = value;
WorkOnSelectedContrato(value);
OnPropertyChanged("SelectedContrato");
}
}
public ContratosViewModel()
{
_ajudaServico = new AjudaServico();
Contratos = LicenseHelper.Produtos;
}
internal async void WorkOnSelectedContrato(Licenca value)
{
Contrato contrato = await _ajudaServico.BuscarContrato(value.Produto);
if (string.IsNullOrEmpty(contrato.HtmlContrato) && contrato.IdModulo == 7)
{
Process.Start($"https://aggilizador.com.br/Contrato.aspx?id={ApplicationHelper.IdFornecedor}");
return;
}
if (string.IsNullOrEmpty(contrato.HtmlContrato) && contrato.IdModulo != 7)
{
contrato = await _ajudaServico.BuscarContrato((Produto)1);
}
string produtos = string.Empty;
LicenseHelper.Produtos.ForEach(delegate(Licenca x)
{
//IL_0031: Unknown result type (might be due to invalid IL or missing references)
//IL_001a: Unknown result type (might be due to invalid IL or missing references)
produtos += (string.IsNullOrEmpty(produtos) ? ValidationHelper.GetDescription((Enum)(object)x.Produto) : ("/ " + ValidationHelper.GetDescription((Enum)(object)x.Produto)));
});
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<NOME>]", Recursos.Empresa.Nome);
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<ENDERECO>]", ((EnderecoBase)Recursos.Empresa).Endereco);
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<CIDADE>]", ((EnderecoBase)Recursos.Empresa).Cidade);
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<CNPJ>]", Recursos.Empresa.Documento);
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<NS>]", Recursos.Empresa.Serial);
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<DATA>]", Funcoes.GetNetworkTime().Date.ToString("dd/MM/yyyy"));
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<VALOR>]", "Conforme Mensalidade");
contrato.HtmlContrato = contrato.HtmlContrato.Replace("[<OUTROS>]", produtos.Replace("*", ""));
string tempPath = Path.GetTempPath();
string text = string.Format("{0}{1}_{2:ddMMyyyyhhmmss}.html", tempPath, new Regex("[" + Regex.Escape(new string(Path.GetInvalidFileNameChars()) + new string(Path.GetInvalidPathChars())) + "]").Replace(ValidationHelper.GetDescription((Enum)(object)value.Produto), ""), Funcoes.GetNetworkTime());
StreamWriter streamWriter = new StreamWriter(text, append: true, Encoding.UTF8);
streamWriter.Write(contrato.HtmlContrato);
streamWriter.Close();
Process.Start(text);
}
}
|