Пример #1
0
        public ActionResult Install(PluginInstallInput pluginInstallInput, DialogSelection dialogSelection)
        {
            if (dialogSelection != null && dialogSelection.Equals(DialogButton.Cancel))
            {
                return(new DialogSelectionResult(dialogSelection.ReturnUrl, true));
            }

            PluginContainer pluginContainer = pluginEngine.LoadPlugin(pluginInstallInput.VirtualPath);

            if (pluginContainer == null)
            {
                return(null);
            }

            ValidationStateDictionary validationState = pluginService.ValidatePlugin(pluginContainer);

            if (dialogSelection == null)
            {
                if (validationState.IsValid)
                {
                    return(this.Dialog("What would you like to do next?", DialogFormat.Question, new DialogButton("no", "Enable this plugin", true), new DialogButton("yes", "Edit plugin settings", true), new DialogButton("cancel", "Cancel install", false)));
                }

                return(this.Dialog("This plugin requires you to fill in some required settings before it can be enabled. Would you like to do that now?", DialogFormat.Question, DialogButton.Yes, new DialogButton("no", "No", true), DialogButton.Cancel));
            }

            bool?overrideEnabled = validationState.IsValid
                ? (bool?)(dialogSelection.Equals(DialogButton.No) /* to editing settings */
                    ? true
                    : false)
                : null;

            Plugin plugin = pluginService.InstallPlugin(pluginInstallInput, overrideEnabled);

            if (dialogSelection.Equals(DialogButton.Yes)) /* to editing settings */
            {
                return new DialogSelectionResult(Url.PluginEdit(plugin))
                       {
                           IsClientRedirect = true
                       }
            }
            ;

            return(Redirect(dialogSelection.ReturnUrl));
        }
Пример #2
0
        public ActionResult Uninstall(PluginAddress pluginAddress, DialogSelection dialogSelection)
        {
            if (dialogSelection != null && dialogSelection.Equals(DialogButton.Cancel))
            {
                return(new DialogSelectionResult(dialogSelection.ReturnUrl, true));
            }

            if (dialogSelection == null)
            {
                return(this.Dialog("Are you sure you want to uninstall this plugin?", DialogFormat.Question, DialogButton.Yes, new DialogButton("cancel", "No", true)));
            }

            pluginService.UninstallPlugin(pluginAddress);

            return(Redirect(dialogSelection.ReturnUrl));
        }
Пример #3
0
        /// <summary>
        /// Set the result to a cancel DialogSelectionResult if cancel was selected.
        /// </summary>
        /// <param name="filterContext">The filter context.</param>
        public void OnActionExecuting(ActionExecutingContext filterContext)
        {
            if (filterContext.ActionParameters.ContainsKey("dialogSelection"))
            {
                DialogSelection dialogSelection = filterContext.ActionParameters["dialogSelection"] as DialogSelection;

                if (dialogSelection != null && dialogSelection.Equals(DialogButton.Cancel))
                {
                    filterContext.Result = new JsonResult {
                        Data = new { cancel = 1 }
                    }
                }
                ;
            }
        }

        #endregion
    }
Пример #4
0
        public ActionResult SetEnabled(PluginAddress pluginAddress, bool enabled, string returnUrl, DialogSelection dialogSelection)
        {
            if (dialogSelection != null && dialogSelection.Equals(DialogButton.Cancel))
            {
                return(new DialogSelectionResult(dialogSelection.ReturnUrl, true));
            }

            Plugin plugin = pluginService.GetPlugin(pluginAddress);

            if (plugin == null)
            {
                return(null);
            }

            plugin.FillContainer(pluginEngine);

            if (dialogSelection == null && !plugin.Enabled && !plugin.Container.IsValid)
            {
                return(this.Dialog("You can not enable a plugin that does not have all its required settings filled in. What would you like to do next?", DialogFormat.Info, new DialogButton("yes", "Edit settings", true), new DialogButton("cancel", "Cancel", false)));
            }

            if (dialogSelection != null)
            {
                return new DialogSelectionResult(Url.PluginEdit(plugin))
                       {
                           IsClientRedirect = true
                       }
            }
            ;

            if (plugin.Container.IsValid || (!plugin.Container.IsValid && !enabled))
            {
                pluginService.SetPluginEnabled(pluginAddress, enabled);
            }

            return(Redirect(returnUrl));
        }