Changeset 7360
- Timestamp:
- 01/18/12 13:04:34 (13 years ago)
- Location:
- branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/Administration/AdministrationService.cs
r7331 r7360 24 24 using System.Linq; 25 25 using System.ServiceModel; 26 using HeuristicLab.Services.Access; 26 27 using HeuristicLab.Services.OKB.DataAccess; 27 28 … … 32 33 [ServiceBehavior(IncludeExceptionDetailInFaults = true)] 33 34 public class AdministrationService : IAdministrationService { 35 IRoleVerifier roleVerifier = AccessServiceLocator.Instance.RoleVerifier; 36 34 37 #region Platform Methods 35 38 public DataTransfer.Platform GetPlatform(long id) { 39 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 40 36 41 using (OKBDataContext okb = new OKBDataContext()) { 37 42 return Convert.ToDto(okb.Platforms.FirstOrDefault(x => x.Id == id)); … … 39 44 } 40 45 public IEnumerable<DataTransfer.Platform> GetPlatforms() { 46 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 47 41 48 using (OKBDataContext okb = new OKBDataContext()) { 42 49 return okb.Platforms.Select(x => Convert.ToDto(x)).ToArray(); … … 44 51 } 45 52 public long AddPlatform(DataTransfer.Platform dto) { 53 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 54 46 55 using (OKBDataContext okb = new OKBDataContext()) { 47 56 DataAccess.Platform entity = Convert.ToEntity(dto); entity.Id = 0; … … 52 61 } 53 62 public void UpdatePlatform(DataTransfer.Platform dto) { 63 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 64 54 65 using (OKBDataContext okb = new OKBDataContext()) { 55 66 DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == dto.Id); … … 59 70 } 60 71 public void DeletePlatform(long id) { 72 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 73 61 74 using (OKBDataContext okb = new OKBDataContext()) { 62 75 DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == id); … … 69 82 #region AlgorithmClass Methods 70 83 public DataTransfer.AlgorithmClass GetAlgorithmClass(long id) { 84 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 85 71 86 using (OKBDataContext okb = new OKBDataContext()) { 72 87 return Convert.ToDto(okb.AlgorithmClasses.FirstOrDefault(x => x.Id == id)); … … 74 89 } 75 90 public IEnumerable<DataTransfer.AlgorithmClass> GetAlgorithmClasses() { 91 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 92 76 93 using (OKBDataContext okb = new OKBDataContext()) { 77 94 return okb.AlgorithmClasses.Select(x => Convert.ToDto(x)).ToArray(); … … 79 96 } 80 97 public long AddAlgorithmClass(DataTransfer.AlgorithmClass dto) { 98 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 99 81 100 using (OKBDataContext okb = new OKBDataContext()) { 82 101 DataAccess.AlgorithmClass entity = Convert.ToEntity(dto); entity.Id = 0; … … 87 106 } 88 107 public void UpdateAlgorithmClass(DataTransfer.AlgorithmClass dto) { 108 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 109 89 110 using (OKBDataContext okb = new OKBDataContext()) { 90 111 DataAccess.AlgorithmClass entity = okb.AlgorithmClasses.FirstOrDefault(x => x.Id == dto.Id); … … 94 115 } 95 116 public void DeleteAlgorithmClass(long id) { 117 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 118 96 119 using (OKBDataContext okb = new OKBDataContext()) { 97 120 DataAccess.AlgorithmClass entity = okb.AlgorithmClasses.FirstOrDefault(x => x.Id == id); … … 104 127 #region Algorithm Methods 105 128 public DataTransfer.Algorithm GetAlgorithm(long id) { 129 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 130 106 131 using (OKBDataContext okb = new OKBDataContext()) { 107 132 return Convert.ToDto(okb.Algorithms.FirstOrDefault(x => x.Id == id)); … … 109 134 } 110 135 public IEnumerable<DataTransfer.Algorithm> GetAlgorithms() { 136 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 137 111 138 using (OKBDataContext okb = new OKBDataContext()) { 112 139 return okb.Algorithms.Select(x => Convert.ToDto(x)).ToArray(); … … 114 141 } 115 142 public long AddAlgorithm(DataTransfer.Algorithm dto) { 143 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 144 116 145 using (OKBDataContext okb = new OKBDataContext()) { 117 146 DataAccess.Algorithm entity = Convert.ToEntity(dto, okb); entity.Id = 0; … … 122 151 } 123 152 public void UpdateAlgorithm(DataTransfer.Algorithm dto) { 153 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 154 124 155 using (OKBDataContext okb = new OKBDataContext()) { 125 156 DataAccess.Algorithm entity = okb.Algorithms.FirstOrDefault(x => x.Id == dto.Id); … … 129 160 } 130 161 public void DeleteAlgorithm(long id) { 162 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 163 131 164 using (OKBDataContext okb = new OKBDataContext()) { 132 165 DataAccess.Algorithm entity = okb.Algorithms.FirstOrDefault(x => x.Id == id); … … 136 169 } 137 170 public IEnumerable<Guid> GetAlgorithmUsers(long algorithmId) { 171 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 172 138 173 using (OKBDataContext okb = new OKBDataContext()) { 139 174 return okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId).Select(x => x.UserId).ToArray(); … … 141 176 } 142 177 public void UpdateAlgorithmUsers(long algorithmId, IEnumerable<Guid> users) { 178 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 179 143 180 using (OKBDataContext okb = new OKBDataContext()) { 144 181 okb.AlgorithmUsers.DeleteAllOnSubmit(okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId)); … … 148 185 } 149 186 public byte[] GetAlgorithmData(long algorithmId) { 187 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 188 150 189 using (OKBDataContext okb = new OKBDataContext()) { 151 190 var data = okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData).FirstOrDefault(); … … 155 194 } 156 195 public void UpdateAlgorithmData(long algorithmId, byte[] data) { 196 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 197 157 198 using (OKBDataContext okb = new OKBDataContext()) { 158 199 var entity = okb.Algorithms.Where(x => x.Id == algorithmId).FirstOrDefault(); … … 166 207 #region ProblemClass Methods 167 208 public DataTransfer.ProblemClass GetProblemClass(long id) { 209 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 210 168 211 using (OKBDataContext okb = new OKBDataContext()) { 169 212 return Convert.ToDto(okb.ProblemClasses.FirstOrDefault(x => x.Id == id)); … … 171 214 } 172 215 public IEnumerable<DataTransfer.ProblemClass> GetProblemClasses() { 216 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 217 173 218 using (OKBDataContext okb = new OKBDataContext()) { 174 219 return okb.ProblemClasses.Select(x => Convert.ToDto(x)).ToArray(); … … 176 221 } 177 222 public long AddProblemClass(DataTransfer.ProblemClass dto) { 223 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 224 178 225 using (OKBDataContext okb = new OKBDataContext()) { 179 226 DataAccess.ProblemClass entity = Convert.ToEntity(dto); entity.Id = 0; … … 184 231 } 185 232 public void UpdateProblemClass(DataTransfer.ProblemClass dto) { 233 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 234 186 235 using (OKBDataContext okb = new OKBDataContext()) { 187 236 DataAccess.ProblemClass entity = okb.ProblemClasses.FirstOrDefault(x => x.Id == dto.Id); … … 191 240 } 192 241 public void DeleteProblemClass(long id) { 242 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 243 193 244 using (OKBDataContext okb = new OKBDataContext()) { 194 245 DataAccess.ProblemClass entity = okb.ProblemClasses.FirstOrDefault(x => x.Id == id); … … 201 252 #region Problem Methods 202 253 public DataTransfer.Problem GetProblem(long id) { 254 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 255 203 256 using (OKBDataContext okb = new OKBDataContext()) { 204 257 return Convert.ToDto(okb.Problems.FirstOrDefault(x => x.Id == id)); … … 206 259 } 207 260 public IEnumerable<DataTransfer.Problem> GetProblems() { 261 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 262 208 263 using (OKBDataContext okb = new OKBDataContext()) { 209 264 return okb.Problems.Select(x => Convert.ToDto(x)).ToArray(); … … 211 266 } 212 267 public long AddProblem(DataTransfer.Problem dto) { 268 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 269 213 270 using (OKBDataContext okb = new OKBDataContext()) { 214 271 DataAccess.Problem entity = Convert.ToEntity(dto, okb); entity.Id = 0; … … 219 276 } 220 277 public void UpdateProblem(DataTransfer.Problem dto) { 278 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 279 221 280 using (OKBDataContext okb = new OKBDataContext()) { 222 281 DataAccess.Problem entity = okb.Problems.FirstOrDefault(x => x.Id == dto.Id); … … 226 285 } 227 286 public void DeleteProblem(long id) { 287 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 288 228 289 using (OKBDataContext okb = new OKBDataContext()) { 229 290 DataAccess.Problem entity = okb.Problems.FirstOrDefault(x => x.Id == id); … … 233 294 } 234 295 public IEnumerable<Guid> GetProblemUsers(long problemId) { 296 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 297 235 298 using (OKBDataContext okb = new OKBDataContext()) { 236 299 return okb.ProblemUsers.Where(x => x.ProblemId == problemId).Select(x => x.UserId).ToArray(); … … 238 301 } 239 302 public void UpdateProblemUsers(long problemId, IEnumerable<Guid> users) { 303 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 304 240 305 using (OKBDataContext okb = new OKBDataContext()) { 241 306 okb.ProblemUsers.DeleteAllOnSubmit(okb.ProblemUsers.Where(x => x.ProblemId == problemId)); … … 245 310 } 246 311 public byte[] GetProblemData(long problemId) { 312 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 313 247 314 using (OKBDataContext okb = new OKBDataContext()) { 248 315 var data = okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData).FirstOrDefault(); … … 252 319 } 253 320 public void UpdateProblemData(long problemId, byte[] data) { 321 roleVerifier.AuthenticateForAllRoles(OKBRoles.OKBAdministrator); 322 254 323 using (OKBDataContext okb = new OKBDataContext()) { 255 324 var entity = okb.Problems.Where(x => x.Id == problemId).FirstOrDefault(); -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj
r7349 r7360 106 106 </PropertyGroup> 107 107 <ItemGroup> 108 <Reference Include="HeuristicLab.GeoIP"> 109 <HintPath>..\..\..\ClientUserManagement\ServerBinaries\HeuristicLab.GeoIP.dll</HintPath> 110 </Reference> 111 <Reference Include="HeuristicLab.Services.Access"> 112 <HintPath>..\..\..\ClientUserManagement\ServerBinaries\HeuristicLab.Services.Access.dll</HintPath> 113 </Reference> 114 <Reference Include="HeuristicLab.Services.Access.DataAccess"> 115 <HintPath>..\..\..\ClientUserManagement\ServerBinaries\HeuristicLab.Services.Access.DataAccess.dll</HintPath> 116 </Reference> 108 117 <Reference Include="Microsoft.CSharp" /> 109 118 <Reference Include="System" /> -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/RunCreation/RunCreationService.cs
r7331 r7360 24 24 using System.Linq; 25 25 using System.ServiceModel; 26 using HeuristicLab.Services.Access; 26 27 using HeuristicLab.Services.OKB.DataAccess; 27 28 … … 32 33 [ServiceBehavior(IncludeExceptionDetailInFaults = true)] 33 34 public class RunCreationService : IRunCreationService { 35 IRoleVerifier roleVerifier = AccessServiceLocator.Instance.RoleVerifier; 36 34 37 public IEnumerable<DataTransfer.Algorithm> GetAlgorithms(string platformName) { 38 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 39 35 40 using (OKBDataContext okb = new OKBDataContext()) { 36 41 DataLoadOptions dlo = new DataLoadOptions(); … … 43 48 44 49 public byte[] GetAlgorithmData(long algorithmId) { 50 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 51 45 52 using (OKBDataContext okb = new OKBDataContext()) { 46 53 return okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault(); … … 49 56 50 57 public IEnumerable<DataTransfer.Problem> GetProblems(string platformName) { 58 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 59 51 60 using (OKBDataContext okb = new OKBDataContext()) { 52 61 DataLoadOptions dlo = new DataLoadOptions(); … … 59 68 60 69 public byte[] GetProblemData(long problemId) { 70 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 71 61 72 using (OKBDataContext okb = new OKBDataContext()) { 62 73 return okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData.Data.ToArray()).FirstOrDefault(); … … 65 76 66 77 public void AddRun(DataTransfer.Run run) { 78 roleVerifier.AuthenticateForAnyRole(OKBRoles.OKBAdministrator, OKBRoles.OKBUser); 79 67 80 using (OKBDataContext okb = new OKBDataContext()) { 68 81 DataAccess.Run entity = Convert.ToEntity(run, okb);
Note: See TracChangeset
for help on using the changeset viewer.