public override void Install(System.Collections.IDictionary stateSaver)
{
try
{
FileInfo myFileInfo=new FileInfo(this.Context.Parameters["targetdir"]+@"/Web.config");
if (!myFileInfo.Exists)
{
throw new InstallException("No find the web.config");
}
XmlDocument myXmlDocument=new XmlDocument();
myXmlDocument.Load(myFileInfo.FullName);
//search the appSetting Node
bool FoundIt;
FoundIt=false;
foreach (XmlNode myNode in myXmlDocument["configuration"]["appSettings"])
{
if (myNode.Name=="add")
{
if (myNode.Attributes.GetNamedItem("key").Value=="ConnectionString")
{
myNode.Attributes.GetNamedItem("value").Value=String.Format("server={0};database={1};uid={2};pwd={3}",this.Context.Parameters["server"],this.Context.Parameters["dbname"],this.Context.Parameters["user"],this.Context.Parameters["pwd"]);
FoundIt=true;
}
}
}
if(FoundIt==false)
{
throw new InstallException("web.Config not inculding ConnectionString");
}
myXmlDocument.Save(myFileInfo.FullName);
}
catch(Exception ex)
{
throw ex;
}
}