protected override void DoExecute(CommandResultBase <string[]> result)
        {
            Assert.ArgumentNotNull(result, "result");

            var name = this.Name;

            Assert.ArgumentNotNullOrEmpty(name, "name");

            var product  = this.Module;
            var version  = this.Version;
            var revision = this.Revision;

            var profile    = Profile.Read();
            var repository = profile.LocalRepository;

            Assert.IsNotNullOrEmpty(repository, "Profile.LocalRepository is null or empty");
            Assert.IsTrue(Directory.Exists(repository), "Profile.LocalRepository points to non-existing folder");

            var license = profile.License;

            Assert.IsNotNullOrEmpty(license, "Profile.License is null or empty");
            Assert.IsTrue(File.Exists(license), "Profile.License points to non-existing file");

            var builder = profile.GetValidConnectionString();

            var instance = InstanceManager.GetInstance(name);

            Assert.IsNotNull(instance, "InstanceManager.GetInstance({0}) is null", name);

            ProductManager.Initialize(repository);

            var distributive = ProductManager.FindProduct(ProductType.Module, product, version, revision);

            if (distributive == null)
            {
                result.Success = false;
                result.Message = "product " + product + " not found";
                result.Data    = null;

                return;
            }

            PipelineManager.Initialize();

            var installArgs = new InstallModulesArgs(instance, new[] { distributive }, builder);
            var controller  = new AggregatePipelineController();

            PipelineManager.StartPipeline("installmodules", installArgs, controller, false);

            result.Success = !string.IsNullOrEmpty(controller.Message);
            result.Message = controller.Message;
            result.Data    = controller.GetMessages().ToArray();
        }
        protected override void DoExecute(CommandResult <string[]> result)
        {
            Assert.ArgumentNotNull(result, "result");

            var name = this.Name;

            Assert.ArgumentNotNullOrEmpty(name, "name");

            var product  = this.Module;
            var version  = this.Version;
            var revision = this.Revision;

            var profile    = Profile.Read();
            var repository = profile.LocalRepository;

            Ensure.IsNotNullOrEmpty(repository, "Profile.LocalRepository is not specified");
            Ensure.IsTrue(Directory.Exists(repository), "Profile.LocalRepository points to missing location");

            var license = profile.License;

            Ensure.IsNotNullOrEmpty(license, "Profile.License is not specified");
            Ensure.IsTrue(File.Exists(license), "Profile.License points to missing file");

            var builder = profile.GetValidConnectionString();

            var instance = InstanceManager.GetInstance(name);

            Ensure.IsNotNull(instance, "instance is not found", name);

            ProductManager.Initialize(repository);

            var distributive = ProductManager.FindProduct(ProductType.Module, product, version, revision);

            Ensure.IsNotNull(distributive, "product is not found");

            PipelineManager.Initialize(XmlDocumentEx.LoadXml(PipelinesConfig.Contents).DocumentElement);

            var installArgs = new InstallModulesArgs(instance, new[] { distributive }, builder);
            var controller  = new AggregatePipelineController();

            PipelineManager.StartPipeline("install", installArgs, controller, false);

            result.Success = !string.IsNullOrEmpty(controller.Message);
            result.Message = controller.Message;
            result.Data    = controller.GetMessages().ToArray();
        }
        public void OnClick(Window mainWindow, Instance instance)
        {
            if (!EnvironmentHelper.CheckSqlServer())
            {
                return;
            }

            if (instance == null)
            {
                return;
            }

            var path = Path.Combine(instance.WebRootPath, @"sitecore\admin\toolbox");

            if (!FileSystem.FileSystem.Local.Directory.Exists(path))
            {
                var product = Product.GetFilePackageProduct(Path.Combine(ApplicationManager.DefaultPackages, PackageName)) ?? Product.GetFilePackageProduct(Path.Combine(ApplicationManager.FilePackagesFolder, PackageName));
                if (product == null)
                {
                    WindowHelper.HandleError("The " + PackageName + " package cannot be found in either the .\\File Packages folder or %appdata%\\Sitecore\\Sitecore Instance Manager\\Custom Packages one", false, null, this);
                    return;
                }

                var products = new[] { product };
                var args     = new InstallModulesArgs(instance, products);
                PipelineManager.StartPipeline("installmodules", args, isAsync: false);
            }

            if (!FileSystem.FileSystem.Local.Directory.Exists(path))
            {
                return;
            }

            if (this.bypassSecurity)
            {
                InstanceHelperEx.OpenInBrowserAsAdmin(instance, mainWindow, @"/sitecore/admin");
            }
            else
            {
                InstanceHelperEx.BrowseInstance(instance, mainWindow, @"/sitecore/admin", false);
            }
        }