Free cookie consent management tool by TermsFeed Policy Generator

source: trunk/sources/HeuristicLab.Hive.Client.Core/JobStorrage/JobStorrageManager.cs @ 1260

Last change on this file since 1260 was 1260, checked in by kgrading, 16 years ago

updates and extension of the implementation (#493)

File size: 1.6 KB
Line 
1using System;
2using System.Collections.Generic;
3using System.Linq;
4using System.Text;
5using System.IO;
6using HeuristicLab.Hive.Client.Common;
7using HeuristicLab.Hive.Client.Communication;
8
9namespace HeuristicLab.Hive.Client.Core.JobStorrage {
10  public class JobStorrageManager {
11    private static List<JobStorrageInfo> StoredJobsList = new List<JobStorrageInfo>();
12   
13    public static void PersistObjectToDisc(String serverIP, long serverPort, long jobId, byte[] job) {
14      String filename = serverIP + "." + serverPort + "." + jobId.ToString();
15     
16      JobStorrageInfo info = new JobStorrageInfo { JobID = jobId, ServerIP = serverIP, ServerPort = serverPort, TimeFinished = DateTime.Now };
17      try {
18        Stream jobstream = File.Create("C:\\Program Files\\HeuristicLab 3.0\\plugins\\jobStorrage\\ "+filename + ".dat");
19        jobstream.Write(job, 0, job.Length);
20        StoredJobsList.Add(info);
21        jobstream.Close();
22        Logging.GetInstance().Info("JobStorrageManager", "Job " + info.JobID + " stored on the harddisc");
23      }
24      catch (Exception e) {
25        Console.WriteLine(e);
26      }       
27    }
28
29    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");
33        }
34      }
35    }
36  }
37}
Note: See TracBrowser for help on using the repository browser.