Index: branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ClientCommunicator.cs
===================================================================
--- branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ClientCommunicator.cs	(revision 4064)
+++ branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/ClientCommunicator.cs	(revision 4091)
@@ -22,24 +22,15 @@
 using System;
 using System.Collections.Generic;
+using System.IO;
 using System.Linq;
-using System.Text;
+using System.Runtime.Serialization.Formatters.Binary;
+using System.Threading;
+using System.Transactions;
+using HeuristicLab.Hive.Contracts;
 using HeuristicLab.Hive.Contracts.BusinessObjects;
 using HeuristicLab.Hive.Contracts.Interfaces;
-using HeuristicLab.Hive.Contracts;
-using HeuristicLab.Core;
-using HeuristicLab.Hive.Server.DataAccess;
-using System.Resources;
-using System.Reflection;
-using HeuristicLab.Hive.JobBase;
 using HeuristicLab.Hive.Server.Core.InternalInterfaces;
-using System.Threading;
 using HeuristicLab.PluginInfrastructure;
-using HeuristicLab.DataAccess.Interfaces;
-using System.IO;
-using System.Runtime.Serialization.Formatters.Binary;
 using HeuristicLab.Tracing;
-using Linq = HeuristicLab.Hive.Server.LINQDataAccess;
-using System.Transactions;
-using HeuristicLab.Hive.Server.LINQDataAccess;
 
 namespace HeuristicLab.Hive.Server.Core {
@@ -75,10 +66,8 @@
 
       lifecycleManager = ServiceLocator.GetLifecycleManager();
-      jobManager = ServiceLocator.GetJobManager() as
-        IInternalJobManager;
+      jobManager = ServiceLocator.GetJobManager() as IInternalJobManager;
       scheduler = ServiceLocator.GetScheduler();
 
-      lifecycleManager.RegisterHeartbeat(
-        new EventHandler(lifecycleManager_OnServerHeartbeat));
+      lifecycleManager.RegisterHeartbeat(new EventHandler(lifecycleManager_OnServerHeartbeat));
     }
 
