/////////////////////////////////////////////////////////////////////////////
//
// File Name: Setup.rul
//
// Description: InstallShield script of Create WebSite and Restore DataBase
//
// Comments: 創建WEB站點,還原數據庫
//
//
/////////////////////////////////////////////////////////////////////////////
// Include header files /////////////////////////////////////////////////////
#include "ifx.h"
////////////////////// string defines ////////////////////////////
//////////////////// installation declarations ///////////////////
// In order to have your InstallScript function executed as a custom
// action by the Windows Installer, it must be prototyped as an
// entry-point function.
// The keyword export identifies MyFunction() as an entry-point function.
// The argument it accepts must be a handle to the Installer database.
/* export prototype MyFunction(HWND); */
export prototype RestoreDataBase();
// To Do: Declare global variables, define constants, and prototype user-
// defined and DLL functions here.
// ----- DLL function prototypes -----
// your DLL function prototypes
prototype NUMBER DBInstall.OpenForm();
// ---- script function prototypes -----
// your script function prototypes
prototype CreateWebSite(STRING,STRING); // 創建 IIS 站點
// your global variables
BOOL IsSelectedWebApp;
BOOL IsSelectedCreateWebSite;
BOOL IsSelectedDataBase;
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnFirstUIBefore
//
// EVENT: FirstUIBefore event is sent when installation is run for the first
// time on given machine. In the handler installation usually displays
// UI allowing end user to specify installation parameters. After this
// function returns, ComponentTransferData is called to perform file
// transfer.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIBefore()
NUMBER nResult, nSetupType, nvSize, nUser;
STRING szTitle, szMsg, szQuestion, svName, svCompany, szFile, svResult;
STRING szLicenseFile;
STRING szServerIP, szServerPort, svServerIP, svServerPort;
LIST list, listStartCopy;
BOOL bCustom;
HWND hInstall;
begin
// TO DO: if you want to enable background, window title, and caption bar title
// SetTitle( @PRODUCT_NAME, 24, WHITE );
SetTitle( @PRODUCT_NAME, 0, BACKGROUNDCAPTION );
// Enable( FULLWINDOWMODE );
// Enable( BACKGROUND );
// SetColor(BACKGROUND,RGB (0, 128, 128));
SHELL_OBJECT_FOLDER = @PRODUCT_NAME;
nSetupType = TYPICAL;
Dlg_SdWelcome:
szTitle = "歡迎使用";
szMsg = @PROJECTLONGNAME+"信息管理平臺";
nResult = SdWelcome(szTitle, szMsg);
if (nResult = BACK) goto Dlg_SdWelcome;
szTitle = "用戶信息";
svName = "";
svCompany = "";
Dlg_SdCustomerInformation:
nResult = SdCustomerInformation(szTitle, svName, svCompany, nUser);
if (nResult = BACK) goto Dlg_SdWelcome;
Dlg_SetupType:
szTitle = "安裝類型";
szMsg = "";
nResult = SetupType(szTitle, szMsg, "", nSetupType, 0);
if (nResult = BACK) then
goto Dlg_SdCustomerInformation;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
nvSize = 0;
FeatureCompareSizeRequired(MEDIA, INSTALLDIR, nvSize);
if (nvSize != 0) then
MessageBox(szSdStr_NotEnoughSpace, WARNING);
goto Dlg_SetupType;
endif;
bCustom = FALSE;
goto Dlg_SdStartCopy;
else
bCustom = TRUE;
endif;
endif;
Dlg_SdAskDestPath:
nResult = SdAskDestPath(szTitle, szMsg, INSTALLDIR, 0);
if (nResult = BACK) goto Dlg_SetupType;
Dlg_SdFeatureTree:
szTitle = "";
szMsg = "";
if (nSetupType = CUSTOM) then
nResult = SdFeatureTree(szTitle, szMsg, INSTALLDIR, "", 2);
if (nResult = BACK) goto Dlg_SdAskDestPath;
// Get IsSelectedWebApp
FeatureGetData (MEDIA, "WebApp", FEATURE_FIELD_SELECTED, IsSelectedWebApp, svResult);
// Get IsSelectedDataBase
FeatureGetData (MEDIA, "DataBase", FEATURE_FIELD_SELECTED, IsSelectedDataBase, svResult);
// Get IsSelectedCreateWebSite
FeatureGetData (MEDIA, "CreateWebSite", FEATURE_FIELD_SELECTED, IsSelectedCreateWebSite, svResult);
endif;
Dlg_SdStartCopy:
szTitle = "確認信息";
szMsg = "請確認一下信息是否正確";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string(svName) to a list(listStartCopy).
//eg. ListAddString(listStartCopy,svName,AFTER);
ListAddString(listStartCopy,"用戶姓名:"+svName,AFTER);
ListAddString(listStartCopy,"公司名稱:"+svCompany,AFTER);
ListAddString(listStartCopy,"安裝目錄:"+INSTALLDIR,AFTER);
ListAddString(listStartCopy,"安裝:",AFTER);
if (IsSelectedWebApp) then
FeatureGetData (MEDIA, "WebApp", FEATURE_FIELD_DISPLAYNAME, nResult, svResult);
ListAddString(listStartCopy,"/t"+svResult,AFTER);
endif;
if (IsSelectedDataBase) then
FeatureGetData (MEDIA, "DataBase", FEATURE_FIELD_DISPLAYNAME, nResult, svResult);
ListAddString(listStartCopy,"/t"+svResult,AFTER);
endif;
if (IsSelectedCreateWebSite) then
FeatureGetData (MEDIA, "CreateWebSite", FEATURE_FIELD_DISPLAYNAME, nResult, svResult);
ListAddString(listStartCopy,"/t"+svResult+szServerIP+svServerIP+"/t"+szServerPort+svServerPort,AFTER);
endif;
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
ListDestroy(listStartCopy);
if (nResult = BACK) then
if (!bCustom) then
goto Dlg_SetupType;
else
goto Dlg_SdFeatureTree;
endif;
endif;
Dlg_AskText ://設置數據庫服務器 對話框
if(IsSelectedCreateWebSite) then
szTitle = "設置IIS信息站點信息";
szMsg = "現在開始設置IIS系統";
szQuestion=" 請輸入本服務器的IP地址,安裝程序將按照您提供的資料設置IIS信息服務。";
szServerIP="地址:";
szServerPort="端口:";
svServerIP="127.0.0.1";
svServerPort="100";
SetDialogTitle(DLG_ASK_TEXT,szTitle);
nResult=SdShowDlgEdit2 (szTitle, szQuestion,szServerIP,szServerPort,svServerIP,svServerPort);
if (nResult = BACK) then
if (!bCustom) then
goto Dlg_SetupType;
else
goto Dlg_SdFeatureTree;
endif;
endif;
endif;
// setup default status
SetStatusWindow(0, "正在複製文件...");
Enable(STATUSEX);
StatusUpdate(ON, 100);
if (IsSelectedCreateWebSite) then
CreateWebSite(svServerIP,svServerPort); // 開始創建 IIS 站點
endif;
if (IsSelectedDataBase) then
RestoreDataBase();
endif;
return 0;
end;
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnFirstUIAfter
//
// EVENT: FirstUIAfter event is sent after file transfer, when installation
// is run for the first time on given machine. In this event handler
// installation usually displays UI that will inform end user that
// installation has been completed successfully.
//
///////////////////////////////////////////////////////////////////////////////
function OnFirstUIAfter()
STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
NUMBER bOpt1, bOpt2;
begin
Disable(STATUSEX);
bOpt1 = FALSE;
bOpt2 = FALSE;
szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);
SdFinishEx(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
end;
//////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnBegin
//
// EVENT: Begin event is always sent as the first event during installation.
//
//////////////////////////////////////////////////////////////////////////////
function OnBegin()
begin
IsSelectedWebApp=TRUE;
IsSelectedCreateWebSite=TRUE;
IsSelectedDataBase=TRUE;
end;
//////////////////////////
// 創建IIS站點
//////////////////////////
function CreateWebSite(szServerIPDefault,szServerPortDefault)
STRING szCmdLine,szWaitTxt;
begin
if ((szServerIPDefault = "") || (szServerPortDefault = "")) then
MessageBox ("您沒有設定"+@PRODUCT_NAME+"運行的服務器IP地址或端口!!IIS信息服務設置失敗!/n請自行創建IIS站點,並將主目錄設爲:"+INSTALLDIR,SEVERE);
else
szWaitTxt="正在創建IIS和設置站點....";
SdShowMsg (szWaitTxt, TRUE);
Delay(2);
szCmdLine = SUPPORTDIR^"mkw3site.vbs"+" -r "+INSTALLDIR+" -i "+szServerIPDefault+" -o "+szServerPortDefault+" -t "+@PRODUCT_NAME;
if (LaunchAppAndWait("WScript.exe", szCmdLine,WAIT) < 0) then
MessageBox ("不能建立WEB 虛擬目錄,沒有找到 WScript.exe 或執行腳本錯誤.",SEVERE);
endif;
SdShowMsg (szWaitTxt, FALSE);
endif;
return 0;
end;
/*
/////////////////////////////////////////////////////////////////////////////////
FUNCTION: RestoreDataBase
PURPOSE: Calls a function to stream a file out of the binary table, then calls
UseDLL and UnUseDLL 還原數據庫
IMPLEMENTATION:
/////////////////////////////////////////////////////////////////////////////////
*/
function RestoreDataBase()
STRING szBinaryKey, szFileName;
NUMBER nResult;
begin
/*
TO DO:
Use your Binary key and file name
*/
szBinaryKey = "BINARYKEY";
szFileName = SUPPORTDIR ^ "DBInstall.dll";
//StreamFileFromBinary(hInstall, szBinaryKey, szFileName);
nResult = UseDLL(szFileName);
/*
TO DO:
Make your function call here
Be sure to prototype your function before you call it, otherwise the script
will fail to compile.
*/
nResult = DBInstall.OpenForm();
nResult = UnUseDLL(szFileName);
end;
// --- include script file section ---