--- dao/DaoMqPump2/MQFilter/FilterController.cs 2014/05/19 19:51:47 2177 +++ dao/DaoMqPump2/MQFilter/FilterController.cs 2014/05/21 09:56:21 2183 @@ -16,6 +16,8 @@ class FilterController { + public const int TRANSACTIONS_PER_RUN = 2000; + public string mqHost { get; private set; } public string mqChannel { get; private set; } public string mqQueueManager { get; private set; } @@ -32,6 +34,8 @@ public static readonly string queueNameMysql = "DAO.ALL"; public static readonly string queueNameStore = "DAO.STORE"; + TimeSpan silentPeriodBegin; + TimeSpan silentPeriodEnd; protected FilterController() { @@ -84,6 +88,24 @@ //////////// + string silentBeginStr = (string)key.GetValue("SilentPeriodBegin"); + if (silentBeginStr == null || silentBeginStr.Length == 0) + { + key.SetValue("SilentPeriodBegin", "", RegistryValueKind.String); + throw new System.ArgumentException("SilentPeriodBegin cannot be null or empty"); + } + silentPeriodBegin = TimeSpan.Parse(silentBeginStr); + + string silentEndStr = (string)key.GetValue("SilentPeriodEnd"); + if (silentEndStr == null || silentEndStr.Length == 0) + { + key.SetValue("SilentPeriodEnd", "", RegistryValueKind.String); + throw new System.ArgumentException("SilentPeriodEnd cannot be null or empty"); + } + silentPeriodEnd = TimeSpan.Parse(silentEndStr); + + //////////// + String tmpFilterTransactions = (string)key.GetValue("FilterTransactions"); if (tmpFilterTransactions == null || tmpFilterTransactions.Length == 0) { @@ -114,6 +136,7 @@ catch (Exception e) { logFile.addSingleLogEntry("Error during transportAllMessages: " + e.Message); + Console.WriteLine(e.StackTrace); } } @@ -160,8 +183,12 @@ queueIndbakke.Get(mqMsg, mqGetMsgOpts); if (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) == 0) { + if (mqMsg.MessageLength == 0) //Skip empty transactions (so far only seen on my test server) + continue; + + //System.Console.WriteLine("LEN>" + mqMsg.MessageLength); string salt2String = mqMsg.ReadString(mqMsg.MessageLength); - //System.Console.WriteLine(msgString); + // validér at headeren er gyldig @@ -200,7 +227,7 @@ messageCount++;// increment per run message counter - 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 { isContinue = false; } @@ -252,10 +279,13 @@ private Boolean saveForLater(Salt2Header header) { - DateTime now = DateTime.Now; - int hour = now.Hour; - if (hour >= 14 && hour < 18) + TimeSpan now = DateTime.Now.TimeOfDay; + + if (now >= silentPeriodBegin && now < silentPeriodEnd) { + + if (header.afsender == "DAO") //DAO transaktioner må altid komme igennem + return false; if (contains(header.transaktionForkortelse, this.filterTranscations) ) //Så længe vi skal være .net3.0 kompatible er LINQ problematisk (LINQ kræver 3.5) {