Changeset 4092 for branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ClientFacade.cs
- Timestamp:
- 07/23/10 14:17:20 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/3.3-HiveMigration/sources/HeuristicLab.Hive/HeuristicLab.Hive.Server.Core/3.3/Facades/ClientFacade.cs
r4091 r4092 33 33 using HeuristicLab.Hive.Server.Core.InternalInterfaces; 34 34 using System.Transactions; 35 using HeuristicLab.Hive.Server.LINQDataAccess; 36 using HeuristicLab.Hive.Server.DataAccess; 35 37 36 38 namespace HeuristicLab.Hive.Server.Core { 37 [ServiceBehavior(InstanceContextMode = 38 InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)] 39 public class ClientFacade: IClientFacade { 39 [ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall, ConcurrencyMode = ConcurrencyMode.Multiple)] 40 public class ClientFacade : IClientFacade { 40 41 41 public ClientFacade() { 42 public ClientFacade() { 42 43 } 43 44 44 45 private IClientCommunicator clientCommunicator = ServiceLocator.GetClientCommunicator(); 45 46 47 private IContextFactory contextFactory = ServiceLocator.GetContextFactory(); 48 46 49 #region IClientCommunicator Members 47 50 48 51 public Response Login(ClientDto clientInfo) { 49 return clientCommunicator.Login(clientInfo); 52 using (contextFactory.GetContext()) { 53 return clientCommunicator.Login(clientInfo); 54 } 50 55 } 51 56 52 57 public ResponseHB ProcessHeartBeat(HeartBeatData hbData) { 53 return clientCommunicator.ProcessHeartBeat(hbData); 58 using (contextFactory.GetContext()) { 59 return clientCommunicator.ProcessHeartBeat(hbData); 60 } 54 61 } 55 62 56 63 public ResponseJob SendJob(Guid clientId) { 57 return clientCommunicator.SendJob(clientId); 64 using (contextFactory.GetContext()) { 65 return clientCommunicator.SendJob(clientId); 66 } 58 67 } 59 68 60 /*public ResponseSerializedJob SendSerializedJob(Guid clientId) { 61 return clientCommunicator.SendSerializedJob(clientId); 62 } */ 63 64 public ResponseResultReceived StoreFinishedJobResult(Guid clientId, 65 Guid jobId, 66 byte[] result, 67 double percentage, 68 Exception exception) { 69 return clientCommunicator.StoreFinishedJobResult(clientId, jobId, result, percentage, exception); 69 public ResponseResultReceived StoreFinishedJobResult(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) { 70 using (contextFactory.GetContext()) { 71 return clientCommunicator.StoreFinishedJobResult(clientId, jobId, result, percentage, exception); 72 } 70 73 } 71 74 72 75 public Response Logout(Guid clientId) { 73 return clientCommunicator.Logout(clientId); 76 using (contextFactory.GetContext()) { 77 return clientCommunicator.Logout(clientId); 78 } 74 79 } 75 80 76 81 public Response IsJobStillNeeded(Guid jobId) { 77 return clientCommunicator.IsJobStillNeeded(jobId); 82 using (contextFactory.GetContext()) { 83 return clientCommunicator.IsJobStillNeeded(jobId); 84 } 78 85 } 79 86 80 87 public ResponsePlugin SendPlugins(List<HivePluginInfoDto> pluginList) { 81 return clientCommunicator.SendPlugins(pluginList); 88 using (contextFactory.GetContext()) { 89 return clientCommunicator.SendPlugins(pluginList); 90 } 82 91 } 83 92 84 93 public ResponseResultReceived ProcessSnapshot(Guid clientId, Guid jobId, byte[] result, double percentage, Exception exception) { 85 return clientCommunicator.ProcessSnapshot(clientId, jobId, result, percentage, exception); 94 using (contextFactory.GetContext()) { 95 return clientCommunicator.ProcessSnapshot(clientId, jobId, result, percentage, exception); 96 } 86 97 } 87 98 88 99 89 100 public ResponseCalendar GetCalendar(Guid clientId) { 90 return clientCommunicator.GetCalendar(clientId); 101 using (contextFactory.GetContext()) { 102 return clientCommunicator.GetCalendar(clientId); 103 } 91 104 } 92 105 93 public Response SetCalendarStatus(Guid clientId, CalendarState state) { 94 return clientCommunicator.SetCalendarStatus(clientId, state); 106 public Response SetCalendarStatus(Guid clientId, CalendarState state) { 107 using (contextFactory.GetContext()) { 108 return clientCommunicator.SetCalendarStatus(clientId, state); 109 } 95 110 } 96 111 #endregion … … 98 113 #region IClientFacade Members 99 114 100 [SpringTransaction(UserTransaction = true)] 115 /// <summary> 116 /// Do not use automatic transactions here 117 /// </summary> 101 118 public Stream SendStreamedJob(Guid clientId) { 102 MultiStream stream = new MultiStream(); 119 using (contextFactory.GetContext(false)) { 120 MultiStream stream = new MultiStream(); 103 121 104 ResponseJob job = null;122 ResponseJob job = null; 105 123 106 job = this.SendJob(clientId);124 job = this.SendJob(clientId); 107 125 108 //first send response109 stream.AddStream(new StreamedObject<ResponseJob>(job));126 //first send response 127 stream.AddStream(new StreamedObject<ResponseJob>(job)); 110 128 111 IJobManager jobManager = ServiceLocator.GetJobManager();112 IInternalJobManager internalJobManager = (IInternalJobManager)jobManager;113 114 //second stream the job binary data115 MemoryStream memoryStream = new MemoryStream();116 if(job.Job != null)117 stream.AddStream(new MemoryStream(internalJobManager.GetSerializedJobDataById(job.Job.Id)));118 119 OperationContext clientContext = OperationContext.Current;129 IJobManager jobManager = ServiceLocator.GetJobManager(); 130 IInternalJobManager internalJobManager = (IInternalJobManager)jobManager; 131 132 //second stream the job binary data 133 MemoryStream memoryStream = new MemoryStream(); 134 if (job.Job != null) 135 stream.AddStream(new MemoryStream(internalJobManager.GetSerializedJobDataById(job.Job.Id))); 136 137 OperationContext clientContext = OperationContext.Current; 120 138 clientContext.OperationCompleted += new EventHandler(delegate(object sender, EventArgs args) { 121 139 if (stream != null) { … … 124 142 }); 125 143 126 return stream; 144 return stream; 145 } 127 146 } 128 147 129 148 public Stream SendStreamedPlugins(List<HivePluginInfoDto> pluginList) { 130 return new StreamedObject<ResponsePlugin>(this.SendPlugins(pluginList)); 149 using (contextFactory.GetContext()) { 150 return new StreamedObject<ResponsePlugin>(this.SendPlugins(pluginList)); 151 } 131 152 } 132 153 133 154 public ResponseResultReceived StoreFinishedJobResultStreamed(Stream stream) { 134 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, true); 135 } 155 using (contextFactory.GetContext()) { 156 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, true); 157 } 158 } 136 159 137 160 public ResponseResultReceived ProcessSnapshotStreamed(Stream stream) { 138 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, false); 161 using (contextFactory.GetContext()) { 162 return ((IInternalClientCommunicator)clientCommunicator).ProcessJobResult(stream, false); 163 } 139 164 } 140 165 #endregion
Note: See TracChangeset
for help on using the changeset viewer.