Changeset 4481 for branches/OKB/HeuristicLab.Services.OKB/3.3
- Timestamp:
- 09/24/10 06:53:43 (14 years ago)
- Location:
- branches/OKB/HeuristicLab.Services.OKB/3.3
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB/HeuristicLab.Services.OKB/3.3/AdminService.cs
r4467 r4481 43 43 } 44 44 } 45 public void StorePlatform(DataTransfer.Platform dto) { 45 public long AddPlatform(DataTransfer.Platform dto) { 46 using (OKBDataContext okb = new OKBDataContext()) { 47 DataAccess.Platform entity = Convert.ToEntity(dto); entity.Id = 0; 48 okb.Platforms.InsertOnSubmit(entity); 49 okb.SubmitChanges(); 50 return entity.Id; 51 } 52 } 53 public void UpdatePlatform(DataTransfer.Platform dto) { 46 54 using (OKBDataContext okb = new OKBDataContext()) { 47 55 DataAccess.Platform entity = okb.Platforms.FirstOrDefault(x => x.Id == dto.Id); 48 if (entity == null) okb.Platforms.InsertOnSubmit(Convert.ToEntity(dto)); 49 else Convert.ToEntity(dto, entity); 56 Convert.ToEntity(dto, entity); 50 57 okb.SubmitChanges(); 51 58 } … … 60 67 #endregion 61 68 69 #region DataType Methods 70 public DataTransfer.DataType GetDataType(long id) { 71 using (OKBDataContext okb = new OKBDataContext()) { 72 return Convert.ToDto(okb.DataTypes.FirstOrDefault(x => x.Id == id)); 73 } 74 } 75 public IEnumerable<DataTransfer.DataType> GetDataTypes() { 76 using (OKBDataContext okb = new OKBDataContext()) { 77 return okb.DataTypes.Select(x => Convert.ToDto(x)).ToArray(); 78 } 79 } 80 public long AddDataType(DataTransfer.DataType dto) { 81 using (OKBDataContext okb = new OKBDataContext()) { 82 DataAccess.DataType entity = Convert.ToEntity(dto); entity.Id = 0; 83 okb.DataTypes.InsertOnSubmit(entity); 84 okb.SubmitChanges(); 85 return entity.Id; 86 } 87 } 88 public void UpdateDataType(DataTransfer.DataType dto) { 89 using (OKBDataContext okb = new OKBDataContext()) { 90 DataAccess.DataType entity = okb.DataTypes.FirstOrDefault(x => x.Id == dto.Id); 91 Convert.ToEntity(dto, entity); 92 okb.SubmitChanges(); 93 } 94 } 95 public void DeleteDataType(long id) { 96 using (OKBDataContext okb = new OKBDataContext()) { 97 DataAccess.DataType entity = okb.DataTypes.FirstOrDefault(x => x.Id == id); 98 if (entity != null) okb.DataTypes.DeleteOnSubmit(entity); 99 okb.SubmitChanges(); 100 } 101 } 102 #endregion 103 62 104 #region AlgorithmClass Methods 63 105 public DataTransfer.AlgorithmClass GetAlgorithmClass(long id) { … … 71 113 } 72 114 } 73 public void StoreAlgorithmClass(DataTransfer.AlgorithmClass dto) { 115 public long AddAlgorithmClass(DataTransfer.AlgorithmClass dto) { 116 using (OKBDataContext okb = new OKBDataContext()) { 117 DataAccess.AlgorithmClass entity = Convert.ToEntity(dto); entity.Id = 0; 118 okb.AlgorithmClasses.InsertOnSubmit(entity); 119 okb.SubmitChanges(); 120 return entity.Id; 121 } 122 } 123 public void UpdateAlgorithmClass(DataTransfer.AlgorithmClass dto) { 74 124 using (OKBDataContext okb = new OKBDataContext()) { 75 125 DataAccess.AlgorithmClass entity = okb.AlgorithmClasses.FirstOrDefault(x => x.Id == dto.Id); 76 if (entity == null) okb.AlgorithmClasses.InsertOnSubmit(Convert.ToEntity(dto)); 77 else Convert.ToEntity(dto, entity); 126 Convert.ToEntity(dto, entity); 78 127 okb.SubmitChanges(); 79 128 } … … 99 148 } 100 149 } 101 public void StoreAlgorithm(DataTransfer.Algorithm dto) { 150 public long AddAlgorithm(DataTransfer.Algorithm dto) { 151 using (OKBDataContext okb = new OKBDataContext()) { 152 DataAccess.Algorithm entity = Convert.ToEntity(dto); entity.Id = 0; 153 okb.Algorithms.InsertOnSubmit(entity); 154 okb.SubmitChanges(); 155 return entity.Id; 156 } 157 } 158 public void UpdateAlgorithm(DataTransfer.Algorithm dto) { 102 159 using (OKBDataContext okb = new OKBDataContext()) { 103 160 DataAccess.Algorithm entity = okb.Algorithms.FirstOrDefault(x => x.Id == dto.Id); 104 if (entity == null) okb.Algorithms.InsertOnSubmit(Convert.ToEntity(dto)); 105 else Convert.ToEntity(dto, entity); 161 Convert.ToEntity(dto, entity); 106 162 okb.SubmitChanges(); 107 163 } … … 119 175 } 120 176 } 121 public void StoreAlgorithmUsers(long algorithmId, IEnumerable<Guid> users) {177 public void UpdateAlgorithmUsers(long algorithmId, IEnumerable<Guid> users) { 122 178 using (OKBDataContext okb = new OKBDataContext()) { 123 179 okb.AlgorithmUsers.DeleteAllOnSubmit(okb.AlgorithmUsers.Where(x => x.AlgorithmId == algorithmId)); … … 134 190 } 135 191 } 136 public void StoreAlgorithmData(DataTransfer.AlgorithmData dto) {192 public void UpdateAlgorithmData(DataTransfer.AlgorithmData dto) { 137 193 using (OKBDataContext okb = new OKBDataContext()) { 138 194 DataAccess.AlgorithmData entity = okb.AlgorithmDatas.FirstOrDefault(x => x.AlgorithmId == dto.AlgorithmId); … … 144 200 #endregion 145 201 146 #region DataType Methods 147 public DataTransfer.DataType GetDataType(long id) { 148 using (OKBDataContext okb = new OKBDataContext()) { 149 return Convert.ToDto(okb.DataTypes.FirstOrDefault(x => x.Id == id)); 150 } 151 } 152 public IEnumerable<DataTransfer.DataType> GetDataTypes() { 153 using (OKBDataContext okb = new OKBDataContext()) { 154 return okb.DataTypes.Select(x => Convert.ToDto(x)).ToArray(); 155 } 156 } 157 public void StoreDataType(DataTransfer.DataType dto) { 158 using (OKBDataContext okb = new OKBDataContext()) { 159 DataAccess.DataType entity = okb.DataTypes.FirstOrDefault(x => x.Id == dto.Id); 160 if (entity == null) okb.DataTypes.InsertOnSubmit(Convert.ToEntity(dto)); 202 #region ProblemClass Methods 203 public DataTransfer.ProblemClass GetProblemClass(long id) { 204 using (OKBDataContext okb = new OKBDataContext()) { 205 return Convert.ToDto(okb.ProblemClasses.FirstOrDefault(x => x.Id == id)); 206 } 207 } 208 public IEnumerable<DataTransfer.ProblemClass> GetProblemClasses() { 209 using (OKBDataContext okb = new OKBDataContext()) { 210 return okb.ProblemClasses.Select(x => Convert.ToDto(x)).ToArray(); 211 } 212 } 213 public long AddProblemClass(DataTransfer.ProblemClass dto) { 214 using (OKBDataContext okb = new OKBDataContext()) { 215 DataAccess.ProblemClass entity = Convert.ToEntity(dto); entity.Id = 0; 216 okb.ProblemClasses.InsertOnSubmit(entity); 217 okb.SubmitChanges(); 218 return entity.Id; 219 } 220 } 221 public void UpdateProblemClass(DataTransfer.ProblemClass dto) { 222 using (OKBDataContext okb = new OKBDataContext()) { 223 DataAccess.ProblemClass entity = okb.ProblemClasses.FirstOrDefault(x => x.Id == dto.Id); 224 Convert.ToEntity(dto, entity); 225 okb.SubmitChanges(); 226 } 227 } 228 public void DeleteProblemClass(long id) { 229 using (OKBDataContext okb = new OKBDataContext()) { 230 DataAccess.ProblemClass entity = okb.ProblemClasses.FirstOrDefault(x => x.Id == id); 231 if (entity != null) okb.ProblemClasses.DeleteOnSubmit(entity); 232 okb.SubmitChanges(); 233 } 234 } 235 #endregion 236 237 #region Problem Methods 238 public DataTransfer.Problem GetProblem(long id) { 239 using (OKBDataContext okb = new OKBDataContext()) { 240 return Convert.ToDto(okb.Problems.FirstOrDefault(x => x.Id == id)); 241 } 242 } 243 public IEnumerable<DataTransfer.Problem> GetProblems() { 244 using (OKBDataContext okb = new OKBDataContext()) { 245 return okb.Problems.Select(x => Convert.ToDto(x)).ToArray(); 246 } 247 } 248 public long AddProblem(DataTransfer.Problem dto) { 249 using (OKBDataContext okb = new OKBDataContext()) { 250 DataAccess.Problem entity = Convert.ToEntity(dto); entity.Id = 0; 251 okb.Problems.InsertOnSubmit(entity); 252 okb.SubmitChanges(); 253 return entity.Id; 254 } 255 } 256 public void UpdateProblem(DataTransfer.Problem dto) { 257 using (OKBDataContext okb = new OKBDataContext()) { 258 DataAccess.Problem entity = okb.Problems.FirstOrDefault(x => x.Id == dto.Id); 259 Convert.ToEntity(dto, entity); 260 okb.SubmitChanges(); 261 } 262 } 263 public void DeleteProblem(long id) { 264 using (OKBDataContext okb = new OKBDataContext()) { 265 DataAccess.Problem entity = okb.Problems.FirstOrDefault(x => x.Id == id); 266 if (entity != null) okb.Problems.DeleteOnSubmit(entity); 267 okb.SubmitChanges(); 268 } 269 } 270 public IEnumerable<Guid> GetProblemUsers(long problemId) { 271 using (OKBDataContext okb = new OKBDataContext()) { 272 return okb.ProblemUsers.Where(x => x.ProblemId == problemId).Select(x => x.UserId).ToArray(); 273 } 274 } 275 public void UpdateProblemUsers(long problemId, IEnumerable<Guid> users) { 276 using (OKBDataContext okb = new OKBDataContext()) { 277 okb.ProblemUsers.DeleteAllOnSubmit(okb.ProblemUsers.Where(x => x.ProblemId == problemId)); 278 okb.ProblemUsers.InsertAllOnSubmit(users.Select(x => new DataAccess.ProblemUser { ProblemId = problemId, UserId = x })); 279 okb.SubmitChanges(); 280 } 281 } 282 #endregion 283 284 #region ProblemData Methods 285 public DataTransfer.ProblemData GetProblemData(long problemId) { 286 using (OKBDataContext okb = new OKBDataContext()) { 287 return Convert.ToDto(okb.ProblemDatas.FirstOrDefault(x => x.ProblemId == problemId)); 288 } 289 } 290 public void UpdateProblemData(DataTransfer.ProblemData dto) { 291 using (OKBDataContext okb = new OKBDataContext()) { 292 DataAccess.ProblemData entity = okb.ProblemDatas.FirstOrDefault(x => x.ProblemId == dto.ProblemId); 293 if (entity == null) okb.ProblemDatas.InsertOnSubmit(Convert.ToEntity(dto)); 161 294 else Convert.ToEntity(dto, entity); 162 okb.SubmitChanges();163 }164 }165 public void DeleteDataType(long id) {166 using (OKBDataContext okb = new OKBDataContext()) {167 DataAccess.DataType entity = okb.DataTypes.FirstOrDefault(x => x.Id == id);168 if (entity != null) okb.DataTypes.DeleteOnSubmit(entity);169 295 okb.SubmitChanges(); 170 296 } -
branches/OKB/HeuristicLab.Services.OKB/3.3/Convert.cs
r4467 r4481 28 28 #region Platform 29 29 public static DT.Platform ToDto(DA.Platform source) { 30 if (source == null) return null; 30 31 return new DT.Platform { Id = source.Id, Name = source.Name, Description = source.Description }; 31 32 } 32 33 public static DA.Platform ToEntity(DT.Platform source) { 34 if (source == null) return null; 33 35 return new DA.Platform { Id = source.Id, Name = source.Name, Description = source.Description }; 34 36 } 35 37 public static void ToEntity(DT.Platform source, DA.Platform target) { 36 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; 38 if ((source != null) && (target != null)) 39 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; 40 } 41 #endregion 42 43 #region DataType 44 public static DT.DataType ToDto(DA.DataType source) { 45 if (source == null) return null; 46 return new DT.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId }; 47 } 48 public static DA.DataType ToEntity(DT.DataType source) { 49 if (source == null) return null; 50 return new DA.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId }; 51 } 52 public static void ToEntity(DT.DataType source, DA.DataType target) { 53 if ((source != null) && (target != null)) 54 target.Id = source.Id; target.Name = source.Name; target.SqlName = source.SqlName; target.PlatformId = source.PlatformId; 37 55 } 38 56 #endregion … … 40 58 #region AlgorithmClass 41 59 public static DT.AlgorithmClass ToDto(DA.AlgorithmClass source) { 60 if (source == null) return null; 42 61 return new DT.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description }; 43 62 } 44 63 public static DA.AlgorithmClass ToEntity(DT.AlgorithmClass source) { 64 if (source == null) return null; 45 65 return new DA.AlgorithmClass { Id = source.Id, Name = source.Name, Description = source.Description }; 46 66 } 47 67 public static void ToEntity(DT.AlgorithmClass source, DA.AlgorithmClass target) { 48 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; 68 if ((source != null) && (target != null)) 69 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; 49 70 } 50 71 #endregion … … 52 73 #region Algorithm 53 74 public static DT.Algorithm ToDto(DA.Algorithm source) { 75 if (source == null) return null; 54 76 return new DT.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId }; 55 77 } 56 78 public static DA.Algorithm ToEntity(DT.Algorithm source) { 79 if (source == null) return null; 57 80 return new DA.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId }; 58 81 } 59 82 public static void ToEntity(DT.Algorithm source, DA.Algorithm target) { 60 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId; 83 if ((source != null) && (target != null)) 84 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId; 61 85 } 62 86 #endregion … … 64 88 #region AlgorithmData 65 89 public static DT.AlgorithmData ToDto(DA.AlgorithmData source) { 90 if (source == null) return null; 66 91 return new DT.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() }; 67 92 } 68 93 public static DA.AlgorithmData ToEntity(DT.AlgorithmData source) { 94 if (source == null) return null; 69 95 return new DA.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) }; 70 96 } 71 97 public static void ToEntity(DT.AlgorithmData source, DA.AlgorithmData target) { 72 target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data); 98 if ((source != null) && (target != null)) 99 target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data); 73 100 } 74 101 #endregion 75 102 76 #region DataType 77 public static DT.DataType ToDto(DA.DataType source) { 78 return new DT.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId }; 103 #region ProblemClass 104 public static DT.ProblemClass ToDto(DA.ProblemClass source) { 105 if (source == null) return null; 106 return new DT.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description }; 79 107 } 80 public static DA.DataType ToEntity(DT.DataType source) { 81 return new DA.DataType { Id = source.Id, Name = source.Name, SqlName = source.SqlName, PlatformId = source.PlatformId }; 108 public static DA.ProblemClass ToEntity(DT.ProblemClass source) { 109 if (source == null) return null; 110 return new DA.ProblemClass { Id = source.Id, Name = source.Name, Description = source.Description }; 82 111 } 83 public static void ToEntity(DT.DataType source, DA.DataType target) { 84 target.Id = source.Id; target.Name = source.Name; target.SqlName = source.SqlName; target.PlatformId = source.PlatformId; 112 public static void ToEntity(DT.ProblemClass source, DA.ProblemClass target) { 113 if ((source != null) && (target != null)) 114 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; 115 } 116 #endregion 117 118 #region Algorithm 119 public static DT.Problem ToDto(DA.Problem source) { 120 if (source == null) return null; 121 return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId }; 122 } 123 public static DA.Problem ToEntity(DT.Problem source) { 124 if (source == null) return null; 125 return new DA.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId }; 126 } 127 public static void ToEntity(DT.Problem source, DA.Problem target) { 128 if ((source != null) && (target != null)) 129 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.ProblemClassId = source.ProblemClassId; 130 } 131 #endregion 132 133 #region ProblemData 134 public static DT.ProblemData ToDto(DA.ProblemData source) { 135 if (source == null) return null; 136 return new DT.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() }; 137 } 138 public static DA.ProblemData ToEntity(DT.ProblemData source) { 139 if (source == null) return null; 140 return new DA.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) }; 141 } 142 public static void ToEntity(DT.ProblemData source, DA.ProblemData target) { 143 if ((source != null) && (target != null)) 144 target.ProblemId = source.ProblemId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data); 85 145 } 86 146 #endregion -
branches/OKB/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj
r4480 r4481 149 149 <FlavorProperties GUID="{3D9AD99F-2412-4246-B90B-4EAA41C64699}"> 150 150 <WcfProjectProperties> 151 <AutoStart> True</AutoStart>151 <AutoStart>False</AutoStart> 152 152 </WcfProjectProperties> 153 153 </FlavorProperties> -
branches/OKB/HeuristicLab.Services.OKB/3.3/Interfaces/IAdminService.cs
r4467 r4481 38 38 IEnumerable<Platform> GetPlatforms(); 39 39 [OperationContract] 40 void StorePlatform(Platform dto); 40 long AddPlatform(Platform dto); 41 [OperationContract] 42 void UpdatePlatform(Platform dto); 41 43 [OperationContract] 42 44 void DeletePlatform(long id); 45 #endregion 46 47 #region DataType Methods 48 [OperationContract] 49 DataType GetDataType(long id); 50 [OperationContract] 51 IEnumerable<DataType> GetDataTypes(); 52 [OperationContract] 53 long AddDataType(DataType dto); 54 [OperationContract] 55 void UpdateDataType(DataType dto); 56 [OperationContract] 57 void DeleteDataType(long id); 43 58 #endregion 44 59 … … 49 64 IEnumerable<AlgorithmClass> GetAlgorithmClasses(); 50 65 [OperationContract] 51 void StoreAlgorithmClass(AlgorithmClass dto); 66 long AddAlgorithmClass(AlgorithmClass dto); 67 [OperationContract] 68 void UpdateAlgorithmClass(AlgorithmClass dto); 52 69 [OperationContract] 53 70 void DeleteAlgorithmClass(long id); … … 60 77 IEnumerable<Algorithm> GetAlgorithms(); 61 78 [OperationContract] 62 void StoreAlgorithm(Algorithm dto); 79 long AddAlgorithm(Algorithm dto); 80 [OperationContract] 81 void UpdateAlgorithm(Algorithm dto); 63 82 [OperationContract] 64 83 void DeleteAlgorithm(long id); … … 66 85 IEnumerable<Guid> GetAlgorithmUsers(long algorithmId); 67 86 [OperationContract] 68 void StoreAlgorithmUsers(long algorithmId, IEnumerable<Guid> users);87 void UpdateAlgorithmUsers(long algorithmId, IEnumerable<Guid> users); 69 88 #endregion 70 89 … … 73 92 AlgorithmData GetAlgorithmData(long algorithmId); 74 93 [OperationContract] 75 void StoreAlgorithmData(AlgorithmData dto);94 void UpdateAlgorithmData(AlgorithmData dto); 76 95 #endregion 77 96 78 #region DataTypeMethods97 #region ProblemClass Methods 79 98 [OperationContract] 80 DataType GetDataType(long id);99 ProblemClass GetProblemClass(long id); 81 100 [OperationContract] 82 IEnumerable< DataType> GetDataTypes();101 IEnumerable<ProblemClass> GetProblemClasses(); 83 102 [OperationContract] 84 void StoreDataType(DataTypedto);103 long AddProblemClass(ProblemClass dto); 85 104 [OperationContract] 86 void DeleteDataType(long id); 105 void UpdateProblemClass(ProblemClass dto); 106 [OperationContract] 107 void DeleteProblemClass(long id); 108 #endregion 109 110 #region Problem Methods 111 [OperationContract] 112 Problem GetProblem(long id); 113 [OperationContract] 114 IEnumerable<Problem> GetProblems(); 115 [OperationContract] 116 long AddProblem(Problem dto); 117 [OperationContract] 118 void UpdateProblem(Problem dto); 119 [OperationContract] 120 void DeleteProblem(long id); 121 [OperationContract] 122 IEnumerable<Guid> GetProblemUsers(long problemId); 123 [OperationContract] 124 void UpdateProblemUsers(long problemId, IEnumerable<Guid> users); 125 #endregion 126 127 #region ProblemData Methods 128 [OperationContract] 129 ProblemData GetProblemData(long problemId); 130 [OperationContract] 131 void UpdateProblemData(ProblemData dto); 87 132 #endregion 88 133 }
Note: See TracChangeset
for help on using the changeset viewer.