/[projects]/dao/DaoMqPump2/DaoMqPump2/Transport.cs
ViewVC logotype

Diff of /dao/DaoMqPump2/DaoMqPump2/Transport.cs

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1986 by torben, Wed Jul 3 07:56:52 2013 UTC revision 2086 by torben, Wed Nov 27 09:46:11 2013 UTC
# Line 7  using System.Diagnostics; Line 7  using System.Diagnostics;
7    
8  using IBM.WMQ;  using IBM.WMQ;
9  using MySql.Data.MySqlClient;  using MySql.Data.MySqlClient;
10    using System.Globalization;
11    
12  namespace DaoMqPump2  namespace DaoMqPump2
13  {  {
14      public class Transport      public class Transport
15      {      {
16    
17            enum LogfileType {
18                LogTransactions,
19                LogEvents,
20                LogDiscarded
21            }
22    
23          public static string SQL2MQ = "sql2mq";          public static string SQL2MQ = "sql2mq";
24          public static string MQ2SQL = "mq2sql";          public static string MQ2SQL = "mq2sql";
25    
26            //private bool enabled;        
         public bool enabled { get; set; }  
27    
28          TransportController controller;          TransportController controller;
29    
30            StatusData statusData = new StatusData();
31    
32          public string name { get; private set; }          public string name { get; private set; }
33          public string direction { get; private set; }          public string direction { get; private set; }
34          public string queueName { get; private set; }          public string queueName { get; private set; }
# Line 27  namespace DaoMqPump2 Line 36  namespace DaoMqPump2
36          public string sql2mqReadQuery { get; private set; }          public string sql2mqReadQuery { get; private set; }
37          public string sql2mqUpdateQuery { get; private set; }          public string sql2mqUpdateQuery { get; private set; }
38    
39          public bool lastrunOk { get; private set; }          //public bool lastrunOk { get; private set; }
40          public string lastErrorMessage { get; private set; }          //public string lastErrorMessage { get; private set; }
41    
42          public string lastOkTime { get; private set; }          //public string lastOkTime { get; private set; }
43          public string lastErrorTime { get; private set; }          //public string lastErrorTime { get; private set; }
44            //public string lastTransferTime { get; private set; }
45    
46            //public int counter { get; private set; }
47    
48            public StatusData TransportStatusData
49            {
50                get
51                {
52                    return this.statusData;
53                }
54            }
55    
56    
57            public bool Enabled
58            {
59                get {
60                    return statusData.transportEnabled;
61                }
62                set
63                {
64                    statusData.transportEnabled = value;
65                    if (value == true)
66                    {
67                        this.addLogEntry("Transport enabled");
68                    }
69                    else
70                    {
71                        this.addLogEntry("Transport disabled");
72                    }
73                }
74            }
75    
         public int counter { get; private set; }  
76    
77          private LinkedList<string> logEntries = new LinkedList<string>();          private LinkedList<string> logEntries = new LinkedList<string>();
78    
# Line 48  namespace DaoMqPump2 Line 87  namespace DaoMqPump2
87              this.sql2mqReadQuery = sql2mqReadQuery;              this.sql2mqReadQuery = sql2mqReadQuery;
88              this.sql2mqUpdateQuery = sql2mqUpdateQuery;              this.sql2mqUpdateQuery = sql2mqUpdateQuery;
89    
90              this.enabled = enabled;              statusData.transportEnabled = enabled;
91                
92                
93              lastrunOk = true;              statusData.lastrunOk = true;
94              counter = 0;              statusData.counter = 0;
95              lastErrorMessage = lastOkTime = lastErrorTime = "";              statusData.lastErrorMessage = statusData.lastOkTime = statusData.lastErrorTime = "";
96    
97              addLogEntry( "Starting ... " );              addLogEntry( "Starting ... " );
98          }          }
99    
100            ~Transport()
101            {
102                addLogEntry("Stopping ... ");
103            }
104    
105    
106          public void transportMessages()          public void transportMessages()
107          {          {
108              if (enabled == false)              if (statusData.transportEnabled == false)
109                  return;                  return;
110    
111              Console.WriteLine(name + " -> transportMessages() ");              Console.WriteLine(name + " -> transportMessages() ");
112              lastrunOk = true;              statusData.lastrunOk = true;
113    
114                int startCounter = statusData.counter;
115    
116              if (direction == SQL2MQ)              if (direction == SQL2MQ)
117              {              {
# Line 75  namespace DaoMqPump2 Line 122  namespace DaoMqPump2
122                  transportMq2Sql();                  transportMq2Sql();
123              }              }
124    
125              if (lastrunOk == true)              if (statusData.lastrunOk == true)
126              {              {
127                  lastOkTime = getNowString();                  statusData.lastOkTime = getNowString();
128    
129                    if (statusData.counter != startCounter)
130                    {
131                        //Vi har transporteret beskeder - så gemmer vi lige transfer tidspunktet
132                        statusData.lastTransferTime = getNowString();
133                    }
134              }              }
135              else              else
136              {              {
137                  addLogEntry(lastErrorMessage);                  addLogEntry(statusData.lastErrorMessage);
138                  lastErrorTime = getNowString();                  statusData.lastErrorTime = getNowString();
139              }              }
140          }          }
141    
142          private void transportSql2Mq()          private void transportSql2Mq()
143          {          {
144              string filename = getTransactionlogFilename();              MQQueueManager mqMgr = null;
145                MQQueue out_queue = null;
146    
147                string filename = getLogFilename(LogfileType.LogTransactions);
148              using (StreamWriter translog = new StreamWriter(filename, true) )              using (StreamWriter translog = new StreamWriter(filename, true) )
149              try              try
150              {              {
151                  //stage 1 connect to mq                  //MQ Options
152                  Hashtable connProps = getConnectionProperties();                  Hashtable connProps = getConnectionProperties();
                 MQQueueManager mqMgr = new MQQueueManager(controller.mqQueueManager, connProps);  
153                  int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;                  int openOptions = MQC.MQOO_OUTPUT + MQC.MQOO_FAIL_IF_QUIESCING;
154    
155                  MQQueue out_queue = mqMgr.AccessQueue(queueName, openOptions);                  //MySQL Options
   
   
                 //stage 2 connect to mysql  
156                  string mysqlString = buildMysqlConnString();                  string mysqlString = buildMysqlConnString();
                 MySqlConnection sqlConnection = new MySqlConnection(mysqlString);  
                 sqlConnection.Open();  
   
157    
158                  //stage 3 move messages                  //MQ objects i v6 implementerer ikke IDisposable og kan derfor ikke bruges med "using" statement
159                  string readSql = "CALL " + sql2mqReadQuery + "()";                  mqMgr = new MQQueueManager(controller.mqQueueManager, connProps);//stage 1 connect to mq
160                  MySqlCommand readCmd = new MySqlCommand(readSql, sqlConnection);                  out_queue = mqMgr.AccessQueue(queueName, openOptions);
161                  MySqlDataReader dataReader = readCmd.ExecuteReader();                  using (MySqlConnection sqlReadConnection = new MySqlConnection(mysqlString)) //stage 2 connect to mysql
162                  while (dataReader.Read())                  using (MySqlConnection sqlWriteConnection = new MySqlConnection(mysqlString))
163                  {                  {
164                      int id = dataReader.GetInt32(0);                      sqlReadConnection.Open();
165                      string msgString = dataReader.GetString(1);                      sqlWriteConnection.Open();
166    
167                      MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults,                      //stage 3 move messages
168                      // same as MQPMO_DEFAULT                      string readSql = "CALL " + sql2mqReadQuery + "()";
169                        MySqlCommand readCmd = new MySqlCommand(readSql, sqlReadConnection);
170                        MySqlDataReader dataReader = readCmd.ExecuteReader();
171                        while (dataReader.Read())
172                        {
173                            int id = dataReader.GetInt32(0);
174                            string msgString = dataReader.GetString(1);
175    
176                      MQMessage msg = new MQMessage();                          MQPutMessageOptions pmo = new MQPutMessageOptions(); // accept the defaults,
177                      msg.Format = MQC.MQFMT_STRING;                          // same as MQPMO_DEFAULT
                     msg.CharacterSet = 1252;  
                     msg.WriteString(msgString);  
178    
179                      out_queue.Put(msg, pmo);                          MQMessage msg = new MQMessage();
180                            msg.Format = MQC.MQFMT_STRING;
181                            msg.CharacterSet = 1252;
182                            msg.WriteString(msgString);
183    
184                      //now that the message has been put on queue mark it as such                          out_queue.Put(msg, pmo);
185    
186                      string updateSql = "CALL " + sql2mqUpdateQuery + "(" + id + ")";                          //now that the message has been put on queue mark it as such
                     MySqlCommand updateCmd = new MySqlCommand(updateSql, sqlConnection);  
                     int numrows = updateCmd.ExecuteNonQuery();  
187    
188                      translog.WriteLine(getNowString() + " " + msgString + "\n");                          string updateSql = "CALL " + sql2mqUpdateQuery + "(" + id + ")";
189                            MySqlCommand updateCmd = new MySqlCommand(updateSql, sqlWriteConnection);
190                            int numrows = updateCmd.ExecuteNonQuery();
191    
192                      if (numrows != 1)                          translog.WriteLine(getNowString() + " " + msgString);
193                      {  
194                          break;                          if (numrows != 1)
195                            {
196                                break;
197                            }
198                            statusData.counter++;
199                      }                      }
                     counter++;  
                 }  
                   
200    
201                  //stage 4: everything went smooth so clean up afterwards                  }
                 dataReader.Close();  
                 out_queue.Close();  
                 mqMgr.Close();  
                 sqlConnection.Close();  
202              }              }
203              catch (Exception e)              catch (Exception e)
204              {              {
205                  lastrunOk = false;                  statusData.lastrunOk = false;
206                  lastErrorMessage = name + ".transportSql2Mq error: " + e.Message;                  statusData.lastErrorMessage = name + ".transportMq2Sql error: " + e.GetType().FullName + " " + e.Message;
207                  Console.WriteLine(lastErrorMessage);                  Console.WriteLine(statusData.lastErrorMessage);
208                  EventLog.WriteEntry("DaoMqPump2", lastErrorMessage, EventLogEntryType.Warning);                  Console.WriteLine(e.StackTrace);
209                    EventLog.WriteEntry("DaoMqPump2", statusData.lastErrorMessage, EventLogEntryType.Warning);
210              }              }
211          }              finally
   
         private void transportMq2Sql()  
         {  
             string filename = getTransactionlogFilename();  
             using (StreamWriter translog = new StreamWriter(filename, true))  
             try  
212              {              {
                 //stage 1 connect to mq  
                 Hashtable connProps = getConnectionProperties();  
                 MQQueueManager mqMgr = new MQQueueManager(controller.mqQueueManager, connProps);  
                 int openOptions = MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING;  
   
                 MQQueue in_queue = mqMgr.AccessQueue(queueName, openOptions);  
213    
214                    if (out_queue != null && out_queue.IsOpen)
215                    {
216                        try
217                        {
218                            out_queue.Close();
219                        }
220                        catch (Exception e)
221                        {
222                            Console.WriteLine("Error cleaning up qmgr " + e.Message);
223                        }
224                    }
225    
226                  //stage 2 connect to mysql                  if (mqMgr != null && mqMgr.IsOpen)
227                  string mysqlString = buildMysqlConnString();                  {
228                  MySqlConnection sqlConnection = new MySqlConnection(mysqlString);                      try
229                  sqlConnection.Open();                      {
230                            mqMgr.Close();
231                        }
232                        catch (Exception e)
233                        {
234                            Console.WriteLine("Error cleaning up qmgr " + e.Message);
235                        }
236                    }
237    
238                }
239            }
240    
241                  //stage 3 move messages          private void transportMq2Sql()
242                  bool isContinue = true;          {
243                  while (isContinue)              MQQueueManager mqMgr = null;
244                MQQueue in_queue = null;
245                string filename = getLogFilename(LogfileType.LogTransactions);
246                using (StreamWriter translog = new StreamWriter(filename, true))
247                    try
248                  {                  {
249                                            //MQ options
250                      MQMessage mqMsg = new MQMessage();                      Hashtable connProps = getConnectionProperties();
251                      MQGetMessageOptions mqGetMsgOpts = new MQGetMessageOptions();                      int openOptions = MQC.MQOO_INPUT_AS_Q_DEF + MQC.MQOO_FAIL_IF_QUIESCING;
252    
253                        //MySQL options
254                        string mysqlString = buildMysqlConnString();
255    
256                        //MQ objects i v6 implementerer ikke IDisposable og kan derfor ikke bruges med "using" statement
257                        mqMgr = new MQQueueManager(controller.mqQueueManager, connProps);//stage 1 connect to mq
258                        in_queue = mqMgr.AccessQueue(queueName, openOptions);
259                        using (MySqlConnection sqlConnection = new MySqlConnection(mysqlString)) //stage 2 connect to mysql
260                        {
261    
262                      mqGetMsgOpts.Options = MQC.MQGMO_SYNCPOINT; //kræver en commit førend at den er fjernet fra køen                          sqlConnection.Open();
263    
                     try  
                     {  
                         in_queue.Get(mqMsg, mqGetMsgOpts);  
                         if (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) == 0)  
                         {                              
                             string msgString = mqMsg.ReadString(mqMsg.MessageLength);  
                             System.Console.WriteLine(msgString);  
264    
265                              string sql = "CALL " + mq2sqlInsertQuery + "( '" + MySqlHelper.EscapeString(msgString) + "' )"; //opbygger en CALL somestoredprocedure('msgString'); sql streng                          //stage 3 move messages
266                            bool isContinue = true;
267                            while (isContinue)
268                            {
269    
270                              MySqlCommand sqlcmd = new MySqlCommand(sql, sqlConnection);                              MQMessage mqMsg = new MQMessage();
271                              int numrows = sqlcmd.ExecuteNonQuery();                              MQGetMessageOptions mqGetMsgOpts = new MQGetMessageOptions();
272    
273                              if (numrows == 1)                              mqGetMsgOpts.Options = MQC.MQGMO_SYNCPOINT; //kræver en commit førend at den er fjernet fra køen
274    
275                                try
276                              {                              {
277                                  translog.WriteLine(getNowString() + " " + msgString + "\n");                                  in_queue.Get(mqMsg, mqGetMsgOpts);
278                                  mqMgr.Commit();                                  if (mqMsg.Format.CompareTo(MQC.MQFMT_STRING) == 0)
279                                  counter++;                                  {
280                                        string msgString = mqMsg.ReadString(mqMsg.MessageLength);
281                                        //System.Console.WriteLine(msgString);
282    
283    
284                                        // Hvis transaktionen starter med et ? er det ikke en gyldig transaktion
285                                        // validér ligeledes at headeren er gyldig
286                                        if ( msgString.StartsWith("?") || validateSalt2Header(msgString) == false )
287                                        {
288                                            string discarded_filename = getLogFilename(LogfileType.LogDiscarded);
289                                            using (StreamWriter discardedlog = new StreamWriter(discarded_filename, true))
290                                            {
291                                                discardedlog.WriteLine(getNowString() + " " + msgString);
292                                            }
293                                            mqMgr.Commit();//fjern den afviste transaktion fra køen
294                                            statusData.discardedCounter++;
295                                            continue; //gå frem til at tage næste transaktion fra køen
296                                        }
297    
298    
299                                        string sql = "CALL " + mq2sqlInsertQuery + "( '" + MySqlHelper.EscapeString(msgString) + "' )"; //opbygger en CALL somestoredprocedure('msgString'); sql streng
300    
301                                        MySqlCommand sqlcmd = new MySqlCommand(sql, sqlConnection);
302                                        int numrows = sqlcmd.ExecuteNonQuery();
303    
304                                        if (numrows == 1)
305                                        {
306                                            translog.WriteLine(getNowString() + " " + msgString);
307                                            mqMgr.Commit();
308                                            statusData.counter++;
309                                        }
310                                        else
311                                        {
312                                            mqMgr.Backout();
313                                            isContinue = false;
314                                        }
315    
316                                    }
317                                    else
318                                    {
319                                        System.Console.WriteLine("Non-text message");
320                                    }
321                              }                              }
322                              else                              catch (MQException mqe)
323                              {                              {
                                 mqMgr.Backout();  
324                                  isContinue = false;                                  isContinue = false;
325                              }                              
326                                    // report reason, if any
327                                    if (mqe.Reason == MQC.MQRC_NO_MSG_AVAILABLE)
328                                    {
329                                        // special report for normal end
330                                        System.Console.WriteLine("no more messages");
331                                    }
332                                    else
333                                    {
334                                        // general report for other reasons
335                                        System.Console.WriteLine("MQQueue::Get ended with " + mqe.Message); ;
336                                        statusData.lastrunOk = false;
337                                    }
338    
339                                }
340    
341    
342                          }                          }
343                          else  
344                        }
345    
346                    }
347                    catch (Exception e)
348                    {
349                        //Det vil være mest korrekt at Rollback/backout MQ Transaktionen her - for at være sikker på at Message'n fjernes fra køen
350                        try
351                        {
352                            if (mqMgr != null)
353                          {                          {
354                              System.Console.WriteLine("Non-text message");                              mqMgr.Backout();
355                          }                          }
356                      }                      }
357                      catch (MQException mqe)                      catch (Exception e2)
358                      {                      {
359                          isContinue = false;                          this.addLogEntry("Error backing out from MQ Transaction: " + e2.Message);
360                        }
361    
362                        statusData.lastrunOk = false;
363    
364                          // report reason, if any                      statusData.lastErrorMessage = name + ".transportMq2Sql error: " + e.GetType().FullName + " " + e.Message;
365                          if (mqe.Reason == MQC.MQRC_NO_MSG_AVAILABLE)                      Console.WriteLine(statusData.lastErrorMessage);
366                        Console.WriteLine(e.StackTrace);
367                        EventLog.WriteEntry("DaoMqPump2", statusData.lastErrorMessage, EventLogEntryType.Warning);
368                    }
369                    finally
370                    {
371    
372                        if (in_queue != null && in_queue.IsOpen)
373                        {
374                            try
375                          {                          {
376                              // special report for normal end                              in_queue.Close();
                             System.Console.WriteLine("no more messages");  
377                          }                          }
378                          else                          catch (Exception e)
379                          {                          {
380                              // general report for other reasons                              Console.WriteLine("Error cleaning up qmgr " + e.Message);
381                              System.Console.WriteLine("MQQueue::Get ended with " + mqe.Message);;                          }
382                              lastrunOk = false;                      }
383                        
384                        if (mqMgr != null && mqMgr.IsOpen)
385                        {
386                            try
387                            {
388                                mqMgr.Close();
389                            } catch (Exception e) {
390                                Console.WriteLine("Error cleaning up qmgr " + e.Message);
391                          }                          }
   
392                      }                      }
   
393    
394                  }                  }
   
                 //stage 4: everything went smooth so clean up afterwards  
                 in_queue.Close();  
                 mqMgr.Close();  
                 sqlConnection.Close();  
   
   
             }  
             catch (Exception e)  
             {  
                 lastrunOk = false;  
   
                 lastErrorMessage = name + ".transportMq2Sql error: " + e.Message;  
                 Console.WriteLine(lastErrorMessage);  
                 EventLog.WriteEntry("DaoMqPump2", lastErrorMessage, EventLogEntryType.Warning);  
             }  
395          }          }
396    
397          private string buildMysqlConnString()          private string buildMysqlConnString()
# Line 264  namespace DaoMqPump2 Line 402  namespace DaoMqPump2
402              //connectionString += "DATABASE=" + controller.mysqlHost + ";";              //connectionString += "DATABASE=" + controller.mysqlHost + ";";
403              connectionString += "UID=" + controller.mysqlUser + ";";              connectionString += "UID=" + controller.mysqlUser + ";";
404              connectionString += "PASSWORD=" + controller.mysqlPassword + ";";              connectionString += "PASSWORD=" + controller.mysqlPassword + ";";
405                connectionString += "Max Pool Size=20;";
406                //connectionString += "ConnectionReset=true;";//ConnectionReset kræver muligvis at Default Database er angivet - det virker ihvertfald ikke uden
407    
408              return connectionString;              return connectionString;
409          }          }
# Line 273  namespace DaoMqPump2 Line 413  namespace DaoMqPump2
413              Hashtable connProperties = new Hashtable();              Hashtable connProperties = new Hashtable();
414              connProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);              connProperties.Add(MQC.TRANSPORT_PROPERTY, MQC.TRANSPORT_MQSERIES_CLIENT);
415              connProperties.Add(MQC.HOST_NAME_PROPERTY, controller.mqHost);              connProperties.Add(MQC.HOST_NAME_PROPERTY, controller.mqHost);
416              connProperties.Add(MQC.CHANNEL_PROPERTY, controller.mqChannel); //WARNING: Hardcoded Channel Value !!!              connProperties.Add(MQC.CHANNEL_PROPERTY, controller.mqChannel);
417              return connProperties;              return connProperties;
418          }          }
419    
420          private string getTransactionlogFilename()  
421    
422            private string getLogFilename(LogfileType type)
423          {          {
424    
425              DateTime now = DateTime.Now;              DateTime now = DateTime.Now;
426              string filename = controller.logDirectory + "\\";              string filename = controller.logDirectory + "\\";
427              filename += "transactionlog_" + name + "_" + now.Year.ToString("D4") + now.Month.ToString("D2") + ".log";  
428                //Find uge nr
429                DateTimeFormatInfo dfi = DateTimeFormatInfo.CurrentInfo;
430                Calendar myCal = CultureInfo.InvariantCulture.Calendar;//System.Globalization
431                int week = myCal.GetWeekOfYear(now, dfi.CalendarWeekRule, dfi.FirstDayOfWeek);
432    
433                switch (type)
434                {
435                    case LogfileType.LogEvents:
436                        filename += "eventlog_";
437                        break;
438    
439                    case LogfileType.LogTransactions:
440                        filename += "transactionlog_";
441                        break;
442                    case LogfileType.LogDiscarded:
443                        filename += "discardedlog_";
444                        break;
445                }
446    
447    
448                filename += name + "_" + now.Year.ToString("D4") + "_W" + week.ToString("D2") + ".log";
449    
450              return filename;              return filename;
451          }          }
# Line 294  namespace DaoMqPump2 Line 457  namespace DaoMqPump2
457              return now.ToString("s");              return now.ToString("s");
458          }          }
459    
460            private bool validateSalt2Header(string salt2String)
461            {
462                if (salt2String.Length < 66)
463                {
464                    addLogEntry("Transaction too short - discarding");
465                    return false;
466                }
467    
468    
469                int result;
470                long result_long;
471    
472                string afsender = salt2String.Substring(0, 5);
473                string modtager = salt2String.Substring(5, 5);
474                string afsenderTegnSaet = salt2String.Substring(10, 6);
475                string standardNavn = salt2String.Substring(16, 6);
476                string standardVersion = salt2String.Substring(22, 3);
477                string afsenderSekvensnr = salt2String.Substring(25, 6);
478                string afsenderTidsstempel = salt2String.Substring(31, 14);
479                string afsenderBakkeIdent = salt2String.Substring(45, 5);
480                string modtagerBakkeIdent = salt2String.Substring(50, 5);
481                string transaktionForkortelse = salt2String.Substring(55, 4);
482                string transaktionsLaengde = salt2String.Substring(59, 5);
483                string prioritet = salt2String.Substring(64, 1);
484    
485    
486                
487                if (int.TryParse(standardVersion.Trim(), out result) == false) // standardVersion _skal_ være en int
488                {
489                    addLogEntry("standardVersion not an integer, discarding");
490                    return false;
491                }
492    
493                if (int.TryParse(afsenderSekvensnr.Trim(), out result) == false) // afsenderSekvensnr _skal_ være en int
494                {
495                    addLogEntry("afsenderSekvensnr not an integer, discarding");
496                    return false;
497                }
498    
499                if (long.TryParse(afsenderTidsstempel.Trim(), out result_long) == false) // afsenderTidsstempel _skal_ være en long
500                {
501                    addLogEntry("afsenderSekvensnr not a long integer, discarding");
502                    return false;
503                }
504    
505                if (int.TryParse(transaktionsLaengde.Trim(), out result) == false) // transaktionsLaengde _skal_ være en int
506                {
507                    addLogEntry("transaktionsLaengde not an integer, discarding");
508                    return false;
509                }
510    
511                if ( int.TryParse(prioritet.Trim(), out result) == false ) // prioritet _skal_ være en int
512                {
513                    addLogEntry("prioritet not an integer, discarding");
514                    return false;
515                }
516    
517                return true;
518            }
519    
520          private void addLogEntry(string msg)          private void addLogEntry(string msg)
521          {          {
522              msg = getNowString() + " " + msg;              msg = getNowString() + " " + msg;
# Line 304  namespace DaoMqPump2 Line 527  namespace DaoMqPump2
527                  if (logEntries.Count > 20)                  if (logEntries.Count > 20)
528                  {                  {
529                      logEntries.RemoveLast();                      logEntries.RemoveLast();
530                  }                  }                
531                                }
532    
533                string filename = getLogFilename(LogfileType.LogEvents);
534                using (StreamWriter eventlog = new StreamWriter(filename, true))
535                {
536                    eventlog.WriteLine(msg);
537              }              }
538          }          }
539    

Legend:
Removed from v.1986  
changed lines
  Added in v.2086

  ViewVC Help
Powered by ViewVC 1.1.20