Free cookie consent management tool by TermsFeed Policy Generator

Changeset 1271


Ignore:
Timestamp:
03/06/09 13:28:49 (16 years ago)
Author:
kgrading
Message:

implementation for #493

Location:
trunk/sources
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/sources/HeuristicLab.Hive.Client.Communication/WcfService.cs

    r1255 r1271  
    217217
    218218    #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    }
    219235  }
    220236}
  • trunk/sources/HeuristicLab.Hive.Client.Core/JobStorrage/JobStorrageManager.cs

    r1260 r1271  
    66using HeuristicLab.Hive.Client.Common;
    77using HeuristicLab.Hive.Client.Communication;
     8using HeuristicLab.Hive.Client.Core.ConfigurationManager;
     9using HeuristicLab.Hive.Contracts;
    810
    911namespace HeuristicLab.Hive.Client.Core.JobStorrage {
    1012  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\\";
    1216   
    1317    public static void PersistObjectToDisc(String serverIP, long serverPort, long jobId, byte[] job) {
    1418      String filename = serverIP + "." + serverPort + "." + jobId.ToString();
    15      
     19
    1620      JobStorrageInfo info = new JobStorrageInfo { JobID = jobId, ServerIP = serverIP, ServerPort = serverPort, TimeFinished = DateTime.Now };
    1721      try {
    18         Stream jobstream = File.Create("C:\\Program Files\\HeuristicLab 3.0\\plugins\\jobStorrage\\ "+filename + ".dat");
     22        Stream jobstream = File.Create(path + filename + ".dat");
    1923        jobstream.Write(job, 0, job.Length);
    20         StoredJobsList.Add(info);
     24        storedJobsList.Add(info);
    2125        jobstream.Close();
    2226        Logging.GetInstance().Info("JobStorrageManager", "Job " + info.JobID + " stored on the harddisc");
     
    2832
    2933    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       //   }
    3347        }
    3448      }
Note: See TracChangeset for help on using the changeset viewer.