private string[] GetValidHostNames() { var hostName = HostNames; Assert.IsNotNull(hostName, "HostNames is null"); var hostNamesString = hostName.Text.EmptyToNull(); Assert.IsNotNull(hostNamesString, "Host names can not be empty"); var hostNames = hostNamesString.Split(new[] { '\r', '\n', ',', '|', ';' }, StringSplitOptions.RemoveEmptyEntries); Assert.IsTrue(hostNames.Any(), "Host names can not be empty"); foreach (var host in hostNames) { var hostExists = WebServerManager.HostBindingExists(host); Assert.IsTrue(!hostExists, $"Website with the host name '{host}' already exists"); } return(hostNames); }
private bool BindingUsing(string hostname) { return(WebServerManager.HostBindingExists(hostname)); }
public bool OnMovingNext(WizardArgs wizardArgs) { var productRevision = this.ProductRevision; Assert.IsNotNull(productRevision, "productRevision"); Product product = productRevision.SelectedValue as Product; Assert.IsNotNull(product, "product"); var instanceName = this.InstanceName; Assert.IsNotNull(instanceName, "instanceName"); string name = instanceName.Text.EmptyToNull(); Assert.IsNotNull(name, @"Instance name isn't set"); var hostName = this.HostName; Assert.IsNotNull(hostName, "hostName"); string host = hostName.Text.EmptyToNull(); Assert.IsNotNull(host, "Hostname must not be emoty"); var rootName = this.RootName; Assert.IsNotNull(rootName, "rootName"); string root = rootName.Text.EmptyToNull(); Assert.IsNotNull(rootName, "Root folder name must not be emoty"); string location = this.locationFolder.Text.EmptyToNull(); Assert.IsNotNull(location, @"The location folder isn't set"); string rootPath = Path.Combine(location, root); bool locationIsPhysical = FileSystem.FileSystem.Local.Directory.HasDriveLetter(rootPath); Assert.IsTrue(locationIsPhysical, "The location folder path must be physical i.e. contain a drive letter. Please choose another location folder"); string webRootPath = Path.Combine(rootPath, "Website"); bool websiteExists = WebServerManager.WebsiteExists(name); if (websiteExists) { using (var context = WebServerManager.CreateContext("InstanceDetails.OnMovingNext('{0}')".FormatWith(name))) { var site = context.Sites.Single(s => s != null && s.Name.EqualsIgnoreCase(name)); var path = WebServerManager.GetWebRootPath(site); if (FileSystem.FileSystem.Local.Directory.Exists(path)) { this.Alert("The website with the same name already exists, please choose another instance name."); return(false); } if ( WindowHelper.ShowMessage("There website with the same name already exists, but points to non-existing location. Would you like to delete it?", MessageBoxButton.OKCancel, MessageBoxImage.Asterisk) != MessageBoxResult.OK) { return(false); } site.Delete(); context.CommitChanges(); } } websiteExists = WebServerManager.WebsiteExists(name); Assert.IsTrue(!websiteExists, "The website with the same name already exists, please choose another instance name."); bool hostExists = WebServerManager.HostBindingExists(host); Assert.IsTrue(!hostExists, "Website with the same host name already exists"); bool rootFolderExists = FileSystem.FileSystem.Local.Directory.Exists(rootPath); if (rootFolderExists && InstanceManager.Instances != null) { if (InstanceManager.Instances.Any(i => i != null && i.WebRootPath.EqualsIgnoreCase(webRootPath))) { this.Alert("There is another instance with the same root path, please choose another folder"); return(false); } if (WindowHelper.ShowMessage("The folder with the same name already exists. Would you like to delete it?", MessageBoxButton.OKCancel, MessageBoxImage.Question, MessageBoxResult.OK) != MessageBoxResult.OK) { return(false); } FileSystem.FileSystem.Local.Directory.DeleteIfExists(rootPath); } var connectionString = ProfileManager.GetConnectionString(); SqlServerManager.Instance.ValidateConnectionString(connectionString); string licensePath = ProfileManager.Profile.License; Assert.IsNotNull(licensePath, @"The license file isn't set in the Settings window"); FileSystem.FileSystem.Local.File.AssertExists(licensePath, "The {0} file is missing".FormatWith(licensePath)); var netFramework = this.NetFramework; Assert.IsNotNull(netFramework, "netFramework"); var framework = netFramework.SelectedValue.ToString(); var frameworkArr = framework.Split(' '); Assert.IsTrue(frameworkArr.Length > 0, "impossible"); var force32Bit = frameworkArr.Length == 2; var mode = this.Mode; Assert.IsNotNull(mode, "mode"); var modeItem = (ListBoxItem)mode.SelectedValue; Assert.IsNotNull(modeItem, "modeItem"); var isClassic = ((string)modeItem.Content).EqualsIgnoreCase("Classic"); var args = (InstallWizardArgs)wizardArgs; args.InstanceName = name; args.InstanceHost = host; args.InstanceWebRootPath = webRootPath; args.InstanceRootName = root; args.InstanceRootPath = rootPath; args.InstanceProduct = product; args.InstanceConnectionString = connectionString; args.LicenseFileInfo = new FileInfo(licensePath); args.InstanceAppPoolInfo = new AppPoolInfo { FrameworkVersion = frameworkArr[0].EmptyToNull() ?? "v2.0", Enable32BitAppOnWin64 = force32Bit, ManagedPipelineMode = !isClassic }; args.Product = product; return(true); }