- Timestamp:
- 08/24/10 02:37:56 (14 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/DataService.cs
r4279 r4298 72 72 private byte[] GetData(EntityType type, int id) { 73 73 Log("loading data", type, id); 74 OKBDataContext okb = new OKBDataContext(); 75 switch (type) { 76 case EntityType.Algorithm: 77 Algorithm algorithm = okb.Algorithms.Single(a => a.Id == id); 78 if (algorithm.AlgorithmData == null) { 79 algorithm.AlgorithmData = new AlgorithmData() { 80 AlgorithmId = algorithm.Id, 81 Data = new Binary(new byte[0]) 82 }; 83 okb.SubmitChanges(); 84 } 85 return algorithm.AlgorithmData.Data.ToArray(); 86 break; 87 case EntityType.Problem: 88 Problem problem = okb.Problems.Single(p => p.Id == id); 89 if (problem.ProblemData == null) { 90 problem.ProblemData = new ProblemData() { 91 ProblemId = problem.Id, 92 Data = new Binary(new byte[0]) 93 }; 94 okb.SubmitChanges(); 95 } 96 return problem.ProblemData.Data.ToArray(); 97 break; 98 default: 99 throw new FaultException("Unsupported EntityType"); 74 using (OKBDataContext okb = new OKBDataContext()) { 75 switch (type) { 76 case EntityType.Algorithm: 77 Algorithm algorithm = okb.Algorithms.Single(a => a.Id == id); 78 if (algorithm.AlgorithmData == null) { 79 algorithm.AlgorithmData = new AlgorithmData() { 80 AlgorithmId = algorithm.Id, 81 Data = new Binary(new byte[0]) 82 }; 83 okb.SubmitChanges(); 84 } 85 return algorithm.AlgorithmData.Data.ToArray(); 86 break; 87 case EntityType.Problem: 88 Problem problem = okb.Problems.Single(p => p.Id == id); 89 if (problem.ProblemData == null) { 90 problem.ProblemData = new ProblemData() { 91 ProblemId = problem.Id, 92 Data = new Binary(new byte[0]) 93 }; 94 okb.SubmitChanges(); 95 } 96 return problem.ProblemData.Data.ToArray(); 97 break; 98 default: 99 throw new FaultException("Unsupported EntityType"); 100 } 100 101 } 101 okb.Dispose();102 102 } 103 103
Note: See TracChangeset
for help on using the changeset viewer.