Line | |
---|
1 | using System;
|
---|
2 | using System.Collections.Generic;
|
---|
3 | using System.Linq;
|
---|
4 | using System.Text;
|
---|
5 | using System.IO;
|
---|
6 | using HeuristicLab.Hive.Client.Common;
|
---|
7 | using HeuristicLab.Hive.Client.Communication;
|
---|
8 |
|
---|
9 | namespace 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.