- Timestamp:
- 03/20/13 16:56:28 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
branches/OaaS/HeuristicLab.Services.Optimization.Controller/Azure/DAL.cs
r9305 r9324 162 162 } 163 163 164 public bool Delete(string username, string experimentId) { 165 TableServiceContext serviceContext = TableClient.GetDataServiceContext(); 166 TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE); 167 var entity = (from e in serviceContext.CreateQuery<ExperimentEntity>(AzureConstants.EXPERIMENT_TABLE) 168 where e.ExperimentId == experimentId 169 select e).FirstOrDefault(); 170 171 if (entity == null) 172 return false; 173 174 if (entity.ExperimentJsonUrl != null) { 175 CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.EXPERIMENT_BLOB_CONTAINER); 176 container.CreateIfNotExist(); 177 var blob = container.GetBlobReference(entity.ExperimentJsonUrl); 178 blob.DeleteIfExists(); 179 } 180 181 serviceContext.DeleteObject(entity); 182 serviceContext.SaveChangesWithRetries(); 183 return true; 184 } 185 164 186 public bool DeleteByName(string username, string experiment) { 165 187 TableServiceContext serviceContext = TableClient.GetDataServiceContext(); … … 209 231 //} 210 232 211 public IEnumerable<Model.Experiment> GetExperiments(string user ) {233 public IEnumerable<Model.Experiment> GetExperiments(string user, bool namesOnly=false) { 212 234 TableServiceContext serviceContext = TableClient.GetDataServiceContext(); 213 235 TableClient.CreateTableIfNotExist(AzureConstants.EXPERIMENT_TABLE); … … 216 238 select e).ToList(); 217 239 var experiments = new List<Experiment>(); 218 CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.EXPERIMENT_BLOB_CONTAINER); 219 container.CreateIfNotExist(); 220 foreach (var entity in entites) { 221 var blob = container.GetBlobReference(entity.ExperimentJsonUrl); 222 experiments.Add(AlgorithmConverter.ConvertJsonToExperiment(blob.DownloadText())); 223 } 224 return experiments; 240 if (namesOnly) { 241 return (from e in entites select new Model.Experiment() { Id = e.ExperimentId, Name = e.RowKey.Split('_')[1] }); 242 } 243 else { 244 CloudBlobContainer container = BlobClient.GetContainerReference(AzureConstants.EXPERIMENT_BLOB_CONTAINER); 245 container.CreateIfNotExist(); 246 foreach (var entity in entites) { 247 var blob = container.GetBlobReference(entity.ExperimentJsonUrl); 248 experiments.Add(AlgorithmConverter.ConvertJsonToExperiment(blob.DownloadText())); 249 } 250 return experiments; 251 } 225 252 } 226 253
Note: See TracChangeset
for help on using the changeset viewer.