コード例 #1
0
        public ActionResult RunPackageActions(string id, PackageInstallationState state)
        {
            var nugetPackage = BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.FindPackage(id);

            //Run the configuration tasks
            //get the package with the name and ensure it exists

            if (nugetPackage != null)
            {
                //get the package folder name, create the task execution context and then execute the package tasks using the utility class
                var packageFolderName = BackOfficeRequestContext.PackageContext.LocalPathResolver.GetPackageDirectory(nugetPackage);
                var taskExeContext    = _packageInstallUtility.GetTaskExecutionContext(nugetPackage, packageFolderName, state, this);
                _packageInstallUtility.RunPostPackageInstallActions(state, taskExeContext, packageFolderName);

                //re-issue authentication token incase any permissions have changed so that a re-login is not required.
                if (User.Identity is UmbracoBackOfficeIdentity)
                {
                    var user   = (UmbracoBackOfficeIdentity)User.Identity;
                    var userId = user.Id;

                    using (var uow = BackOfficeRequestContext.Application.Hive.OpenReader <ISecurityStore>())
                    {
                        var entity = uow.Repositories.Get <User>(userId);

                        HttpContext.CreateUmbracoAuthTicket(entity);
                    }
                }
            }

            //if the task did not redirect, then show the LocalRepositoryr
            return(RedirectToAction("LocalRepository"));
        }
コード例 #2
0
 public ActionResult RecycleApplication(string id, PackageInstallationState state)
 {
     if (id == null)
     {
         throw new ArgumentNullException("id");
     }
     return(View(new PackageInstallerStateModel {
         PackageId = id, State = state
     }));
 }
コード例 #3
0
        /// <summary>
        /// Runs package actions for either PostPackageInstall and PostPackageUninstall & the packagefoldername specific task
        /// </summary>
        /// <param name="state"></param>
        /// <param name="taskExecContext"></param>
        /// <param name="packageFolderName"></param>
        internal void RunPostPackageInstallActions(PackageInstallationState state, TaskExecutionContext taskExecContext, string packageFolderName)
        {
            //Run the post pacakge install/uninstall tasks
            var triggerType = state == PackageInstallationState.Installing
                                  ? TaskTriggers.PostPackageInstall
                                  : TaskTriggers.PostPackageUninstall;

            _backOfficeRequestContext.Application.FrameworkContext.TaskManager.ExecuteInContext(triggerType, taskExecContext);

            //Execute all  tasks registered with the package folder name... though that will only fire for packages that have just been installed obviously.
            // ...This will redirect to the appopriate controller/action if a UI task is found for this package
            _backOfficeRequestContext.Application.FrameworkContext.TaskManager.ExecuteInContext(packageFolderName + "-" + triggerType, taskExecContext);
        }
コード例 #4
0
        /// <summary>
        /// Runs package actions for either PostPackageInstall and PostPackageUninstall & the packagefoldername specific task
        /// </summary>
        /// <param name="state"></param>
        /// <param name="taskExecContext"></param>
        /// <param name="packageFolderName"></param>
        internal void RunPostPackageInstallActions(PackageInstallationState state, TaskExecutionContext taskExecContext, string packageFolderName)
        {
            //Run the post pacakge install/uninstall tasks
            var triggerType = state == PackageInstallationState.Installing
                                  ? TaskTriggers.PostPackageInstall
                                  : TaskTriggers.PostPackageUninstall;

            _backOfficeRequestContext.Application.FrameworkContext.TaskManager.ExecuteInContext(triggerType, taskExecContext);

            //Execute all  tasks registered with the package folder name... though that will only fire for packages that have just been installed obviously.
            // ...This will redirect to the appopriate controller/action if a UI task is found for this package
            _backOfficeRequestContext.Application.FrameworkContext.TaskManager.ExecuteInContext(packageFolderName + "-" + triggerType, taskExecContext);
        }
コード例 #5
0
        public ActionResult RunPackageActions(string id, PackageInstallationState state)
        {
            var nugetPackage = BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.FindPackage(id);

            //Run the configuration tasks
            //get the package with the name and ensure it exists

            if (nugetPackage != null)
            {
                //get the package folder name, create the task execution context and then execute the package tasks using the utility class
                var packageFolderName = BackOfficeRequestContext.PackageContext.LocalPathResolver.GetPackageDirectory(nugetPackage);
                var taskExeContext    = _packageInstallUtility.GetTaskExecutionContext(nugetPackage, packageFolderName, state, this);
                _packageInstallUtility.RunPostPackageInstallActions(state, taskExeContext, packageFolderName);

                //re-issue authentication token incase any permissions have changed so that a re-login is not required.
                if (User.Identity is RebelBackOfficeIdentity)
                {
                    var userId   = ((RebelBackOfficeIdentity)User.Identity).Id;
                    var user     = BackOfficeRequestContext.Application.Security.Users.GetById(userId, true);
                    var userData = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map <UserData>(user);
                    HttpContext.CreateRebelAuthTicket(userData);
                }

                switch (state)
                {
                case PackageInstallationState.Installing:

                    Notifications.Add(new NotificationMessage(nugetPackage.Title + " has been installed", "Package installed", NotificationType.Success));
                    SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", nugetPackage.Id);

                    return(RedirectToAction("Installed", new { id = nugetPackage.Id }));

                case PackageInstallationState.Uninstalling:

                    Notifications.Add(new NotificationMessage(nugetPackage.Title + " has been uninstalled", "Package uninstalled", NotificationType.Success));
                    SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", nugetPackage.Id);

                    return(RedirectToAction("Uninstalled"));
                }
            }

            //if the task did not redirect, then perform default redirects
            return(RedirectToAction("LocalRepository"));
        }
