Hi Team,
I am generating setup for window service.
I want to give option to user to mention all config level data on UI at the time of setup installation.
By referring no of sites I am able to achieve that expected output, but there are some moification.
I am able to show label and text box and bind that value by referring some below link.
Customize User Interfaces and Pass User Input to Installer Classes[
^]
ScottGu's Blog - Tip/Trick: Creating Packaged ASP.NET Setup Programs with VS 2005[
^]
Expection is:
1)I want to do validation means user will be not able to click on next button by keeping empty text box.
2)Now user mentioning data into text box normally, instead of that I want to give browse button to select path and fill text box.
What I have tried:
This is code that I am using for showing and binding text box value.
[RunInstaller(true)]
public partial class ProjectInstaller : System.Configuration.Install.Installer
{
public ProjectInstaller()
{
InitializeComponent();
}
public override void Install(System.Collections.IDictionary stateSaver)
{
base.Install(stateSaver);
}
public override void Commit(IDictionary savedState)
{
base.Commit(savedState);
try
{
AddConfigurationFileDetails();
}
catch (Exception e)
{
base.Rollback(savedState);
}
}
private void showParameters()
{
StringBuilder sb = new StringBuilder();
StringDictionary myStringDictionary = this.Context.Parameters;
if (this.Context.Parameters.Count > 0)
{
foreach (string myString in this.Context.Parameters.Keys)
{
sb.AppendFormat("String={0} Value= {1}\n", myString,
this.Context.Parameters[myString]);
}
}
}
private void AddConfigurationFileDetails()
{
try
{
string LogFilePath = Context.Parameters["LogFilePath"];
string Customer_Input_Filepath = Context.Parameters["Customer_InputFilePath"];
string ServerPublicKeyPath = Context.Parameters["ServerPublicKeyPath"];
string ClientPrivateKeyPath = Context.Parameters["ClientPrivateKeyPath"];
string ClientPrivateKeyPassword = Context.Parameters["ClientPrivateKeyPassword"];
string SFTP_IN_PATH = Context.Parameters["SFTP_IN_PATH"];
string SFTP_OUT_PATH = Context.Parameters["SFTP_OUT_PATH"];
string HostName = Context.Parameters["HostName"];
string PortNo = Context.Parameters["PortNo"];
string UserName = Context.Parameters["UserName"];
string CertificateKeyFilePath = Context.Parameters["CertificateKeyFilePath"];
string PassPhrase = Context.Parameters["PassPhrase"];
string assemblypath = Context.Parameters["assemblypath"];
string appConfigPath = assemblypath + ".config";
XmlDocument doc = new XmlDocument();
doc.Load(appConfigPath);
XmlNode configuration = null;
foreach (XmlNode node in doc.ChildNodes)
if (node.Name == "configuration")
configuration = node;
if (configuration != null)
{
XmlNode settingNode = null;
foreach (XmlNode node in configuration.ChildNodes)
{
if (node.Name == "appSettings")
settingNode = node;
}
if (settingNode != null)
{
foreach (XmlNode node in settingNode.ChildNodes)
{
if (node.Attributes == null)
continue;
XmlAttribute attribute = node.Attributes["value"];
if (node.Attributes["key"] != null)
{
switch (node.Attributes["key"].Value)
{
case "Test":
attribute.Value = Convert.ToString(LogFilePath.Replace("\\", @"\"));
break;
case "LogFilePath":
attribute.Value = Convert.ToString(LogFilePath.Replace("\\", @"\"));
break;
case "Customer_InputFilePath":
attribute.Value = Convert.ToString(Customer_Input_Filepath.Replace("\\", @"\"));
break;
case "ServerPublicKeyPath":
attribute.Value = ServerPublicKeyPath;
break;
case "ClientPrivateKeyPath":
attribute.Value = ClientPrivateKeyPath;
break;
case "ClientPrivateKeyPassword":
attribute.Value = ClientPrivateKeyPassword;
break;
case "SFTP_IN_PATH":
attribute.Value = SFTP_IN_PATH;
break;
case "SFTP_OUT_PATH":
attribute.Value = SFTP_OUT_PATH;
break;
case "HostName":
attribute.Value = HostName;
break;
case "PortNo":
attribute.Value = PortNo;
break;
case "UserName":
attribute.Value = UserName;
break;
case "CertificateKeyFilePath":
attribute.Value = CertificateKeyFilePath;
break;
case "PassPhrase":
attribute.Value = PassPhrase;
break;
}
}
}
}
if (!string.IsNullOrEmpty(CertificateKeyFilePath))
{
doc.Save(appConfigPath);
}
else
{
}
}
}
catch
{
throw;
}
}
}
Please give me solution for validation and browse button
Please reply as soon as possible.
Please give me solution for validation and browse button
Please reply as soon as possible.