/[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 2086 by torben, Wed Nov 27 09:46:11 2013 UTC revision 2166 by torben, Fri May 16 18:24:05 2014 UTC
# Line 9  using IBM.WMQ; Line 9  using IBM.WMQ;
9  using MySql.Data.MySqlClient;  using MySql.Data.MySqlClient;
10  using System.Globalization;  using System.Globalization;
11    
12    using DaoCommon;
13    
14  namespace DaoMqPump2  namespace DaoMqPump2
15  {  {
16      public class Transport      public class Transport
# Line 124  namespace DaoMqPump2 Line 126  namespace DaoMqPump2
126    
127              if (statusData.lastrunOk == true)              if (statusData.lastrunOk == true)
128              {              {
129                  statusData.lastOkTime = getNowString();                  statusData.lastOkTime = DaoUtil.getNowString();
130    
131                  if (statusData.counter != startCounter)                  if (statusData.counter != startCounter)
132                  {                  {
133                      //Vi har transporteret beskeder - så gemmer vi lige transfer tidspunktet                      //Vi har transporteret beskeder - så gemmer vi lige transfer tidspunktet
134                      statusData.lastTransferTime = getNowString();                      statusData.lastTransferTime = DaoUtil.getNowString();
135                  }                  }
136              }              }
137              else              else
138              {              {
139                  addLogEntry(statusData.lastErrorMessage);                  addLogEntry(statusData.lastErrorMessage);
140                  statusData.lastErrorTime = getNowString();                  statusData.lastErrorTime = DaoUtil.getNowString();
141              }              }
142          }          }
143    
# Line 189  namespace DaoMqPump2 Line 191  namespace DaoMqPump2
191                          MySqlCommand updateCmd = new MySqlCommand(updateSql, sqlWriteConnection);                          MySqlCommand updateCmd = new MySqlCommand(updateSql, sqlWriteConnection);
192                          int numrows = updateCmd.ExecuteNonQuery();                          int numrows = updateCmd.ExecuteNonQuery();
193    
194                          translog.WriteLine(getNowString() + " " + msgString);                          translog.WriteLine(DaoUtil.getNowString() + " " + msgString);
195    
196                          if (numrows != 1)                          if (numrows != 1)
197                          {                          {
# Line 240  namespace DaoMqPump2 Line 242  namespace DaoMqPump2
242    
243          private void transportMq2Sql()          private void transportMq2Sql()
244          {          {
245                int messageCount = 0;
246    
247              MQQueueManager mqMgr = null;              MQQueueManager mqMgr = null;
248              MQQueue in_queue = null;              MQQueue in_queue = null;
249              string filename = getLogFilename(LogfileType.LogTransactions);              string filename = getLogFilename(LogfileType.LogTransactions);
# Line 288  namespace DaoMqPump2 Line 292  namespace DaoMqPump2
292                                          string discarded_filename = getLogFilename(LogfileType.LogDiscarded);                                          string discarded_filename = getLogFilename(LogfileType.LogDiscarded);
293                                          using (StreamWriter discardedlog = new StreamWriter(discarded_filename, true))                                          using (StreamWriter discardedlog = new StreamWriter(discarded_filename, true))
294                                          {                                          {
295                                              discardedlog.WriteLine(getNowString() + " " + msgString);                                              discardedlog.WriteLine( DaoUtil.getNowString() + " " + msgString );
296                                          }                                          }
297                                          mqMgr.Commit();//fjern den afviste transaktion fra køen                                          mqMgr.Commit();//fjern den afviste transaktion fra køen
298                                          statusData.discardedCounter++;                                          statusData.discardedCounter++;
# Line 303  namespace DaoMqPump2 Line 307  namespace DaoMqPump2
307    
308                                      if (numrows == 1)                                      if (numrows == 1)
309                                      {                                      {
310                                          translog.WriteLine(getNowString() + " " + msgString);                                          translog.WriteLine( DaoUtil.getNowString() + " " + msgString );
311                                          mqMgr.Commit();                                          mqMgr.Commit();
312                                          statusData.counter++;                                          statusData.counter++;
313    
314    
315                                            messageCount++;// increment per run message counter
316                                            if (messageCount >= 10000) // if we have moved  10000 messages in this run - let it go and give the other transports a change
317                                            {
318                                                isContinue = false;
319                                            }
320    
321    
322    
323                                      }                                      }
324                                      else                                      else
325                                      {                                      {
# Line 450  namespace DaoMqPump2 Line 464  namespace DaoMqPump2
464              return filename;              return filename;
465          }          }
466    
         public string getNowString()  
         {  
             DateTime now = DateTime.Now;  
   
             return now.ToString("s");  
         }  
   
467          private bool validateSalt2Header(string salt2String)          private bool validateSalt2Header(string salt2String)
468          {          {
469              if (salt2String.Length < 66)              if (salt2String.Length < 66)
# Line 498  namespace DaoMqPump2 Line 505  namespace DaoMqPump2
505    
506              if (long.TryParse(afsenderTidsstempel.Trim(), out result_long) == false) // afsenderTidsstempel _skal_ være en long              if (long.TryParse(afsenderTidsstempel.Trim(), out result_long) == false) // afsenderTidsstempel _skal_ være en long
507              {              {
508                  addLogEntry("afsenderSekvensnr not a long integer, discarding");                  addLogEntry("afsenderTidsstempel not a long integer, discarding");
509                  return false;                  return false;
510              }              }
511    
# Line 519  namespace DaoMqPump2 Line 526  namespace DaoMqPump2
526    
527          private void addLogEntry(string msg)          private void addLogEntry(string msg)
528          {          {
529              msg = getNowString() + " " + msg;              msg = DaoUtil.getNowString() + " " + msg;
530              lock (logEntries)              lock (logEntries)
531              {              {
532                  logEntries.AddFirst(msg);                  logEntries.AddFirst(msg);

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

  ViewVC Help
Powered by ViewVC 1.1.20