コード例 #1
0
 public static MockActivatedFeature GetMockActivatedFeature(IFeatureParent parent)
 {
     return(new MockActivatedFeature()
     {
         Id = Id,
         Name = Name,
         Scope = Scope,
         DefinitionVersion = Version,
         Faulty = Faulty,
         Parent = SharePointContainers.SiCoActivated.GetMockFeatureParent(),
         Version = Version
     });
 }
コード例 #2
0
 public static MockActivatedFeature GetMockActivatedFeature(IFeatureParent parent)
 {
     return(new MockActivatedFeature()
     {
         Id = Id,
         Name = Name,
         Scope = Scope,
         DefinitionVersion = Version,
         Faulty = Faulty,
         Parent = parent,
         Version = Version
     });
 }
コード例 #3
0
 public LocationViewModel(IFeatureParent location)
 {
     Location = location;
 }
        private static int ProcessAllFeaturesWithinSharePointContainer(IFeatureParent sharePointContainer, IEnumerable <IFeatureIdentifier> featureDefinitions, bool activate, bool force, out Exception exception)
        {
            var processingCounter = 0;

            exception = null;

            if (sharePointContainer == null)
            {
                exception = new ArgumentNullException("sharePointContainer (FeatureParent) is null");
                return(0);
            }
            if (featureDefinitions == null || featureDefinitions.Count() == 0)
            {
                exception = new ArgumentNullException("No features to activate!");
                return(0);
            }

            var farmFeatureIds    = featureDefinitions.Where(fd => fd.Scope == SPFeatureScope.Farm).Select(fd => fd.Id);
            var webAppFeatureIds  = featureDefinitions.Where(fd => fd.Scope == SPFeatureScope.WebApplication).Select(fd => fd.Id);
            var siteFeatureIds    = featureDefinitions.Where(fd => fd.Scope == SPFeatureScope.Site).Select(fd => fd.Id);
            var webFeatureIds     = featureDefinitions.Where(fd => fd.Scope == SPFeatureScope.Web).Select(fd => fd.Id);
            var invalidFeatureIds = featureDefinitions.Where(fd => fd.Scope == SPFeatureScope.ScopeInvalid).Select(fd => fd.Id);

            var activationLevel = sharePointContainer.Scope;

            switch (activationLevel)
            {
            case SPFeatureScope.Farm:
                processingCounter += ProcessAllFeaturesInFarm(farmFeatureIds, SPFeatureScope.Farm, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInFarm(webAppFeatureIds, SPFeatureScope.WebApplication, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInFarm(siteFeatureIds, SPFeatureScope.Site, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInFarm(webFeatureIds, SPFeatureScope.Web, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInFarm(invalidFeatureIds, SPFeatureScope.ScopeInvalid, activate, force, out exception);
                break;

            case SPFeatureScope.WebApplication:
                processingCounter += ProcessAllFeaturesInWebApp(sharePointContainer.Url, webAppFeatureIds, SPFeatureScope.WebApplication, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInWebApp(sharePointContainer.Url, siteFeatureIds, SPFeatureScope.Site, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInWebApp(sharePointContainer.Url, webFeatureIds, SPFeatureScope.Web, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInWebApp(sharePointContainer.Url, invalidFeatureIds, SPFeatureScope.ScopeInvalid, activate, force, out exception);
                break;

            case SPFeatureScope.Site:
                processingCounter += ProcessAllFeaturesInSite(sharePointContainer.Url, siteFeatureIds, SPFeatureScope.Site, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInSite(sharePointContainer.Url, webFeatureIds, SPFeatureScope.Web, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInSite(sharePointContainer.Url, invalidFeatureIds, SPFeatureScope.ScopeInvalid, activate, force, out exception);
                break;

            case SPFeatureScope.Web:
                processingCounter += ProcessAllFeaturesInWeb(sharePointContainer.Url, webFeatureIds, activate, force, out exception);
                processingCounter += ProcessAllFeaturesInWeb(sharePointContainer.Url, invalidFeatureIds, activate, force, out exception);

                break;

            default:
                exception = new ArgumentException("sharepoint container scope was invalid");
                break;
            }

            return(processingCounter);
        }
 public static int DeactivateAllFeaturesWithinSharePointContainer(IFeatureParent sharePointContainer, IEnumerable <IFeatureIdentifier> featureDefinitions, bool force, out Exception exception)
 {
     return(ProcessAllFeaturesWithinSharePointContainer(sharePointContainer, featureDefinitions, false, force, out exception));
 }
        public static int DeactivateAllFeatures(IEnumerable <IActivatedFeature> features, bool force, out Exception exception)
        {
            var processingCounter = 0;

            exception = null;

            if (features == null || features.Count() == 0)
            {
                exception = new ArgumentNullException("No features to deactivate!");
                return(0);
            }


            var farmFeatureIds  = features.Where(fd => fd.Scope == SPFeatureScope.Farm).Select(fd => fd.Id);
            var webAppFeatures  = features.Where(fd => fd.Scope == SPFeatureScope.WebApplication);
            var siteFeatures    = features.Where(fd => fd.Scope == SPFeatureScope.Site);
            var webFeatures     = features.Where(fd => fd.Scope == SPFeatureScope.Web);
            var invalidFeatures = features.Where(fd => fd.Scope == SPFeatureScope.ScopeInvalid);

            // deactivate farm features
            if (farmFeatureIds != null && farmFeatureIds.Count() > 0)
            {
                processingCounter += ProcessAllFeaturesInFarm(farmFeatureIds, SPFeatureScope.Farm, false, force, out exception);
            }

            // deactivate WebApp features
            if (webAppFeatures != null && webAppFeatures.Count() > 0)
            {
                var groupedFeatures = webAppFeatures.GroupBy(f => f.Parent.Url);
                foreach (var featureGroup in groupedFeatures)
                {
                    IFeatureParent sharePointContainer = featureGroup.First().Parent;

                    processingCounter += ProcessAllFeaturesInWebApp(sharePointContainer.Url, featureGroup.Select(f => f.Id), SPFeatureScope.WebApplication, false, force, out exception);
                }
            }

            // deactivate SiteCollection features
            if (siteFeatures != null && siteFeatures.Count() > 0)
            {
                var groupedFeatures = siteFeatures.GroupBy(f => f.Parent.Url);
                foreach (var featureGroup in groupedFeatures)
                {
                    IFeatureParent sharePointContainer = featureGroup.First().Parent;

                    processingCounter += ProcessAllFeaturesInSite(sharePointContainer.Url, featureGroup.Select(f => f.Id), SPFeatureScope.Site, false, force, out exception);
                }
            }

            // deactivate Web features
            if (webFeatures != null && webFeatures.Count() > 0)
            {
                var groupedFeatures = webFeatures.GroupBy(f => f.Parent.Url);
                foreach (var featureGroup in groupedFeatures)
                {
                    IFeatureParent sharePointContainer = featureGroup.First().Parent;

                    processingCounter += ProcessAllFeaturesInWeb(sharePointContainer.Url, featureGroup.Select(f => f.Id), false, force, out exception);
                }
            }
            return(processingCounter);
        }