Example #1
0
        /// <summary>
        /// at this time, there is always only one feature to be activated or deactivated in a location with same scope
        /// </summary>
        /// <param name="message"></param>
        private void HandleFeatureToggleRequest(FeatureToggleRequest message)
        {
            _log.Debug("Entered LocationActor-HandleFeatureToggleRequest");

            if (message.Activate)
            {
                ActivatedFeature af;
                var error = dataService.ActivateFeature(
                    message.FeatureDefinition
                    , message.Location
                    , message.ElevatedPrivileges
                    , message.Force
                    , out af);

                var completed = new Core.Messages.Completed.FeatureActivationCompleted(
                    message.TaskId
                    , message.Location.Id
                    , af
                    , string.Empty
                    );

                Sender.Tell(completed);
            }
            else
            {
                var completed = new Core.Messages.Completed.FeatureDeactivationCompleted(
                    message.TaskId
                    , message.Location.Id
                    , string.Empty
                    );

                Sender.Tell(completed);
            }
        }
        private void HandleDeactivation(FeatureToggleRequest message)
        {
            string errorMsg = null;

            switch (message.Location.Scope)
            {
            case Core.Models.Enums.Scope.Web:
                errorMsg += dataService.DeactivateWebFeature(
                    message.FeatureDefinition,
                    message.Location,
                    message.ElevatedPrivileges.Value,
                    message.Force.Value);
                break;

            case Core.Models.Enums.Scope.Site:
                errorMsg += dataService.DeactivateSiteFeature(
                    message.FeatureDefinition,
                    message.Location,
                    message.ElevatedPrivileges.Value,
                    message.Force.Value
                    );
                break;

            case Core.Models.Enums.Scope.WebApplication:
                errorMsg += dataService.DeactivateWebAppFeature(
                    message.FeatureDefinition,
                    message.Location,
                    message.Force.Value
                    );
                break;

            case Core.Models.Enums.Scope.Farm:
                errorMsg += dataService.DeactivateFarmFeature(
                    message.FeatureDefinition,
                    message.Location,
                    message.Force.Value
                    );
                break;

            case Core.Models.Enums.Scope.ScopeInvalid:
                errorMsg += string.Format("Location '{0}' has invalid scope - not supported for feature deactivation.", message.Location.Id);
                break;

            default:
                errorMsg += string.Format("Location '{0}' has unidentified scope - not supported for feature deactivation.", message.Location.Id);
                break;
            }

            if (string.IsNullOrEmpty(errorMsg))
            {
                var completed = new Core.Messages.Completed.FeatureDeactivationCompleted(
                    message.TaskId,
                    message.Location.UniqueId,
                    message.FeatureDefinition.UniqueIdentifier
                    );

                Sender.Tell(completed);
            }
            else
            {
                var cancelationMsg = new CancelMessage(
                    message.TaskId,
                    errorMsg,
                    true
                    );

                Sender.Tell(cancelationMsg);
            }
        }