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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
|
using Gestor.Application.Helpers;
using Gestor.Application.Servicos.Generic;
using Gestor.Application.ViewModels;
using Gestor.Infrastructure.Repository.Interface;
using Gestor.Infrastructure.UnitOfWork.Generic;
using Gestor.Infrastructure.UnitOfWork.Logic;
using Gestor.Model.Common;
using Gestor.Model.Domain.Common;
using Gestor.Model.Domain.Generic;
using Gestor.Model.Domain.Seguros;
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Net;
using System.Net.Sockets;
using System.Runtime.CompilerServices;
using System.Threading.Tasks;
namespace Gestor.Application.Servicos.Seguros
{
public class ExpedicaoServico : BaseServico
{
public ExpedicaoServico()
{
}
public async Task<List<Expedicao>> BuscarExpedicoes(Documento documento)
{
int num = 3;
List<Expedicao> expedicaos1 = await Task.Run<List<Expedicao>>(() => {
List<Expedicao> expedicaos;
while (num > 0)
{
try
{
using (UnitOfWork read = Instancia.Read)
{
expedicaos = read.get_ExpedicaoRepository().FindByIdDocumento(documento.get_Id());
}
}
catch (Exception exception)
{
num = base.Registrar(exception, 289, num, documento, true);
continue;
}
return expedicaos;
}
return new List<Expedicao>();
});
return expedicaos1;
}
public async Task<bool> Delete(Expedicao expedicao)
{
int num = 3;
bool flag1 = await Task.Run<bool>(() => {
bool flag;
string str;
while (num > 0)
{
try
{
using (UnitOfWork commited = Instancia.Commited)
{
commited.get_ExpedicaoRepository().Delete(expedicao.get_Id());
DateTime networkTime = Funcoes.GetNetworkTime();
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
RegistroLog registroLog = new RegistroLog();
registroLog.set_Acao(2);
registroLog.set_Usuario(Recursos.Usuario);
registroLog.set_DataHora(networkTime);
registroLog.set_Descricao(string.Concat(new string[] { string.Format("O USUÁRIO {0} EXCLUIU, EM {1}, A EXPEDIÇÃO DE ", Recursos.Usuario.get_Nome(), networkTime), string.Format("ID: '{0}'", expedicao.get_Id()), ", DOCUMENTO: '", expedicao.get_Documento(), "', DESTINO: '", expedicao.get_Destino(), "'", string.Format(", DATA ENVIO: '{0}'", expedicao.get_DataEnvio()), string.Format(", DATA RECEBIMENTO: '{0}'", expedicao.get_DataRecebimento()), ", RESPONSÁVEL: 'R$", expedicao.get_Responsavel(), "'." }));
registroLog.set_EntidadeId(expedicao.get_Id());
registroLog.set_Versao(LoginViewModel.VersaoAtual);
registroLog.set_Tela(46);
registroLog.set_NomeMaquina(Environment.MachineName);
registroLog.set_UsuarioMaquina(Environment.UserName);
RegistroLog registroLog1 = registroLog;
IPAddress[] addressList = hostEntry.AddressList;
Func<IPAddress, bool> u003cu003e9_21 = ExpedicaoServico.u003cu003ec.u003cu003e9__2_1;
if (u003cu003e9_21 == null)
{
u003cu003e9_21 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
ExpedicaoServico.u003cu003ec.u003cu003e9__2_1 = u003cu003e9_21;
}
IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_21);
if (pAddress != null)
{
str = pAddress.ToString();
}
else
{
str = null;
}
registroLog1.set_Ip(str);
base.SaveLog(registroLog, commited);
commited.Commit();
flag = true;
}
}
catch (Exception exception)
{
num = base.Registrar(exception, 291, num, expedicao, true);
continue;
}
return flag;
}
return false;
});
return flag1;
}
public async Task<Expedicao> Save(Expedicao expedicao)
{
int num = 3;
base.Sucesso = true;
Expedicao expedicao2 = expedicao;
Expedicao expedicao3 = await Task.Run<Expedicao>(() => {
Expedicao expedicao4;
string str;
while (num > 0)
{
expedicao = expedicao2;
try
{
using (UnitOfWork commited = Instancia.Commited)
{
TipoAcao tipoAcao = (expedicao.get_Id() == 0 ? 0 : 1);
DateTime networkTime = Funcoes.GetNetworkTime();
if (expedicao.get_Id() != 0)
{
expedicao.set_UsuarioAlteracao(new long?(Recursos.Usuario.get_Id()));
expedicao.set_DataAlteracao(new DateTime?(networkTime));
expedicao = commited.get_ExpedicaoRepository().Merge(expedicao);
}
else
{
expedicao.set_UsuarioCriacao(new long?(Recursos.Usuario.get_Id()));
expedicao.set_DataCriacao(new DateTime?(networkTime));
expedicao = commited.get_ExpedicaoRepository().SaveOrUpdate(expedicao);
}
IPHostEntry hostEntry = Dns.GetHostEntry(Dns.GetHostName());
RegistroLog registroLog = new RegistroLog();
registroLog.set_Acao(tipoAcao);
registroLog.set_Usuario(Recursos.Usuario);
registroLog.set_DataHora(networkTime);
Expedicao expedicao1 = expedicao;
JsonSerializerSettings jsonSerializerSetting = new JsonSerializerSettings();
jsonSerializerSetting.set_ReferenceLoopHandling(1);
registroLog.set_Descricao(JsonConvert.SerializeObject(expedicao1, jsonSerializerSetting));
registroLog.set_EntidadeId(expedicao.get_Id());
registroLog.set_Tela(46);
registroLog.set_Versao(LoginViewModel.VersaoAtual);
registroLog.set_NomeMaquina(Environment.MachineName);
registroLog.set_UsuarioMaquina(Environment.UserName);
IPAddress[] addressList = hostEntry.AddressList;
Func<IPAddress, bool> u003cu003e9_11 = ExpedicaoServico.u003cu003ec.u003cu003e9__1_1;
if (u003cu003e9_11 == null)
{
u003cu003e9_11 = (IPAddress ip) => ip.AddressFamily == AddressFamily.InterNetwork;
ExpedicaoServico.u003cu003ec.u003cu003e9__1_1 = u003cu003e9_11;
}
IPAddress pAddress = ((IEnumerable<IPAddress>)addressList).FirstOrDefault<IPAddress>(u003cu003e9_11);
if (pAddress != null)
{
str = pAddress.ToString();
}
else
{
str = null;
}
registroLog.set_Ip(str);
base.SaveLog(registroLog, commited);
commited.Commit();
expedicao4 = expedicao;
}
}
catch (Exception exception)
{
num = base.Registrar(exception, 290, num, expedicao, true);
continue;
}
return expedicao4;
}
return expedicao2;
});
return expedicao3;
}
}
}
|