Changeset 5389
- Timestamp:
- 01/28/11 02:37:12 (14 years ago)
- Location:
- branches/OKB (trunk integration)
- Files:
-
- 2 deleted
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OKB (trunk integration)/HeuristicLab.Services.OKB.DataTransfer/3.3/BinaryData.cs
r5378 r5389 27 27 [DataMember] 28 28 public byte[] Data { get; set; } 29 [DataMember]30 public byte[] Hash { get; set; }31 29 } 32 30 } -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/AdministrationService.cs
r5299 r5389 24 24 using System.Data.Linq; 25 25 using System.Linq; 26 using System.Security.Cryptography; 26 27 using System.ServiceModel; 27 28 using HeuristicLab.Services.OKB.DataAccess; … … 103 104 #endregion 104 105 106 #region BinaryData Methods 107 public long GetBinaryDataId(byte[] hash) { 108 using (OKBDataContext okb = new OKBDataContext()) { 109 var id = okb.BinaryDatas.Where(x => x.Hash.Equals(hash)).Select(x => x.Id).FirstOrDefault(); 110 if (id == 0) return -1; 111 else return id; 112 } 113 } 114 public long AddBinaryData(DataTransfer.BinaryData dto) { 115 byte[] hash; 116 using (SHA1 sha1 = SHA1.Create()) { 117 hash = sha1.ComputeHash(dto.Data); 118 } 119 120 using (OKBDataContext okb = new OKBDataContext()) { 121 var id = okb.BinaryDatas.Where(x => x.Hash.Equals(hash)).Select(x => x.Id).FirstOrDefault(); 122 if (id != 0) { 123 return id; 124 } else { 125 DataAccess.BinaryData entity = Convert.ToEntity(dto); entity.Id = 0; 126 okb.BinaryDatas.InsertOnSubmit(entity); 127 okb.SubmitChanges(); 128 return entity.Id; 129 } 130 } 131 } 132 public void DeleteBinaryData(long id) { 133 using (OKBDataContext okb = new OKBDataContext()) { 134 DataAccess.BinaryData entity = okb.BinaryDatas.FirstOrDefault(x => x.Id == id); 135 if (entity != null) okb.BinaryDatas.DeleteOnSubmit(entity); 136 okb.SubmitChanges(); 137 } 138 } 139 #endregion 140 105 141 #region AlgorithmClass Methods 106 142 public DataTransfer.AlgorithmClass GetAlgorithmClass(long id) { … … 183 219 } 184 220 } 185 #endregion 186 187 #region AlgorithmData Methods 188 public DataTransfer.AlgorithmData GetAlgorithmData(long algorithmId) { 189 using (OKBDataContext okb = new OKBDataContext()) { 190 return Convert.ToDto(okb.AlgorithmDatas.FirstOrDefault(x => x.AlgorithmId == algorithmId)); 191 } 192 } 193 public void UpdateAlgorithmData(DataTransfer.AlgorithmData dto) { 194 using (OKBDataContext okb = new OKBDataContext()) { 195 DataAccess.AlgorithmData entity = okb.AlgorithmDatas.FirstOrDefault(x => x.AlgorithmId == dto.AlgorithmId); 196 if (entity == null) okb.AlgorithmDatas.InsertOnSubmit(Convert.ToEntity(dto)); 197 else Convert.ToEntity(dto, entity); 198 okb.SubmitChanges(); 199 } 200 } 201 #endregion 202 203 #region AlgorithmParameter Methods 204 public DataTransfer.AlgorithmParameter GetAlgorithmParameter(long id) { 205 using (OKBDataContext okb = new OKBDataContext()) { 206 return Convert.ToDto(okb.AlgorithmParameters.FirstOrDefault(x => x.Id == id)); 207 } 208 } 209 public IEnumerable<DataTransfer.AlgorithmParameter> GetAlgorithmParameters(long algorithmId) { 210 using (OKBDataContext okb = new OKBDataContext()) { 211 return okb.AlgorithmParameters.Where(x => x.AlgorithmId == algorithmId).Select(x => Convert.ToDto(x)).ToArray(); 212 } 213 } 214 public long AddAlgorithmParameter(DataTransfer.AlgorithmParameter dto) { 215 using (OKBDataContext okb = new OKBDataContext()) { 216 DataAccess.AlgorithmParameter entity = Convert.ToEntity(dto); entity.Id = 0; 217 okb.AlgorithmParameters.InsertOnSubmit(entity); 218 okb.SubmitChanges(); 219 return entity.Id; 220 } 221 } 222 public void UpdateAlgorithmParameter(DataTransfer.AlgorithmParameter dto) { 223 using (OKBDataContext okb = new OKBDataContext()) { 224 DataAccess.AlgorithmParameter entity = okb.AlgorithmParameters.FirstOrDefault(x => x.Id == dto.Id); 225 Convert.ToEntity(dto, entity); 226 okb.SubmitChanges(); 227 } 228 } 229 public void DeleteAlgorithmParameter(long id) { 230 using (OKBDataContext okb = new OKBDataContext()) { 231 DataAccess.AlgorithmParameter entity = okb.AlgorithmParameters.FirstOrDefault(x => x.Id == id); 232 if (entity != null) okb.AlgorithmParameters.DeleteOnSubmit(entity); 233 okb.SubmitChanges(); 221 public DataTransfer.BinaryData GetAlgorithmData(long algorithmId) { 222 using (OKBDataContext okb = new OKBDataContext()) { 223 DataLoadOptions dlo = new DataLoadOptions(); 224 dlo.LoadWith<Algorithm>(x => x.BinaryData); 225 okb.LoadOptions = dlo; 226 return Convert.ToDto(okb.Algorithms.Where(x => x.Id == algorithmId).Select(x => x.BinaryData).FirstOrDefault()); 234 227 } 235 228 } … … 316 309 } 317 310 } 318 #endregion 319 320 #region ProblemData Methods 321 public DataTransfer.ProblemData GetProblemData(long problemId) { 322 using (OKBDataContext okb = new OKBDataContext()) { 323 return Convert.ToDto(okb.ProblemDatas.FirstOrDefault(x => x.ProblemId == problemId)); 324 } 325 } 326 public void UpdateProblemData(DataTransfer.ProblemData dto) { 327 using (OKBDataContext okb = new OKBDataContext()) { 328 DataAccess.ProblemData entity = okb.ProblemDatas.FirstOrDefault(x => x.ProblemId == dto.ProblemId); 329 if (entity == null) okb.ProblemDatas.InsertOnSubmit(Convert.ToEntity(dto)); 330 else Convert.ToEntity(dto, entity); 331 okb.SubmitChanges(); 311 public DataTransfer.BinaryData GetProblemData(long problemId) { 312 using (OKBDataContext okb = new OKBDataContext()) { 313 DataLoadOptions dlo = new DataLoadOptions(); 314 dlo.LoadWith<Problem>(x => x.BinaryData); 315 okb.LoadOptions = dlo; 316 return Convert.ToDto(okb.Problems.Where(x => x.Id == problemId).Select(x => x.BinaryData).FirstOrDefault()); 332 317 } 333 318 } -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/Convert.cs
r5295 r5389 47 47 public static DT.DataType ToDto(DA.DataType source) { 48 48 if (source == null) return null; 49 return new DT.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, SqlName = source.SqlName,PlatformId = source.PlatformId };49 return new DT.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, PlatformId = source.PlatformId }; 50 50 } 51 51 public static DA.DataType ToEntity(DT.DataType source) { 52 52 if (source == null) return null; 53 return new DA.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, SqlName = source.SqlName,PlatformId = source.PlatformId };53 return new DA.DataType { Id = source.Id, Name = source.Name, TypeName = source.TypeName, PlatformId = source.PlatformId }; 54 54 } 55 55 public static void ToEntity(DT.DataType source, DA.DataType target) { 56 56 if ((source != null) && (target != null)) { 57 target.Id = source.Id; target.Name = source.Name; target.TypeName = source.TypeName; target.SqlName = source.SqlName; target.PlatformId = source.PlatformId; 57 target.Id = source.Id; target.Name = source.Name; target.TypeName = source.TypeName; target.PlatformId = source.PlatformId; 58 } 59 } 60 #endregion 61 62 #region BinaryData 63 public static DT.BinaryData ToDto(DA.BinaryData source) { 64 if (source == null) return null; 65 return new DT.BinaryData { Id = source.Id, Data = source.Data.ToArray() }; 66 } 67 public static DA.BinaryData ToEntity(DT.BinaryData source) { 68 if (source == null) return null; 69 return new DA.BinaryData { Id = source.Id, Data = source.Data }; 70 } 71 public static void ToEntity(DT.BinaryData source, DA.BinaryData target) { 72 if ((source != null) && (target != null)) { 73 target.Id = source.Id; target.Data = source.Data; 58 74 } 59 75 } … … 79 95 public static DT.Algorithm ToDto(DA.Algorithm source) { 80 96 if (source == null) return null; 81 return new DT.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId };97 return new DT.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId }; 82 98 } 83 99 public static DA.Algorithm ToEntity(DT.Algorithm source) { 84 100 if (source == null) return null; 85 return new DA.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId };101 return new DA.Algorithm { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, AlgorithmClassId = source.AlgorithmClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId }; 86 102 } 87 103 public static void ToEntity(DT.Algorithm source, DA.Algorithm target) { 88 104 if ((source != null) && (target != null)) { 89 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId; 90 } 91 } 92 #endregion 93 94 #region AlgorithmData 95 public static DT.AlgorithmData ToDto(DA.AlgorithmData source) { 96 if (source == null) return null; 97 return new DT.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() }; 98 } 99 public static DA.AlgorithmData ToEntity(DT.AlgorithmData source) { 100 if (source == null) return null; 101 return new DA.AlgorithmData { AlgorithmId = source.AlgorithmId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) }; 102 } 103 public static void ToEntity(DT.AlgorithmData source, DA.AlgorithmData target) { 104 if ((source != null) && (target != null)) { 105 target.AlgorithmId = source.AlgorithmId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data); 105 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.AlgorithmClassId = source.AlgorithmClassId; target.DataTypeId = source.DataTypeId; target.BinaryDataId = source.BinaryDataId; 106 106 } 107 107 } … … 223 223 public static DT.Problem ToDto(DA.Problem source) { 224 224 if (source == null) return null; 225 return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId };225 return new DT.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId }; 226 226 } 227 227 public static DA.Problem ToEntity(DT.Problem source) { 228 228 if (source == null) return null; 229 return new DA.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId };229 return new DA.Problem { Id = source.Id, Name = source.Name, Description = source.Description, PlatformId = source.PlatformId, ProblemClassId = source.ProblemClassId, DataTypeId = source.DataTypeId, BinaryDataId = source.BinaryDataId }; 230 230 } 231 231 public static void ToEntity(DT.Problem source, DA.Problem target) { 232 232 if ((source != null) && (target != null)) { 233 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.ProblemClassId = source.ProblemClassId; 234 } 235 } 236 #endregion 237 238 #region ProblemData 239 public static DT.ProblemData ToDto(DA.ProblemData source) { 240 if (source == null) return null; 241 return new DT.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = source.Data.ToArray() }; 242 } 243 public static DA.ProblemData ToEntity(DT.ProblemData source) { 244 if (source == null) return null; 245 return new DA.ProblemData { ProblemId = source.ProblemId, DataTypeId = source.DataTypeId, Data = new Binary(source.Data) }; 246 } 247 public static void ToEntity(DT.ProblemData source, DA.ProblemData target) { 248 if ((source != null) && (target != null)) { 249 target.ProblemId = source.ProblemId; target.DataTypeId = source.DataTypeId; target.Data = new Binary(source.Data); 233 target.Id = source.Id; target.Name = source.Name; target.Description = source.Description; target.PlatformId = source.PlatformId; target.ProblemClassId = source.ProblemClassId; target.DataTypeId = source.DataTypeId; target.BinaryDataId = source.BinaryDataId; 250 234 } 251 235 } -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/HeuristicLab.Services.OKB-3.3.csproj
r5299 r5389 160 160 <Compile Include="Filters\ResultStringValueValueFilter.cs" /> 161 161 <Compile Include="Filters\ResultFloatValueValueFilter.cs" /> 162 <Compile Include="GenericEqualityComparer.cs" />163 <Compile Include="ExperimentEqualityComparer.cs" />164 162 <Compile Include="Interfaces\IQueryService.cs" /> 165 163 <Compile Include="Interfaces\IAuthenticationService.cs" /> -
branches/OKB (trunk integration)/HeuristicLab.Services.OKB/3.3/Interfaces/IAdministrationService.cs
r5299 r5389 58 58 #endregion 59 59 60 #region BinaryData Methods 61 [OperationContract] 62 long GetBinaryDataId(byte[] hash); 63 [OperationContract] 64 long AddBinaryData(BinaryData dto); 65 [OperationContract] 66 void DeleteBinaryData(long id); 67 #endregion 68 60 69 #region AlgorithmClass Methods 61 70 [OperationContract] … … 86 95 [OperationContract] 87 96 void UpdateAlgorithmUsers(long algorithmId, IEnumerable<Guid> users); 88 #endregion89 90 #region AlgorithmData Methods91 97 [OperationContract] 92 AlgorithmData GetAlgorithmData(long algorithmId); 93 [OperationContract] 94 void UpdateAlgorithmData(AlgorithmData dto); 95 #endregion 96 97 #region AlgorithmParameter Methods 98 [OperationContract] 99 AlgorithmParameter GetAlgorithmParameter(long id); 100 [OperationContract] 101 IEnumerable<AlgorithmParameter> GetAlgorithmParameters(long algorithmId); 102 [OperationContract] 103 long AddAlgorithmParameter(AlgorithmParameter dto); 104 [OperationContract] 105 void UpdateAlgorithmParameter(AlgorithmParameter dto); 106 [OperationContract] 107 void DeleteAlgorithmParameter(long id); 98 BinaryData GetAlgorithmData(long algorithmId); 108 99 #endregion 109 100 … … 136 127 [OperationContract] 137 128 void UpdateProblemUsers(long problemId, IEnumerable<Guid> users); 138 #endregion139 140 #region ProblemData Methods141 129 [OperationContract] 142 ProblemData GetProblemData(long problemId); 143 [OperationContract] 144 void UpdateProblemData(ProblemData dto); 145 #endregion 146 147 #region ProblemParameter Methods 148 [OperationContract] 149 ProblemParameter GetProblemParameter(long id); 150 [OperationContract] 151 IEnumerable<ProblemParameter> GetProblemParameters(long problemId); 152 [OperationContract] 153 long AddProblemParameter(ProblemParameter dto); 154 [OperationContract] 155 void UpdateProblemParameter(ProblemParameter dto); 156 [OperationContract] 157 void DeleteProblemParameter(long id); 158 #endregion 159 160 #region Result Methods 161 [OperationContract] 162 Result GetResult(long id); 163 [OperationContract] 164 IEnumerable<Result> GetResults(long algorithmId); 165 [OperationContract] 166 long AddResult(Result dto); 167 [OperationContract] 168 void UpdateResult(Result dto); 169 [OperationContract] 170 void DeleteResult(long id); 171 #endregion 172 173 #region Experiment Methods 174 [OperationContract] 175 Experiment GetExperiment(long id); 176 [OperationContract] 177 IEnumerable<Experiment> GetExperiments(long algorithmId, long problemId); 178 [OperationContract] 179 long AddExperiment(Experiment dto); 180 [OperationContract] 181 void DeleteExperiment(long id); 130 BinaryData GetProblemData(long problemId); 182 131 #endregion 183 132 … … 186 135 Run GetRun(long id); 187 136 [OperationContract] 188 IEnumerable<Run> GetRuns(long experimentId);137 IEnumerable<Run> GetRuns(long algorithmId, long problemId); 189 138 [OperationContract] 190 139 long AddRun(Run dto);
Note: See TracChangeset
for help on using the changeset viewer.