21 |
public static string SQL2MQ = "sql2mq"; |
public static string SQL2MQ = "sql2mq"; |
22 |
public static string MQ2SQL = "mq2sql"; |
public static string MQ2SQL = "mq2sql"; |
23 |
|
|
24 |
private bool enabled; |
//private bool enabled; |
25 |
|
|
26 |
TransportController controller; |
TransportController controller; |
27 |
|
|
55 |
public bool Enabled |
public bool Enabled |
56 |
{ |
{ |
57 |
get { |
get { |
58 |
return this.enabled; |
return statusData.transportEnabled; |
59 |
} |
} |
60 |
set |
set |
61 |
{ |
{ |
62 |
this.enabled = value; |
statusData.transportEnabled = value; |
63 |
if (value == true) |
if (value == true) |
64 |
{ |
{ |
65 |
this.addLogEntry("Transport enabled"); |
this.addLogEntry("Transport enabled"); |
85 |
this.sql2mqReadQuery = sql2mqReadQuery; |
this.sql2mqReadQuery = sql2mqReadQuery; |
86 |
this.sql2mqUpdateQuery = sql2mqUpdateQuery; |
this.sql2mqUpdateQuery = sql2mqUpdateQuery; |
87 |
|
|
88 |
this.enabled = enabled; |
statusData.transportEnabled = enabled; |
89 |
|
|
90 |
|
|
91 |
statusData.lastrunOk = true; |
statusData.lastrunOk = true; |
103 |
|
|
104 |
public void transportMessages() |
public void transportMessages() |
105 |
{ |
{ |
106 |
if (enabled == false) |
if (statusData.transportEnabled == false) |
107 |
return; |
return; |
108 |
|
|
109 |
Console.WriteLine(name + " -> transportMessages() "); |
Console.WriteLine(name + " -> transportMessages() "); |
153 |
|
|
154 |
//stage 2 connect to mysql |
//stage 2 connect to mysql |
155 |
string mysqlString = buildMysqlConnString(); |
string mysqlString = buildMysqlConnString(); |
156 |
MySqlConnection sqlConnection = new MySqlConnection(mysqlString); |
MySqlConnection sqlReadConnection = new MySqlConnection(mysqlString); |
157 |
sqlConnection.Open(); |
sqlReadConnection.Open(); |
158 |
|
|
159 |
|
MySqlConnection sqlWriteConnection = new MySqlConnection(mysqlString); |
160 |
|
sqlWriteConnection.Open(); |
161 |
|
|
162 |
|
|
163 |
//stage 3 move messages |
//stage 3 move messages |
164 |
string readSql = "CALL " + sql2mqReadQuery + "()"; |
string readSql = "CALL " + sql2mqReadQuery + "()"; |
165 |
MySqlCommand readCmd = new MySqlCommand(readSql, sqlConnection); |
MySqlCommand readCmd = new MySqlCommand(readSql, sqlReadConnection); |
166 |
MySqlDataReader dataReader = readCmd.ExecuteReader(); |
MySqlDataReader dataReader = readCmd.ExecuteReader(); |
167 |
while (dataReader.Read()) |
while (dataReader.Read()) |
168 |
{ |
{ |
182 |
//now that the message has been put on queue mark it as such |
//now that the message has been put on queue mark it as such |
183 |
|
|
184 |
string updateSql = "CALL " + sql2mqUpdateQuery + "(" + id + ")"; |
string updateSql = "CALL " + sql2mqUpdateQuery + "(" + id + ")"; |
185 |
MySqlCommand updateCmd = new MySqlCommand(updateSql, sqlConnection); |
MySqlCommand updateCmd = new MySqlCommand(updateSql, sqlWriteConnection); |
186 |
int numrows = updateCmd.ExecuteNonQuery(); |
int numrows = updateCmd.ExecuteNonQuery(); |
187 |
|
|
188 |
translog.WriteLine(getNowString() + " " + msgString + "\n"); |
translog.WriteLine(getNowString() + " " + msgString + "\n"); |
199 |
dataReader.Close(); |
dataReader.Close(); |
200 |
out_queue.Close(); |
out_queue.Close(); |
201 |
mqMgr.Close(); |
mqMgr.Close(); |
202 |
sqlConnection.Close(); |
sqlReadConnection.Close(); |
203 |
|
sqlWriteConnection.Close(); |
204 |
} |
} |
205 |
catch (Exception e) |
catch (Exception e) |
206 |
{ |
{ |
352 |
} |
} |
353 |
|
|
354 |
|
|
355 |
filename += "transactionlog_" + name + "_" + now.Year.ToString("D4") + now.Month.ToString("D2") + ".log"; |
filename += name + "_" + now.Year.ToString("D4") + now.Month.ToString("D2") + ".log"; |
356 |
|
|
357 |
return filename; |
return filename; |
358 |
} |
} |