/
SettlementTask.cs
148 lines (124 loc) · 4.54 KB
/
SettlementTask.cs
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
using Aplicacion.Process;
using Microsoft.Practices.EnterpriseLibrary.Logging;
using Quartz;
using System;
using System.Diagnostics;
using Utilitarios.CustomDatabaseTraceListener;
using Utilitarios.Excepciones;
namespace WindowsService_HostAPI
{
[DisallowConcurrentExecutionAttribute]
public class SettlementTask : IJob, IDisposable
{
#region Miembros
/// <summary>
///
/// </summary>
private SettlementServicioScheduler settlementServicio;
#endregion
#region Constructor
/// <summary>
///
/// </summary>
/// <param name="_processSchedulerServicio"></param>
public SettlementTask()
{
this.settlementServicio = new SettlementServicioScheduler();
}
#endregion
#region Métodos Base
/// <summary>
///
/// </summary>
/// <param name="context"></param>
public void Execute(IJobExecutionContext context)
{
var newGuid = Guid.NewGuid();
var logWritter = Logger.Writer;
var traceManager = new TraceManager(logWritter);
using (traceManager.StartTrace("Scheduler Execution Error", newGuid))
{
try
{
this.InsertarCustomLogEntryScheduler(logWritter, "Inicio Proceso Scheduler Settlement", TraceEventType.Information, "Scheduler", "Settlement Scheduler Information");
JobDataMap dataMap = context.JobDetail.JobDataMap;
var countryId = int.Parse(dataMap.GetString("countryId"));
var currencyId = int.Parse(dataMap.GetString("currencyId"));
var transactionTypeConfigurationCountryCurrencyId = int.Parse(dataMap.GetString("transactionTypeConfigurationCountryCurrencyId"));
this.settlementServicio.ProcesoSchedulerSettlementInit(countryId, currencyId, "Scheduler", transactionTypeConfigurationCountryCurrencyId);
this.InsertarCustomLogEntryScheduler(logWritter, "Fin Proceso Scheduler Settlement", TraceEventType.Information, "Scheduler", "Settlement Scheduler Information");
}
catch (JobExecutionException jEx)
{
ProveedorExcepciones.ManejaExcepcion(jEx, "PoliticaSchedulerExecutionError");
}
catch (Exception ex)
{
ProveedorExcepciones.ManejaExcepcion(ex, "PoliticaSchedulerExecutionError");
}
}
}
#endregion
#region Métodos Privados
/// <summary>
///
/// </summary>
/// <param name="message"></param>
/// <param name="traceEventType"></param>
/// <param name="customData"></param>
/// <param name="Title"></param>
/// <returns></returns>
private void InsertarCustomLogEntryScheduler(LogWriter logWriter, string message, TraceEventType traceEventType, string customData, string title)
{
var customLogEntry = new CustomLogEntry()
{
Categories = new string[] { "Scheduler Execution Error" },
Message = message,
Severity = traceEventType,
CustomData = customData,
Title = title
};
logWriter.Write(customLogEntry);
}
#endregion
#region IDisposable Implementation
/// <summary>
///
/// </summary>
~SettlementTask()
{
Dispose(false);
}
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
/// <summary>
///
/// </summary>
/// <param name="disposing"></param>
public virtual void Dispose(bool disposing)
{
if (disposing)
{
SettlementDispose();
}
}
/// <summary>
///
/// </summary>
private void SettlementDispose()
{
if (this.settlementServicio != null)
{
if (this.settlementServicio is IDisposable)
{
((IDisposable)this.settlementServicio).Dispose();
}
this.settlementServicio = null;
}
}
#endregion
}
}