Free cookie consent management tool by TermsFeed Policy Generator

Ignore:
Timestamp:
05/04/10 20:16:21 (15 years ago)
Author:
gkronber
Message:

Implemented change requests of reviewers. #989 (Implement review comments in plugin infrastructure)

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  
    3838    }
    3939    [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")]
    4045    public void DeployPlugin(PluginDescription plugin, byte[] zipFile) {
    4146      var store = new PluginStore();
  • trunk/sources/HeuristicLab.Services.Deployment/3.3/IAdmin.cs

    r3084 r3612  
    3535
    3636    [OperationContract]
     37    void DeleteProduct(ProductDescription product);
     38
     39    [OperationContract]
    3740    void DeployPlugin(PluginDescription plugin, byte[] zipFile);
    3841  }
  • trunk/sources/HeuristicLab.Services.Deployment/3.3/PluginStore.cs

    r3217 r3612  
    111111      }
    112112    }
    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
    117138    private void InsertOrUpdateProduct(PluginStoreClassesDataContext ctx, ProductDescription product) {
    118139      var productEntity = (from p in ctx.Products
     
    126147      }
    127148
    128       DeleteOldPlugins(ctx, productEntity);
     149      DeleteProductPlugins(ctx, productEntity);
    129150
    130151      foreach (var plugin in product.Plugins) {
     
    137158    }
    138159
    139     private void DeleteOldPlugins(PluginStoreClassesDataContext ctx, Product productEntity) {
     160    private void DeleteProductPlugins(PluginStoreClassesDataContext ctx, Product productEntity) {
    140161      var oldPlugins = (from p in ctx.ProductPlugins
    141162                        where p.ProductId == productEntity.Id
     
    253274    }
    254275
     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
    255283    private IEnumerable<Plugin> GetDependencies(PluginStoreClassesDataContext ctx, Plugin plugin) {
    256284      return from pair in ctx.Dependencies
Note: See TracChangeset for help on using the changeset viewer.