public static string WebAppFeatureAction( FeatureDefinition feature, Location location, Func <SPFeatureCollection, Guid, bool, SPFeature> featureAction, bool force, out ActivatedFeature resultingFeature) { resultingFeature = null; try { var wa = SpLocationHelper.GetWebApplication(location.Id); var spResultingFeature = featureAction(wa.Features, feature.Id, force); if (spResultingFeature != null) { resultingFeature = spResultingFeature.ToActivatedFeature(location); } } catch (Exception ex) { return(ex.Message); } return(string.Empty); }
public static string WebFeatureAction(FeatureDefinition feature, Location location, Func <SPFeatureCollection, Guid, bool, SPFeature> featureAction, bool elevatedPrivileges, bool force, out ActivatedFeature resultingFeature) { resultingFeature = null; SPWeb spWeb = null; try { spWeb = SpLocationHelper.GetWeb(location, elevatedPrivileges); SPFeatureCollection featureCollection = SpFeatureHelper.GetFeatureCollection(spWeb, elevatedPrivileges); SPFeature spResultingFeature; spResultingFeature = featureAction(featureCollection, feature.Id, force); if (spResultingFeature != null) { resultingFeature = spResultingFeature.ToActivatedFeature(location); } } catch (Exception ex) { return(ex.Message); } finally { if (spWeb != null) { spWeb.Dispose(); } } return(string.Empty); }
public static Location ToLocation(this SPWebService farm) { var id = farm.Id; var webAppsCount = SpLocationHelper.GetAllWebApplications().Count(); var location = LocationFactory.GetFarm(id, webAppsCount); return(location); }