protected override void UpdateDataObject()
        {
            SPFeatureDefinition featureDef = null;
            ActivationScope scope = ActivationScope.Feature;

            if (DeactivateAtScope.HasValue)
                scope = DeactivateAtScope.Value;

            if (farmLevelFeature)
            {
                featureDef = SPFarm.Local.FeatureDefinitions[base.DataObject.Id];
            }
            else
            {
                featureDef = base.DataObject;
            }

            try
            {
                Logger.Write("Started at {0}", DateTime.Now.ToString());
                Guid featureId = featureDef.Id;
                FeatureHelper fh = new FeatureHelper();
                fh.ActivateDeactivateFeatureAtScope(featureDef, scope, false, Url, Force.IsPresent, IgnoreNonActive.IsPresent);
            }
            finally
            {
                Logger.Write("Finished at {0}\r\n", DateTime.Now.ToString());
            }

            if ((featureDef != null) && (PassThru.IsPresent))
            {
                base.DataObject = featureDef;
                base.WriteResult(base.DataObject);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Executes the specified command.
        /// </summary>
        /// <param name="command">The command.</param>
        /// <param name="keyValues">The key values.</param>
        /// <param name="output">The output.</param>
        /// <returns></returns>
        public override int Execute(string command, StringDictionary keyValues, out string output)
        {
            output         = string.Empty;
            Logger.Verbose = true;

            ActivationScope scope = ActivationScope.Feature;

            if (Params["scope"].UserTypedIn)
            {
                scope = (ActivationScope)Enum.Parse(typeof(ActivationScope), Params["scope"].Value.ToLowerInvariant(), true);
            }

            bool force           = Params["force"].UserTypedIn;
            bool ignoreNonActive = Params["ignorenonactive"].UserTypedIn;

            if (ignoreNonActive)
            {
                force = true;
            }

            string url = null;

            if (Params["url"].UserTypedIn)
            {
                url = Params["url"].Value.TrimEnd('/');
            }

            try
            {
                Logger.Write("Started at {0}", DateTime.Now.ToString());
                Guid          featureId = FeatureHelper.GetFeatureIdFromParams(Params);
                FeatureHelper fh        = new FeatureHelper();
                fh.ActivateDeactivateFeatureAtScope(scope, featureId, false, url, force, ignoreNonActive);
            }
            finally
            {
                Logger.Write("Finished at {0}\r\n", DateTime.Now.ToString());
            }

            return((int)ErrorCodes.NoError);
        }