求助installsheld打包ASP.NET
请问谁会使用Installsheld打包ASP.NET(将asp.net程序和SQL数据库打包一起),谢谢:
本人邮件为:fangjingbo111@hotmail.com
问题点数:20、回复次数:5Top
1 楼yc_zhj()回复于 2005-04-01 16:03:09 得分 20
为什么一定要用Installsheld打包ASP.NET,直接用vs2003自带的工具不是更好吗?
protected override void Dispose( bool disposing )
{
if( disposing )
{
if(components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}
#region 组件设计器生成的代码
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
components = new System.ComponentModel.Container();
}
#endregion
private void InstallDateBase()
{
SqlConnection sqlConnection1 = new SqlConnection();
string DBName = this.Context.Parameters["DataBaseName"];
string DBServer = this.Context.Parameters["ServerName"];
string DBUser = this.Context.Parameters["InStallAdmin"];
string DBKey = this.Context.Parameters["InstallPassword"];
string dir=this.Context.Parameters["dir"];
create_install_log("安装参数取的成功");
string CONSTR = "data source=" + DBServer +";database=master;uid=" + DBUser +";password=" + DBKey;
sqlConnection1.ConnectionString = CONSTR;
string MSQL = "RESTORE DATABASE " + DBName +
" FROM DISK = '" + dir + @"\database\OA_DATA.BAK' " ;
SqlCommand cmd = new SqlCommand(MSQL,sqlConnection1);
cmd.Connection.Open();
cmd.ExecuteNonQuery();
cmd.Connection.Close();
if(sqlConnection1.State == ConnectionState.Open)
{
sqlConnection1.Close();
}
create_install_log("数据库创建成功");
// 修改web.config
string web_dir=dir + @"\web.config";
System.IO.FileInfo fileinfo=new FileInfo(web_dir);
if (fileinfo.Exists==false)
{
throw new InstallException("没有找到配置文件");
}
else
{
create_install_log("配置文件查找成功");
}
System.Xml.XmlDocument xm = new System.Xml.XmlDocument();
xm.Load(fileinfo.FullName);
System.Xml.XmlNodeList xnl=xm.SelectSingleNode("/configuration/appSettings").ChildNodes ;
foreach (System.Xml.XmlNode node in xnl )
{
System.Xml.XmlElement xe=(XmlElement)node;
if (xe.GetAttribute("key").IndexOf("strConnection")!=-1)
{
xe.SetAttribute("value","server="+DBServer+ " ;uid=" + DBUser +" ;password=" + DBKey+" ;database="+DBName);
xm.Save(web_dir);
create_install_log("配置文件修改成功");
break;
}
}
//安装sql脚本
string execsql;
execsql="/U "+DBUser+" /P "+DBKey+" /d "+DBName+ " /i "+ dir + @"database\SQLServerAgent_job.sql";
System.Diagnostics.Process sqlprocess=new System.Diagnostics.Process ();
sqlprocess.StartInfo.FileName="osql.exe ";
sqlprocess.StartInfo.Arguments=execsql;
try
{
sqlprocess.Start();
sqlprocess.WaitForExit();
sqlprocess.Close() ;
this.create_install_log("脚本安装成功");
System.IO.FileInfo fl=new FileInfo(dir + @"database\SQLServerAgent_job.sql");
if (fl.Exists)
{
fl.Delete();
}
}
catch
{
throw new InstallException("安装脚本失败,请检查SQLServerAgent是否运行");
}
//安装TreeView
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo();
psi.WorkingDirectory = dir+"\\database";
psi.FileName = dir + @"\database\iewebcontrols.msi ";
psi.UseShellExecute=true; //msi文件,如是exe不用设
System.Diagnostics.Process.Start(psi);
}
public override void Install(IDictionary stateSaver)
{
try
{
base.Install (stateSaver);
this.InstallDateBase();
}
catch
{
throw;
}
}
public override void Uninstall(IDictionary savedState)
{
base.Uninstall (savedState);
}
public override void Commit(IDictionary savedState)
{
base.Commit (savedState);
}
public override void Rollback(IDictionary savedState)
{
base.Rollback (savedState);
}
private void create_install_log(string message)
{
StreamWriter ss=new StreamWriter(@"c:\OA软件安装日志.txt",true);
ss.WriteLine(System.DateTime.Now.ToString()+":"+message);
ss.Close();
}
}
}
Top
2 楼eqh(我想早恋,可已经晚了...)回复于 2005-04-01 16:39:42 得分 0
学习Top
3 楼ip928(赵晓骏)回复于 2005-04-01 17:09:26 得分 0
学习Top
4 楼w_lion(狮子)回复于 2005-04-03 16:58:03 得分 0
markTop
5 楼fangbo111(方波)回复于 2005-04-06 09:41:03 得分 0
谁可以告诉我,哪位高手可以告诉我本人有急用,摆脱了,我这两天就用,否则过期就没分了Top




