summaryrefslogtreecommitdiff
path: root/Decompiler/Gestor.Application.Servicos.Financeiro/PlanoServico.cs
blob: 166690de043d1e2bed95ba20f7db50c9a19f35f0 (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
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Threading.Tasks;
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Generic;
using Gestor.Application.ViewModels;
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;
using Newtonsoft.Json;

namespace Gestor.Application.Servicos.Financeiro;

internal class PlanoServico : BaseServico
{
	public async Task<Plano> Save(Plano plano)
	{
		int tries = 3;
		base.Sucesso = true;
		Plano planoOriginal = plano;
		return await Task.Run((Func<Plano>)delegate
		{
			//IL_0028: Unknown result type (might be due to invalid IL or missing references)
			//IL_006b: Unknown result type (might be due to invalid IL or missing references)
			//IL_0070: Unknown result type (might be due to invalid IL or missing references)
			//IL_0071: Unknown result type (might be due to invalid IL or missing references)
			//IL_0077: Unknown result type (might be due to invalid IL or missing references)
			//IL_0082: Unknown result type (might be due to invalid IL or missing references)
			//IL_008d: Unknown result type (might be due to invalid IL or missing references)
			//IL_0094: Unknown result type (might be due to invalid IL or missing references)
			//IL_0099: Unknown result type (might be due to invalid IL or missing references)
			//IL_00a5: Expected O, but got Unknown
			//IL_00aa: Unknown result type (might be due to invalid IL or missing references)
			//IL_00bb: Unknown result type (might be due to invalid IL or missing references)
			//IL_00c3: Unknown result type (might be due to invalid IL or missing references)
			//IL_00ce: Unknown result type (might be due to invalid IL or missing references)
			//IL_00d9: Unknown result type (might be due to invalid IL or missing references)
			//IL_00e4: Unknown result type (might be due to invalid IL or missing references)
			//IL_0121: Expected O, but got Unknown
			while (tries > 0)
			{
				plano = planoOriginal;
				try
				{
					UnitOfWork commited = Instancia.Commited;
					try
					{
						TipoAcao acao = (TipoAcao)(((DomainBase)plano).Id != 0L);
						plano = ((((DomainBase)plano).Id == 0L) ? commited.PlanoRepository.SaveOrUpdate(plano) : commited.PlanoRepository.Merge(plano));
						IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
						RegistroLog keyValues = new RegistroLog
						{
							Acao = acao,
							Usuario = Recursos.Usuario,
							DataHora = Funcoes.GetNetworkTime(),
							Descricao = JsonConvert.SerializeObject((object)plano, new JsonSerializerSettings
							{
								ReferenceLoopHandling = (ReferenceLoopHandling)1
							}),
							EntidadeId = ((DomainBase)plano).Id,
							Tela = (TipoTela)27,
							Versao = LoginViewModel.VersaoAtual,
							NomeMaquina = Environment.MachineName,
							UsuarioMaquina = Environment.UserName,
							Ip = hostEntry.AddressList.FirstOrDefault((IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork)?.ToString()
						};
						SaveLog(keyValues, commited);
						((GenericUnitOfWork)commited).Commit();
						return plano;
					}
					finally
					{
						((IDisposable)commited)?.Dispose();
					}
				}
				catch (Exception e)
				{
					tries = Registrar(e, (TipoErro)250, tries, plano);
				}
			}
			return planoOriginal;
		});
	}

	public async Task<List<Planos>> BuscarPlanos()
	{
		int tries = 3;
		return await Task.Run(delegate
		{
			while (tries > 0)
			{
				try
				{
					UnitOfWork read = Instancia.Read;
					try
					{
						return read.PlanosRepository.Find();
					}
					finally
					{
						((IDisposable)read)?.Dispose();
					}
				}
				catch (Exception e)
				{
					tries = Registrar(e, (TipoErro)167, tries);
				}
			}
			return new List<Planos>();
		});
	}
}