24 |
|
|
25 |
public string[] filterTranscations { get; private set; } |
public string[] filterTranscations { get; private set; } |
26 |
|
|
27 |
|
Logfile logFile; |
28 |
|
|
29 |
|
|
30 |
public static readonly string queueNameIndbakke = "DAO.INDBAKKE"; |
public static readonly string queueNameIndbakke = "DAO.INDBAKKE"; |
31 |
public static readonly string queueNameDimaps = "DAO.SAMLET"; |
public static readonly string queueNameDimaps = "DAO.SAMLET"; |
32 |
public static readonly string queueNameMysql = "DAO.ALL"; |
public static readonly string queueNameMysql = "DAO.ALL"; |
33 |
public static readonly string queueNameStore = "DAO.STORE"; |
public static readonly string queueNameStore = "DAO.STORE"; |
34 |
|
|
35 |
|
TimeSpan silentPeriodBegin; |
36 |
|
TimeSpan silentPeriodEnd; |
37 |
|
|
38 |
protected FilterController() |
protected FilterController() |
39 |
{ |
{ |
40 |
initialize(); |
initialize(); |
41 |
|
logFile = new Logfile(LogfileType.LogEvents, "filter", logDirectory); |
42 |
|
logFile.addSingleLogEntry("Starting service"); |
43 |
} |
} |
44 |
|
|
45 |
private void initialize() |
private void initialize() |
86 |
|
|
87 |
//////////// |
//////////// |
88 |
|
|
89 |
|
string silentBeginStr = (string)key.GetValue("SilentPeriodBegin"); |
90 |
|
if (silentBeginStr == null || silentBeginStr.Length == 0) |
91 |
|
{ |
92 |
|
key.SetValue("SilentPeriodBegin", "", RegistryValueKind.String); |
93 |
|
throw new System.ArgumentException("SilentPeriodBegin cannot be null or empty"); |
94 |
|
} |
95 |
|
silentPeriodBegin = TimeSpan.Parse(silentBeginStr); |
96 |
|
|
97 |
|
string silentEndStr = (string)key.GetValue("SilentPeriodEnd"); |
98 |
|
if (silentEndStr == null || silentEndStr.Length == 0) |
99 |
|
{ |
100 |
|
key.SetValue("SilentPeriodEnd", "", RegistryValueKind.String); |
101 |
|
throw new System.ArgumentException("SilentPeriodEnd cannot be null or empty"); |
102 |
|
} |
103 |
|
silentPeriodEnd = TimeSpan.Parse(silentEndStr); |
104 |
|
|
105 |
|
//////////// |
106 |
|
|
107 |
String tmpFilterTransactions = (string)key.GetValue("FilterTransactions"); |
String tmpFilterTransactions = (string)key.GetValue("FilterTransactions"); |
108 |
if (tmpFilterTransactions == null || tmpFilterTransactions.Length == 0) |
if (tmpFilterTransactions == null || tmpFilterTransactions.Length == 0) |
109 |
{ |
{ |
125 |
|
|
126 |
|
|
127 |
|
|
|
|
|
128 |
public void transportAllMessages() |
public void transportAllMessages() |
129 |
{ |
{ |
130 |
|
try |
131 |
|
{ |
132 |
|
transportMessagesWorker(); |
133 |
|
} |
134 |
|
catch (Exception e) |
135 |
|
{ |
136 |
|
logFile.addSingleLogEntry("Error during transportAllMessages: " + e.Message); |
137 |
|
} |
138 |
|
} |
139 |
|
|
140 |
|
private void transportMessagesWorker() |
141 |
|
{ |
142 |
int messageCount = 0; |
int messageCount = 0; |
143 |
|
|
144 |
MQQueueManager mqMgr = null; |
MQQueueManager mqMgr = null; |
146 |
MQQueue queueMysql = null; |
MQQueue queueMysql = null; |
147 |
MQQueue queueDimaps = null; |
MQQueue queueDimaps = null; |
148 |
MQQueue queueStore = null; |
MQQueue queueStore = null; |
149 |
|
|
150 |
|
using (Logfile translog = new Logfile(LogfileType.LogTransactions, "filter", logDirectory)) |
151 |
try |
try |
152 |
{ |
{ |
153 |
//MQ options |
//MQ options |
187 |
// validér at headeren er gyldig |
// validér at headeren er gyldig |
188 |
if ( Salt2Helper.validateSalt2Header(salt2String) == false) |
if ( Salt2Helper.validateSalt2Header(salt2String) == false) |
189 |
{ |
{ |
190 |
string discarded_filename = Logfile.getLogFilename(LogfileType.LogTransactions, logDirectory, "filter"); |
|
191 |
using (StreamWriter discardedlog = new StreamWriter(discarded_filename, true)) |
|
192 |
|
using (Logfile discardedlog = new Logfile(LogfileType.LogDiscarded, "filter", logDirectory)) |
193 |
{ |
{ |
194 |
discardedlog.WriteLine(Logfile.getNowString() + " " + salt2String); |
discardedlog.writeLogEntry(salt2String); |
195 |
} |
} |
196 |
continue; //gå frem til at tage næste transaktion fra køen |
continue; //gå frem til at tage næste transaktion fra køen |
197 |
} |
} |
198 |
|
|
199 |
|
translog.writeLogEntry(salt2String); |
200 |
|
|
201 |
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults, |
MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults, |
202 |
// same as MQPMO_DEFAULT |
// same as MQPMO_DEFAULT |
203 |
|
|
217 |
queueDimaps.Put(msg, pmo); |
queueDimaps.Put(msg, pmo); |
218 |
} |
} |
219 |
|
|
220 |
|
|
221 |
|
|
222 |
messageCount++;// increment per run message counter |
messageCount++;// increment per run message counter |
223 |
if (messageCount >= 10000) // if we have moved 10000 messages in this run - let it go |
if (messageCount >= 10000) // if we have moved 10000 messages in this run - let it go |
272 |
private Boolean saveForLater(Salt2Header header) |
private Boolean saveForLater(Salt2Header header) |
273 |
{ |
{ |
274 |
|
|
275 |
DateTime now = DateTime.Now; |
TimeSpan now = DateTime.Now.TimeOfDay; |
276 |
int hour = now.Hour; |
|
277 |
if (hour >= 14 && hour < 18) |
if (now >= silentPeriodBegin && now < silentPeriodEnd) |
278 |
{ |
{ |
279 |
|
|
280 |
if (contains(header.transaktionForkortelse, this.filterTranscations) ) //Så længe vi skal være .net3.0 kompatible er LINQ problematisk (LINQ kræver 3.5) |
if (contains(header.transaktionForkortelse, this.filterTranscations) ) //Så længe vi skal være .net3.0 kompatible er LINQ problematisk (LINQ kræver 3.5) |