/[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 1986 by torben, Wed Jul 3 07:56:52 2013 UTC revision 2000 by torben, Mon Jul 8 14:23:01 2013 UTC
# Line 7  using System.Text; Line 7  using System.Text;
7  using System.Windows.Forms;  using System.Windows.Forms;
8    
9  using DaoMqGUI.ServiceReference1;  using DaoMqGUI.ServiceReference1;
10    using System.ServiceModel;
11    using Microsoft.Win32;
12    
13  namespace DaoMqGUI  namespace DaoMqGUI
14  {  {
15      public partial class MainForm : Form      public partial class MainForm : Form
16      {      {
17          RemoteControlClient client = new RemoteControlClient();          RemoteControlClient client = null;
18    
19          List<string> transportNameList = new List<string>();          List<string> transportNameList = new List<string>();
20    
21            string hostname = "";
22    
23          public MainForm()          public MainForm()
24          {          {
25              InitializeComponent();              InitializeComponent();
26              loadTransports();  
27                //initClient(); is now called on shown() event
28                // loadTransports(); is now called on shown() event
29    
30            }
31    
32            private void initClient()
33            {
34                RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\DAO\\DaoMqGui");
35    
36                hostname = (string) key.GetValue("Hostname", "localhost");
37                hostname = hostname.Trim();
38    
39                lnkServer.Text = hostname;
40    
41                //Step 1 - initialize client
42                BasicHttpBinding binding = new BasicHttpBinding();
43                EndpointAddress endpoint = new EndpointAddress(new Uri("http://" + hostname + ":8000/RemoteControl/RemoteControl"));
44                client = new RemoteControlClient(binding, endpoint);
45          }          }
46    
47          private string[] getSafeTransports()          private string[] getSafeTransports()
# Line 55  namespace DaoMqGUI Line 77  namespace DaoMqGUI
77              foreach (string t in transportNames)              foreach (string t in transportNames)
78              {              {
79                  transportNameList.Add(t);                  transportNameList.Add(t);
80                    StatusData statusData = client.GetTransportStatus(t);
81                  bool enabled = client.GetTransportEnabled(t);                  bool enabled = statusData.transportEnabled;
82                  string status = "";                  string status = "";
83    
84                  if (enabled)                  if (enabled)
85                  {                  {
86                      bool lastOk = client.GetTransportLastrunOk(t);                      bool lastOk = statusData.lastrunOk;                    
87                                            
88                      if (lastOk)                      if (lastOk)
89                      {                      {
# Line 131  namespace DaoMqGUI Line 153  namespace DaoMqGUI
153    
154          private void transports_SelectedIndexChanged(object sender, EventArgs e)          private void transports_SelectedIndexChanged(object sender, EventArgs e)
155          {          {
156              loadFormData();              showData();
157          }          }
158    
159          private void loadFormData()          private void loadStatusData()
160          {          {
161              if (transports.SelectedIndex == -1)              if (transports.SelectedIndex == -1)
162                  return;                  return;
163    
164              string transportName = transportNameList[transports.SelectedIndex];              string transportName = transportNameList[transports.SelectedIndex];
165    
166              bool enabled = client.GetTransportEnabled(transportName);              StatusData statusData = client.GetTransportStatus(transportName);
             bool lastOk = client.GetTransportLastrunOk(transportName);  
   
             string lastokTime = client.GetTransportLastOkTime(transportName);  
             string lastErrorTime = client.GetTransportLastErrorTime(transportName);  
167    
168              string errorMsg = client.GetTransportLastErrorMessage(transportName);              bool enabled = statusData.transportEnabled;
   
             int counter = client.GetTransportCounter(transportName);  
169    
170              txtTransport.Text = transportName;              txtTransport.Text = transportName;
171              txtEnabled.Text = "" + enabled;              txtEnabled.Text = "" + enabled;
172              txtLastOK.Text = "" + lastOk;              txtLastOK.Text = "" + statusData.lastrunOk;
173    
174              txtOkTime.Text = lastokTime;              txtOkTime.Text = statusData.lastOkTime;
175              txtErrorTime.Text = lastErrorTime;              txtErrorTime.Text = statusData.lastErrorTime;
176                txtTransferTime.Text = statusData.lastTransferTime;
177    
178              txtErrorMsg.Text = errorMsg;              txtErrorMsg.Text = statusData.lastErrorMessage;
179    
180              txtCounter.Text = "" + counter;              txtCounter.Text = "" + statusData.counter;
181    
182    
183    
# Line 176  namespace DaoMqGUI Line 193  namespace DaoMqGUI
193              if (transports.SelectedIndex == -1)              if (transports.SelectedIndex == -1)
194                  return;                  return;
195    
196              if (tabControl1.SelectedIndex != 0) //0 er status siden              showData();
                 return;  
   
             loadFormData();  
197          }          }
198    
199          private void loadLog()          private void loadLog()
# Line 219  namespace DaoMqGUI Line 233  namespace DaoMqGUI
233    
234          }          }
235    
236          private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)          private void showData()
237          {          {
238              if (transports.SelectedIndex == -1)              if (transports.SelectedIndex == -1)
239                  return;                  return;
# Line 227  namespace DaoMqGUI Line 241  namespace DaoMqGUI
241              switch (tabControl1.SelectedIndex)              switch (tabControl1.SelectedIndex)
242              {              {
243                  case 0:                  case 0:
244                      loadFormData();                      loadStatusData();
245                      break;                      break;
246                  case 1:                  case 1:
247                      loadLog();                      loadLog();
# Line 238  namespace DaoMqGUI Line 252  namespace DaoMqGUI
252              }              }
253          }          }
254    
255            private void tabControl1_SelectedIndexChanged(object sender, EventArgs e)
256            {
257                showData();
258            }
259    
260            private void lnkServer_LinkClicked(object sender, LinkLabelLinkClickedEventArgs e)
261            {
262                string tmp_hostname = Microsoft.VisualBasic.Interaction.InputBox("Indtast servernavn/ip", "MQ Gui", hostname);
263                if (tmp_hostname == null || tmp_hostname.Trim().Length == 0)
264                    return;
265    
266                hostname = tmp_hostname.Trim();
267    
268                RegistryKey key = Registry.LocalMachine.CreateSubKey("Software\\DAO\\DaoMqGui");
269                key.SetValue("Hostname", hostname, RegistryValueKind.String);
270                key.Close();
271    
272                initClient();
273                loadTransports();
274            }
275    
276            private void MainForm_Shown(object sender, EventArgs e)
277            {
278                lnkServer.Text = "Connecting ...";
279                this.Refresh(); //force a redraw now () before we do the heavy work
280                
281                initClient();
282                loadTransports();
283            }
284    
285      }      }
286  }  }

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

  ViewVC Help
Powered by ViewVC 1.1.20