Changeset 3612 for trunk/sources/HeuristicLab.Services.Deployment
- Timestamp:
- 05/04/10 20:16:21 (15 years ago)
- Location:
- trunk/sources/HeuristicLab.Services.Deployment/3.3
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/sources/HeuristicLab.Services.Deployment/3.3/Admin.cs
r3084 r3612 38 38 } 39 39 [PrincipalPermission(SecurityAction.Demand, Role = "Managers")] 40 public void DeleteProduct(ProductDescription product) { 41 var store = new PluginStore(); 42 store.Delete(product); 43 } 44 [PrincipalPermission(SecurityAction.Demand, Role = "Managers")] 40 45 public void DeployPlugin(PluginDescription plugin, byte[] zipFile) { 41 46 var store = new PluginStore(); -
trunk/sources/HeuristicLab.Services.Deployment/3.3/IAdmin.cs
r3084 r3612 35 35 36 36 [OperationContract] 37 void DeleteProduct(ProductDescription product); 38 39 [OperationContract] 37 40 void DeployPlugin(PluginDescription plugin, byte[] zipFile); 38 41 } -
trunk/sources/HeuristicLab.Services.Deployment/3.3/PluginStore.cs
r3217 r3612 111 111 } 112 112 } 113 114 #endregion 115 116 #region insert/update product 113 public void Delete(ProductDescription productDescription) { 114 using (var ctx = new PluginStoreClassesDataContext()) { 115 try { 116 using (var transaction = new TransactionScope()) { 117 var productEntity = GetExistingProduct(ctx, productDescription.Name, productDescription.Version); 118 119 DeleteProductPlugins(ctx, productEntity); 120 ctx.Products.DeleteOnSubmit(productEntity); 121 122 ctx.SubmitChanges(); 123 transaction.Complete(); 124 } 125 } 126 catch (SqlException ex) { 127 throw new ArgumentException("Something went wrong while trying to delete product", ex); 128 } 129 catch (InvalidOperationException ex) { 130 throw new ArgumentException("Something went wrong while trying to delete product", ex); 131 } 132 } 133 } 134 135 #endregion 136 137 #region insert/update/delete product 117 138 private void InsertOrUpdateProduct(PluginStoreClassesDataContext ctx, ProductDescription product) { 118 139 var productEntity = (from p in ctx.Products … … 126 147 } 127 148 128 Delete OldPlugins(ctx, productEntity);149 DeleteProductPlugins(ctx, productEntity); 129 150 130 151 foreach (var plugin in product.Plugins) { … … 137 158 } 138 159 139 private void Delete OldPlugins(PluginStoreClassesDataContext ctx, Product productEntity) {160 private void DeleteProductPlugins(PluginStoreClassesDataContext ctx, Product productEntity) { 140 161 var oldPlugins = (from p in ctx.ProductPlugins 141 162 where p.ProductId == productEntity.Id … … 253 274 } 254 275 276 private Product GetExistingProduct(PluginStoreClassesDataContext ctx, string name, Version version) { 277 return (from p in ctx.Products 278 where p.Name == name 279 where p.Version == version.ToString() 280 select p).Single(); 281 } 282 255 283 private IEnumerable<Plugin> GetDependencies(PluginStoreClassesDataContext ctx, Plugin plugin) { 256 284 return from pair in ctx.Dependencies
Note: See TracChangeset
for help on using the changeset viewer.