Changeset 7914 for branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs
- Timestamp:
- 05/29/12 12:45:22 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs
r7360 r7914 34 34 public class RunCreationService : IRunCreationService { 35 35 IRoleVerifier roleVerifier = AccessServiceLocator.Instance.RoleVerifier; 36 IUserManager userManager = AccessServiceLocator.Instance.UserManager; 36 37 37 38 public IEnumerable<DataTransfer.Algorithm> GetAlgorithms(string platformName) { … … 42 43 dlo.LoadWith<Algorithm>(x => x.AlgorithmClass); 43 44 dlo.LoadWith<Algorithm>(x => x.DataType); 45 dlo.LoadWith<Algorithm>(x => x.AlgorithmUsers); 44 46 okb.LoadOptions = dlo; 45 return okb.Algorithms.Where(x => x.Platform.Name == platformName).Select(x => Convert.ToDto(x)).ToArray(); 47 48 var query = okb.Algorithms.Where(x => x.Platform.Name == platformName); 49 List<Algorithm> results = new List<Algorithm>(); 50 51 if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { 52 results.AddRange(query); 53 } else { 54 foreach (var alg in query) { 55 if (alg.AlgorithmUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, alg.AlgorithmUsers.Select(y => y.UserGroupId).ToList())) { 56 results.Add(alg); 57 } 58 } 59 } 60 return results.Select(x => Convert.ToDto(x)).ToArray(); 46 61 } 47 62 } … … 51 66 52 67 using (OKBDataContext okb = new OKBDataContext()) { 53 return okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault(); 68 var result = okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault(); 69 70 if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { 71 return result; 72 } else { 73 var algUsers = okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId); 74 if (algUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, algUsers.Select(y => y.UserGroupId).ToList())) { 75 return result; 76 } else { 77 return null; 78 } 79 } 54 80 } 55 81 } … … 62 88 dlo.LoadWith<Problem>(x => x.ProblemClass); 63 89 dlo.LoadWith<Problem>(x => x.DataType); 90 dlo.LoadWith<Problem>(x => x.ProblemUsers); 64 91 okb.LoadOptions = dlo; 65 return okb.Problems.Where(x => x.Platform.Name == platformName).Select(x => Convert.ToDto(x)).ToArray(); 92 93 var query = okb.Problems.Where(x => x.Platform.Name == platformName); 94 List<Problem> results = new List<Problem>(); 95 96 if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { 97 results.AddRange(query); 98 } else { 99 foreach (var problem in query) { 100 if (problem.ProblemUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, problem.ProblemUsers.Select(y => y.UserGroupId).ToList())) { 101 results.Add(problem); 102 } 103 } 104 } 105 return results.Select(x => Convert.ToDto(x)).ToArray(); 66 106 } 67 107 } … … 71 111 72 112 using (OKBDataContext okb = new OKBDataContext()) { 73 return okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault(); 113 var result = okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault(); 114 115 if (roleVerifier.IsInRole(OKBRoles.OKBAdministrator)) { 116 return result; 117 } else { 118 var problemUsers = okb.ProblemUsers.Where(x => x.ProblemId == problemId); 119 if (problemUsers.Count() == 0 || userManager.VerifyUser(userManager.CurrentUserId, problemUsers.Select(y => y.UserGroupId).ToList())) { 120 return result; 121 } else { 122 return null; 123 } 124 } 74 125 } 75 126 }
Note: See TracChangeset
for help on using the changeset viewer.