Index: trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs
===================================================================
--- trunk/sources/HeuristicLab.Hive.Server.Core/3.2/ClientCommunicator.cs	(revision 3203)
+++ 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 3203)
+++ 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 3203)
+++ 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 3203)
+++ 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 3203)
+++ 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 3203)
+++ 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);
+    }
   }
 }
