/
//
// 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 ---