站點: 如果新建默認的Web安裝項目,那它將創建的默認網站下的一個虛擬應用程序目錄而不是一個新的站點。故我們只有創建新的安裝項目,而不是Web安裝項目。然后通過安裝類進行自定義操作,創建新站如下圖:
![]()
2、創建新的安項目之后,在(文件系統編輯器)里的應用程序文件夾里,添加ASP.net2.0的項目輸出(還有第二種方法是用ASP.NET2.0發布網站到一個文件夾下面,再把這個文件夾下面所有文件復制粘貼過來,這樣生成的安裝文件,在安裝之后就沒有源代碼文件了,我自己就是這樣做的)如下圖:
圖1下圖的MyPojectSetup項目下已有了Web項目的輸出,以及一個SQL腳本(SQL腳本是通SQL2005生成的,將在安裝類庫里要使用的)
![]()
圖2文件系統左邊界面,添加了Web項目輸出
![]()
2.2添加完項目輸出之后,需要設置安裝界面。我們的要求是第一、建一個新站點,所以需要所安裝的IIS服務器地址,以及新站點的端口。第二、需要數據庫的地址,新建的數據庫名稱,以及訪問數據庫的用戶名和密碼兩項(需要有創庫權限的)。
如圖1在文件系統編輯器右邊,選擇用戶界面,然后看到如下:
![]()
在啟動選擇單擊右擊菜單,添加對話框A,并在對話框A上單擊右鍵=》上移到安裝文件夾的上面:
![]()
再次設置右邊屬性,文本框A是站點信息輸入如下信息,其中Edit1Property是一個需要傳入安裝類的參數。
![]()
按照以上方式再添加文本框B并移到文本框A的下面,如下圖所示
![]()
注意:如上所示安裝項目基本的事情已經做完了,但還有最后一個步驟沒有做,那就是自定義操作,也就安裝的重中之重的事情,安裝類庫的創建,如3點所示。創建安裝類庫之后就需要把它的輸出來添加到安裝項目里如同Web項目,然后設置自定義活動為這個項目就可以,詳情在下面介紹。
3、需要創建一個安裝類庫,里面把Class1.cs刪除,再添加一個新的安裝文件。安裝項目所有的自定義都是在這里用編碼完成的(包括數據庫生成,虛擬站點創建,IIS屬性修改,Web.Config文件修改)。也就是說,安裝項目是個外殼,通過創建一些界面接收用戶參數,然后利用這個安裝類庫,提供的功能,進行自己的操作。
![]()
?
![]()
4、安裝程序類新建之后,雙擊進入代碼狀態,用override重載Install函數如下所示:
?
using?System;
using?System.Collections.Generic;
using?System.ComponentModel;
using?System.Configuration.Install;
![]()
namespace?MyProjectInstall
![]()
...{
????[RunInstaller(true)]
????public?partial?class?InstallerMySample?:?Installer
![]()
????...{
????????public?InstallerMySample()
![]()
????????...{
????????????InitializeComponent();
????????}
![]()
????????public?override?void?Install(System.Collections.IDictionary?stateSaver)
![]()
????????...{
![]()
????????}
????}
}
?
安裝數據庫的代碼如下,其中用了兩種方法,一種是用SQL命令方式創建數據庫,另一種是調用osql命令執行腳本,創建數據表結構等,最后用命令追加一條記錄.
?
![]()
?????數據庫操作#region?數據庫操作
![]()
????????protected?void?AddDBTable()
![]()
????????...{
????????????try
![]()
????????????...{
????????????????//創建數據庫
????????????????ExcuteSQL("master",?string.Format("CREATE?DATABASE?{0}",?this._dataBaseName));
![]()
????????????????//調用osql執行腳本
????????????????ExcuteScript();
![]()
????????????????//添加原始數據
????????????????ExcuteSQL(_dataBaseName,?"INSERT?INTO?GV_SystemAdmin(SystemAdminUser,SystemAdminPass,SystemAdminName,SystemAdminMemo)?VALUES?('admin',?'admin',?'Administrator'?,'系統默認超級用戶')");
????????????}
????????????catch?(Exception?ex)
![]()
????????????...{
????????????????throw?new?ApplicationException(ex.Message);
????????????}
????????}
![]()
????????//此方法在本例中未用到,因為最后只要追加一條記錄,
????????//但如果有多條可以寫成一個腳本,以資源的形式嵌入到這個項目
????????//然后用如下的方法讀取,然后調用SQL命令執行
????????private?string?GetSQLScript(string?fileName)
![]()
????????...{
????????????try
![]()
????????????...{
????????????????//得到當前程序集
????????????????Assembly?asm?=?Assembly.GetExecutingAssembly();
????????????????//資源文件
????????????????Stream?strm?=
????????????????????asm.GetManifestResourceStream(asm.GetName().Name?+?"."?+?fileName);
????????????????//讀取嵌入文件內容,文本文件內容必須為Unicode
????????????????StreamReader?reader?=?new?StreamReader(strm);
![]()
????????????????return?reader.ReadToEnd();
????????????}
????????????catch
![]()
????????????...{
????????????????return?String.Empty;
????????????}
????????}
![]()
????????private?void?ExcuteSQL(string?dataBaseName,?string?SQL)
![]()
????????...{
????????????SqlConnection?con?=
????????????????new?SqlConnection(string.Format("user?id={0};password={1};Initial?Catalog={2};Data?Source={3};",?_username,?_saPassword,?dataBaseName,?_servername));
????????????SqlCommand?cmd?=?new?SqlCommand(SQL,?con);
????????????cmd.Connection.Open();
????????????cmd.Connection.ChangeDatabase(dataBaseName);
![]()
????????????try
![]()
????????????...{
????????????????cmd.ExecuteNonQuery();
????????????}
????????????finally
![]()
????????????...{
????????????????//最后總要關閉數據庫
????????????????cmd.Connection.Close();
????????????}
????????}?????
![]()
????????private?void?ExcuteScript()
![]()
????????...{
????????????try
![]()
????????????...{
????????????????Process?sqlProcess?=?new?Process();
????????????????//調用osql必須在目標機,也就是安裝的機子上要有安裝SQLServer服務器
????????????????//不然找不到這個命令
????????????????sqlProcess.StartInfo.FileName?=?"osql.exe";
????????????????//如下所指的SQL腳本文件是打包打安裝項目的文件名,
????????????????//targetPath就是在安裝界面用戶指定的安裝目錄
????????????????sqlProcess.StartInfo.Arguments?=?string.Format("-U?{0}?-P{1}?-d?{2}?-S?{3}?-i?{4}VideoMeetingCreateSQL2000.sql",
????????????????????_username,?_saPassword,?_dataBaseName,?_servername,?_targetPath);
????????????????sqlProcess.StartInfo.WindowStyle?=?ProcessWindowStyle.Hidden;
????????????????sqlProcess.Start();
????????????????sqlProcess.WaitForExit();
????????????????sqlProcess.Close();
????????????}
????????????catch?(Exception?ex)
![]()
????????????...{
????????????????throw?ex;
????????????}
????????}
????????#endregion
?修改Web.Config配置的代碼如下:
![]()
?WriteWebConfig?修改web.config的連接數據庫的字符串#region?WriteWebConfig?修改web.config的連接數據庫的字符串
????????private?bool?WriteWebConfig()
![]()
????????...{
????????????System.IO.FileInfo?FileInfo?=?new?System.IO.FileInfo(this.Context.Parameters["targetdir"]?+?"/web.config");
????????????if?(!FileInfo.Exists)
![]()
????????????...{
????????????????throw?new?InstallException("Missing?config?file?:"?+?this.Context.Parameters["targetdir"]?+?"/web.config");
????????????}
????????????System.Xml.XmlDocument?xmlDocument?=?new?System.Xml.XmlDocument();
????????????xmlDocument.Load(FileInfo.FullName);
????????????bool?FoundIt?=?false;
????????????foreach?(System.Xml.XmlNode?Node?in?xmlDocument["configuration"]["connectionStrings"])
![]()
????????????...{
????????????????if?(Node.Name?==?"add")
![]()
????????????????...{
????????????????????if?(Node.Attributes.GetNamedItem("name").Value?==?"MonitorConnectionString")
![]()
????????????????????...{
????????????????????????Node.Attributes.GetNamedItem("connectionString").Value?=?String.Format("Data?Source={0};database={1};User?ID={2};Password={3}",?_servername,?_dataBaseName,?_username,?_saPassword);
????????????????????????FoundIt?=?true;
????????????????????}
????????????????}
????????????}
????????????if?(!FoundIt)
![]()
????????????...{
????????????????throw?new?InstallException("Error?when?writing?the?config?file:?web.config");
????????????}
????????????xmlDocument.Save(FileInfo.FullName);
????????????return?FoundIt;
????????}
????????#endregion
創建IIS站點的代碼如下(注我也是從網找到的,其中CreateNewWebsit這個方法中我加了IIS參數設置的代碼,也就是在創建IIS時一并設置了):
注意這一句:string fileName = Environment.GetEnvironmentVariable("windir") + @"/Microsoft.NET/Framework/v2.0.50727/ASPnet_regiis.exe";原因是當你不管是手動還是自動創建一個新站點,在它的屬性頁ASP.NET設置里都會有1.1版和2.0版這個選項,默認是1.1,現在我要部署2.0所以在默認情況下就不能夠一步到位,安裝完就可以訪問執行,而要去設置成2.0才行.所以要調用FrameworkV2.0下的regiis.exe得新注冊一下我們指定的虛擬目錄,使它是2.0.?
using?System;
using?System.DirectoryServices;
using?System.Collections;
using?System.Text.RegularExpressions;
using?System.Text;
using?System.Runtime;
using?System.Diagnostics;
![]()
/**//**
?*?@author?吳海燕
?*?@email??wuhy80-usual@yahoo.com
?*?2004-6-25?第一版
?*/
![]()
namespace?Wuhy.ToolBox
![]()
...{
![]()
????/**////?<summary>
????///??這個類是靜態類。用來實現管理IIS的基本操作。
????///??管理IIS有兩種方式,一是ADSI,一是WMI。由于系統限制的原因,只好選擇使用ADSI實現功能。
????///??這是一個遺憾。只有等到只有使用IIS?6的時候,才有可能使用WMI來管理系統
????///??不過有一個問題就是,我現在也覺得這樣的一個方法在本地執行會比較的好。最好不要遠程執行。
????///??因為那樣需要占用相當數量的帶寬,即使要遠程執行,也是推薦在同一個網段里面執行
????///?</summary>
????public?class?IISAdminLib
![]()
????...{
![]()
????????UserName,Password,HostName的定義#region?UserName,Password,HostName的定義
????????public?static?string?HostName
![]()
????????...{
????????????get
![]()
????????????...{
????????????????return?hostName;
????????????}
????????????set
![]()
????????????...{
????????????????hostName?=?value;
????????????}
????????}
![]()
????????public?static?string?UserName
![]()
????????...{
????????????get
![]()
????????????...{
????????????????return?userName;
????????????}
????????????set
![]()
????????????...{
????????????????userName?=?value;
????????????}
????????}
????????public?static?string?Password
![]()
????????...{
????????????get
![]()
????????????...{
????????????????return?password;
????????????}
????????????set
![]()
????????????...{
????????????????if?(UserName.Length?<=?1)
![]()
????????????????...{
????????????????????throw?new?ArgumentException("還沒有指定好用戶名。請先指定用戶名");
????????????????}
????????????????password?=?value;
????????????}
????????}
![]()
????????public?static?void?RemoteConfig(string?hostName,?string?userName,?string?password)
![]()
????????...{
????????????HostName?=?hostName;
????????????UserName?=?userName;
????????????Password?=?password;
????????}
????????private?static?string?hostName?=?"localhost";
????????private?static?string?userName;
????????private?static?string?password;
????????#endregion
![]()
![]()
????????根據路徑構造Entry的方法#region?根據路徑構造Entry的方法
![]()
????????/**////?<summary>
????????///??根據是否有用戶名來判斷是否是遠程服務器。
????????///??然后再構造出不同的DirectoryEntry出來
????????///?</summary>
????????///?<param?name="entPath">DirectoryEntry的路徑</param>
????????///?<returns>返回的是DirectoryEntry實例</returns>
????????public?static?DirectoryEntry?GetDirectoryEntry(string?entPath)
![]()
????????...{
????????????DirectoryEntry?ent;
????????????if?(UserName?==?null)
![]()
????????????...{
????????????????ent?=?new?DirectoryEntry(entPath);
????????????}
????????????else
![]()
????????????...{
????????????????//????ent?=?new?DirectoryEntry(entPath,?HostName+"/"+UserName,?Password,?AuthenticationTypes.Secure);
????????????????ent?=?new?DirectoryEntry(entPath,?UserName,?Password,?AuthenticationTypes.Secure);
????????????}
????????????return?ent;
????????}
????????#endregion
![]()
![]()
????????添加,刪除網站的方法#region?添加,刪除網站的方法
![]()
????????/**////?<summary>
????????///??創建一個新的網站。根據傳過來的信息進行配置
????????///?</summary>
????????///?<param?name="siteInfo">存儲的是新網站的信息</param>
????????public?static?void?CreateNewWebSite(NewWebSiteInfo?siteInfo)
![]()
????????...{
????????????if?(!EnsureNewSiteEnavaible(siteInfo.BindString))
![]()
????????????...{
????????????????throw?new?Exception("已經有了這樣的網站了。"?+?Environment.NewLine?+?siteInfo.BindString);
????????????}
????????????string?entPath?=?String.Format("IIS://{0}/w3svc",?HostName);
????????????DirectoryEntry?rootEntry?=?GetDirectoryEntry(entPath);
![]()
????????????string?newSiteNum?=?GetNewWebSiteID();
????????????DirectoryEntry?newSiteEntry?=?rootEntry.Children.Add(newSiteNum,?"IIsWebServer");
????????????newSiteEntry.CommitChanges();
![]()
????????????//Hashtable?ahs1?=?new?Hashtable();
????????????//foreach?(string?a1?in?newSiteEntry.Properties.PropertyNames)
????????????//{
????????????//????ahs1.Add(a1,?newSiteEntry.Properties[a1].Value);
????????????//}
![]()
????????????newSiteEntry.Properties["ServerBindings"].Value?=?siteInfo.BindString;
????????????newSiteEntry.Properties["ServerComment"].Value?=?siteInfo.CommentOfWebSite;
????????????newSiteEntry.CommitChanges();
????????????DirectoryEntry?vdEntry?=?newSiteEntry.Children.Add("root",?"IIsWebVirtualDir");
????????????vdEntry.CommitChanges();
????????????vdEntry.Properties["Path"].Value?=?siteInfo.WebPath;
![]()
????????????vdEntry.Invoke("AppCreate",?true);//創建應用程序
![]()
????????????vdEntry.Properties["AccessRead"][0]?=?true;?//設置讀取權限
????????????vdEntry.Properties["DefaultDoc"][0]?=?"default.htm";//設置默認文檔
????????????vdEntry.Properties["AppFriendlyName"][0]?=?"VideoMeeting";?//應用程序名稱
????????????vdEntry.Properties["AccessScript"][0]?=?true;//執行權限
????????????vdEntry.Properties["AuthFlags"][0]?=?1;//0表示不允許匿名訪問,1表示就可以3為基本身份驗證,7為windows繼承身份驗證
![]()
????????????//Hashtable?ahs?=?new?Hashtable();
????????????//ArrayList?list?=?new?ArrayList();
![]()
????????????//foreach?(string?a?in?vdEntry.Properties.PropertyNames)
????????????//{
????????????//????list.Add(a);
????????????//????ahs.Add(a,?vdEntry.Properties[a].Value);
????????????//}
![]()
????????????vdEntry.CommitChanges();
![]()
???????????
![]()
????????????//啟動ASPnet_iis.exe程序?
????????????string?fileName?=?Environment.GetEnvironmentVariable("windir")?+?@"Microsoft.NETFrameworkv2.0.50727ASPnet_regiis.exe";
????????????ProcessStartInfo?startInfo?=?new?ProcessStartInfo(fileName);
????????????//處理目錄路徑?
????????????string?path?=?vdEntry.Path.ToUpper();
????????????int?index?=?path.IndexOf("W3SVC");
????????????path?=?path.Remove(0,?index);
????????????//啟動ASPnet_iis.exe程序,刷新教本映射?
????????????startInfo.Arguments?=?"-s?"?+?path;
????????????startInfo.WindowStyle?=?ProcessWindowStyle.Hidden;
????????????startInfo.UseShellExecute?=?false;
????????????startInfo.CreateNoWindow?=?true;
????????????startInfo.RedirectStandardOutput?=?true;
????????????startInfo.RedirectStandardError?=?true;
????????????Process?process?=?new?Process();
????????????process.StartInfo?=?startInfo;
????????????process.Start();
????????????process.WaitForExit();
????????????string?errors?=?process.StandardError.ReadToEnd();
????????????if?(errors?!=?string.Empty)
![]()
????????????...{
????????????????throw?new?Exception(errors);
????????????}
![]()
????????}
![]()
![]()
????????/**////?<summary>
????????///??刪除一個網站。根據網站名稱刪除。
????????///?</summary>
????????///?<param?name="siteName">網站名稱</param>
????????public?static?void?DeleteWebSiteByName(string?siteName)
![]()
????????...{
????????????string?siteNum?=?GetWebSiteNum(siteName);
????????????string?siteEntPath?=?String.Format("IIS://{0}/w3svc/{1}",?HostName,?siteNum);
????????????DirectoryEntry?siteEntry?=?GetDirectoryEntry(siteEntPath);
![]()
????????????string?rootPath?=?String.Format("IIS://{0}/w3svc",?HostName);
????????????DirectoryEntry?rootEntry?=?GetDirectoryEntry(rootPath);
????????????rootEntry.Children.Remove(siteEntry);
????????????rootEntry.CommitChanges();
????????}
????????#endregion
![]()
![]()
![]()
![]()
????????Start和Stop網站的方法#region?Start和Stop網站的方法
????????public?static?void?StartWebSite(string?siteName)
![]()
????????...{
????????????string?siteNum?=?GetWebSiteNum(siteName);
????????????string?siteEntPath?=?String.Format("IIS://{0}/w3svc/{1}",?HostName,?siteNum);
????????????DirectoryEntry?siteEntry?=?GetDirectoryEntry(siteEntPath);
![]()
????????????siteEntry.Invoke("Start",?new?object[]?...{?});
????????}
????????
????????public?static?void?StopWebSite(string?siteName)
![]()
????????...{
????????????string?siteNum?=?GetWebSiteNum(siteName);
????????????string?siteEntPath?=?String.Format("IIS://{0}/w3svc/{1}",?HostName,?siteNum);
????????????DirectoryEntry?siteEntry?=?GetDirectoryEntry(siteEntPath);
![]()
????????????siteEntry.Invoke("Stop",?new?object[]?...{?});
????????}
????????#endregion
????????
![]()
????????確認網站是否相同#region?確認網站是否相同
![]()
????????/**////?<summary>
????????///??確定一個新的網站與現有的網站沒有相同的。
????????///??這樣防止將非法的數據存放到IIS里面去
????????///?</summary>
????????///?<param?name="bindStr">網站邦定信息</param>
????????///?<returns>真為可以創建,假為不可以創建</returns>
????????public?static?bool?EnsureNewSiteEnavaible(string?bindStr)
![]()
????????...{
????????????string?entPath?=?String.Format("IIS://{0}/w3svc",?HostName);
????????????DirectoryEntry?ent?=?GetDirectoryEntry(entPath);
![]()
????????????foreach?(DirectoryEntry?child?in?ent.Children)
![]()
????????????...{
????????????????if?(child.SchemaClassName?==?"IIsWebServer")
![]()
????????????????...{
????????????????????if?(child.Properties["ServerBindings"].Value?!=?null)
![]()
????????????????????...{
????????????????????????if?(child.Properties["ServerBindings"].Value.ToString()?==?bindStr)
![]()
????????????????????????...{
????????????????????????????return?false;
????????????????????????}
????????????????????}
????????????????}
????????????}
????????????return?true;
????????}
????????#endregion
![]()
![]()
????????獲取一個網站編號的方法#region?獲取一個網站編號的方法
![]()
????????/**////?<summary>
????????///??獲取一個網站的編號。根據網站的ServerBindings或者ServerComment來確定網站編號
????????///?</summary>
????????///?<param?name="siteName"></param>
????????///?<returns>返回網站的編號</returns>
????????///?<exception?cref="NotFoundWebSiteException">表示沒有找到網站</exception>
????????public?static?string?GetWebSiteNum(string?siteName)
![]()
????????...{
????????????Regex?regex?=?new?Regex(siteName);
????????????string?tmpStr;
![]()
????????????string?entPath?=?String.Format("IIS://{0}/w3svc",?HostName);
????????????DirectoryEntry?ent?=?GetDirectoryEntry(entPath);
![]()
????????????foreach?(DirectoryEntry?child?in?ent.Children)
![]()
????????????...{
????????????????if?(child.SchemaClassName?==?"IIsWebServer")
![]()
????????????????...{
????????????????????if?(child.Properties["ServerBindings"].Value?!=?null)
![]()
????????????????????...{
????????????????????????tmpStr?=?child.Properties["ServerBindings"].Value.ToString();
????????????????????????if?(regex.Match(tmpStr).Success)
![]()
????????????????????????...{
????????????????????????????return?child.Name;
????????????????????????}
????????????????????}
????????????????????if?(child.Properties["ServerComment"].Value?!=?null)
![]()
????????????????????...{
????????????????????????tmpStr?=?child.Properties["ServerComment"].Value.ToString();
????????????????????????if?(regex.Match(tmpStr).Success)
![]()
????????????????????????...{
????????????????????????????return?child.Name;
????????????????????????}
????????????????????}
????????????????}
????????????}
![]()
????????????throw?new?Exception("沒有找到我們想要的站點"?+?siteName);
????????}
????????#endregion????????
![]()
![]()
????????獲取新網站id的方法#region?獲取新網站id的方法
![]()
![]()
????????/**////?<summary>
????????///??獲取網站系統里面可以使用的最小的ID。
????????///??這是因為每個網站都需要有一個唯一的編號,而且這個編號越小越好。
????????///??這里面的算法經過了測試是沒有問題的。
????????///?</summary>
????????///?<returns>最小的id</returns>
????????public?static?string?GetNewWebSiteID()
![]()
????????...{
????????????ArrayList?list?=?new?ArrayList();
????????????string?tmpStr;
????????????string?entPath?=?String.Format("IIS://{0}/w3svc",?HostName);
????????????DirectoryEntry?ent?=?GetDirectoryEntry(entPath);
![]()
????????????foreach?(DirectoryEntry?child?in?ent.Children)
![]()
????????????...{
????????????????if?(child.SchemaClassName?==?"IIsWebServer")
![]()
????????????????...{
????????????????????tmpStr?=?child.Name.ToString();
????????????????????list.Add(Convert.ToInt32(tmpStr));
????????????????}
????????????}
????????????list.Sort();
????????????int?i?=?1;
????????????foreach?(int?j?in?list)
![]()
????????????...{
????????????????if?(i?==?j)
![]()
????????????????...{
????????????????????i++;
????????????????}
????????????}
????????????return?i.ToString();
????????}
????????#endregion
????}
????
![]()
????新網站信息結構體#region?新網站信息結構體
![]()
????public?struct?NewWebSiteInfo
![]()
????...{
????????private?string?hostIP;???//?The?Hosts?IP?Address
????????private?string?portNum;???//?The?New?Web?Sites?Port.generally?is?"80"
????????private?string?descOfWebSite;?//?網站表示。一般為網站的網站名。例如"www.dns.com.cn"
????????private?string?commentOfWebSite;//?網站注釋。一般也為網站的網站名。
????????private?string?webPath;???//?網站的主目錄。例如"e: mp"
![]()
????????public?NewWebSiteInfo(string?hostIP,?string?portNum,?string?descOfWebSite,?string?commentOfWebSite,?string?webPath)
![]()
????????...{
????????????this.hostIP?=?hostIP;
????????????this.portNum?=?portNum;
????????????this.descOfWebSite?=?descOfWebSite;
????????????this.commentOfWebSite?=?commentOfWebSite;
????????????this.webPath?=?webPath;
????????}
![]()
????????public?string?BindString
![]()
????????...{
????????????get
![]()
????????????...{
????????????????return?String.Format("{0}:{1}:{2}",?hostIP,?portNum,?descOfWebSite);
????????????}
????????}
![]()
????????public?string?CommentOfWebSite
![]()
????????...{
????????????get
![]()
????????????...{
????????????????return?commentOfWebSite;
????????????}
????????}
![]()
????????public?string?WebPath
![]()
????????...{
????????????get
![]()
????????????...{
????????????????return?webPath;
????????????}
????????}
????}
????#endregion
}
?
最后重載的InStall函數如:
?
????public?override?void?Install(IDictionary?stateSaver)
![]()
????????...{
????????????//數據庫安裝程序入口
????????????_saPassword?=?this.Context.Parameters["pwd"];
????????????_dataBaseName?=?this.Context.Parameters["dbname"];
????????????_targetPath?=?this.Context.Parameters["targetdir"];
????????????_servername?=?this.Context.Parameters["server"];
????????????_username?=?this.Context.Parameters["user"];
![]()
????????????iis?=?this.Context.Parameters["iis"];
????????????port?=?this.Context.Parameters["port"];
????????????//添加數據庫
????????????AddDBTable();
![]()
????????????//注冊新站點????????????
????????????Wuhy.ToolBox.NewWebSiteInfo?siteInfo?=?new?Wuhy.ToolBox.NewWebSiteInfo(string.Empty,?port,?"",?"VideoMeeting",?_targetPath);
????????????Wuhy.ToolBox.IISAdminLib.HostName?=?iis;
????????????Wuhy.ToolBox.IISAdminLib.UserName?=?null;???????
![]()
????????????Wuhy.ToolBox.IISAdminLib.CreateNewWebSite(siteInfo);
![]()
????????????Wuhy.ToolBox.IISAdminLib.StartWebSite(siteInfo.BindString);
????????????
????????????//修改Web.Config文件
????????????if?(!WriteWebConfig())
![]()
????????????...{
????????????????throw?new?ApplicationException("設置數據庫連接字符串時出現錯誤");
????????????}
????????}
?