public ReinstallArgs(Instance instance, SqlConnectionStringBuilder connectionString, string license, string webServerIdentity, bool serverSideRedirect)
        {
            this.ConnectionString = connectionString;
              this.Name = instance.Name;
              this.Bindings = instance.Bindings;
              this.Product = instance.Product;
              this.WebRootPath = instance.WebRootPath;
              this.RootPath = instance.RootPath;
              this.DataFolderPath = instance.DataFolderPath;
              this.DatabasesFolderPath = Path.Combine(this.RootPath, "Databases");
              this.WebServerIdentity = webServerIdentity;
              this.LicenseFilePath = license;
              this.Modules = new Product[0];
              this.IsClassic = instance.IsClassic;
              this.Is32Bit = instance.Is32Bit;
              this.ForceNetFramework4 = instance.IsNetFramework4;
              this.ServerSideRedirect = serverSideRedirect;
              this.TempFolder = Path.Combine(this.RootPath, "Temp");
              this.InstanceDatabases = instance.AttachedDatabases;
              this.instanceName = instance.Name;
              this.StopInstance = instance.Stop;
              this.WebsiteID = instance.ID;

              var executionTimeout = UpdateWebConfigHelper.GetHttpRuntime(instance.GetWebResultConfig()).GetAttribute("executionTimeout");
              this.IncreaseExecutionTimeout = string.IsNullOrEmpty(executionTimeout) || executionTimeout != "600";
        }
        public InstallArgs([NotNull] string name, [NotNull] string host, [NotNull] Product product, [NotNull] string webRootPath, [NotNull] string dataFolderPath, [NotNull] string databasesFolderPath, [NotNull] SqlConnectionStringBuilder connectionString, [NotNull] string sqlServerIdentity, [NotNull] string webServerIdentity, [NotNull] FileInfo license, bool forceNetFramework4, bool is32Bit, bool isClassic, bool installRadControls, bool installDictionaries, bool serverSideRedirect, bool increaseExecutionTimeout, [NotNull] string rootPath, [NotNull] IEnumerable<Product> modules)
        {
            Assert.ArgumentNotNull(name, "name");
              Assert.ArgumentNotNull(host, "host");
              Assert.ArgumentNotNull(product, "product");
              Assert.ArgumentNotNull(webRootPath, "webRootPath");
              Assert.ArgumentNotNull(dataFolderPath, "dataFolderPath");
              Assert.ArgumentNotNull(databasesFolderPath, "databasesFolderPath");
              Assert.ArgumentNotNull(connectionString, "connectionString");
              Assert.ArgumentNotNull(sqlServerIdentity, "sqlServerIdentity");
              Assert.ArgumentNotNull(webServerIdentity, "webServerIdentity");
              Assert.ArgumentNotNull(license, "license");
              Assert.ArgumentNotNull(rootPath, "rootPath");
              Assert.ArgumentNotNull(modules, "modules");

              this.Name = name;
              this.Modules = modules;
              this.HostName = host;
              this.Product = product;
              this.ConnectionString = connectionString;
              this.DataFolderPath = dataFolderPath;
              this.DatabasesFolderPath = databasesFolderPath;
              this.WebRootPath = webRootPath;
              this.LicenseFilePath = license.FullName;
              this.SqlServerIdentity = sqlServerIdentity;
              this.WebServerIdentity = webServerIdentity;
              this.ForceNetFramework4 = forceNetFramework4;
              this.Is32Bit = is32Bit;
              this.IsClassic = isClassic;
              this.RootFolderPath = rootPath;
              this.InstallRadControls = installRadControls;
              this.InstallDictionaries = installDictionaries;
              this.ServerSideRedirect = serverSideRedirect;
              this.IncreaseExecutionTimeout = increaseExecutionTimeout;
        }
 public ReinstallArgs(Instance instance, SqlConnectionStringBuilder connectionString, string license, string webServerIdentity)
 {
   this.ConnectionString = connectionString;
   this.Name = instance.Name;
   this.Bindings = instance.Bindings;
   this.Product = instance.Product;
   this.WebRootPath = instance.WebRootPath;
   this.RootPath = instance.RootPath;
   this.DataFolderPath = instance.DataFolderPath;
   this.DatabasesFolderPath = Path.Combine(this.RootPath, "Databases");
   this.WebServerIdentity = webServerIdentity;
   this.LicenseFilePath = license;
   this.Modules = new Product[0];
   this.IsClassic = instance.IsClassic;
   this.Is32Bit = instance.Is32Bit;
   this.ForceNetFramework4 = instance.IsNetFramework4;
   this.TempFolder = Path.Combine(this.RootPath, "Temp");
   this.InstanceDatabases = instance.AttachedDatabases;
   this.instanceName = instance.Name;
   this.StopInstance = instance.Stop;
   this.WebsiteID = instance.ID;
 }
        private void Append(string folder, Product product)
        {
            var ver = product.Version;
              IEnumerable<string> files = FileSystem.FileSystem.Local.Directory.GetFiles(folder, "*.zip", SearchOption.AllDirectories).Where(f => !f.ContainsIgnoreCase("- Sitecore") || (f.ContainsIgnoreCase("- Sitecore " + ver) || (f.ContainsIgnoreCase("- Sitecore " + ver.Substring(0, 3) + " ") || f.ContainsIgnoreCase("- Sitecore " + ver[0] + " "))));

              var productsToAdd = files.Select(f => new ProductInCheckbox(Product.GetFilePackageProduct(f))).ToList();
              foreach (ProductInCheckbox productInCheckbox in productsToAdd)
              {
            this.checkBoxItems.Add(productInCheckbox);
              }
        }
        private static void ProcessActions(Instance instance, SqlConnectionStringBuilder connectionString, 
      IPipelineController controller, Product module, Dictionary<string, string> variables, 
      XmlElement actionsElement)
        {
            // made replacement
              actionsElement.InnerXml = variables.Aggregate(actionsElement.InnerXml,
            (result, variable) => result.Replace(variable.Key, variable.Value)).Replace("{InstanceName}", instance.Name);

              var actions = actionsElement.ChildNodes.OfType<XmlElement>();
              var webRootPath = instance.WebRootPath;
              List<string> ignoreCommands = new List<string>();
              foreach (XmlElement action in actions.Where(a => a.Name.EqualsIgnoreCase("patch")))
              {
            var commandText = action.GetAttribute("command").EmptyToNull().IsNotNull("The command attribute of <patch /> element must exist and must not be empty");
            var actionText = action.GetAttribute("action");
            if (actionText == "delete")
            {
              ignoreCommands.Add(commandText);
            }
              }

              // give extract more priority
              if (actions.Any(xml => xml.Name.EqualsIgnoreCase("extract")) && !ignoreCommands.Contains("extract"))
              {
            FileSystem.FileSystem.Local.Zip.UnpackZip(module.PackagePath, instance.WebRootPath);
              }

              foreach (XmlElement action in actions)
              {
            var children = action.ChildNodes.OfType<XmlElement>();
            string actionName = action.Name;
            if (ignoreCommands.Contains(actionName))
            {
              continue;
            }

            switch (actionName)
            {
              case "extract":
              {
            // give extract more priority
            // FileSystem.Instance.UnpackZip(module.PackagePath, instance.GetRootPath(webRootPath));
            break;
              }

              case "config":
              {
            string configPath = action.GetAttribute("path");
            try
            {
              XmlDocumentEx config = !string.IsNullOrEmpty(configPath)
                ? XmlDocumentEx.LoadFile(Path.Combine(webRootPath, configPath))
                : instance.GetWebConfig(webRootPath);
              PerformConfigChanges(instance, children, module, config, variables);
            }
            catch (XmlDocumentEx.FileIsMissingException ex)
            {
              Log.Warn(
                "The path attribute is specified (path: {0}) but the file doesn't exist".FormatWith(configPath),
                typeof(ConfigurationActions), ex);
            }

            break;
              }

              case "databases":
              {
            AddDatabase(instance, children, module, connectionString, controller);
            break;
              }

              case "editfile":
              {
            EditFile(action.GetAttribute("path"), children, instance, variables);
            break;
              }

              case "setRestrictingPlaceholders":
              {
            InstanceHelper.StartInstance(instance);
            SetRestrictingPlaceholders(action.GetAttribute("names"), GetWebServiceUrl(instance));
            break;
              }

              case "custom":
              {
            var typeName = action.GetAttribute("type").EmptyToNull().IsNotNull("The type attribute is missing in the <custom> install action");
            var obj = (IPackageInstallActions)ReflectionUtil.CreateObject(typeName);
            obj.Execute(instance, module);
            break;
              }

              case "sql":
              {
            var db = action.GetAttribute("database");
            var file = action.GetAttribute("file").Replace("$(data)", instance.DataFolderPath).Replace("$(website)", instance.WebRootPath);
            if (!string.IsNullOrEmpty(file))
            {
              Assert.IsTrue(File.Exists(file), string.Format("The {0} file does not exist", file));
            }

            var sql = string.IsNullOrEmpty(file) ? action.InnerText : FileSystem.FileSystem.Local.File.ReadAllText(file);
            Assert.IsNotNullOrEmpty(sql.Trim(), "The SQL command is empty");

            var cstr = instance.Configuration.ConnectionStrings.FirstOrDefault(x => x.Name == db);
            Assert.IsNotNull(cstr, "The {0} connection string is not found".FormatWith(db));
            using (var conn = SqlServerManager.Instance.OpenConnection(new SqlConnectionStringBuilder(cstr.Value), false))
            {
              foreach (var command in sql.Split("GO"))
              {
                SqlServerManager.Instance.Execute(conn, command);
              }
            }

            break;
              }
            }
              }
        }
 private static void ExtractDatabase(Product module, string fileName, string sourceFileName, string databasesFolder, string locationInPackage)
 {
     var packagePath = module.PackagePath;
       if (!string.IsNullOrEmpty(locationInPackage))
       {
     using (var tmp = FileSystem.FileSystem.Local.Directory.GetTempFolder())
     {
       var tmpPath = tmp.Path;
       ExtractDatabase(packagePath, fileName, sourceFileName, databasesFolder, locationInPackage, tmpPath);
     }
       }
       else
       {
     ExtractDatabase(packagePath, fileName, sourceFileName, databasesFolder, null, null);
       }
 }
 private void SelectAddedPackage(ProductInCheckbox family, Product product)
 {
     family.IsChecked = true;
       family.Value = product;
 }
 private static Product GetProduct(ProductInCheckbox module, Product product)
 {
     return module.Scope.FirstOrDefault(version => version.Version.Equals(product.Version, StringComparison.InvariantCultureIgnoreCase) && version.Revision.Equals(product.Revision, StringComparison.InvariantCultureIgnoreCase));
 }
 private bool CheckProduct(Product product)
 {
     return (product.Name.EqualsIgnoreCase(this.name) || product.OriginalName.EqualsIgnoreCase(this.name))
      && product.Version == this.version
      && product.Revision == this.revision;
 }
 private bool CheckAnalyticsProduct(Product product)
 {
     return product.Name.Equals("Sitecore Analytics")
      && product.Revision == this.revision;
 }
 public ProductInCheckbox(string name, Product[] products)
 {
   this.name = name;
   this.products = products;
   this.Value = products.First();
 }
 public ProductInCheckbox(Product value)
 {
   this.Value = value;
   this.products = null;
 }
 public void Execute(Instance instance, Product module)
 {
     InstallCleanupHelper.DoInstanceCleanup(instance.RootPath);
 }