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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
|
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Generic;
using Gestor.Infrastructure.UnitOfWork.Generic;
using Gestor.Infrastructure.UnitOfWork.Logic;
using Gestor.Model.API;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Financeiro;
using Gestor.Model.Domain.Generic;
namespace Gestor.Application.Servicos.Financeiro;
public class FornecedorServico : BaseServico
{
public async Task<Fornecedor> Save(Fornecedor fornecedor)
{
int tries = 3;
base.Sucesso = true;
Fornecedor fornecedorOriginal = fornecedor;
return await Task.Run((Func<Fornecedor>)delegate
{
//IL_002e: Unknown result type (might be due to invalid IL or missing references)
//IL_002f: Unknown result type (might be due to invalid IL or missing references)
//IL_0031: Invalid comparison between Unknown and I4
//IL_0058: Unknown result type (might be due to invalid IL or missing references)
//IL_0084: Unknown result type (might be due to invalid IL or missing references)
while (tries > 0)
{
List<RegistroLog> list = new List<RegistroLog>();
fornecedor = fornecedorOriginal;
try
{
UnitOfWork commited = Instancia.Commited;
try
{
TipoAcao val = (TipoAcao)(fornecedor.Id != 0L);
if ((int)val == 1)
{
list.Add(CreateLog(fornecedor.Id, fornecedor, (TipoTela)24));
}
fornecedor = (((int)val == 0) ? commited.FornecedorRepository.SaveOrUpdate(fornecedor) : commited.FornecedorRepository.Merge(fornecedor));
if ((int)val == 0)
{
list.Add(CreateLog(fornecedor.Id, ((DomainBase)fornecedor).GetValorOriginal(), (TipoTela)24, (TipoAcao)0));
}
SaveLog(list, commited);
((GenericUnitOfWork)commited).Commit();
return fornecedor;
}
finally
{
((IDisposable)commited)?.Dispose();
}
}
catch (Exception e)
{
tries = Registrar(e, (TipoErro)243, tries, fornecedor);
}
}
return fornecedorOriginal;
});
}
public async Task<bool> Delete(Fornecedor fornecedor)
{
int tries = 3;
return await Task.Run(delegate
{
while (tries > 0)
{
List<RegistroLog> list = new List<RegistroLog>();
try
{
UnitOfWork commited = Instancia.Commited;
try
{
list.Add(CreateLog(fornecedor.Id, ((DomainBase)fornecedor).GetValorOriginal(), (TipoTela)24, (TipoAcao)2));
commited.FornecedorRepository.Delete(fornecedor.Id);
SaveLog(list, commited);
((GenericUnitOfWork)commited).Commit();
return true;
}
finally
{
((IDisposable)commited)?.Dispose();
}
}
catch (Exception e)
{
tries = Registrar(e, (TipoErro)244, tries, fornecedor);
}
}
return false;
});
}
public async Task<List<Fornecedor>> BuscarFornecedores()
{
int tries = 3;
return await Task.Run(delegate
{
while (tries > 0)
{
try
{
UnitOfWork read = Instancia.Read;
try
{
return read.FornecedorRepository.Find();
}
finally
{
((IDisposable)read)?.Dispose();
}
}
catch (Exception e)
{
tries = Registrar(e, (TipoErro)166, tries);
}
}
return new List<Fornecedor>();
});
}
}
|