Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain.csproj
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain.csproj	(revision 12822)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain.csproj	(revision 12823)
@@ -75,4 +75,5 @@
     </Compile>
     <Compile Include="JobDownloader.cs" />
+    <Compile Include="JobTaskOneFileDownloader.cs" />
     <Compile Include="Plugin.cs" />
     <Compile Include="Properties\AssemblyInfo.cs" />
Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HiveDrainMainWindow.Designer.cs
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HiveDrainMainWindow.Designer.cs	(revision 12822)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HiveDrainMainWindow.Designer.cs	(revision 12823)
@@ -1,3 +1,3 @@
-﻿namespace HiveDrain {
+﻿namespace HeuristicLab.HiveDrain {
   partial class HiveDrainMainWindow {
     /// <summary>
@@ -29,4 +29,5 @@
       this.downloadButton = new System.Windows.Forms.Button();
       this.logView = new HeuristicLab.Core.Views.LogView();
+      this.oneFileCheckBox = new System.Windows.Forms.CheckBox();
       this.SuspendLayout();
       // 
@@ -73,4 +74,14 @@
       this.logView.TabIndex = 4;
       // 
+      // oneFileCheckBox
+      // 
+      this.oneFileCheckBox.AutoSize = true;
+      this.oneFileCheckBox.Location = new System.Drawing.Point(15, 44);
+      this.oneFileCheckBox.Name = "oneFileCheckBox";
+      this.oneFileCheckBox.Size = new System.Drawing.Size(102, 17);
+      this.oneFileCheckBox.TabIndex = 5;
+      this.oneFileCheckBox.Text = "Save as one file";
+      this.oneFileCheckBox.UseVisualStyleBackColor = true;
+      // 
       // HiveDrainMainWindow
       // 
@@ -78,4 +89,5 @@
       this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
       this.ClientSize = new System.Drawing.Size(842, 447);
+      this.Controls.Add(this.oneFileCheckBox);
       this.Controls.Add(this.logView);
       this.Controls.Add(this.downloadButton);
@@ -97,4 +109,5 @@
     private System.Windows.Forms.Button downloadButton;
     private HeuristicLab.Core.Views.LogView logView;
+    private System.Windows.Forms.CheckBox oneFileCheckBox;
   }
 }
Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HiveDrainMainWindow.cs
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HiveDrainMainWindow.cs	(revision 12822)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/HiveDrainMainWindow.cs	(revision 12823)
@@ -5,5 +5,5 @@
 using HeuristicLab.Core;
 
-namespace HiveDrain {
+namespace HeuristicLab.HiveDrain {
   public partial class HiveDrainMainWindow : Form {
     public HiveDrainMainWindow() {
@@ -29,5 +29,5 @@
       downloadButton.Enabled = false;
 
-      JobDownloader jobDownloader = new JobDownloader(Environment.CurrentDirectory, pattern, Log);
+      JobDownloader jobDownloader = new JobDownloader(Environment.CurrentDirectory, pattern, Log, oneFileCheckBox.Checked);
       task = new Task(jobDownloader.Start);
       task.ContinueWith(x => { Log.LogMessage("All tasks written, quitting."); EnableButton(); }, TaskContinuationOptions.OnlyOnRanToCompletion);
Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobDownloader.cs
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobDownloader.cs	(revision 12822)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobDownloader.cs	(revision 12823)
@@ -1,3 +1,24 @@
-﻿using System;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
 using System.Collections.Generic;
 using System.IO;
@@ -6,20 +27,22 @@
 using HeuristicLab.Core;
 
-
-namespace HiveDrain {
+namespace HeuristicLab.HiveDrain {
   /// <summary>
   /// Retrieves all jobs and starts downloading their tasks
   /// </summary>
-  class JobDownloader {
+  public class JobDownloader {
     public string RootLocation { get; set; }
 
     public string NamePattern { get; set; }
 
+    public bool OneFile { get; set; }
+
     private ILog log;
 
-    public JobDownloader(string location, string pattern, ILog log) {
+    public JobDownloader(string location, string pattern, ILog log, bool oneFile = false) {
       RootLocation = location;
       NamePattern = pattern;
       this.log = log;
+      OneFile = oneFile;
     }
 
@@ -34,6 +57,11 @@
           log.LogMessage(String.Format("\"{0}\": {1}", j.Name, j.Id));
 
-          JobTaskDownloader taskDownloader = new JobTaskDownloader(jobPath, j, limitSemaphore, log);
-          taskDownloader.Start();
+          if (OneFile) {
+            JobTaskOneFileDownloader taskDownloader = new JobTaskOneFileDownloader(jobPath, j, limitSemaphore, log);
+            taskDownloader.Start();
+          } else {
+            JobTaskDownloader taskDownloader = new JobTaskDownloader(jobPath, j, limitSemaphore, log);
+            taskDownloader.Start();
+          }
         } else {
           log.LogMessage(String.Format("\"{0}\": {1} ---> ignored", j.Name, j.Id));
Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobTaskDownloader.cs
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobTaskDownloader.cs	(revision 12822)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobTaskDownloader.cs	(revision 12823)
@@ -1,3 +1,24 @@
-﻿using System;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
 using System.Collections.Generic;
 using System.IO;
@@ -8,9 +29,9 @@
 using HeuristicLab.Core;
 
-namespace HiveDrain {
+namespace HeuristicLab.HiveDrain {
   /// <summary>
   /// downloads all finished tasks for a job
   /// </summary>
-  class JobTaskDownloader {
+  public class JobTaskDownloader {
     public String RootLocation { get; set; }
     public Job ParentJob { get; set; }
Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobTaskOneFileDownloader.cs
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobTaskOneFileDownloader.cs	(revision 12823)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/JobTaskOneFileDownloader.cs	(revision 12823)
@@ -0,0 +1,128 @@
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
+using System.Collections.Generic;
+using System.Threading;
+using HeuristicLab.Clients.Hive;
+using HeuristicLab.Clients.Hive.Jobs;
+using HeuristicLab.Common;
+using HeuristicLab.Core;
+using HeuristicLab.Optimization;
+
+namespace HeuristicLab.HiveDrain {
+  public class JobTaskOneFileDownloader {
+    public String RootLocation { get; set; }
+
+    public Job ParentJob { get; set; }
+
+    private ILog log;
+
+    private RunCollection results = new RunCollection();
+
+    private static ConcurrentTaskDownloader<ItemTask> downloader =
+        new ConcurrentTaskDownloader<ItemTask>(HeuristicLabHiveDrainApplication.MaxParallelDownloads, HeuristicLabHiveDrainApplication.MaxParallelDownloads);
+
+    private static int jobCount = 0;
+
+    private static bool endReached = false;
+
+    private ManualResetEvent allJobsFinished = new ManualResetEvent(false);
+
+    private Semaphore limitSemaphore = null;
+
+    static JobTaskOneFileDownloader() {
+      downloader.ExceptionOccured += downloader_ExceptionOccured;
+    }
+
+    static void downloader_ExceptionOccured(object sender, HeuristicLab.Common.EventArgs<Exception> e) {
+      HiveDrainMainWindow.Log.LogMessage(DateTime.Now.ToShortTimeString() + " ### Exception occured: " + e.Value);
+    }
+
+    public JobTaskOneFileDownloader(string path, Job parentJob, Semaphore sem, ILog log) {
+      RootLocation = path + ".hl";
+      ParentJob = parentJob;
+      limitSemaphore = sem;
+      this.log = log;
+    }
+
+    public void Start() {
+      results = new RunCollection();
+
+      IEnumerable<LightweightTask> allTasks;
+      allTasks = HiveServiceLocator.Instance.CallHiveService(s =>
+          s.GetLightweightJobTasksWithoutStateLog(ParentJob.Id));
+
+      foreach (var lightTask in allTasks) {
+        if (lightTask.State == TaskState.Finished) {
+          AddDownloaderTask(lightTask.Id);
+          log.LogMessage(String.Format("   Getting Id {0}: {1}", lightTask.Id, DateTime.Now.ToShortTimeString()));
+        } else
+          log.LogMessage(String.Format("   {0} => ignored ({1})", lightTask.Id, lightTask.State.ToString()));
+      }
+      endReached = true;
+      if (jobCount == 0)
+        allJobsFinished.Set();
+
+      allJobsFinished.WaitOne();
+      log.LogMessage("Saving data to file...");
+      ContentManager.Save(results, RootLocation, true);
+
+      GC.Collect();
+      log.LogMessage(String.Format("All tasks for job {0} finished", ParentJob.Name));
+    }
+
+    /// <summary>
+    /// adds a task with state finished to the downloader
+    /// </summary>
+    /// <param name="taskId"></param>
+    /// <param name="taskPath"></param>
+    private void AddDownloaderTask(Guid taskId) {
+      //wait for free slot
+      limitSemaphore.WaitOne();
+
+      Interlocked.Increment(ref jobCount);
+      downloader.DownloadTaskDataAndTask(taskId, (task, itemTask) => {
+
+        log.LogMessage(String.Format("\"{0}\" - [{1}]: {2} finished", ParentJob.Name, task.Id, itemTask.Name));
+        if (itemTask is OptimizerTask) {
+          OptimizerTask optimizerTask = itemTask as OptimizerTask;
+          IOptimizer opt = (IOptimizer)optimizerTask.Item;
+
+          lock (results) {
+            results.AddRange(opt.Runs);
+          }
+
+          log.LogMessage(String.Format("\"{0}\" - [{1}]: {2} added to result collection", ParentJob.Name, task.Id, itemTask.Name));
+        } else {
+          log.LogMessage(String.Format("Unsupported task type {0}", itemTask.GetType().Name));
+        }
+
+        limitSemaphore.Release();
+        Interlocked.Decrement(ref jobCount);
+
+        //if this was the last job
+        if (jobCount == 0 && endReached)
+          allJobsFinished.Set();
+      });
+    }
+  }
+}
Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/Plugin.cs
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/Plugin.cs	(revision 12822)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/Plugin.cs	(revision 12823)
@@ -1,6 +1,27 @@
-﻿using System.Windows.Forms;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System.Windows.Forms;
 using HeuristicLab.PluginInfrastructure;
 
-namespace HiveDrain {
+namespace HeuristicLab.HiveDrain {
   // Hive Drain HeuristicLab Application, based on the original code of apetrei's Hive Drain Console Application
   [Plugin("HeuristicLab.HiveDrain", "1.0.0.0")]
Index: /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/TaskSerializer.cs
===================================================================
--- /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/TaskSerializer.cs	(revision 12822)
+++ /branches/HeuristicLab.Tools/HeuristicLab.HiveDrain/HeuristicLab.HiveDrain/TaskSerializer.cs	(revision 12823)
@@ -1,7 +1,27 @@
-﻿using System;
+﻿#region License Information
+/* HeuristicLab
+ * Copyright (C) 2002-2015 Heuristic and Evolutionary Algorithms Laboratory (HEAL)
+ *
+ * This file is part of HeuristicLab.
+ *
+ * HeuristicLab is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * HeuristicLab is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with HeuristicLab. If not, see <http://www.gnu.org/licenses/>.
+ */
+#endregion
+
+using System;
 using HeuristicLab.Common;
 
-
-namespace HiveDrain {
+namespace HeuristicLab.HiveDrain {
   static class TaskSerializer {
     public static void Serialize(SerializerTask serializerTask) {
