/// <summary> /// Store the deployment location as a node in the given XML document /// </summary> /// <param name="config">The XML document</param> /// <param name="root">The node in which to store the element</param> /// <param name="id">The id of the element to create</param> /// <returns>Returns the node that was added or the one that /// already existed in the document.</returns> /// <remarks>The deployment location is stored in an element called /// <b>deploymentLocation</b> with two attributes (<b>id</b> matching /// the specified id and <b>location</b>) and nested /// <b>userCredentials</b> and <b>proxyCredentials</b> elements. It /// is created if it does not already exist.</remarks> public XmlNode ToXml(XmlDocument config, XmlNode root, string id) { XmlNode node; XmlAttribute attr; if (root == null) { throw new ArgumentNullException("root"); } node = root.SelectSingleNode("deploymentLocation[@id='" + id + "']"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "deploymentLocation", null); root.AppendChild(node); attr = config.CreateAttribute("id"); attr.Value = id; node.Attributes.Append(attr); attr = config.CreateAttribute("location"); node.Attributes.Append(attr); } node.Attributes["location"].Value = (location == null) ? String.Empty : location.OriginalString; userCreds.ToXml(config, node); proxyCreds.ToXml(config, node); return(node); }
/// <summary> /// Store the credentials as a node in the given XML document /// </summary> /// <param name="config">The XML document</param> /// <param name="root">The node in which to store the element</param> /// <returns>Returns the node that was added or the one that /// already existed in the document.</returns> /// <remarks>The credentials are stored in an element called /// <b>proxyCredentials</b> with two attributes (<b>useProxy</b> and /// <b>proxyServer</b>) and a nested <b>userCredentials</b> element. /// It is created if it does not already exist.</remarks> public XmlNode ToXml(XmlDocument config, XmlNode root) { XmlNode node; XmlAttribute attr; if (root == null) { throw new ArgumentNullException("root"); } node = root.SelectSingleNode("proxyCredentials"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "proxyCredentials", null); root.AppendChild(node); attr = config.CreateAttribute("useProxy"); node.Attributes.Append(attr); attr = config.CreateAttribute("proxyServer"); node.Attributes.Append(attr); } node.Attributes["useProxy"].Value = useProxyServer.ToString().ToLower( CultureInfo.InvariantCulture); node.Attributes["proxyServer"].Value = (proxyServer == null) ? String.Empty : proxyServer.OriginalString; credentials.ToXml(config, node); return(node); }
/// <summary> /// Validate the configuration and save it /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnOK_Click(object sender, EventArgs e) { XmlAttribute attr; XmlNode root, node; UserCredentials credentials; bool isValid = true; txtSmtpServer.Text = txtSmtpServer.Text.Trim(); txtUserName.Text = txtUserName.Text.Trim(); txtPassword.Text = txtPassword.Text.Trim(); txtSuccessEMailAddress.Text = txtSuccessEMailAddress.Text.Trim(); txtFailureEMailAddress.Text = txtFailureEMailAddress.Text.Trim(); txtXSLTransform.Text = txtXSLTransform.Text.Trim(); epErrors.Clear(); if(!chkUseDefaultCredentials.Checked) { if(txtUserName.Text.Length == 0) { epErrors.SetError(txtUserName, "A user name is " + "required if not using default credentials"); isValid = false; } if(txtPassword.Text.Length == 0) { epErrors.SetError(txtPassword, "A password is " + "required if not using default credentials"); isValid = false; } } if(txtFailureEMailAddress.Text.Length == 0) { epErrors.SetError(txtFailureEMailAddress, "A failure " + "e-mail address is required"); isValid = false; } if(!isValid) return; // Store the changes root = config.SelectSingleNode("configuration"); node = root.SelectSingleNode("smtpServer"); if(node == null) { node = config.CreateNode(XmlNodeType.Element, "smtpServer", null); root.AppendChild(node); attr = config.CreateAttribute("host"); node.Attributes.Append(attr); attr = config.CreateAttribute("port"); node.Attributes.Append(attr); } node.Attributes["host"].Value = txtSmtpServer.Text; node.Attributes["port"].Value = udcSmtpPort.Value.ToString( CultureInfo.InvariantCulture); credentials = new UserCredentials(chkUseDefaultCredentials.Checked, txtUserName.Text, txtPassword.Text); credentials.ToXml(config, root); node = root.SelectSingleNode("fromEMail"); if(node == null) { node = config.CreateNode(XmlNodeType.Element, "fromEMail", null); root.AppendChild(node); attr = config.CreateAttribute("address"); node.Attributes.Append(attr); } node.Attributes["address"].Value = txtFromEMail.Text; node = root.SelectSingleNode("successEMail"); if(node == null) { node = config.CreateNode(XmlNodeType.Element, "successEMail", null); root.AppendChild(node); attr = config.CreateAttribute("address"); node.Attributes.Append(attr); attr = config.CreateAttribute("attachLog"); node.Attributes.Append(attr); } node.Attributes["address"].Value = txtSuccessEMailAddress.Text; node.Attributes["attachLog"].Value = chkAttachLogFileOnSuccess.Checked.ToString().ToLower( CultureInfo.InvariantCulture); node = root.SelectSingleNode("failureEMail"); if(node == null) { node = config.CreateNode(XmlNodeType.Element, "failureEMail", null); root.AppendChild(node); attr = config.CreateAttribute("address"); node.Attributes.Append(attr); attr = config.CreateAttribute("attachLog"); node.Attributes.Append(attr); } node.Attributes["address"].Value = txtFailureEMailAddress.Text; node.Attributes["attachLog"].Value = chkAttachLogFileOnFailure.Checked.ToString().ToLower( CultureInfo.InvariantCulture); node = root.SelectSingleNode("xslTransform"); if(node == null) { node = config.CreateNode(XmlNodeType.Element, "xslTransform", null); root.AppendChild(node); attr = config.CreateAttribute("filename"); node.Attributes.Append(attr); } node.Attributes["filename"].Value = txtXSLTransform.Text; this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// Validate the configuration and save it /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnOK_Click(object sender, EventArgs e) { XmlAttribute attr; XmlNode root, node; UserCredentials credentials; bool isValid = true; txtSmtpServer.Text = txtSmtpServer.Text.Trim(); txtUserName.Text = txtUserName.Text.Trim(); txtPassword.Text = txtPassword.Text.Trim(); txtSuccessEMailAddress.Text = txtSuccessEMailAddress.Text.Trim(); txtFailureEMailAddress.Text = txtFailureEMailAddress.Text.Trim(); txtXSLTransform.Text = txtXSLTransform.Text.Trim(); epErrors.Clear(); if (!chkUseDefaultCredentials.Checked) { if (txtUserName.Text.Length == 0) { epErrors.SetError(txtUserName, "A user name is required if not using default credentials"); isValid = false; } if (txtPassword.Text.Length == 0) { epErrors.SetError(txtPassword, "A password is required if not using default credentials"); isValid = false; } } if (txtFailureEMailAddress.Text.Length == 0) { epErrors.SetError(txtFailureEMailAddress, "A failure e-mail address is required"); isValid = false; } if (!isValid) { return; } // Store the changes root = config.SelectSingleNode("configuration"); node = root.SelectSingleNode("smtpServer"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "smtpServer", null); root.AppendChild(node); attr = config.CreateAttribute("host"); node.Attributes.Append(attr); attr = config.CreateAttribute("port"); node.Attributes.Append(attr); } node.Attributes["host"].Value = txtSmtpServer.Text; node.Attributes["port"].Value = udcSmtpPort.Value.ToString(CultureInfo.InvariantCulture); credentials = new UserCredentials(chkUseDefaultCredentials.Checked, txtUserName.Text, txtPassword.Text); credentials.ToXml(config, root); node = root.SelectSingleNode("fromEMail"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "fromEMail", null); root.AppendChild(node); attr = config.CreateAttribute("address"); node.Attributes.Append(attr); } node.Attributes["address"].Value = txtFromEMail.Text; node = root.SelectSingleNode("successEMail"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "successEMail", null); root.AppendChild(node); attr = config.CreateAttribute("address"); node.Attributes.Append(attr); attr = config.CreateAttribute("attachLog"); node.Attributes.Append(attr); } node.Attributes["address"].Value = txtSuccessEMailAddress.Text; node.Attributes["attachLog"].Value = chkAttachLogFileOnSuccess.Checked.ToString().ToLowerInvariant(); node = root.SelectSingleNode("failureEMail"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "failureEMail", null); root.AppendChild(node); attr = config.CreateAttribute("address"); node.Attributes.Append(attr); attr = config.CreateAttribute("attachLog"); node.Attributes.Append(attr); } node.Attributes["address"].Value = txtFailureEMailAddress.Text; node.Attributes["attachLog"].Value = chkAttachLogFileOnFailure.Checked.ToString().ToLowerInvariant(); node = root.SelectSingleNode("xslTransform"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "xslTransform", null); root.AppendChild(node); attr = config.CreateAttribute("filename"); node.Attributes.Append(attr); } node.Attributes["filename"].Value = txtXSLTransform.Text; this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// Validate the configuration and save it /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnOK_Click(object sender, EventArgs e) { XmlAttribute attr; XmlNode root, node; UserCredentials userCreds; ProxyCredentials proxyCreds; bool isValid = true; Uri ajaxDoc = null, proxyServer = null; txtAjaxDocUrl.Text = txtAjaxDocUrl.Text.Trim(); txtProjectName.Text = txtProjectName.Text.Trim(); txtUserName.Text = txtUserName.Text.Trim(); txtPassword.Text = txtPassword.Text.Trim(); txtProxyServer.Text = txtProxyServer.Text.Trim(); txtProxyUserName.Text = txtProxyUserName.Text.Trim(); txtProxyPassword.Text = txtProxyPassword.Text.Trim(); epErrors.Clear(); if(txtAjaxDocUrl.Text.Length == 0) { epErrors.SetError(txtAjaxDocUrl, "An AjaxDoc URL is required"); isValid = false; } else if(!Uri.TryCreate(txtAjaxDocUrl.Text, UriKind.RelativeOrAbsolute, out ajaxDoc)) { epErrors.SetError(txtAjaxDocUrl, "The AjaxDoc URL does not appear to be valid"); isValid = false; } if(txtProjectName.Text.Length == 0) { epErrors.SetError(txtProjectName, "A project filename is required"); isValid = false; } if(!chkUseDefaultCredentials.Checked) { if(txtUserName.Text.Length == 0) { epErrors.SetError(txtUserName, "A user name is required if not using default credentials"); isValid = false; } if(txtPassword.Text.Length == 0) { epErrors.SetError(txtPassword, "A password is required if not using default credentials"); isValid = false; } } Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute, out proxyServer); if(chkUseProxyServer.Checked) { if(txtProxyServer.Text.Length == 0) { epErrors.SetError(txtProxyServer, "A proxy server is required if one is used"); isValid = false; } else if(proxyServer == null) { epErrors.SetError(txtProxyServer, "The proxy server name does not appear to be valid"); isValid = false; } if(!chkUseProxyDefCreds.Checked) { if(txtProxyUserName.Text.Length == 0) { epErrors.SetError(txtProxyUserName, "A user name is required if not using " + "default credentials"); isValid = false; } if(txtProxyPassword.Text.Length == 0) { epErrors.SetError(txtProxyPassword, "A password is required if not using default " + "credentials"); isValid = false; } } } if(!isValid) return; if(txtAjaxDocUrl.Text[txtAjaxDocUrl.Text.Length - 1] != '/') txtAjaxDocUrl.Text += "/"; // Store the changes root = config.SelectSingleNode("configuration"); node = root.SelectSingleNode("ajaxDoc"); if(node == null) { node = config.CreateNode(XmlNodeType.Element, "ajaxDoc", null); root.AppendChild(node); attr = config.CreateAttribute("url"); node.Attributes.Append(attr); attr = config.CreateAttribute("project"); node.Attributes.Append(attr); attr = config.CreateAttribute("regenerate"); node.Attributes.Append(attr); } node.Attributes["url"].Value = txtAjaxDocUrl.Text; node.Attributes["project"].Value = txtProjectName.Text; node.Attributes["regenerate"].Value = chkRegenerateFiles.Checked.ToString().ToLowerInvariant(); userCreds = new UserCredentials(chkUseDefaultCredentials.Checked, txtUserName.Text, txtPassword.Text); userCreds.ToXml(config, root); proxyCreds = new ProxyCredentials(chkUseProxyServer.Checked, proxyServer, new UserCredentials(chkUseProxyDefCreds.Checked, txtProxyUserName.Text, txtProxyPassword.Text)); proxyCreds.ToXml(config, root); this.DialogResult = DialogResult.OK; this.Close(); }
/// <summary> /// Validate the configuration and save it /// </summary> /// <param name="sender">The sender of the event</param> /// <param name="e">The event arguments</param> private void btnOK_Click(object sender, EventArgs e) { XmlAttribute attr; XmlNode root, node; UserCredentials userCreds; ProxyCredentials proxyCreds; bool isValid = true; Uri ajaxDoc = null, proxyServer = null; txtAjaxDocUrl.Text = txtAjaxDocUrl.Text.Trim(); txtProjectName.Text = txtProjectName.Text.Trim(); txtUserName.Text = txtUserName.Text.Trim(); txtPassword.Text = txtPassword.Text.Trim(); txtProxyServer.Text = txtProxyServer.Text.Trim(); txtProxyUserName.Text = txtProxyUserName.Text.Trim(); txtProxyPassword.Text = txtProxyPassword.Text.Trim(); epErrors.Clear(); if (txtAjaxDocUrl.Text.Length == 0) { epErrors.SetError(txtAjaxDocUrl, "An AjaxDoc URL is required"); isValid = false; } else if (!Uri.TryCreate(txtAjaxDocUrl.Text, UriKind.RelativeOrAbsolute, out ajaxDoc)) { epErrors.SetError(txtAjaxDocUrl, "The AjaxDoc URL does " + "not appear to be valid"); isValid = false; } if (txtProjectName.Text.Length == 0) { epErrors.SetError(txtProjectName, "A project filename " + "is required"); isValid = false; } if (!chkUseDefaultCredentials.Checked) { if (txtUserName.Text.Length == 0) { epErrors.SetError(txtUserName, "A user name is " + "required if not using default credentials"); isValid = false; } if (txtPassword.Text.Length == 0) { epErrors.SetError(txtPassword, "A password is " + "required if not using default credentials"); isValid = false; } } Uri.TryCreate(txtProxyServer.Text, UriKind.RelativeOrAbsolute, out proxyServer); if (chkUseProxyServer.Checked) { if (txtProxyServer.Text.Length == 0) { epErrors.SetError(txtProxyServer, "A proxy server is " + "required if one is used"); isValid = false; } else if (proxyServer == null) { epErrors.SetError(txtProxyServer, "The proxy server " + "name does not appear to be valid"); isValid = false; } if (!chkUseProxyDefCreds.Checked) { if (txtProxyUserName.Text.Length == 0) { epErrors.SetError(txtProxyUserName, "A user name is " + "required if not using default credentials"); isValid = false; } if (txtProxyPassword.Text.Length == 0) { epErrors.SetError(txtProxyPassword, "A password is " + "required if not using default credentials"); isValid = false; } } } if (!isValid) { return; } if (txtAjaxDocUrl.Text[txtAjaxDocUrl.Text.Length - 1] != '/') { txtAjaxDocUrl.Text += "/"; } // Store the changes root = config.SelectSingleNode("configuration"); node = root.SelectSingleNode("ajaxDoc"); if (node == null) { node = config.CreateNode(XmlNodeType.Element, "ajaxDoc", null); root.AppendChild(node); attr = config.CreateAttribute("url"); node.Attributes.Append(attr); attr = config.CreateAttribute("project"); node.Attributes.Append(attr); attr = config.CreateAttribute("regenerate"); node.Attributes.Append(attr); } node.Attributes["url"].Value = txtAjaxDocUrl.Text; node.Attributes["project"].Value = txtProjectName.Text; node.Attributes["regenerate"].Value = chkRegenerateFiles.Checked.ToString().ToLower( CultureInfo.InvariantCulture); userCreds = new UserCredentials(chkUseDefaultCredentials.Checked, txtUserName.Text, txtPassword.Text); userCreds.ToXml(config, root); proxyCreds = new ProxyCredentials(chkUseProxyServer.Checked, proxyServer, new UserCredentials(chkUseProxyDefCreds.Checked, txtProxyUserName.Text, txtProxyPassword.Text)); proxyCreds.ToXml(config, root); this.DialogResult = DialogResult.OK; this.Close(); }