Changeset 1271
- Timestamp:
- 03/06/09 13:28:49 (16 years ago)
- Location:
- trunk/sources
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Hive.Client.Communication/WcfService.cs
r1255 r1271 217 217 218 218 #endregion 219 220 /// <summary> 221 /// Send back finished and Stored Job Results 222 /// </summary> 223 #region SendJobResults 224 public event System.EventHandler<SendJobResultCompletedEventArgs> SendStoredJobResultCompleted; 225 public void SendStoredJobResultAsync(Guid clientId, long jobId, byte[] result, double percentage, Exception exception, bool finished) { 226 if (ConnState == NetworkEnum.WcfConnState.Loggedin) 227 //TODO: some sort of algo for the stored jobs 228 proxy.SendJobResultAsync(clientId, jobId, result, percentage, exception, finished); 229 } 230 #endregion 231 232 public ResponseResultReceived SendStoredJobResultsSync(Guid clientId, long jobId, byte[] result, double percentage, Exception exception, bool finished) { 233 return proxy.SendJobResult(clientId, jobId, result, percentage, exception, finished); 234 } 219 235 } 220 236 } -
trunk/sources/HeuristicLab.Hive.Client.Core/JobStorrage/JobStorrageManager.cs
r1260 r1271 6 6 using HeuristicLab.Hive.Client.Common; 7 7 using HeuristicLab.Hive.Client.Communication; 8 using HeuristicLab.Hive.Client.Core.ConfigurationManager; 9 using HeuristicLab.Hive.Contracts; 8 10 9 11 namespace HeuristicLab.Hive.Client.Core.JobStorrage { 10 12 public class JobStorrageManager { 11 private static List<JobStorrageInfo> StoredJobsList = new List<JobStorrageInfo>(); 13 14 private static List<JobStorrageInfo> storedJobsList = new List<JobStorrageInfo>(); 15 private static String path = "C:\\Program Files\\HeuristicLab 3.0\\plugins\\jobStorrage\\"; 12 16 13 17 public static void PersistObjectToDisc(String serverIP, long serverPort, long jobId, byte[] job) { 14 18 String filename = serverIP + "." + serverPort + "." + jobId.ToString(); 15 19 16 20 JobStorrageInfo info = new JobStorrageInfo { JobID = jobId, ServerIP = serverIP, ServerPort = serverPort, TimeFinished = DateTime.Now }; 17 21 try { 18 Stream jobstream = File.Create( "C:\\Program Files\\HeuristicLab 3.0\\plugins\\jobStorrage\\ "+filename + ".dat");22 Stream jobstream = File.Create(path + filename + ".dat"); 19 23 jobstream.Write(job, 0, job.Length); 20 StoredJobsList.Add(info);24 storedJobsList.Add(info); 21 25 jobstream.Close(); 22 26 Logging.GetInstance().Info("JobStorrageManager", "Job " + info.JobID + " stored on the harddisc"); … … 28 32 29 33 public static void CheckAndSubmitJobsFromDisc() { 30 foreach (JobStorrageInfo info in StoredJobsList) { 31 if (WcfService.Instance.ConnState == NetworkEnum.WcfConnState.Loggedin && (info.ServerIP == WcfService.Instance.ServerIP && info.ServerPort == WcfService.Instance.ServerPort)) { 32 Logging.GetInstance().Info("JobStorrageManager", "Sending stored job " + info.JobID + " to the server"); 34 for(int index=storedJobsList.Count; index > 0; index--) { 35 if (WcfService.Instance.ConnState == NetworkEnum.WcfConnState.Loggedin && (storedJobsList[index-1].ServerIP == WcfService.Instance.ServerIP && storedJobsList[index-1].ServerPort == WcfService.Instance.ServerPort)) { 36 String filename = storedJobsList[index-1].ServerIP + "." + storedJobsList[index-1].ServerPort + "." + storedJobsList[index-1].JobID.ToString(); 37 Logging.GetInstance().Info("JobStorrageManager", "Sending stored job " + storedJobsList[index-1].JobID + " to the server"); 38 byte[] job = File.ReadAllBytes(path + filename + ".dat"); 39 ResponseResultReceived res = WcfService.Instance.SendStoredJobResultsSync(ConfigManager.Instance.GetClientInfo().ClientId, storedJobsList[index-1].JobID, job, 1.00, null, true); 40 //TODO: has to be fixed from server side 41 //if (res.Success == true) { 42 Logging.GetInstance().Info("JobStorrageManager", "Sending of job " + storedJobsList[index - 1].JobID + " done"); 43 storedJobsList.Remove(storedJobsList[index - 1]); 44 File.Delete(path + filename + ".dat"); 45 46 // } 33 47 } 34 48 }
Note: See TracChangeset
for help on using the changeset viewer.