24 |
{ |
{ |
25 |
InitializeComponent(); |
InitializeComponent(); |
26 |
|
|
27 |
initClient(); |
//initClient(); is now called on shown() event |
28 |
|
// loadTransports(); is now called on shown() event |
29 |
|
|
|
loadTransports(); |
|
30 |
} |
} |
31 |
|
|
32 |
private void initClient() |
private void initClient() |
64 |
return result; |
return result; |
65 |
} |
} |
66 |
|
|
67 |
|
public int getSelectedTransportIndex() |
68 |
|
{ |
69 |
|
if (transports.SelectedIndices.Count == 0) |
70 |
|
return -1; |
71 |
|
else |
72 |
|
return transports.SelectedIndices[0]; |
73 |
|
} |
74 |
|
|
75 |
public void loadTransports() |
public void loadTransports() |
76 |
{ |
{ |
77 |
int selected = transports.SelectedIndex; |
|
78 |
|
int selected = getSelectedTransportIndex(); |
79 |
if (selected == -1) //er der ikke valgt - vælger vi den første |
if (selected == -1) //er der ikke valgt - vælger vi den første |
80 |
selected = 0; |
selected = 0; |
81 |
|
|
86 |
foreach (string t in transportNames) |
foreach (string t in transportNames) |
87 |
{ |
{ |
88 |
transportNameList.Add(t); |
transportNameList.Add(t); |
89 |
|
StatusData statusData = client.GetTransportStatus(t); |
90 |
bool enabled = client.GetTransportEnabled(t); |
bool enabled = statusData.transportEnabled; |
91 |
string status = ""; |
string status = ""; |
92 |
|
Color bgColor; |
93 |
if (enabled) |
if (enabled) |
94 |
{ |
{ |
95 |
bool lastOk = client.GetTransportLastrunOk(t); |
bool lastOk = statusData.lastrunOk; |
96 |
|
|
97 |
if (lastOk) |
if (lastOk) |
98 |
{ |
{ |
99 |
status = "running"; |
status = "running"; |
100 |
|
bgColor = Color.Green; |
101 |
} |
} |
102 |
else |
else |
103 |
{ |
{ |
104 |
status = "error"; |
status = "error"; |
105 |
|
bgColor = Color.Red; |
106 |
} |
} |
107 |
} |
} |
108 |
else |
else |
109 |
{ |
{ |
110 |
status = "stopped"; |
status = "stopped"; |
111 |
|
bgColor = Color.DarkOrange; |
112 |
} |
} |
113 |
|
|
114 |
transports.Items.Add(t + " - " + status); |
ListViewItem item = new ListViewItem(t + " - " + status); |
115 |
|
item.ForeColor = bgColor; |
116 |
|
transports.Items.Add(item); |
117 |
} |
} |
118 |
|
|
119 |
|
|
125 |
selected = -1; |
selected = -1; |
126 |
} |
} |
127 |
|
|
128 |
transports.SelectedIndex = selected; |
transports.SelectedIndices.Clear(); |
129 |
|
if (selected != -1) |
130 |
|
transports.SelectedIndices.Add(selected); |
131 |
|
//transports.SelectedIndices[0] = selected; |
132 |
|
|
133 |
} |
} |
134 |
|
|
170 |
|
|
171 |
private void transports_SelectedIndexChanged(object sender, EventArgs e) |
private void transports_SelectedIndexChanged(object sender, EventArgs e) |
172 |
{ |
{ |
173 |
loadFormData(); |
showData(); |
174 |
} |
} |
175 |
|
|
176 |
private void loadFormData() |
private void loadStatusData() |
177 |
{ |
{ |
178 |
if (transports.SelectedIndex == -1) |
if (getSelectedTransportIndex() == -1) |
179 |
return; |
return; |
180 |
|
|
181 |
string transportName = transportNameList[transports.SelectedIndex]; |
string transportName = transportNameList[getSelectedTransportIndex() ]; |
|
|
|
|
bool enabled = client.GetTransportEnabled(transportName); |
|
|
bool lastOk = client.GetTransportLastrunOk(transportName); |
|
182 |
|
|
183 |
string lastokTime = client.GetTransportLastOkTime(transportName); |
StatusData statusData = client.GetTransportStatus(transportName); |
|
string lastErrorTime = client.GetTransportLastErrorTime(transportName); |
|
184 |
|
|
185 |
string errorMsg = client.GetTransportLastErrorMessage(transportName); |
bool enabled = statusData.transportEnabled; |
|
|
|
|
int counter = client.GetTransportCounter(transportName); |
|
186 |
|
|
187 |
txtTransport.Text = transportName; |
txtTransport.Text = transportName; |
188 |
txtEnabled.Text = "" + enabled; |
txtEnabled.Text = "" + enabled; |
189 |
txtLastOK.Text = "" + lastOk; |
txtLastOK.Text = "" + statusData.lastrunOk; |
190 |
|
|
191 |
txtOkTime.Text = lastokTime; |
txtOkTime.Text = statusData.lastOkTime; |
192 |
txtErrorTime.Text = lastErrorTime; |
txtErrorTime.Text = statusData.lastErrorTime; |
193 |
|
txtTransferTime.Text = statusData.lastTransferTime; |
194 |
|
|
195 |
txtErrorMsg.Text = errorMsg; |
txtErrorMsg.Text = statusData.lastErrorMessage; |
196 |
|
|
197 |
txtCounter.Text = "" + counter; |
txtCounter.Text = "" + statusData.counter; |
198 |
|
|
199 |
|
|
200 |
|
|
205 |
|
|
206 |
private void refreshTimer_Tick(object sender, EventArgs e) |
private void refreshTimer_Tick(object sender, EventArgs e) |
207 |
{ |
{ |
208 |
loadTransports(); |
loadTransports(); |
|
|
|
|
if (transports.SelectedIndex == -1) |
|
|
return; |
|
209 |
|
|
210 |
if (tabControl1.SelectedIndex != 0) //0 er status siden |
if (getSelectedTransportIndex() == -1) |
211 |
return; |
return; |
212 |
|
|
213 |
loadFormData(); |
showData(); |
214 |
} |
} |
215 |
|
|
216 |
private void loadLog() |
private void loadLog() |
217 |
{ |
{ |
218 |
if (transports.SelectedIndex == -1) |
if (getSelectedTransportIndex() == -1) |
219 |
return; |
return; |
220 |
string transportName = transportNameList[transports.SelectedIndex]; |
string transportName = transportNameList[getSelectedTransportIndex()]; |
221 |
|
|
222 |
string[] logEntries = client.GetTransportLog(transportName); |
string[] logEntries = client.GetTransportLog(transportName); |
223 |
|
|
232 |
|
|
233 |
private void loadConfig() |
private void loadConfig() |
234 |
{ |
{ |
235 |
if (transports.SelectedIndex == -1) |
if (getSelectedTransportIndex() == -1) |
236 |
return; |
return; |
237 |
string transportName = transportNameList[transports.SelectedIndex]; |
string transportName = transportNameList[getSelectedTransportIndex()]; |
238 |
|
|
239 |
string direction = client.GetTransportDirection(transportName); |
string direction = client.GetTransportDirection(transportName); |
240 |
string queue = client.GetTransportQueueName(transportName); |
string queue = client.GetTransportQueueName(transportName); |
250 |
|
|
251 |
} |
} |
252 |
|
|
253 |
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) |
private void showData() |
254 |
{ |
{ |
255 |
if (transports.SelectedIndex == -1) |
if (getSelectedTransportIndex() == -1) |
256 |
return; |
return; |
257 |
|
|
258 |
switch (tabControl1.SelectedIndex) |
switch (tabControl1.SelectedIndex) |
259 |
{ |
{ |
260 |
case 0: |
case 0: |
261 |
loadFormData(); |
loadStatusData(); |
262 |
break; |
break; |
263 |
case 1: |
case 1: |
264 |
loadLog(); |
loadLog(); |
269 |
} |
} |
270 |
} |
} |
271 |
|
|
272 |
|
private void tabControl1_SelectedIndexChanged(object sender, EventArgs e) |
273 |
|
{ |
274 |
|
showData(); |
275 |
|
} |
276 |
|
|
277 |
private void lnkServer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
private void lnkServer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e) |
278 |
{ |
{ |
279 |
string tmp_hostname = Microsoft.VisualBasic.Interaction.InputBox("Indtast servernavn/ip", "MQ Gui", hostname); |
string tmp_hostname = Microsoft.VisualBasic.Interaction.InputBox("Indtast servernavn/ip", "MQ Gui", hostname); |
289 |
initClient(); |
initClient(); |
290 |
loadTransports(); |
loadTransports(); |
291 |
} |
} |
292 |
|
|
293 |
|
private void MainForm_Shown(object sender, EventArgs e) |
294 |
|
{ |
295 |
|
lnkServer.Text = "Connecting ..."; |
296 |
|
this.Refresh(); //force a redraw now () before we do the heavy work |
297 |
|
|
298 |
|
initClient(); |
299 |
|
loadTransports(); |
300 |
|
} |
301 |
|
|
302 |
} |
} |
303 |
} |
} |