Changeset 13682 for trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation
- Timestamp:
- 03/10/16 15:04:15 (9 years ago)
- Location:
- trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation
- Files:
-
- 3 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/Convert.cs
r13511 r13682 38 38 if (source == null) return null; 39 39 return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, ProblemClass = Convert.ToDto(source.ProblemClass), DataType = Convert.ToDto(source.DataType) }; 40 } 41 42 public static DT.SingleObjectiveSolution ToDto(DA.SingleObjectiveSolution source) { 43 if (source == null) return null; 44 return new DT.SingleObjectiveSolution() { 45 Id = source.Id, 46 ProblemId = source.ProblemId.Value, 47 RunId = source.RunId, 48 Quality = source.Quality 49 }; 40 50 } 41 51 -
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/IRunCreationService.cs
r13511 r13682 44 44 45 45 [OperationContract] 46 [FaultContract(typeof(MissingProblem))] 47 IEnumerable<Solution> GetSolutions(long problemId); 48 49 [OperationContract] 50 [FaultContract(typeof(MissingSolution))] 51 byte[] GetSolutionData(long solutionId); 52 53 [OperationContract] 46 54 void AddRun(Run run); 47 55 -
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/MissingProblem.cs
r13501 r13682 28 28 public string Message { get; set; } 29 29 30 public MissingProblem( string message, params object[] c) {31 Message = string.Format( message, c);30 public MissingProblem(long problemId) { 31 Message = string.Format("Problem with id {0} cannot be found", problemId); 32 32 } 33 33 } -
trunk/sources/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs
r13513 r13682 127 127 } 128 128 129 public IEnumerable<DataTransfer.Solution> GetSolutions(long problemId) { 130 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 131 132 using (OKBDataContext okb = new OKBDataContext()) { 133 var problem = okb.Problems.SingleOrDefault(x => x.Id == problemId); 134 if (problem == null) throw new FaultException<MissingProblem>(new MissingProblem(problemId)); 135 // TODO: In case of multi-objective problems one has to check whether it contains single- or multi-objective problems 136 var result = problem.SingleObjectiveSolutions.Select(x => Convert.ToDto(x)).ToList(); 137 if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { 138 return result; 139 } else { 140 var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == problemId).ToList(); 141 if (problemUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers.Select(y => y.UserGroupId).ToList())) { 142 return result; 143 } else { 144 return null; 145 } 146 } 147 } 148 } 149 150 public byte[] GetSolutionData(long solutionId) { 151 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 152 153 using (OKBDataContext okb = new OKBDataContext()) { 154 var solution = okb.SingleObjectiveSolutions.SingleOrDefault(x => x.Id == solutionId); 155 if (solution == null) throw new FaultException<MissingSolution>(new MissingSolution(solutionId)); 156 157 var result = solution.BinaryData.Data.ToArray(); 158 if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { 159 return result; 160 } else { 161 var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == solution.ProblemId).ToList(); 162 if (problemUsers.Count == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers.Select(y => y.UserGroupId).ToList())) { 163 return result; 164 } else { 165 return null; 166 } 167 } 168 } 169 } 170 129 171 public void AddRun(DataTransfer.Run run) { 130 172 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); … … 150 192 using (OKBDataContext okb = new OKBDataContext()) { 151 193 var problem = okb.Problems.SingleOrDefault(x => x.Id == problemId); 152 if (problem == null) throw new FaultException<MissingProblem>(new MissingProblem( "Problem with id {0} cannot be found",problemId));194 if (problem == null) throw new FaultException<MissingProblem>(new MissingProblem(problemId)); 153 195 154 196 DoSetCharacteristicValue(okb, problem, value); … … 162 204 using (OKBDataContext okb = new OKBDataContext()) { 163 205 var problem = okb.Problems.SingleOrDefault(x => x.Id == problemId); 164 if (problem == null) throw new FaultException<MissingProblem>(new MissingProblem( "Problem with id {0} cannot be found",problemId));206 if (problem == null) throw new FaultException<MissingProblem>(new MissingProblem(problemId)); 165 207 166 208 foreach (var v in values) {
Note: See TracChangeset
for help on using the changeset viewer.