Changeset 12584 for branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs
- Timestamp:
- 07/03/15 16:35:17 (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/HiveStatistics/sources/HeuristicLab.Services.WebApp.Statistics/3.3/WebApi/TaskController.cs
r12562 r12584 22 22 using System; 23 23 using System.Collections.Generic; 24 using System.IO; 24 25 using System.Linq; 26 using System.Net; 27 using System.Net.Http; 28 using System.Net.Http.Headers; 25 29 using System.Web.Http; 26 30 using HeuristicLab.Services.Access; … … 153 157 } 154 158 } 159 160 public HttpResponseMessage GetTaskDataById(Guid id) { 161 using (var pm = PersistenceManager) { 162 var taskDataDao = pm.TaskDataDao; 163 return pm.UseTransaction(() => { 164 var taskData = taskDataDao.GetById(id); 165 if (taskData == null) 166 return new HttpResponseMessage(HttpStatusCode.NotFound); 167 HttpResponseMessage result = new HttpResponseMessage(HttpStatusCode.OK); 168 var stream = new MemoryStream(taskData.Data); 169 result.Content = new StreamContent(stream); 170 result.Content.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream"); 171 result.Content.Headers.ContentDisposition = 172 new ContentDispositionHeaderValue("attachment") { 173 FileName = string.Format("{0}.hl", id) 174 }; 175 return result; 176 }); 177 } 178 } 155 179 } 156 180 }
Note: See TracChangeset
for help on using the changeset viewer.