/[projects]/dao/DaoMqPump2/DaoMqGUI/MainForm.cs
ViewVC logotype

Diff of /dao/DaoMqPump2/DaoMqGUI/MainForm.cs

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

revision 1994 by torben, Fri Jul 5 08:43:21 2013 UTC revision 2058 by torben, Wed Aug 28 06:45:20 2013 UTC
# Line 64  namespace DaoMqGUI Line 64  namespace DaoMqGUI
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    
# Line 77  namespace DaoMqGUI Line 86  namespace DaoMqGUI
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    
# Line 111  namespace DaoMqGUI Line 125  namespace DaoMqGUI
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    
# Line 153  namespace DaoMqGUI Line 170  namespace DaoMqGUI
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;
   
             txtOkTime.Text = lastokTime;  
             txtErrorTime.Text = lastErrorTime;  
190    
191              txtErrorMsg.Text = errorMsg;              txtOkTime.Text = statusData.lastOkTime;
192                txtErrorTime.Text = statusData.lastErrorTime;
193                txtTransferTime.Text = statusData.lastTransferTime;
194    
195              txtCounter.Text = "" + counter;              txtErrorMsg.Text = statusData.lastErrorMessage;
196    
197                txtCounter.Text = "" + statusData.counter;
198    
199                txtDiscarded.Text = "" + statusData.discardedCounter;
200    
201              btnDisableOne.Enabled = enabled;              btnDisableOne.Enabled = enabled;
202              btnEnableOne.Enabled = (!enabled);                          btnEnableOne.Enabled = (!enabled);            
# Line 193  namespace DaoMqGUI Line 205  namespace DaoMqGUI
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    
# Line 223  namespace DaoMqGUI Line 232  namespace DaoMqGUI
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);
# Line 241  namespace DaoMqGUI Line 250  namespace DaoMqGUI
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();
# Line 260  namespace DaoMqGUI Line 269  namespace DaoMqGUI
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);
# Line 278  namespace DaoMqGUI Line 292  namespace DaoMqGUI
292    
293          private void MainForm_Shown(object sender, EventArgs e)          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();              initClient();
299              loadTransports();              loadTransports();
300          }          }

Legend:
Removed from v.1994  
changed lines
  Added in v.2058

  ViewVC Help
Powered by ViewVC 1.1.20