Index: trunk/sources/HeuristicLab.Hive.Client.Console/3.2/HiveClientConsole.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Client.Console/3.2/HiveClientConsole.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Client.Console/3.2/HiveClientConsole.cs	(revision 3220)
@@ -531,4 +531,6 @@
           onlineTimes = e.Result.ToList<Appointment>();
           onlineTimes.ForEach(a => a.BorderColor = Color.Red);
+          dvOnline.Invalidate();
+
         }
         else
Index: trunk/sources/HeuristicLab.Hive.Client.Core/3.2/ConfigurationManager/UptimeManager.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Client.Core/3.2/ConfigurationManager/UptimeManager.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Client.Core/3.2/ConfigurationManager/UptimeManager.cs	(revision 3220)
@@ -33,4 +33,8 @@
         return instance;
       }
+    }
+
+    public UptimeManager() {
+      RestoreFromHDD();
     }
 
Index: trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Client.Core/3.2/Core.cs	(revision 3220)
@@ -311,6 +311,6 @@
     /// <param name="e"></param>
     void wcfService_SendJobCompleted(object sender, SendJobCompletedEventArgs e) {
-      Logging.Instance.Info(this.ToString(), "Received new job with id " + e.Result.Job.Id);
-      if (e.Result.StatusMessage != ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT) {        
+      if (e.Result.StatusMessage != ApplicationConstants.RESPONSE_COMMUNICATOR_NO_JOBS_LEFT) {
+        Logging.Instance.Info(this.ToString(), "Received new job with id " + e.Result.Job.Id);      
         bool sandboxed = false;
         List<byte[]> files = new List<byte[]>();
Index: trunk/sources/HeuristicLab.Hive.Client.Core/3.2/JobStorage/JobStorageManager.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Client.Core/3.2/JobStorage/JobStorageManager.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Client.Core/3.2/JobStorage/JobStorageManager.cs	(revision 3220)
@@ -63,4 +63,5 @@
             Logging.Instance.Error("JobStorageManager", "Job not on hdd but on list - deleting job from list", e);
             storedJobsList.Remove(storedJobsList[index - 1]);
+            StoreJobList();
           }
       
@@ -82,7 +83,8 @@
             
       XmlSerializer serializer = new XmlSerializer(typeof(List<JobStorageInfo>));
+      FileStream stream = null;
       if(File.Exists(Path.Combine(path ,"list.xml"))) {
         try {
-          FileStream stream = new FileStream(Path.Combine(path, "list.xml"), FileMode.Open);
+          stream = new FileStream(Path.Combine(path, "list.xml"), FileMode.Open);
           XmlTextReader reader = new XmlTextReader(stream);
           storedJobsList = (List<JobStorageInfo>)serializer.Deserialize(reader);
@@ -91,4 +93,7 @@
         catch (Exception e) {
           Logging.Instance.Error("JobStorageManager", "Exception while loading the Stored Job List", e);
+        } finally {
+          if(stream != null) 
+            stream.Dispose();
         }
       } else {
Index: trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IExecutionEngineFacade.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IExecutionEngineFacade.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IExecutionEngineFacade.cs	(revision 3220)
@@ -33,9 +33,11 @@
     ResponseObject<JobDto> AddJob(SerializedJob job);
     [OperationContract]
+    ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob jobObj, IEnumerable<string> groups);
+    [OperationContract]
     Response RequestSnapshot(Guid jobId);
     [OperationContract]
     ResponseObject<SerializedJob> GetLastSerializedResult(Guid jobId, bool requested);
     [OperationContract]
-    Response AbortJob(Guid jobId);
+    Response AbortJob(Guid jobId);    
   }
 }
Index: trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IJobManager.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IJobManager.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Contracts/3.2/Interfaces/IJobManager.cs	(revision 3220)
@@ -61,4 +61,6 @@
     [OperationContract]
     ResponseList<JobDto> GetJobsByProject(Guid projectId);
+    [OperationContract]
+    ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources);
   }
 }
Index: trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Engine/3.2/HiveEngine.cs	(revision 3220)
@@ -94,6 +94,11 @@
       var jobObj = CreateJobObj();
       IExecutionEngineFacade executionEngineFacade = ServiceLocator.CreateExecutionEngineFacade(HiveServerUrl);
