16 |
class FilterController |
class FilterController |
17 |
{ |
{ |
18 |
|
|
19 |
|
public const int TRANSACTIONS_PER_RUN = 2000; |
20 |
|
|
21 |
public string mqHost { get; private set; } |
public string mqHost { get; private set; } |
22 |
public string mqChannel { get; private set; } |
public string mqChannel { get; private set; } |
23 |
public string mqQueueManager { get; private set; } |
public string mqQueueManager { get; private set; } |
34 |
public static readonly string queueNameMysql = "DAO.ALL"; |
public static readonly string queueNameMysql = "DAO.ALL"; |
35 |
public static readonly string queueNameStore = "DAO.STORE"; |
public static readonly string queueNameStore = "DAO.STORE"; |
36 |
|
|
37 |
|
TimeSpan silentPeriodBegin; |
38 |
|
TimeSpan silentPeriodEnd; |
39 |
|
|
40 |
protected FilterController() |
protected FilterController() |
41 |
{ |
{ |
88 |
|
|
89 |
//////////// |
//////////// |
90 |
|
|
91 |
|
string silentBeginStr = (string)key.GetValue("SilentPeriodBegin"); |
92 |
|
if (silentBeginStr == null || silentBeginStr.Length == 0) |
93 |
|
{ |
94 |
|
key.SetValue("SilentPeriodBegin", "", RegistryValueKind.String); |
95 |
|
throw new System.ArgumentException("SilentPeriodBegin cannot be null or empty"); |
96 |
|
} |
97 |
|
silentPeriodBegin = TimeSpan.Parse(silentBeginStr); |
98 |
|
|
99 |
|
string silentEndStr = (string)key.GetValue("SilentPeriodEnd"); |
100 |
|
if (silentEndStr == null || silentEndStr.Length == 0) |
101 |
|
{ |
102 |
|
key.SetValue("SilentPeriodEnd", "", RegistryValueKind.String); |
103 |
|
throw new System.ArgumentException("SilentPeriodEnd cannot be null or empty"); |
104 |
|
} |
105 |
|
silentPeriodEnd = TimeSpan.Parse(silentEndStr); |
106 |
|
|
107 |
|
//////////// |
108 |
|
|
109 |
String tmpFilterTransactions = (string)key.GetValue("FilterTransactions"); |
String tmpFilterTransactions = (string)key.GetValue("FilterTransactions"); |
110 |
if (tmpFilterTransactions == null || tmpFilterTransactions.Length == 0) |
if (tmpFilterTransactions == null || tmpFilterTransactions.Length == 0) |
111 |
{ |
{ |
136 |
catch (Exception e) |
catch (Exception e) |
137 |
{ |
{ |
138 |
logFile.addSingleLogEntry("Error during transportAllMessages: " + e.Message); |
logFile.addSingleLogEntry("Error during transportAllMessages: " + e.Message); |
139 |
|
Console.WriteLine(e.StackTrace); |
140 |
} |
} |
141 |
} |
} |
142 |
|
|
183 |
queueIndbakke.Get(mqMsg, mqGetMsgOpts); |
queueIndbakke.Get(mqMsg, mqGetMsgOpts); |
184 |
if (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) == 0) |
if (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) == 0) |
185 |
{ |
{ |
186 |
|
if (mqMsg.MessageLength == 0) //Skip empty transactions (so far only seen on my test server) |
187 |
|
continue; |
188 |
|
|
189 |
|
//System.Console.WriteLine("LEN>" + mqMsg.MessageLength); |
190 |
string salt2String = mqMsg.ReadString(mqMsg.MessageLength); |
string salt2String = mqMsg.ReadString(mqMsg.MessageLength); |
191 |
//System.Console.WriteLine(msgString); |
|
192 |
|
|
193 |
|
|
194 |
// validér at headeren er gyldig |
// validér at headeren er gyldig |
227 |
|
|
228 |
|
|
229 |
messageCount++;// increment per run message counter |
messageCount++;// increment per run message counter |
230 |
if (messageCount >= 10000) // if we have moved 10000 messages in this run - let it go |
if (messageCount >= TRANSACTIONS_PER_RUN) // if we have moved TRANSACTIONS_PER_RUN messages in this run - let it go |
231 |
{ |
{ |
232 |
isContinue = false; |
isContinue = false; |
233 |
} |
} |
279 |
private Boolean saveForLater(Salt2Header header) |
private Boolean saveForLater(Salt2Header header) |
280 |
{ |
{ |
281 |
|
|
282 |
DateTime now = DateTime.Now; |
TimeSpan now = DateTime.Now.TimeOfDay; |
283 |
int hour = now.Hour; |
|
284 |
if (hour >= 14 && hour < 18) |
if (now >= silentPeriodBegin && now < silentPeriodEnd) |
285 |
{ |
{ |
286 |
|
|
287 |
|
if (header.afsender == "DAO") //DAO transaktioner må altid komme igennem |
288 |
|
return false; |
289 |
|
|
290 |
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) |
291 |
{ |
{ |