コード例 #6
0
        /// <summary>
        /// Creates the task execution context for use in the Package installation actions
        /// </summary>
        /// <param name="nugetPackage"></param>
        /// <param name="packageFolderName"></param>
        /// <param name="state"></param>
        /// <param name="controller"></param>
        /// <returns></returns>
        internal TaskExecutionContext GetTaskExecutionContext(
            IPackage nugetPackage, 
            string packageFolderName, 
            PackageInstallationState state,
            Controller controller)
        {
            var package = new PackageFolder
            {
                IsNugetInstalled = nugetPackage.IsInstalled(_backOfficeRequestContext.PackageContext.LocalPackageManager.LocalRepository),
                Name = packageFolderName
            };

            return new TaskExecutionContext
            {
                EventSource = controller,
                EventArgs = new TaskEventArgs(_backOfficeRequestContext.Application.FrameworkContext,
                    new PackageInstallEventArgs(nugetPackage.Id, package, state))
            };
        }
コード例 #7
0
        /// <summary>
        /// Creates the task execution context for use in the Package installation actions
        /// </summary>
        /// <param name="nugetPackage"></param>
        /// <param name="packageFolderName"></param>
        /// <param name="state"></param>
        /// <param name="controller"></param>
        /// <returns></returns>
        internal TaskExecutionContext GetTaskExecutionContext(
            IPackage nugetPackage,
            string packageFolderName,
            PackageInstallationState state,
            Controller controller)
        {
            var package = new PackageFolder
            {
                IsNugetInstalled = nugetPackage.IsInstalled(_backOfficeRequestContext.PackageContext.LocalPackageManager.LocalRepository),
                Name             = packageFolderName
            };

            return(new TaskExecutionContext
            {
                EventSource = controller,
                EventArgs = new TaskEventArgs(_backOfficeRequestContext.Application.FrameworkContext,
                                              new PackageInstallEventArgs(nugetPackage.Id, package, state))
            });
        }
コード例 #8
0
        public ActionResult RunPackageActions(string id, PackageInstallationState state)
        {
            var nugetPackage = BackOfficeRequestContext.PackageContext.LocalPackageManager.SourceRepository.FindPackage(id);
            
            //Run the configuration tasks
            //get the package with the name and ensure it exists
            
            if (nugetPackage != null)
            {
                //get the package folder name, create the task execution context and then execute the package tasks using the utility class
                var packageFolderName = BackOfficeRequestContext.PackageContext.LocalPathResolver.GetPackageDirectory(nugetPackage);
                var taskExeContext = _packageInstallUtility.GetTaskExecutionContext(nugetPackage, packageFolderName, state, this);
                _packageInstallUtility.RunPostPackageInstallActions(state, taskExeContext, packageFolderName);    
            
                //re-issue authentication token incase any permissions have changed so that a re-login is not required.
                if (User.Identity is UmbracoBackOfficeIdentity)
                {
                    var userId = ((UmbracoBackOfficeIdentity)User.Identity).Id;
                    var user = BackOfficeRequestContext.Application.Security.Users.GetById(userId, true);
                    var userData = BackOfficeRequestContext.Application.FrameworkContext.TypeMappers.Map<UserData>(user);  
                    HttpContext.CreateUmbracoAuthTicket(userData);
                }

                switch (state)
                {
                    case PackageInstallationState.Installing:

                        Notifications.Add(new NotificationMessage(nugetPackage.Title + " has been installed", "Package installed", NotificationType.Success));
                        SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", nugetPackage.Id);

                        return RedirectToAction("Installed", new { id = nugetPackage.Id });
                    case PackageInstallationState.Uninstalling:

                        Notifications.Add(new NotificationMessage(nugetPackage.Title + " has been uninstalled", "Package uninstalled", NotificationType.Success));
                        SuccessfulOnRedirectAttribute.EnsureRouteData(this, "id", nugetPackage.Id);

                        return RedirectToAction("Uninstalled");
                }
            }

            //if the task did not redirect, then perform default redirects
            return RedirectToAction("LocalRepository");
        }
コード例 #9
0
 public ActionResult RecycleApplication(string id, PackageInstallationState state)
 {
     if (id == null) throw new ArgumentNullException("id");
     return View(new PackageInstallerStateModel {PackageId = id, State = state});
 }
コード例 #10
0
 public PackageInstallEventArgs(string nugetPackageId, PackageFolder packageFolder, PackageInstallationState state)
 {
     NugetPackageId = nugetPackageId;
     PackageFolder = packageFolder;
     State = state;
 }
コード例 #11
0
 public PackageInstallEventArgs(string nugetPackageId, PackageFolder packageFolder, PackageInstallationState state)
 {
     NugetPackageId = nugetPackageId;
     PackageFolder  = packageFolder;
     State          = state;
 }