- Timestamp:
- 12/11/08 16:53:26 (15 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Console/HiveClientConsole.cs
r953 r973 31 31 using System.Threading; 32 32 using ZedGraph; 33 //using HeuristicLab.Hive.Client.Console.ClientWCFService;33 using HeuristicLab.Hive.Client.Console.ClientService; 34 34 using System.ServiceModel; 35 using System.Net; 35 36 36 37 namespace HeuristicLab.Hive.Client.Console { … … 41 42 42 43 EventLog HiveClientEventLog; 43 int selectedEventLogId; 44 ClientConsoleCommunicatorClient cccc; 45 System.Windows.Forms.Timer refreshTimer; 44 46 45 47 public HiveClientConsole() { 46 48 InitializeComponent(); 49 InitTimer(); 50 ConnectToClient(); 51 RefreshGui(); 47 52 GetEventLog(); 48 49 //ClientConsoleCommunicatorClient cccc = new ClientConsoleCommunicatorClient(new NetTcpBinding(), 50 // new EndpointAddress("net.tcp://127.0.0.1:8000/ClientConsole/ClientConsoleCommunicator")); 51 //StatusCommons sc = cccc.GetStatusInfos(); 53 } 54 55 private void InitTimer() { 56 refreshTimer = new System.Windows.Forms.Timer(); 57 refreshTimer.Interval = 1000; 58 refreshTimer.Tick += new EventHandler(refreshTimer_Tick); 59 refreshTimer.Start(); 60 } 61 62 void refreshTimer_Tick(object sender, EventArgs e) { 63 RefreshGui(); 64 } 65 66 private void RefreshGui() { 67 StatusCommons sc = new StatusCommons(); 68 69 try { 70 sc = cccc.GetStatusInfos(); 71 } 72 catch (Exception ex) { 73 refreshTimer.Stop(); 74 DialogResult res = MessageBox.Show("Connection Error, check if Hive Client is running!", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 75 if (res == DialogResult.OK) 76 this.Close(); 77 } 78 79 lbGuid.Text = sc.ClientGuid.ToString(); 80 lbCs.Text = sc.ConnectedSince.ToString(); 81 lbConnectionStatus.Text = sc.Status.ToString(); 82 lbJobdone.Text = sc.JobsDone.ToString(); 83 lbJobsAborted.Text = sc.JobsAborted.ToString(); 84 lbJobsFetched.Text = sc.JobsFetched.ToString(); 85 86 this.Text = "Client Console (" + sc.Status.ToString() + ")"; 87 lbStatus.Text = sc.Status.ToString(); 88 89 ListViewItem curJobStatusItem; 90 91 if (sc.Jobs != null) { 92 lvJobDetail.Items.Clear(); 93 double progress; 94 foreach (JobStatus curJob in sc.Jobs) { 95 curJobStatusItem = new ListViewItem(curJob.JobId.ToString()); 96 curJobStatusItem.SubItems.Add(curJob.Since.ToString()); 97 progress = curJob.Progress * 100; 98 curJobStatusItem.SubItems.Add(progress.ToString()); 99 lvJobDetail.Items.Add(curJobStatusItem); 100 } 101 } 102 103 UpdateGraph(zGJobs, sc.JobsDone, sc.JobsAborted); 104 105 if (sc.Status == NetworkEnumWcfConnState.Connected) { 106 btConnect.Enabled = false; 107 btnDisconnect.Enabled = true; 108 ConnectionContainer curConnection = cccc.GetCurrentConnection(); 109 tbIPAdress.Text = curConnection.IPAdress; 110 tbPort.Text = curConnection.Port.ToString(); 111 } else if (sc.Status == NetworkEnumWcfConnState.Disconnected) { 112 btConnect.Enabled = true; 113 btnDisconnect.Enabled = false; 114 } else if (sc.Status == NetworkEnumWcfConnState.Failed) { 115 btConnect.Enabled = true; 116 btnDisconnect.Enabled = false; 117 } 118 } 119 120 private void ConnectToClient() { 121 try { 122 cccc = new ClientConsoleCommunicatorClient(); 123 } 124 catch (Exception) { 125 refreshTimer.Stop(); 126 DialogResult res = MessageBox.Show("Connection Error, check if Hive Client is running!", "Connection Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 127 if (res == DialogResult.OK) 128 this.Close(); 129 } 52 130 } 53 131 … … 72 150 73 151 private void HiveClientConsole_Load(object sender, EventArgs e) { 74 CreateGraph(zGJobs);75 152 //SetSize(); 76 153 } … … 89 166 curEventLogEntry.SubItems.Add(ev.TimeGenerated.Date.ToString()); 90 167 curEventLogEntry.SubItems.Add(ev.TimeGenerated.TimeOfDay.ToString()); 168 lvLog.Items.Add(curEventLogEntry); 91 169 } 92 170 } … … 96 174 } 97 175 98 private void SetSize() { 99 zGJobs.Location = new Point(10, 10); 100 // Leave a small margin around the outside of the control 101 102 zGJobs.Size = new Size(ClientRectangle.Width - 20, 103 ClientRectangle.Height - 20); 104 } 105 106 107 private void CreateGraph(ZedGraphControl zgc) { 176 private void UpdateGraph(ZedGraphControl zgc, int jobsDone, int jobsAborted) { 177 zgc.GraphPane.GraphObjList.Clear(); 108 178 GraphPane myPane = zgc.GraphPane; 109 179 … … 113 183 myPane.Fill.Type = FillType.None; 114 184 115 myPane.AddPieSlice(40, Color.Red, 0, "Jobs aborted"); 116 myPane.AddPieSlice(60, Color.Green, 0.1, "Jobs done"); 117 185 double sum = jobsDone + jobsAborted; 186 double perDone = jobsDone / sum * 100; 187 double perAborted = jobsAborted / sum * 100; 188 189 myPane.AddPieSlice(perAborted, Color.Red, 0, "Jobs aborted"); 190 myPane.AddPieSlice(perDone, Color.Green, 0.1, "Jobs done"); 118 191 myPane.AxisChange(); 119 192 } … … 130 203 EventlogDetails.Show(); 131 204 } 205 206 private void btConnect_Click(object sender, EventArgs e) { 207 IPAddress ipAdress; 208 int port; 209 ConnectionContainer cc = new ConnectionContainer(); 210 //IPAddress.TryParse(tbIPAdress.Text.ToString(), ipAdress); 211 if (IPAddress.TryParse(tbIPAdress.Text, out ipAdress) && int.TryParse(tbPort.Text, out port)) { 212 cc.IPAdress = tbIPAdress.Text; 213 cc.Port = port; 214 cccc.SetConnection(cc); 215 } else { 216 MessageBox.Show("IP Adress and/or Port Error", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); 217 } 218 219 } 220 221 private void btnDisconnect_Click(object sender, EventArgs e) { 222 cccc.Disconnect(); 223 } 132 224 } 133 225 }
Note: See TracChangeset
for help on using the changeset viewer.