@@ -109,5 +98,5 @@
               foreach (JobDto job in DaoLocator.JobDao.FindActiveJobsOfClient(client)) {
                 //maybe implementa n additional Watchdog? Till then, just set them offline..
-                DaoLocator.JobDao.SetJobOffline(job);                                
+                DaoLocator.JobDao.SetJobOffline(job);
               }
             } else {
@@ -168,5 +157,5 @@
             if (pendingJobs[currJob.Id] <= 0) {
               currJob.State = State.offline;
-              DaoLocator.JobDao.Update(currJob);              
+              DaoLocator.JobDao.Update(currJob);
             } else {
               pendingJobs[currJob.Id]--;
@@ -216,12 +205,12 @@
 
       ClientDto client = DaoLocator.ClientDao.FindById(clientId);
-      if(client == null) {
+      if (client == null) {
         response.Success = false;
         response.StatusMessage = ApplicationConstants.RESPONSE_CLIENT_RESOURCE_NOT_FOUND;
         return response;
       }
-      
+
       response.ForceFetch = (client.CalendarSyncStatus == CalendarState.ForceFetch);
-      
+
       IEnumerable<AppointmentDto> appointments = DaoLocator.UptimeCalendarDao.GetCalendarForClient(client);
       if (appointments.Count() == 0) {
@@ -239,5 +228,5 @@
 
     public Response SetCalendarStatus(Guid clientId, CalendarState state) {
-      Response response = new Response();      
+      Response response = new Response();
       ClientDto client = DaoLocator.ClientDao.FindById(clientId);
       if (client == null) {
@@ -246,11 +235,11 @@
         return response;
       }
-      
+
       client.CalendarSyncStatus = state;
       DaoLocator.ClientDao.Update(client);
-      
+
       response.Success = true;
       response.StatusMessage = ApplicationConstants.RESPONSE_UPTIMECALENDAR_STATUS_UPDATED;
-      
+
       return response;
     }
@@ -298,5 +287,5 @@
 
       Logger.Debug("BEGIN Processing Heartbeat Jobs");
-      processJobProcess(hbData, response);
+      ProcessJobProcess(hbData, response);
       Logger.Debug("END Processed Heartbeat Jobs");
 
@@ -306,8 +295,8 @@
         response.StatusMessage = ApplicationConstants.RESPONSE_COMMUNICATOR_FETCH_OR_FORCEFETCH_CALENDAR;
         response.ActionRequest.Add(new MessageContainer(MessageContainer.MessageType.FetchOrForceFetchCalendar));
-        
+
         //client.CalendarSyncStatus = CalendarState.Fetching;
-        
-        Logger.Info("fetch or forcefetch sent");        
+
+        Logger.Info("fetch or forcefetch sent");
       }
 
@@ -338,8 +327,8 @@
     /// <param name="clientAdapter"></param>
     /// <param name="response"></param>
-    private void processJobProcess(HeartBeatData hbData, ResponseHB response) {
+    private void ProcessJobProcess(HeartBeatData hbData, ResponseHB response) {
       Logger.Debug("Started for Client " + 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 (hbData.JobProgress != null && hbData.JobProgress.Count > 0) {
         if (jobsOfClient == null || jobsOfClient.Count == 0) {
           response.Success = false;
@@ -372,8 +361,8 @@
           DaoLocator.JobDao.Update(curJob);
         }
-       }
+      }
       foreach (JobDto currJob in jobsOfClient) {
         bool found = false;
-        if(hbData.JobProgress != null) {
+        if (hbData.JobProgress != null) {
           foreach (Guid jobId in hbData.JobProgress.Keys) {
             if (jobId == currJob.Id) {
@@ -428,5 +417,5 @@
       JobDto job2Calculate = scheduler.GetNextJobForClient(clientId);
       if (job2Calculate != null) {
-        response.Job = job2Calculate;        
+        response.Job = job2Calculate;
         response.Job.PluginsNeeded = DaoLocator.PluginInfoDao.GetPluginDependenciesForJob(response.Job);
         response.Success = true;
@@ -437,5 +426,5 @@
             newAssignedJobs.Add(job2Calculate.Id, ApplicationConstants.JOB_TIME_TO_LIVE);
         }
-      } else {                  
+      } else {
         response.Success = false;
         response.Job = null;
@@ -449,20 +438,14 @@
     }
 
-    public ResponseResultReceived ProcessJobResult(
-      Stream stream,
-      bool finished) {
-
+    public ResponseResultReceived ProcessJobResult(Stream stream, bool finished) {
       Logger.Info("BEGIN Job received for Storage - main method:");
 
-
-      Stream jobResultStream = null;
-      Stream jobStream = null;
+      //Stream jobResultStream = null;
+      //Stream jobStream = null;
 
       //try {
-      BinaryFormatter formatter =
-        new BinaryFormatter();
-
-      JobResult result =
-        (JobResult)formatter.Deserialize(stream);
+      BinaryFormatter formatter = new BinaryFormatter();
+
+      JobResult result = (JobResult)formatter.Deserialize(stream);
 
       //important - repeatable read isolation level is required here, 
@@ -487,15 +470,15 @@
         List<byte> serializedJob = new List<byte>();
         int read = 0;
-        int i = 0;        
-        while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {          
+        int i = 0;
+        while ((read = stream.Read(buffer, 0, buffer.Length)) > 0) {
           for (int j = 0; j < read; j++) {
             serializedJob.Add(buffer[j]);
           }
-          if (i% 100 == 0)
-            Logger.Debug("Writing to stream: " + i);         
+          if (i % 100 == 0)
+            Logger.Debug("Writing to stream: " + i);
           //jobStream.Write(buffer, 0, read);
           i++;
         }
-        Logger.Debug("Done Writing, closing the stream!");               
+        Logger.Debug("Done Writing, closing the stream!");
         //jobStream.Close();
 
@@ -518,13 +501,10 @@
 
       ResponseResultReceived response = new ResponseResultReceived();
-      ClientDto client =
-        DaoLocator.ClientDao.FindById(clientId);
-
-      SerializedJob job =
-        new SerializedJob();
+      ClientDto client = DaoLocator.ClientDao.FindById(clientId);
+
+      SerializedJob job = new SerializedJob();
 
       if (job != null) {
-        job.JobInfo =
-          DaoLocator.JobDao.FindById(jobId);
+        job.JobInfo = DaoLocator.JobDao.FindById(jobId);
         job.JobInfo.Client = job.JobInfo.Client = DaoLocator.ClientDao.GetClientForJob(jobId);
       }
@@ -650,5 +630,5 @@
 
       Logger.Info("Client logged out " + clientId);
-      
+
       Response response = new Response();
 
@@ -680,5 +660,5 @@
 
       return response;
-    } 
+    }
 
     /// <summary>