-      
-      if(!String.Empty.Equals(RessourceIds)) {
+
+      List<string> groups = new List<string>();
+      if (!String.Empty.Equals(RessourceIds)) {
+        groups.AddRange(RessourceIds.Split(';'));        
+      }
+
+      /*if(!String.Empty.Equals(RessourceIds)) {
         String[] ids = RessourceIds.Split(';');
         foreach (string sid in ids) {        
@@ -105,5 +110,5 @@
           }   
         }
-      }      
+      } */     
 
       int loops = 1;
@@ -114,5 +119,5 @@
 
       for (int i = 0; i < loops; i++) {
-        ResponseObject<Contracts.BusinessObjects.JobDto> res = executionEngineFacade.AddJob(jobObj);
+        ResponseObject<Contracts.BusinessObjects.JobDto> res = executionEngineFacade.AddJobWithGroupStrings(jobObj, groups);
         jobId = res.Obj.Id;
       }
Index: trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.Designer.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.Designer.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.Designer.cs	(revision 3220)
@@ -24,5 +24,5 @@
     /// </summary>
     private void InitializeComponent() {
-      Calendar.DrawTool drawTool2 = new Calendar.DrawTool();
+      Calendar.DrawTool drawTool1 = new Calendar.DrawTool();
       this.dvOnline = new Calendar.DayView();
       this.btnSaveCal = new System.Windows.Forms.Button();
@@ -46,6 +46,6 @@
       // dvOnline
       // 
-      drawTool2.DayView = this.dvOnline;
-      this.dvOnline.ActiveTool = drawTool2;
+      drawTool1.DayView = this.dvOnline;
+      this.dvOnline.ActiveTool = drawTool1;
       this.dvOnline.AmPmDisplay = false;
       this.dvOnline.AppointmentDuration = Calendar.AppointmentSlotDuration.SixtyMinutes;
@@ -67,4 +67,5 @@
       this.dvOnline.StartDate = new System.DateTime(((long)(0)));
       this.dvOnline.TabIndex = 42;
+      this.dvOnline.OnSelectionChanged += new System.EventHandler<System.EventArgs>(this.dvOnline_OnSelectionChanged);
       // 
       // btnSaveCal
@@ -231,5 +232,4 @@
       this.Controls.Add(this.dvOnline);
       this.Name = "CgCalendar";
-      this.Text = "Calendar";
       this.groupBox1.ResumeLayout(false);
       this.groupBox1.PerformLayout();
Index: trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Console/3.2/CgCalendar.cs	(revision 3220)
@@ -28,4 +28,5 @@
 
     public Guid ResourceId { get; set; }
+    public string Name { get; set; }
 
     [XmlArray("Appointments")]
@@ -33,6 +34,8 @@
     public List<Appointment> onlineTimes = new List<Appointment>();
 
-    public CgCalendar(Guid resourceId) {
+    public CgCalendar(Guid resourceId, String name) {      
+      Name = name;
       ResourceId = resourceId;
+      this.Text = Name + "(" + ResourceId + ")";
       InitializeComponent();
       InitCalender();
Index: trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Console/3.2/HiveServerManagementConsole.cs	(revision 3220)
@@ -131,5 +131,5 @@
       menuItemOpenCalendar.Click += (s, e) => {
                                       if (tvClientControl.SelectedNode != null) {
-                                        CgCalendar cal = new CgCalendar(((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id);                                        
+                                        CgCalendar cal = new CgCalendar(((ClientGroupDto)tvClientControl.SelectedNode.Tag).Id, ((ClientGroupDto)tvClientControl.SelectedNode.Tag).Name);                                        
                                         cal.Show();
                                       }
Index: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs	(revision 3220)
@@ -41,4 +41,5 @@
 using Linq = HeuristicLab.Hive.Server.LINQDataAccess;
 using System.Transactions;
+using HeuristicLab.Hive.Server.LINQDataAccess;
 
 namespace HeuristicLab.Hive.Server.Core {
@@ -107,5 +108,7 @@
                               " wasn't offline but hasn't sent heartbeats - Resetting all his jobs");
               foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) {
-                jobManager.ResetJobsDependingOnResults(job);
+                //maybe implementa n additional Watchdog? Till then, just set them offline..
+                DaoLocator.JobDao.SetJobOffline(job);                
+                //jobManager.ResetJobsDependingOnResults(job);
               }
             } else {
@@ -193,7 +196,12 @@
       heartbeatLock.ExitWriteLock();
 
+      ClientDto dbClient = DaoLocator.ClientDao.FindById(clientInfo.Id);
+
+      //Really set offline? 
+      //Reconnect issues with the currently calculating jobs
       clientInfo.State = State.idle;
-
-      if (DaoLocator.ClientDao.FindById(clientInfo.Id) == null)
+      clientInfo.CalendarSyncStatus = dbClient != null ? dbClient.CalendarSyncStatus : CalendarState.NotAllowedToFetch;
+
+      if (dbClient == null)
         DaoLocator.ClientDao.Insert(clientInfo);
       else
@@ -336,7 +344,6 @@
     private void processJobProcess(HeartBeatData hbData, ResponseHB response) {
       HiveLogger.Info(this.ToString() + " processJobProcess: Started for Client " + hbData.ClientId);
-
-      if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {
-        List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId)));
+      List<JobDto> jobsOfClient = new List<JobDto>(DaoLocator.JobDao.FindActiveJobsOfClient(DaoLocator.ClientDao.FindById(hbData.ClientId)));
+      if (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {        
         if (jobsOfClient == null || jobsOfClient.Count == 0) {
           response.Success = false;
@@ -369,6 +376,8 @@
           DaoLocator.JobDao.Update(curJob);
         }
-        foreach (JobDto currJob in jobsOfClient) {
-          bool found = false;
+       }
+      foreach (JobDto currJob in jobsOfClient) {
+        bool found = false;
+        if(hbData.JobProgress != null) {
           foreach (Guid jobId in hbData.JobProgress.Keys) {
             if (jobId == currJob.Id) {
@@ -377,32 +386,32 @@
             }
           }
-          if (!found) {
-            lock (newAssignedJobs) {
-              if (newAssignedJobs.ContainsKey(currJob.Id)) {
-                newAssignedJobs[currJob.Id]--;
-                HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client);
-                if (newAssignedJobs[currJob.Id] <= 0) {
-                  HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client);
-
-                  currJob.State = State.offline;
-                  DaoLocator.JobDao.Update(currJob);
-
-                  response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id));
-
-                  newAssignedJobs.Remove(currJob.Id);
-                }
-              } else {
-                HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);
+        }
+        if (!found) {
+          lock (newAssignedJobs) {
+            if (newAssignedJobs.ContainsKey(currJob.Id)) {
+              newAssignedJobs[currJob.Id]--;
+              HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL Reduced by one for job: " + currJob + "and is now: " + newAssignedJobs[currJob.Id] + ". User that sucks: " + currJob.Client);
+              if (newAssignedJobs[currJob.Id] <= 0) {
+                HiveLogger.Error(this.ToString() + " processJobProcess: Job TTL reached Zero, Job gets removed: " + currJob + " and set back to offline. User that sucks: " + currJob.Client);
+
                 currJob.State = State.offline;
                 DaoLocator.JobDao.Update(currJob);
-              }
-            } // lock
-          } else {
-            lock (newAssignedJobs) {
-
-              if (newAssignedJobs.ContainsKey(currJob.Id)) {
-                HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob);
+
+                response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.AbortJob, currJob.Id));
+
                 newAssignedJobs.Remove(currJob.Id);
               }
+            } else {
+              HiveLogger.Error(this.ToString() + " processJobProcess: Job ID wasn't with the heartbeats:  " + currJob);
+              currJob.State = State.offline;
+              DaoLocator.JobDao.Update(currJob);
+            }
+          } // lock
+        } else {
+          lock (newAssignedJobs) {
+
+            if (newAssignedJobs.ContainsKey(currJob.Id)) {
+              HiveLogger.Info(this.ToString() + " processJobProcess: Job is sending a heart beat, removing it from the newAssignedJobList: " + currJob);
+              newAssignedJobs.Remove(currJob.Id);
             }
           }
Index: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientFacade.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientFacade.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientFacade.cs	(revision 3220)
@@ -32,4 +32,5 @@
 using System.ServiceModel;
 using HeuristicLab.Hive.Server.Core.InternalInterfaces;
+using System.Transactions;
 
 namespace HeuristicLab.Hive.Server.Core {
@@ -103,6 +104,7 @@
         new MultiStream();
 
-      ResponseJob job = 
-        this.SendJob(clientId);
+      ResponseJob job = null;
+
+      job = this.SendJob(clientId);      
 
       //first send response
@@ -114,9 +116,11 @@
 
       //second stream the job binary data
-      stream.AddStream(
-        ((IInternalJobManager)(jobManager)).
-        GetJobStreamById(
-          job.Job.Id));
-
+      
+      if(job.Job != null)
+        stream.AddStream(
+          ((IInternalJobManager) (jobManager)).
+            GetJobStreamById(
+            job.Job.Id));
+      
       OperationContext clientContext = OperationContext.Current;
         clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) {
Index: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/DbTestApp.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Core/3.2/DbTestApp.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Core/3.2/DbTestApp.cs	(revision 3220)
@@ -22,4 +22,5 @@
 using System;
 using System.Collections.Generic;
+using System.Data.SqlClient;
 using System.Text;
 using HeuristicLab.PluginInfrastructure;
@@ -35,261 +36,10 @@
 using HeuristicLab.Core;
 using HeuristicLab.Hive.Server.LINQDataAccess;
+using System.Transactions;
 
 namespace HeuristicLab.Hive.Server {
   [Application("Hive DB Test App", "Test Application for the Hive DataAccess Layer")]
   class HiveDbTestApplication : ApplicationBase {
-    /*  private void TestClientAdapter() {
-        IClientAdapter clientAdapter =
-          ServiceLocator.GetClientAdapter();
-
-        ClientInfo client = new ClientInfo();
-        client.Login = DateTime.Now;
-        clientAdapter.Update(client);
-
-        ClientInfo clientRead =
-          clientAdapter.GetById(client.Id);
-        Debug.Assert(
-          clientRead != null &&
-          client.Id == clientRead.Id);
-
-        client.CpuSpeedPerCore = 2000;
-        clientAdapter.Update(client);
-        clientRead =
-          clientAdapter.GetById(client.Id);
-        Debug.Assert(
-         clientRead != null &&
-         client.Id == clientRead.Id &&
-         clientRead.CpuSpeedPerCore == 2000);
-
-        ICollection<ClientInfo> clients = 
-          clientAdapter.GetAll();
-        int count = clients.Count;
-
-        clientAdapter.Delete(client);
-
-        clients = clientAdapter.GetAll();
-        Debug.Assert(count - 1 == clients.Count);
-      } 
-
-      private void TestClientGroupAdapter() {
-        ISessionFactory factory =
-          ServiceLocator.GetSessionFactory();
-
-        ISession session =
-          factory.GetSessionForCurrentThread();
-
-        ITransaction trans = null;
-
-        try {
-          IClientGroupAdapter clientGroupAdapter =
-          session.GetDataAdapter<ClientGroup, IClientGroupAdapter>();
-
-          trans =
-            session.BeginTransaction();
-
-          ClientInfo client =
-            new ClientInfo();
-          client.Name = "Stefan";
-          client.Login = DateTime.Now;
-
-          ClientInfo client2 =
-            new ClientInfo();
-          client2.Name = "Martin";
-          client2.Login = DateTime.Now;
-
-          ClientInfo client3 =
-            new ClientInfo();
-          client3.Name = "Heinz";
-          client3.Login = DateTime.Now;
-
-          ClientGroup group =
-            new ClientGroup();
-
-          ClientGroup subGroup =
-            new ClientGroup();
-          subGroup.Resources.Add(client);
-
-          group.Resources.Add(client3);
-          group.Resources.Add(client2);
-          group.Resources.Add(subGroup);
-
-          clientGroupAdapter.Update(group);
-
-          ClientGroup read =
-            clientGroupAdapter.GetById(group.Id);
-
-          ICollection<ClientGroup> clientGroups =
-            clientGroupAdapter.GetAll();
-
-          IClientAdapter clientAdapter =
-            session.GetDataAdapter<ClientInfo, IClientAdapter>();
-
-          clientAdapter.Delete(client3);
-
-          read =
-             clientGroupAdapter.GetById(group.Id);
-
-          clientGroupAdapter.Delete(subGroup);
-
-          read =
-             clientGroupAdapter.GetById(group.Id);
-
-          clientGroups =
-            clientGroupAdapter.GetAll();
-
-          clientGroupAdapter.Delete(group);
-
-          clientGroups =
-            clientGroupAdapter.GetAll();
-
-          clientAdapter.Delete(client);
-          clientAdapter.Delete(client2);
-        }
-        finally {
-          if (trans != null)
-            trans.Rollback();
-
-          session.EndSession();
-        }
-      }
-
-      private void InsertTestClientGroups() {
-        ISessionFactory factory =
-          ServiceLocator.GetSessionFactory();
-
-        ISession session =
-          factory.GetSessionForCurrentThread();
-
-        ITransaction trans = null;
-
-        try {
-          IClientGroupAdapter clientGroupAdapter =
-          session.GetDataAdapter<ClientGroup, IClientGroupAdapter>();
-
-          trans =
-            session.BeginTransaction();
-
-          ClientInfo client =
-            new ClientInfo();
-          client.Name = "Stefan";
-          client.Login = DateTime.Now;
-
-          ClientInfo client2 =
-            new ClientInfo();
-          client2.Name = "Martin";
-          client2.Login = DateTime.Now;
-
-          ClientGroup group =
-            new ClientGroup();
-          group.Name = "Gruppe1";
-
-          ClientGroup subGroup =
-            new ClientGroup();
-          subGroup.Name = "Untergruppe1";
-          subGroup.Resources.Add(client);
-
-          group.Resources.Add(client2);
-          group.Resources.Add(subGroup);
-
-          clientGroupAdapter.Update(group);
-
-          trans.Commit();
-        }
-        finally {
-          session.EndSession();
-        }
-      }
-
-      private void TestJobAdapter() {
-        IJobAdapter jobAdapter = 
-          ServiceLocator.GetJobAdapter();
-        IClientAdapter clientAdapter =
-          ServiceLocator.GetClientAdapter();
-
-        Job job = new Job();
-
-        ClientInfo client = new ClientInfo();
-        client.Login = DateTime.Now;
-
-        job.Client = client;
-        jobAdapter.Update(job);
-
-        ICollection<Job> jobs = jobAdapter.GetAll();
-
-        jobAdapter.Delete(job);
-        clientAdapter.Delete(client);
-
-        jobs = jobAdapter.GetAll();
-      }
-
-      private void TestJobResultsAdapter() {
-        Job job = new Job();
-
-        ClientInfo client = new ClientInfo();
-        client.Login = DateTime.Now;
-
-        job.Client = client;
-
-        IJobResultsAdapter resultsAdapter = 
-          ServiceLocator.GetJobResultsAdapter();
-
-        byte[] resultByte = {0x0f, 0x1f, 0x2f, 0x3f, 0x4f};
-
-        JobResult result = new JobResult();
-        result.Client = client;
-        result.Job = job;
-        result.Result = resultByte;
-
-        resultsAdapter.Update(result);
-
-        JobResult read =
-          resultsAdapter.GetById(result.Id);
-        Debug.Assert(
-          read.Id == result.Id &&
-          result.Client.Id == read.Client.Id &&
-          result.Job.Id == read.Job.Id &&
-          result.Result == result.Result);
-
-        int count =
-          resultsAdapter.GetAll().Count;
-
-        resultsAdapter.Delete(result);
-
-        ICollection<JobResult> allResults =
-          resultsAdapter.GetAll();
-
-        Debug.Assert(allResults.Count == count - 1);
-
-        IJobAdapter jboAdapter =
-          ServiceLocator.GetJobAdapter();
-        jboAdapter.Delete(job);
-        IClientAdapter clientAdapter =
-          ServiceLocator.GetClientAdapter();
-        clientAdapter.Delete(client);
-      }      
-
-      private void TestTransaction() {
-        ISessionFactory factory =
-          ServiceLocator.GetSessionFactory();
-
-        ISession session =
-          factory.GetSessionForCurrentThread();
-
-        IClientAdapter clientAdapter =
-          session.GetDataAdapter<ClientInfo, IClientAdapter>();
-
-        ITransaction trans =
-          session.BeginTransaction();
-
-        ClientInfo client = new ClientInfo();
-        client.Login = DateTime.Now;
-        clientAdapter.Update(client);
-
-        trans.Rollback();
-
-        session.EndSession();
-      }  */
-
-    private void TestJobStreaming() {
+    /*private void TestJobStreaming() {
       ISessionFactory factory =
          ServiceLocator.GetSessionFactory();
@@ -489,6 +239,28 @@
 
       //SpeedTest();
-      TestJobBytearrFetching();
-
+      //TestJobBytearrFetching();
+      TestJobStreamFetching();
+
+    }
+
+    private void TestJobStreamFetching() {
+      //using (TransactionScope scope = new TransactionScope()) {
+      HiveDataContext context = ContextFactory.Context;
+
+      ContextFactory.Context.Connection.Open();
+      ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction();
+      
+      ClientFacade facade = new ClientFacade();
+      Stream stream = facade.SendStreamedJob(new Guid("F5CFB334-66A0-417C-A585-71711BA21D3F"));
+      
+      byte[] buffer = new byte[3024];
+      int read = 0;
+      
+      while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {}
+      
+      stream.Close();
+
+      //Stream stream = DaoLocator.JobDao.GetSerializedJobStream(new Guid("bbb51f87-4e2f-4499-a9b6-884e589c78b6"));
+      //}
     }
 
Index: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ExecutionEngineFacade.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ExecutionEngineFacade.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ExecutionEngineFacade.cs	(revision 3220)
@@ -44,4 +44,8 @@
     }
 
+    public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {      
+      return jobManager.AddJobWithGroupStrings(job, resources);
+    }
+
     public Response RequestSnapshot(Guid jobId) {
       return jobManager.RequestSnapshot(jobId);
Index: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Core/3.2/JobManager.cs	(revision 3220)
@@ -34,4 +34,5 @@
 using HeuristicLab.Tracing;
 using System.Transactions;
+using HeuristicLab.Hive.Server.LINQDataAccess;
 
 namespace HeuristicLab.Hive.Server.Core {
@@ -149,4 +150,14 @@
       }
     }   */
+
+    public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {
+      IClientGroupDao cgd = DaoLocator.ClientGroupDao;
+      foreach (string res in resources) {
+        foreach(ClientGroupDto cg in cgd.FindByName(res)) {
+          job.JobInfo.AssignedResourceIds.Add(cg.Id);
+        }
+      }
+      return AddNewJob(job);
+    }
 
     /// <summary>
Index: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ServerConsoleFacade.cs	(revision 3220)
@@ -180,4 +180,7 @@
     }
 
+    public ResponseObject<JobDto> AddJobWithGroupStrings(SerializedJob job, IEnumerable<string> resources) {
+      return jobManager.AddJobWithGroupStrings(job, resources);
+    }
   }
 }
Index: trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/HeuristicLab.Hive.Server.DataAccess-3.2.csproj
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/HeuristicLab.Hive.Server.DataAccess-3.2.csproj	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/HeuristicLab.Hive.Server.DataAccess-3.2.csproj	(revision 3220)
@@ -93,5 +93,4 @@
     <Compile Include="IJobResultsAdapter.cs" />
     <Compile Include="IResourceAdapter.cs" />
-    <Compile Include="VarBinaryStream.cs" />
   </ItemGroup>
   <ItemGroup>
Index: trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/IClientGroupDao.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/IClientGroupDao.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/IClientGroupDao.cs	(revision 3220)
@@ -13,4 +13,6 @@
     IEnumerable<ClientGroupDto> FindAllWithSubGroupsAndClients();
     IEnumerable<Guid> FindAllGroupAndParentGroupIdsForClient(Guid clientId);
+
+    IEnumerable<ClientGroupDto> FindByName(string res);
   }
 }
Index: trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/VarBinaryStream.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.DataAccess/3.2/VarBinaryStream.cs	(revision 3219)
+++ 	(revision )
@@ -1,277 +1,0 @@
-/* Based on: 
- *   http://www.eggheadcafe.com/conversation.aspx?messageid=29988910&threadid=29988841
- * */
-
-using System;
-using System.IO;
-using System.Data.SqlClient;
-using System.Data;
-
-namespace HeuristicLab.Hive.Server.DataAccess {
-  /// <summary>
-  /// The VarBinaryStream class inherits from Stream. It uses a
-  /// VarBinarySource class to execute the actual TSQL.
-  /// </summary>
-  public class VarBinaryStream : Stream, IDisposable {
-    private long _position;
-    private readonly VarBinarySource _source;
-
-    public VarBinaryStream(VarBinarySource source) {
-      _position = 0;
-      _source = source;
-    }
-
-    public override bool CanRead {
-      get { return true; }
-    }
-
-    public override bool CanSeek {
-      get { return true; }
-    }
-
-    public override bool CanWrite {
-      get { return true; }
-    }
-
-    public override long Length {
-      get { return _source.Length; }
-    }
-
-    public override long Position {
-      get { return _position; }
-      set { this.Seek(value, SeekOrigin.Begin); }
-    }
-
-    public override void Flush() { }
-
-    public override long Seek(long offset, SeekOrigin origin) {
-      switch (origin) {
-        case SeekOrigin.Begin: {
-            if ((offset < 0) && (offset > this.Length))
-              throw new ArgumentException("Invalid seek origin.");
-            _position = offset;
-            break;
-          }
-        case SeekOrigin.End: {
-            if ((offset > 0) && (offset < -this.Length))
-              throw new ArgumentException("Invalid seek origin.");
-            _position = this.Length - offset;
-            break;
-          }
-        case SeekOrigin.Current: {
-            if ((_position + offset > this.Length))
-              throw new ArgumentException("Invalid seek origin.");
-            _position = _position + offset;
-            break;
-          }
-        default: {
-            throw new ArgumentOutOfRangeException("origin");
-          }
-      }
-      return _position;
-    }
-
-    public override void SetLength(long value) {
-      throw new NotSupportedException();
-    }
-
-    public override int Read(byte[] buffer, int offset, int count) {
-      if (buffer == null)
-        throw new ArgumentNullException("buffer");
-      if (offset < 0)
-        throw new ArgumentOutOfRangeException("offset");
-      if (count < 0)
-        throw new ArgumentOutOfRangeException("count");
-      if (buffer.Length - offset < count)
-        throw new ArgumentException("Offset and length were out of bounds for the array");
-
-      byte[] data = _source.Read(Position, count);
-      if (data == null)
-        return 0;
-
-      Buffer.BlockCopy(data, 0, buffer, offset, data.Length);
-      _position += data.Length;
-      return data.Length;
-    }
-
-    public override void Write(byte[] buffer, int offset, int count) {
-      if (buffer == null)
-        throw new ArgumentNullException("buffer");
-      if (offset < 0)
-        throw new ArgumentOutOfRangeException("offset");
-      if (count < 0)
-        throw new ArgumentOutOfRangeException("count");
-      if (buffer.Length - offset < count)
-        throw new ArgumentException("Offset and length were out of bounds for the array");
-
-      byte[] data = GetWriteBuffer(buffer, count, offset);
-      _source.Write(data, _position, count);
-      _position += count;
-    }
-
-    private static byte[] GetWriteBuffer(byte[] buffer, int count, int
-    offset) {
-      if (buffer.Length == count)
-        return buffer;
-      byte[] data = new byte[count];
-      Buffer.BlockCopy(buffer, offset, data, 0, count);
-      return data;
-    }
-
-    public override void Close() {
-      _source.Close();
-    }
-
-    protected override void Dispose(bool disposing) {
-      if (!disposing) {
-        if (_source != null) {
-          _source.Close();
-          _source.Dispose();
-        }
-      }
-      base.Dispose(disposing);
-    }
-  }
-
-
-  public class VarBinarySource : IDisposable {
-    private SqlCommand _readCommand;
-    private SqlCommand _writeCommand;
-    private SqlConnection _connection;
-    private SqlTransaction _transaction;
-    private bool _ownedTransaction = false;
-    private bool _ownedConnection = false;
-    private readonly long _length;
-
-    public VarBinarySource(SqlConnection connection,
-      SqlTransaction transaction,
-      string table, string
-    dataColumn, string keyColumn, Guid key) {
-      _connection = connection;
-      
-      if (_connection.State == ConnectionState.Closed) {
-        _connection.Open();
-        _ownedConnection = true;
-
-        _transaction =
-          _connection.BeginTransaction(IsolationLevel.RepeatableRead) as SqlTransaction;
-        _ownedTransaction = true;
-      } else {
-        _ownedConnection = false;
-
-        if (transaction != null) {
-          _transaction = transaction;
-
-          _ownedTransaction = false;
-        } else {
-          _transaction =
-            _connection.BeginTransaction(IsolationLevel.ReadCommitted) as SqlTransaction;
-
-          _ownedTransaction = true;
-        }
-      }
-
-      _length = GetLength(connection, table, dataColumn, keyColumn, key);
-      _readCommand = CreateReadCommand(connection, table, dataColumn,
-      keyColumn, key);
-      _writeCommand = CreateWriteCommand(connection, table, dataColumn,
-      keyColumn, key);
-    }
-
-    public long Length {
-      get { return _length; }
-    }
-
-    private static SqlCommand CreateReadCommand(SqlConnection connection,
-    string table, string dataColumn, string keyColumn,
-    Guid key) {
-      SqlCommand readCommand = connection.CreateCommand();
-      readCommand.CommandText = string.Format(@"
-select substring({0}, @offset, @length)
-from {1}
-where {2} = @key", dataColumn, table, keyColumn);
-      readCommand.Parameters.Add("@key", SqlDbType.UniqueIdentifier).Value = key;
-      readCommand.Parameters.Add("@offset", SqlDbType.BigInt);
-      readCommand.Parameters.Add("@length", SqlDbType.BigInt);
-      return readCommand;
-    }
-
-    private static SqlCommand CreateWriteCommand(SqlConnection connection,
-    string table, string dataColumn, string keyColumn,
-    Guid key) {
-      SqlCommand writecommand = connection.CreateCommand();
-      writecommand.CommandText = string.Format(@"
-update {0}
-set {1}.write(@buffer, @offset, @length)
-where {2} = @key", table, dataColumn, keyColumn);
-      writecommand.Parameters.Add("@key", SqlDbType.UniqueIdentifier).Value = key;
-      writecommand.Parameters.Add("@offset", SqlDbType.BigInt);
-      writecommand.Parameters.Add("@length", SqlDbType.BigInt);
-      writecommand.Parameters.Add("@buffer", SqlDbType.VarBinary);
-      return writecommand;
-    }
-
-    private long GetLength(SqlConnection connection,
-      string table,
-    string dataColumn, string keyColumn,
-    Guid key) {
-      using (SqlCommand command = connection.CreateCommand()) {
-        command.Transaction = _transaction;
-
-        SqlParameter length = command.Parameters.Add("@length",
-        SqlDbType.BigInt);
-        length.Direction = ParameterDirection.Output;
-
-        command.CommandText = string.Format(@"
-select @length = cast(datalength({0}) as bigint)
-from {1}
-where {2} = @key", dataColumn, table, keyColumn);
-        command.Parameters.Add("@key", SqlDbType.UniqueIdentifier).Value = key;
-        command.ExecuteNonQuery();
-        return length.Value == DBNull.Value ? 0 : (long)length.Value;
-      }
-    }
-
-    public byte[] Read(long offset, long length) {
-      _readCommand.Transaction = _transaction;
-
-      // substring is 1-based.
-      _readCommand.Parameters["@offset"].Value = offset + 1;
-      _readCommand.Parameters["@length"].Value = length;
-      return (byte[])_readCommand.ExecuteScalar();
-    }
-
-    public void Write(byte[] buffer, long offset, long length) {
-      _writeCommand.Transaction = _transaction;
-
-      _writeCommand.Parameters["@buffer"].Value = buffer;
-      _writeCommand.Parameters["@offset"].Value = offset;
-      _writeCommand.Parameters["@length"].Value = length;
-      _writeCommand.ExecuteNonQuery();
-    }
-
-    public void Close() {
-      if (_transaction != null) {
-        if (_ownedTransaction)
-          _transaction.Commit();
-        _transaction = null;
-      }
-
-      if (_connection != null) {
-        if (_ownedConnection)
-          _connection.Close();
-        _connection = null;
-      }
-    }
-
-    public void Dispose() {
-      if (_readCommand != null) {
-        _readCommand.Dispose();
-      }
-      if (_writeCommand != null) {
-        _writeCommand.Dispose();
-      }
-    }
-  }
-}
-
Index: trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientGroupDao.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientGroupDao.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ClientGroupDao.cs	(revision 3220)
@@ -153,4 +153,12 @@
       return target;
     }
+
+    public IEnumerable<ClientGroupDto> FindByName(string res) {
+      return (from cq in Context.ClientGroups
+              where cq.Resource.Name == res
+              select EntityToDto(cq, null)).ToList();      
+    }
+
+
   }
 }
Index: trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/ContextFactory.cs	(revision 3220)
@@ -3,4 +3,6 @@
 using System.Linq;
 using System.Text;
+using System.Data.Common;
+using System.Data.SqlClient;
 
 namespace HeuristicLab.Hive.Server.LINQDataAccess {
@@ -8,4 +10,7 @@
     [ThreadStatic]
     private static HiveDataContext _hiveDataContext;
+
+    [ThreadStatic]
+    private static SqlTransaction _currentTransaction;
 
     public static HiveDataContext Context { 
@@ -15,8 +20,16 @@
         return _hiveDataContext;        
       } 
-      set {
+      set {        
         _hiveDataContext = value;
       }
     }
+
+    public static SqlTransaction CurrentTransaction { 
+      get {
+        return _currentTransaction;
+      } set {
+        _currentTransaction = value;
+      } 
+    }
   }
 }
Index: trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HeuristicLab.Hive.Server.LINQDataAccess-3.2.csproj
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HeuristicLab.Hive.Server.LINQDataAccess-3.2.csproj	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/HeuristicLab.Hive.Server.LINQDataAccess-3.2.csproj	(revision 3220)
@@ -106,4 +106,5 @@
     </Compile>
     <Compile Include="UptimeCalendarDao.cs" />
+    <Compile Include="VarBinaryStream.cs" />
   </ItemGroup>
   <ItemGroup>
Index: trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/JobDao.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/JobDao.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/JobDao.cs	(revision 3220)
@@ -60,5 +60,9 @@
       Job job = Context.Jobs.SingleOrDefault(j => j.JobId.Equals(bObj.Id));
       DtoToEntity(bObj, job);
-      Context.SubmitChanges();
+      try {
+        Context.SubmitChanges();
+      } catch (ChangeConflictException cfe) {
+        
+      }
     }
 
@@ -112,10 +116,7 @@
 
     public Stream GetSerializedJobStream(Guid jobId) {
-      HiveDataContext hdc = new HiveDataContext();
-      String ConnStr = hdc.Connection.ConnectionString;
-      SqlConnection connection = new SqlConnection(hdc.Connection.ConnectionString);      
       VarBinarySource source =
         new VarBinarySource(
-          connection, null,
+          (SqlConnection)Context.Connection, null,
           "Job", "SerializedJob", "JobId", jobId);
 
Index: trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/VarBinaryStream.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/VarBinaryStream.cs	(revision 3220)
+++ trunk/sources/HeuristicLab.Hive.Server.LINQDataAccess/3.2/VarBinaryStream.cs	(revision 3220)
@@ -0,0 +1,277 @@
+/* Based on: 
+ *   http://www.eggheadcafe.com/conversation.aspx?messageid=29988910&threadid=29988841
+ * */
+
+using System;
+using System.IO;
+using System.Data.SqlClient;
+using System.Data;
+
+namespace HeuristicLab.Hive.Server.LINQDataAccess {
+  /// <summary>
+  /// The VarBinaryStream class inherits from Stream. It uses a
+  /// VarBinarySource class to execute the actual TSQL.
+  /// </summary>
+  public class VarBinaryStream : Stream, IDisposable {
+    private long _position;
+    private readonly VarBinarySource _source;
+
+    public VarBinaryStream(VarBinarySource source) {
+      _position = 0;
+      _source = source;
+    }
+
+    public override bool CanRead {
+      get { return true; }
+    }
+
+    public override bool CanSeek {
+      get { return true; }
+    }
+
+    public override bool CanWrite {
+      get { return true; }
+    }
+
+    public override long Length {
+      get { return _source.Length; }
+    }
+
+    public override long Position {
+      get { return _position; }
+      set { this.Seek(value, SeekOrigin.Begin); }
+    }
+
+    public override void Flush() { }
+
+    public override long Seek(long offset, SeekOrigin origin) {
+      switch (origin) {
+        case SeekOrigin.Begin: {
+            if ((offset < 0) && (offset > this.Length))
+              throw new ArgumentException("Invalid seek origin.");
+            _position = offset;
+            break;
+          }
+        case SeekOrigin.End: {
+            if ((offset > 0) && (offset < -this.Length))
+              throw new ArgumentException("Invalid seek origin.");
+            _position = this.Length - offset;
+            break;
+          }
+        case SeekOrigin.Current: {
+            if ((_position + offset > this.Length))
+              throw new ArgumentException("Invalid seek origin.");
+            _position = _position + offset;
+            break;
+          }
+        default: {
+            throw new ArgumentOutOfRangeException("origin");
+          }
+      }
+      return _position;
+    }
+
+    public override void SetLength(long value) {
+      throw new NotSupportedException();
+    }
+
+    public override int Read(byte[] buffer, int offset, int count) {
+      if (buffer == null)
+        throw new ArgumentNullException("buffer");
+      if (offset < 0)
+        throw new ArgumentOutOfRangeException("offset");
+      if (count < 0)
+        throw new ArgumentOutOfRangeException("count");
+      if (buffer.Length - offset < count)
+        throw new ArgumentException("Offset and length were out of bounds for the array");
+
+      byte[] data = _source.Read(Position, count);
+      if (data == null)
+        return 0;
+
+      Buffer.BlockCopy(data, 0, buffer, offset, data.Length);
+      _position += data.Length;
+      return data.Length;
+    }
+
+    public override void Write(byte[] buffer, int offset, int count) {
+      if (buffer == null)
+        throw new ArgumentNullException("buffer");
+      if (offset < 0)
+        throw new ArgumentOutOfRangeException("offset");
+      if (count < 0)
+        throw new ArgumentOutOfRangeException("count");
+      if (buffer.Length - offset < count)
+        throw new ArgumentException("Offset and length were out of bounds for the array");
+
+      byte[] data = GetWriteBuffer(buffer, count, offset);
+      _source.Write(data, _position, count);
+      _position += count;
+    }
+
+    private static byte[] GetWriteBuffer(byte[] buffer, int count, int
+    offset) {
+      if (buffer.Length == count)
+        return buffer;
+      byte[] data = new byte[count];
+      Buffer.BlockCopy(buffer, offset, data, 0, count);
+      return data;
+    }
+
+    public override void Close() {
+      _source.Close();
+    }
+
+    protected override void Dispose(bool disposing) {
+      if (!disposing) {
+        if (_source != null) {
+          _source.Close();
+          _source.Dispose();
+        }
+      }
+      base.Dispose(disposing);
+    }
+  }
+
+
+  public class VarBinarySource : IDisposable {
+    private SqlCommand _readCommand;
+    private SqlCommand _writeCommand;
+    private SqlConnection _connection;
+    private SqlTransaction _transaction;
+    private bool _ownedTransaction = false;
+    private bool _ownedConnection = false;
+    private readonly long _length;
+
+    public VarBinarySource(SqlConnection connection,
+      SqlTransaction transaction,
+      string table, string
+    dataColumn, string keyColumn, Guid key) {
+      _connection = connection;
+      _transaction = (SqlTransaction) ContextFactory.Context.Transaction;
+      /*
+      if (_connection.State == ConnectionState.Closed) {
+        _connection.Open();
+        _ownedConnection = true;
+
+        _transaction =
+          _connection.BeginTransaction(IsolationLevel.RepeatableRead) as SqlTransaction;
+        _ownedTransaction = true;
+      } else {
+        _ownedConnection = false;
+
+        if (transaction != null) {
+          _transaction = transaction;
+
+          _ownedTransaction = false;
+        } else {
+          _transaction =
+            _connection.BeginTransaction(IsolationLevel.ReadCommitted) as SqlTransaction;
+
+          _ownedTransaction = true;
+        }
+      }        */
+
+      _length = GetLength(connection, table, dataColumn, keyColumn, key);
+      _readCommand = CreateReadCommand(connection, table, dataColumn,
+      keyColumn, key);
+      _writeCommand = CreateWriteCommand(connection, table, dataColumn,
+      keyColumn, key);
+    }
+
+    public long Length {
+      get { return _length; }
+    }
+
+    private static SqlCommand CreateReadCommand(SqlConnection connection,
+    string table, string dataColumn, string keyColumn,
+    Guid key) {
+      SqlCommand readCommand = connection.CreateCommand();
+      readCommand.CommandText = string.Format(@"
+select substring({0}, @offset, @length)
+from {1}
+where {2} = @key", dataColumn, table, keyColumn);
+      readCommand.Parameters.Add("@key", SqlDbType.UniqueIdentifier).Value = key;
+      readCommand.Parameters.Add("@offset", SqlDbType.BigInt);
+      readCommand.Parameters.Add("@length", SqlDbType.BigInt);
+      return readCommand;
+    }
+
+    private static SqlCommand CreateWriteCommand(SqlConnection connection,
+    string table, string dataColumn, string keyColumn,
+    Guid key) {
+      SqlCommand writecommand = connection.CreateCommand();
+      writecommand.CommandText = string.Format(@"
+update {0}
+set {1}.write(@buffer, @offset, @length)
+where {2} = @key", table, dataColumn, keyColumn);
+      writecommand.Parameters.Add("@key", SqlDbType.UniqueIdentifier).Value = key;
+      writecommand.Parameters.Add("@offset", SqlDbType.BigInt);
+      writecommand.Parameters.Add("@length", SqlDbType.BigInt);
+      writecommand.Parameters.Add("@buffer", SqlDbType.VarBinary);
+      return writecommand;
+    }
+
+    private long GetLength(SqlConnection connection,
+      string table,
+    string dataColumn, string keyColumn,
+    Guid key) {
+      using (SqlCommand command = connection.CreateCommand()) {
+        command.Transaction = _transaction;
+
+        SqlParameter length = command.Parameters.Add("@length",
+        SqlDbType.BigInt);
+        length.Direction = ParameterDirection.Output;
+
+        command.CommandText = string.Format(@"
+select @length = cast(datalength({0}) as bigint)
+from {1}
+where {2} = @key", dataColumn, table, keyColumn);
+        command.Parameters.Add("@key", SqlDbType.UniqueIdentifier).Value = key;
+        command.ExecuteNonQuery();
+        return length.Value == DBNull.Value ? 0 : (long)length.Value;
+      }
+    }
+
+    public byte[] Read(long offset, long length) {
+      _readCommand.Transaction = _transaction;
+
+      // substring is 1-based.
+      _readCommand.Parameters["@offset"].Value = offset + 1;
+      _readCommand.Parameters["@length"].Value = length;
+      return (byte[])_readCommand.ExecuteScalar();
+    }
+
+    public void Write(byte[] buffer, long offset, long length) {
+      _writeCommand.Transaction = _transaction;
+
+      _writeCommand.Parameters["@buffer"].Value = buffer;
+      _writeCommand.Parameters["@offset"].Value = offset;
+      _writeCommand.Parameters["@length"].Value = length;
+      _writeCommand.ExecuteNonQuery();
+    }
+
+    public void Close() {
+      if (_transaction != null) {
+        _transaction.Commit();
+        _transaction = null;
+      }
+
+      if (_connection != null) {
+        _connection.Close();
+        ContextFactory.Context.Dispose();
+        ContextFactory.Context = null;
+      }
+    }
+
+    public void Dispose() {
+      if (_readCommand != null) {
+        _readCommand.Dispose();
+      }
+      if (_writeCommand != null) {
+        _writeCommand.Dispose();
+      }
+    }
+  }
+}
+
Index: trunk/sources/HeuristicLab.Hive.Server/3.2/ServiceCallInterception.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server/3.2/ServiceCallInterception.cs	(revision 3219)
+++ trunk/sources/HeuristicLab.Hive.Server/3.2/ServiceCallInterception.cs	(revision 3220)
@@ -9,28 +9,73 @@
 
 namespace HeuristicLab.Hive.Server {
-  class ServiceCallInterception: IMethodInterceptor {
-    #region IMethodInterceptor Members
+  internal class ServiceCallInterception : IMethodInterceptor {
+
+    private bool useTransactions = false;
 
     public object Invoke(IMethodInvocation invocation) {
-      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " + invocation.Method.Name);
+      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Entering Method " +
+                        invocation.Method.Name);
 
-      Object obj;
-      
-      using (TransactionScope scope = new TransactionScope()) {
+      if(ContextFactory.Context != null) {
+        Console.WriteLine("Error - Not null context found - why wasn't this disposed?");
+        ContextFactory.Context = null;
+      }
+
+      Object obj = null;
+
+      if (invocation.Method.Name.Equals("SendStreamedJob") || invocation.Method.Name.Equals("StoreFinishedJobResultStreamed")) {        
+        ContextFactory.Context.Connection.Open();
+        if(useTransactions)
+          ContextFactory.Context.Transaction = ContextFactory.Context.Connection.BeginTransaction();
         try {
           obj = invocation.Proceed();
-          scope.Complete();
-        } finally {
+          Console.WriteLine("leaving context open for Streaming");
+        }
+        catch (Exception e) {          
+          Console.WriteLine(e);
           ContextFactory.Context.Dispose();
-          Console.WriteLine("setting old context null");
           ContextFactory.Context = null;
-          Console.WriteLine("Disposing old Context");      
+        }        
+      } else {
+        if(useTransactions) {
+          using (TransactionScope scope = new TransactionScope()) {
+            try {
+              obj = invocation.Proceed();
+              scope.Complete();
+            }
+            catch (Exception e) {
+              Console.WriteLine("Exception Occured");
+              Console.WriteLine(e);
+            }
+            finally {
+              ContextFactory.Context.Dispose();
+              Console.WriteLine("setting old context null");
+              ContextFactory.Context = null;
+              Console.WriteLine("Disposing old Context");
+            }
+          }
+        } else {
+          try {
+            obj = invocation.Proceed();            
+          }
+          catch (Exception e) {
+            Console.WriteLine("Exception Occured");
+            Console.WriteLine(e);
+          }
+          finally {
+            ContextFactory.Context.Dispose();
+            Console.WriteLine("setting old context null");
+            ContextFactory.Context = null;
+            Console.WriteLine("Disposing old Context");
+          }  
         }
-      }     
-      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " + invocation.Method.Name);            
+      }
+      Console.WriteLine(DateTime.Now + " - " + Thread.CurrentThread.ManagedThreadId + " - Leaving Method " +
+                          invocation.Method.Name);
+
       return obj;
     }
-
-    #endregion
   }
 }
+     
+  
