private void btnOk_Click(object sender, EventArgs e) { if (EditingStageArea && !Directory.Exists(tbStageArea.Text.Trim())) { if (MessageBox.Show("The Staging Area does not exist.\nDo you want to create the directory?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { try { Directory.CreateDirectory(tbStageArea.Text.Trim()); } catch (Exception ex) { MessageBox.Show(string.Format("There was an error when trying to create the directory.\n\n{0}", ex.ToString()), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbStageArea.Focus(); tbStageArea.SelectAll(); return; } } else { tbStageArea.Focus(); tbStageArea.SelectAll(); return; } } if (string.IsNullOrEmpty(tbWebserverName.Text.Trim())) { MessageBox.Show("Webserver Name can not be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbWebserverName.Focus(); return; } if (string.IsNullOrEmpty(tbVirtualDirectory.Text.Trim())) { MessageBox.Show("Main Virtual Directory can not be empty.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbVirtualDirectory.Focus(); return; } if (!Directory.Exists(tbVirtualDirectoryPath.Text.Trim())) { if (MessageBox.Show("The Virtual Directory does not exist. Do you want to create it?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.Yes) { try { Directory.CreateDirectory(tbVirtualDirectoryPath.Text.Trim()); } catch (Exception ex) { MessageBox.Show(string.Format("Unable to create the directory.\n\n{0}", ex.ToString()), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbVirtualDirectoryPath.Focus(); tbVirtualDirectory.SelectAll(); return; } } else { tbVirtualDirectoryPath.Focus(); tbVirtualDirectory.SelectAll(); return; } } // Check the virtual directory if (!CheckVirtualDirectory(tbVirtualDirectory.Text.Trim(), tbVirtualDirectoryPath.Text.Trim())) { return; } // Check internet guest account if (!AccessControlList.AccountExist(tbInternetGuestAccount.Text.Trim())) { MessageBox.Show("The Internet Guest Account is not an existing account.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); tbInternetGuestAccount.Focus(); return; } // Check if Internet Guest Account is changed if (InternetGuestAccount != tbInternetGuestAccount.Text.Trim()) { // Check if any products are published since the deploy manifest file // should have the internet guest account in the ACL. if (ProductList.AnyPublished()) { if (MessageBox.Show("There are one or more published products, and since the Internet Guest Account has\n" + "changed the published manifest files, for each published instance, needs to be updated\n" + "with the correct Internet Guest Account so that they will continue to function correctly.\n" + "\nDo you want to continue with the change?", "Question", MessageBoxButtons.YesNo, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1) == DialogResult.No) { return; } string errorText = string.Empty; foreach (ProductStandard product in ProductList) { try { product.Instances.UpdateRightsOnManifestFiles(product.InstallPath, tbInternetGuestAccount.Text.Trim(), InternetGuestAccount); } catch (Exception ex) { errorText += ex.Message + Environment.NewLine; } } if (!string.IsNullOrEmpty(errorText)) { MessageBox.Show(string.Format("One or more files couldn't have the ACL updated:\n" + "\n{0}\n" + "\nEither update the files manually or try to unpublish and publish the products again.", errorText), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } // All ok, save the values to the configuration if (EditingStageArea) { Config.SetStagingArea(tbStageArea.Text.Trim()); } Config.SetWebserverPort(tbWebserverPort.Text.Trim()); Config.SetWebserverName(tbWebserverName.Text.Trim()); Config.SetMainVirtualDirectoryName(tbVirtualDirectory.Text.Trim()); Config.SetMainVirtualDirectoryPath(tbVirtualDirectoryPath.Text.Trim()); Config.SetInternetGuestAccount(tbInternetGuestAccount.Text.Trim()); Config.SetCertificateFile(tbCertificateFile.Text.Trim()); Config.SetAskForCertificatePassword(cbAskForPassword.Checked); Config.Save(); DialogResult = DialogResult.OK; }