高手帮我优化优化6.3的代码啊 谢谢啊
installshield吧
全部回复
仅看楼主
level 1
bladdck 楼主
// Include header files
#include "ifx.h"
////////////////////// string defines ////////////////////////////
#define DLGTITLE_SETUP "Vision-X Setup"
#define MSG_SETUP_BEGIN "The Vision-X Setup Wizard will install "
// ----- SdShowDlg_AskDSN -----------------//
#define DISPLAY_ASK_DSN "Please input DB connection informaton for installation"
//----Process_CheckDSN----//
#define DISPLAY_DSN_TESTING "Setup is checking the DB availability ..."
#define DISPLAY_DSN_TESTING_END "Setup has ended the DB availability check"
#define DISPLAY_DSN_LOGIN_UNKNOWNERROR "Setup reminder: an unknown error occurred while validating the database information."
#define DISPLAY_DSN_LOGIN_INVALID "Setup reminder: could not login by specified DB Host,username or password."
#define DISPLAY_DSN_LOADDLL_FAILED "Setup reminder: Failed to load DB Dll for DB accessing"
//---- message title to popup during the course ----//
#define MSG_DSN_TITLE_VALIDATE_FAILED "DB ACCESS ERROR "
#define MSG_DSN_TITLE_CREATE_DB_FAILED "CREATE DB FAILED "
// message to popup during the course
#define MSG_DSN_NOTEXIST "DSN does not exist, could not access database"
#define MSG_DB_SCRIPT_NOTEXIST "DB script does not exist"
//----Process_ExecuteDBScript----//
#define DISPLAY_DB_CREATING "Setup is creating the databases: "
#define DISPLAY_DB_CREATING_END "Setup has ended the Vision-X databases creation"
#define MSG_DB_TITLE_CREATE_FAILED "CREATE DB FAILED "
#define MSG_DB_DISPLAY_SCRIPT_NOTEXIST "DB script does not exist, could not setup Vision-X databases"
#define MSG_DB_UNKNOWNERROR "An unknown error occurred while creating database"
#define DISPLAY_ASKPATH_JAVAHOME "The path to JAVA_HOME is required for configuration"
#define DISPLAY_ASKPATH_TOMCATHOME "The path to Tomcat is required for configuration"
#define MSG_FailedtoModifyFile_Telephony_INI "Error occurred while trying to modify the ini file of Telephony server configuration"
// --------------------------- on End ----------------------------------//
#define DLG_TITLE_END "Vision-X Setup"
#define MSG_Install_End "Thank you for choosing Vision-X products. Setup has been succeed to install Vision-X components on you computer."
#define MSG_Maintain_End "Thank you for choosing Vision-X products. Setup has successfully completed Vision-X components maintenance on you computer."
#define MSG_Exception_End "The Vision-X setup has to be ended because of the exception occurred during setup."
#define MSG_End_Click_Quit "Click Finish to quit setup."
////////////////////// end of string defines ////////////////////////////
//////////////////// installation declarations ///////////////////

2011年12月15日 08点12分 1
level 1
bladdck 楼主

// ----- DLL function prototypes -----
// your DLL function prototypes
// validate the database information
// return value:
// 0 : DSN Info invalid
// 1 : DSN exists, but authentication failed
// 3 : DSN exists, authentication passed, but database does not exist
// 7 : DSN exists, authentication passed, database exists
// -2147483648 : other error
// Note: the DatabaseName in arg1: DSN could different from the arg4: Database
//ValidateDBInfo(LPSTR DSN, LPSTR Account, LPSTR Password, LPSTR Database);
//prototype NUMBER DBSetup.ValidateDBInfo(BYVAL STRING, BYREF STRING, BYREF STRING, BYREF STRING);
prototype NUMBER DBSetup.DBValidate(BYVAL STRING, BYVAL STRING, BYVAL STRING, BYVAL STRING);
// execute the script to create the database
// return value
// 0 : all right
// 1 : script does not exist
// -2147483648 : other error
//ExecuteScript(LPSTR DSN, LPSTR Account, LPSTR Password, LPSTR ScriptFullPath);
//prototype NUMBER DBSetup.ExecuteScript(BYVAL STRING, BYREF STRING, BYREF STRING, BYREF STRING);
prototype NUMBER DBSetup.DBExecuteScript(BYVAL STRING, BYVAL STRING, BYVAL STRING, BYVAL STRING);
// execute the script to create the database
// return value
// 0 : all right
// 1 : script does not exist
// -2147483648 : other error
//ExecuteScript(LPSTR DSN, LPSTR Account, LPSTR Password, LPSTR ScriptFullPath, mode);
//int mode 0 为文件 1 为sql 语句
//prototype NUMBER DBSetup.ExecuteProcedureScript(BYVAL STRING, BYREF STRING, BYREF STRING, BYREF STRING);
//--------IP Address API-----//
// initsocket
prototype NUMBER WSOCK32.WSAStartup( NUMBER, POINTER);
// release the memory
prototype NUMBER KERNEL32.RtlMoveMemory (POINTER, NUMBER, NUMBER);
// relasesocket
prototype NUMBER WSOCK32.WSACleanup();
prototype NUMBER SdAskPath_Report_TomcatHome(BYVAL NUMBER, BYREF STRING);
prototype SetEnvironment ();
// 外部安装程序调用
prototype OuterCall_Setup_Java();
prototype OuterCall_Setup_Tomcat();
prototype OuterCall_Setup_PCAP();
//---- 数据库操作函数 --/
prototype NUMBER SdShowDlg_AskDSN(NUMBER);
prototype Process_CreateDSN(STRING, STRING);
prototype Process_Delete_DSN(STRING);
prototype NUMBER Process_CheckDSN(STRING);
// 安装DataBase 数据库DSN
prototype NUMBER Process_CreateDataBaseDSN();
// 安装DataBase 数据库
prototype NUMBER Process_CreateDataBase();
// 安装脚本
prototype NUMBER Process_DB_ExecuteDBScript(STRING);
// your global variables

2011年12月15日 08点12分 2
level 1
bladdck 楼主
// 数据库标记
BOOL b_db_def, b_db_sys, b_db_ucd, b_db_ivr, b_db_crm, b_db_rec, b_db_rep, b_db_rtd, b_db_setup;
// 安装部件
// BOOL b_comp_common, b_comp_corba, b_comp_licsrv, b_comp_control, b_comp_visionone, b_comp_jdk, b_comp_tomcat, b_comp_setup, b_comp_mon;
BOOL b_comp_common, b_comp_licsrv, b_comp_control, b_comp_visionone, b_comp_jdk, b_comp_tomcat;
BOOL b_comp_cti, b_comp_ems;
BOOL b_comp_log, b_comp_fms, b_comp_vrs, b_comp_srs;
BOOL b_askip, b_asktom, b_jdk, b_tomcat;
STRING g_DB_Host,g_DB_UserName,g_DB_PWD,g_DB_DBName;
STRING g_JAVA_HOME, g_TOMCAT_HOME;
STRING g_context_key;
//STRING g_context_cti, g_context_ems,g_context_irs, g_context_ivr, g_context_bds, g_context_setup, g_context_control,g_context_log, g_context_vrs, g_context_fms, g_context_mon;
STRING g_channel_factory_key;
//STRING g_channel_factory_cti, g_channel_factory_ems,g_channel_factory_irs, g_channel_factory_ivr,g_channel_factory_bds,g_channel_factory_setup, g_channel_factory_control, g_channel_factory_log, g_channel_factory_vrs, g_channel_factory_fms, g_channel_factory_mon;
STRING g_channel_key;
//STRING g_channel_cti, g_channel_ems,g_channel_irs, g_channel_ivr, g_channel_bds, g_channel_setup, g_channel_control,g_channel_log,g_channel_vrs ,g_channel_fms, g_channel_mon;
//STRING g_error_msg_cti,g_error_msg_ems, g_error_msg_irs, g_error_msg_ivr, g_error_msg_bds, g_error_msg_setup ,g_error_msg_con,g_error_msg_log, g_error_msg_vrs, g_error_msg_fms, g_error_msg_mon ;
STRING nRootKey;
number g_EndType;
//////////////////////////////////////////////////////////////////////////////
//
// 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;
string szTitle, szMsg;
string szLicenseFile, szQuestion;
string szName, szCompany;
string szFile;
string szTargetPath;
string szDir;
string szfolder;
string szComponents, szTargetdir;
number nLevel;
LIST listStartCopy;
LIST list;
number nvSize, nSetupType;
string szhost, szlocalip, szlastoctet;
begin
// 数据库初始化
b_db_def = TRUE;
b_db_sys = TRUE;
b_db_ucd = TRUE;
b_db_ivr = TRUE;
b_db_crm = TRUE;
b_db_rec = TRUE;
b_db_rep = TRUE;
b_db_rtd = TRUE;
b_db_setup = TRUE;
Dlg_Start:
// beginning of dialogs label
// welcome
Dlg_SdWelcome:
szTitle = "";
szMsg = "";
DialogSetInfo (DLG_INFO_ALTIMAGE,SUPPORTDIR ^ @Pic_Welcome, TRUE);
nResult = SdWelcome( szTitle, szMsg );
if (nResult = BACK) goto Dlg_Start;

2011年12月15日 08点12分 3
level 1
bladdck 楼主

//license.txt
Dlg_SdLicense:
szLicenseFile = SUPPORTDIR ^ "license.txt";
szTitle = "";
szMsg = "";
szQuestion = "";
DialogSetInfo (DLG_INFO_ALTIMAGE,SUPPORTDIR ^ @Pic_Common, TRUE);
nResult = SdLicense( szTitle, szMsg, szQuestion, szLicenseFile );
if (nResult = BACK) goto Dlg_SdWelcome;
//Dlg_SdShowInfoList:
// if (nResult = BACK) goto Dlg_SdLicense;
// 问注册者
Dlg_SdRegisterUser:
szMsg = "";
szTitle = "";
nResult = SdRegisterUser( szTitle, szMsg, szName, szCompany );
// if (nResult = BACK) goto Dlg_SdShowInfoList;
if (nResult = BACK) goto Dlg_SdLicense;
Dlg_SdAskDestPath:
szTitle = "";
szMsg = "";
TARGETDIR = PROGRAMFILES ^ @COMPANY_NAME;
szDir = TARGETDIR;
DialogSetInfo (DLG_INFO_ALTIMAGE,SUPPORTDIR ^ @Pic_Common, TRUE);
nResult = SdAskDestPath( szTitle, szMsg, szDir, 0 );
TARGETDIR = szDir;
if (nResult = BACK) goto Dlg_SdRegisterUser;
Dlg_SetupType:
szTitle = "";
szMsg = "";
nSetupType = TYPICAL;
nResult = SetupType ( szTitle, szMsg, "", nSetupType, 0 );
if (nResult = BACK) then
goto Dlg_SdAskDestPath;
else
nSetupType = nResult;
if (nSetupType != CUSTOM) then
szTargetPath = TARGETDIR;
nvSize = 0;
ComponentSetTarget( "VisionONE\\VisionONE", "<tomdir>", szTargetPath ^"\\webapps\\VisionONE");
ComponentCompareSizeRequired( MEDIA, szTargetPath, nvSize );
if (nvSize != 0) then
MessageBox( szSdStr_NotEnoughSpace, WARNING );
goto Dlg_SdAskDestPath;
endif;
endif;
endif;
Dlg_SdComponentTree:
if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath;
szTitle = "";
szMsg = "";
szTargetdir = TARGETDIR;
szComponents = "";
nLevel = 2;
if (nSetupType = CUSTOM) then
nResult = SdComponentTree( szTitle, szMsg, szTargetdir, szComponents, nLevel );
if (nResult = BACK) goto Dlg_SetupType;
endif;
Dlg_ObjDialogs:
nResult = ShowObjWizardPages( nResult );
if (nResult = BACK) goto Dlg_SdComponentTree;
Dlg_SdSelectFolder:
SHELL_OBJECT_FOLDER = @FOLDER_NAME;
szfolder = SHELL_OBJECT_FOLDER;
szTitle = "";
szMsg = "";
nResult = SdSelectFolder( szTitle, szMsg, szfolder );
SHELL_OBJECT_FOLDER = szfolder;
if (nResult = BACK) goto Dlg_ObjDialogs;
SetEnvironment();
Dlg_SdStartCopy:
szTitle = "";
szMsg = "";
listStartCopy = ListCreate( STRINGLIST );
//The following is an example of how to add a string (szName) to a list (listStartCopy).
//e.g. ListAddString( listStartCopy, szName, AFTER );

2011年12月15日 08点12分 4
level 1
bladdck 楼主

ListAddString( listStartCopy, "The products will be installed in folder " + TARGETDIR , AFTER );
ListAddString( listStartCopy, "The components you selected:", AFTER );
// 检查公告组建
// 如果已经安装就取消安装
// if (ComponentIsItemSelected (MEDIA,"corba") == TRUE) then
// ListAddString( listStartCopy, "corba", AFTER );
// b_comp_corba =1;
// endif;
// if (ComponentIsItemSelected (MEDIA,"LicSrv") == TRUE) then
// ListAddString( listStartCopy, "LicSrv", AFTER );
// b_comp_licsrv =1;
// endif;
// if (ComponentIsItemSelected (MEDIA,"controller") == TRUE) then
// ListAddString( listStartCopy, "controller", AFTER );
// b_comp_control =1;
// endif;
if (ComponentIsItemSelected (MEDIA,"VisionONE\\VisionONE") == TRUE) then
ListAddString( listStartCopy, "VisionONE", AFTER );
b_comp_visionone =1;
endif;
if (ComponentIsItemSelected (MEDIA,"VisionONE\\JDK") == TRUE) then
ListAddString( listStartCopy, "JDK", AFTER );
b_comp_jdk =1;
endif;
if (ComponentIsItemSelected (MEDIA,"VisionONE\\Tomcat") == TRUE) then
ListAddString( listStartCopy, "Tomcat", AFTER );
b_comp_tomcat =1;
endif;
// if (ComponentIsItemSelected (MEDIA,"VisionALM") == TRUE) then
// ListAddString( listStartCopy, "VisionALM", AFTER );
// b_comp_alm =1;
// endif;
//安装JDK,Tomcat,VRS,ONE的条件
SD_StartCopy:
nResult = SdStartCopy( szTitle, szMsg, listStartCopy );
if (nResult = BACK) then
goto Dlg_SdComponentTree;
endif;
if ComponentIsItemSelected (MEDIA,"VisionONE\\JDK") then
OuterCall_Setup_Java();
b_jdk = TRUE;
endif;
if ComponentIsItemSelected (MEDIA,"VisionONE\\Tomcat") then
OuterCall_Setup_Tomcat();
b_tomcat = TRUE;
endif;
if ComponentIsItemSelected (MEDIA,"VisionVRS") then
OuterCall_Setup_PCAP();
endif;
if ComponentIsItemSelected (MEDIA,"VisionONE\\VisionONE") then
nResult = SdAskPath_Report_TomcatHome(0, g_TOMCAT_HOME);
if ( nResult == BACK ) then
goto SD_StartCopy;
endif;
ComponentSetTarget( "VisionONE\\VisionONE", "<tomdir>", g_TOMCAT_HOME ^"\\webapps\\VisionONE");
b_asktom = TRUE;
endif;
ListDestroy( listStartCopy );
// set up default status
SetStatusWindow( 0, "" );
Enable( STATUSEX );
StatusUpdate( ON, 100 );
return 0;
end;

2011年12月15日 08点12分 5
level 1
bladdck 楼主

///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMoving
//
// EVENT: Moving event is sent when file transfer is started as a result of
// ComponentTransferData call, before any file transfer operations
// are performed.
//
///////////////////////////////////////////////////////////////////////////////
function OnMoving()
string szAppPath;
NUMBER nResult;
begin
// Set Logo Compliance Application Path
szAppPath = TARGETDIR;
if ComponentIsItemSelected (MEDIA,"VisionONE\\JDK") then
if (b_jdk != TRUE) then
OuterCall_Setup_Java();
endif;
endif;
if ComponentIsItemSelected (MEDIA,"VisionONE\\Tomcat") then
if (b_tomcat != TRUE) then
OuterCall_Setup_Tomcat();
endif;
endif;
if (ComponentIsItemSelected (MEDIA,"VisionONE\\VisionONE")== TRUE) then
if (b_asktom != TRUE) then
nResult = SdAskPath_Report_TomcatHome(0, g_TOMCAT_HOME);
ComponentSetTarget( "VisionONE\\VisionONE", "<tomdir>", g_TOMCAT_HOME ^"\\webapps\\VisionONE");
endif;
endif;
// if (ComponentIsItemSelected (MEDIA,"corba") == TRUE) then
// b_comp_corba =1;
// endif;
if (ComponentIsItemSelected (MEDIA,"LicSrv") == TRUE) then
b_comp_licsrv =1;
endif;
if (ComponentIsItemSelected (MEDIA,"controller") == TRUE) then
b_comp_control =1;
endif;
if (ComponentIsItemSelected (MEDIA,"VisionONE\\VisionONE") == TRUE) then
b_comp_visionone =1;
endif;
if (ComponentIsItemSelected (MEDIA,"VisionONE\\JDK") == TRUE) then
b_comp_jdk =1;
endif;
if (ComponentIsItemSelected (MEDIA,"VisionONE\\Tomcat") == TRUE) then
b_comp_tomcat =1;
endif;
// if (ComponentIsItemSelected (MEDIA,"VisionALM") == TRUE) then
// b_comp_alm =1;
// endif;
// Process_commonConfig();
// 配置数据库参数
// TO DO: if your application's main executable file is in a subfolder of TARGETDIR then append this subfolder to szAppPath
DeleteDir (szAppPath, ALLCONTENTS);
RegDBSetItem( REGDB_APPPATH, szAppPath );
RegDBSetItem( REGDB_APPPATH_DEFAULT, szAppPath ^ @PRODUCT_KEY );
end;
// --- include script file section ---
//安装TOMCAT方法
function NUMBER SdAskPath_Report_TomcatHome(szDisableBackButton, szTomcatHome)
string szMsg,szDefPath;
NUMBER nResult;
begin
szMsg = DISPLAY_ASKPATH_TOMCATHOME;
szDefPath = "C:\\Program Files\\Apache Software Foundation\\Tomcat 6.0";
if (szDisableBackButton) then
Disable( BACKBUTTON );

2011年12月15日 08点12分 6
level 1
bladdck 楼主
endif;
DialogSetInfo (DLG_INFO_ALTIMAGE,SUPPORTDIR ^ @Pic_Common, TRUE);
nResult = AskPath (szMsg, szDefPath, szTomcatHome);
while ( nResult == NEXT && ExistsDir(szTomcatHome) == NOTEXISTS )
szDefPath = szTomcatHome;
SprintfBox(INFORMATION, "error", "not exist directory: %s", szTomcatHome);
nResult = AskPath (szMsg, szDefPath, szTomcatHome);
endwhile;
//Enable( BACKBUTTON );
return nResult;
end;
// 外部安装程序调用
function OuterCall_Setup_Java()
begin
LaunchAppAndWait (SUPPORTDIR ^ @SETUPFILE_JAVA, "",WAIT);
end;
function OuterCall_Setup_Tomcat()
begin
LaunchAppAndWait (SUPPORTDIR ^ @SETUPFILE_TOMCAT,"", WAIT);
end;
function OuterCall_Setup_PCAP()
begin
LaunchAppAndWait (SUPPORTDIR ^ @SETUPFILE_PCAP,"", WAIT);
end;
///////////////////////////////////////////////////////////////////////////////
//
// FUNCTION: OnMaintUIAfter
//
// EVENT: MaintUIAfter event is sent after file transfer, when end user runs
// installation that has already been installed on the machine. Usually
// this happens through Add/Remove Programs applet.
// In the handler installation usually displays UI that will inform
// end user that maintenance/uninstallation has been completed successfully.
//
///////////////////////////////////////////////////////////////////////////////
function OnMaintUIAfter()
STRING szTitle, szMsg1, szMsg2, szOption1, szOption2;
NUMBER bOpt1, bOpt2;
NUMBER nResult;
begin
Dlg_AskDSN:
if (b_db_sys || b_db_ucd || b_db_ivr || b_db_rec|| b_db_crm || b_db_def || b_db_rep || b_db_rtd ||b_db_setup ) then
nResult = SdShowDlg_AskDSN(0);
if (nResult = -1) goto Dlg_AskDSN;
endif;
P_CheckDSN:
if (b_db_sys || b_db_ucd || b_db_ivr || b_db_rec|| b_db_crm || b_db_def || b_db_rep || b_db_rtd ||b_db_setup) then
Process_CreateDSN(@DSN_TEMP, "master");
//nResult = Process_CheckDSN(@DSN_TEMP, "master");
nResult = Process_CheckDSN("master");
if (7 != nResult) then
SprintfBox (INFORMATION, MSG_DSN_TITLE_VALIDATE_FAILED,DISPLAY_DSN_LOGIN_INVALID);
Process_Delete_DSN(@DSN_TEMP);
goto Dlg_AskDSN;
endif;
endif;
P_CreateDSN:
Process_CreateDataBaseDSN();
Process_CreateDataBase();
P_ChangePath:
ShowObjWizardPages(NEXT);

2011年12月15日 08点12分 7
level 1
bladdck 楼主
bOpt1 = FALSE;
bOpt2 = FALSE;
szMsg1 = SdLoadString(IFX_SDFINISH_MAINT_MSG1);
szTitle = SdLoadString(IFX_SDFINISH_MAINT_TITLE);
DialogSetInfo (DLG_INFO_ALTIMAGE,SUPPORTDIR ^ @Pic_Complete, TRUE);
SdFinish(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
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;
NUMBER nResult;
begin
Dlg_AskDSN:
if (b_db_sys || b_db_ucd || b_db_ivr || b_db_rec|| b_db_crm || b_db_def || b_db_rep || b_db_rtd ||b_db_setup) then
nResult = SdShowDlg_AskDSN(0);
if (nResult = -1) goto Dlg_AskDSN;
endif;
P_CheckDSN:
if (b_db_sys || b_db_ucd || b_db_ivr || b_db_rec|| b_db_crm || b_db_def || b_db_rep || b_db_rtd ||b_db_setup) then
Process_CreateDSN(@DSN_TEMP, "master");
//nResult = Process_CheckDSN(@DSN_TEMP, "master");
nResult = Process_CheckDSN("master");
if (0 != nResult) then
SprintfBox (INFORMATION, MSG_DSN_TITLE_VALIDATE_FAILED,DISPLAY_DSN_LOGIN_INVALID);
Process_Delete_DSN(@DSN_TEMP);
goto Dlg_AskDSN;
endif;
endif;
P_CreateDSN:
Process_CreateDataBaseDSN();
Process_CreateDataBase();
P_ChangePath:
Disable(STATUSEX);
ShowObjWizardPages(NEXT);
bOpt1 = FALSE;
bOpt2 = FALSE;
szMsg1 = SdLoadString(IFX_SDFINISH_MSG1);
DialogSetInfo (DLG_INFO_ALTIMAGE,SUPPORTDIR ^ @Pic_Complete, TRUE);
SdFinish(szTitle, szMsg1, szMsg2, szOption1, szOption2, bOpt1, bOpt2);
end;
function NUMBER SdShowDlg_AskDSN(szDisableBackButton)
NUMBER nResult;
string szTitle, szMsg;
begin
szTitle = DLGTITLE_SETUP;
szMsg = DISPLAY_ASK_DSN;
Disable( BACKBUTTON );
DialogSetInfo (DLG_INFO_ALTIMAGE,SUPPORTDIR ^ @Pic_Common, TRUE);
//g_DB_Host,g_DB_UserName,g_DB_PWD

2011年12月15日 08点12分 8
level 1
bladdck 楼主
nResult = SdShowDlgEdit3 (szTitle, szMsg, "DB Server:", "Login ID:", "Password:", g_DB_Host,g_DB_UserName , g_DB_PWD);
Enable( BACKBUTTON );
end;
//function NUMBER Process_CheckDSN(sDsnName, sDBName)
function NUMBER Process_CheckDSN(sDBName)
NUMBER nResult,nvSize;
NUMBER nTemp;
string szKey,szDBDllPath;
begin
nResult = -1; // failed
// call dll function to check the DB information............
szDBDllPath = SUPPORTDIR^@FileName_DBDLL;
nTemp = UseDLL (szDBDllPath);
if (nTemp = 0) then
//Test ODBC
SdShowMsg(DISPLAY_DSN_TESTING, TRUE);
//nResult = ValidateDBInfo(sDsnName, g_DB_UserName, g_DB_PWD, sDBName);
nResult = DBValidate(g_DB_Host, g_DB_UserName, g_DB_PWD, sDBName);
SdShowMsg(DISPLAY_DSN_TESTING_END, TRUE);
else
nResult = -1;
endif;
UnUseDLL(szDBDllPath);
if ( nResult == 1) then
return 0;
else
return -1;
endif;
end;
function Process_Delete_DSN(sDsnName)
string szKey;
begin
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKey = "SOFTWARE\\ODBC\\ODBC.INI";
RegDBDeleteKey(szKey ^ sDsnName);
RegDBDeleteValue (szKey^ "ODBC Data Sources", sDsnName);
end;
function Process_CreateDSN(sDsnName, sDBName)
NUMBER nResult, nvSize;
string szKey;
begin
//create dsn for PDS database ....................................
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
szKey = "SOFTWARE\\ODBC\\ODBC.INI";
nResult = RegDBSetKeyValueEx(szKey ^ sDsnName, "Database", REGDB_STRING, sDBName, nvSize);
nResult = RegDBSetKeyValueEx(szKey ^ sDsnName, "server", REGDB_STRING, g_DB_Host, nvSize);
nResult = RegDBSetKeyValueEx(szKey ^ sDsnName, "LastUser", REGDB_STRING, g_DB_UserName, nvSize);
nResult = RegDBSetKeyValueEx(szKey ^ sDsnName, "Driver", REGDB_STRING, WINSYSDIR ^ "SQLSRV32.dll", nvSize);
nResult = RegDBSetKeyValueEx(szKey ^ "ODBC Data Sources", sDsnName, REGDB_STRING, "SQL Server", nvSize);
end;

2011年12月15日 08点12分 9
level 1
bladdck 楼主

// 安装DataBase 数据库DSN
function NUMBER Process_CreateDataBaseDSN()
NUMBER nResult;
begin
if (b_db_def) then
nResult = Process_CreateDSN(@DSN_DEF, @DB_DEF);
endif;
if (b_db_sys) then
nResult = Process_CreateDSN(@DSN_SYS, @DB_SYS);
endif;
if (b_db_ivr) then
nResult = Process_CreateDSN(@DSN_IVR, @DB_IVR);
endif;
if (b_db_rec) then
nResult = Process_CreateDSN(@DSN_REC, @DB_REC);
endif;
if (b_db_ucd) then
nResult = Process_CreateDSN(@DSN_UCD, @DB_UCD);
endif;
if (b_db_crm) then
nResult = Process_CreateDSN(@DSN_CRM, @DB_CRM);
endif;
if (b_db_rep) then
nResult = Process_CreateDSN(@DSN_REP, @DB_REP);
endif;
if (b_db_rtd) then
nResult = Process_CreateDSN(@DSN_RTD, @DB_RTD);
endif;
if (b_db_setup) then
nResult = Process_CreateDSN(@DSN_RTD, @DB_RTD);
endif;
end;
// 安装DataBase 数据库
function NUMBER Process_CreateDataBase()
NUMBER nResult;
begin
if ( b_db_def == TRUE ) then
nResult = Process_CheckDSN(@DB_DEF);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_DEF) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_sys == TRUE ) then
nResult = Process_CheckDSN(@DB_SYS);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_SYS) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_ucd == TRUE ) then
nResult = Process_CheckDSN(@DB_UCD);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_UCD) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_ivr == TRUE ) then
nResult = Process_CheckDSN(@DB_IVR);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_IVR) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_rec == TRUE ) then
nResult = Process_CheckDSN(@DB_REC);

2011年12月15日 08点12分 10
level 1
bladdck 楼主
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_REC) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_crm == TRUE ) then
nResult = Process_CheckDSN(@DB_CRM);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_CRM) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_rep == TRUE ) then
nResult = Process_CheckDSN(@DB_REP);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_REP) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_rtd == TRUE ) then
nResult = Process_CheckDSN(@DB_RTD);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_RTD) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
if ( b_db_setup == TRUE ) then
nResult = Process_CheckDSN(@DB_RTD);
if ( nResult != 0 ) then
if ( Process_DB_ExecuteDBScript(@DB_RTD) != 0) then
g_EndType = -1;
return -1;
endif;
endif;
endif;
end;
//function NUMBER Process_DB_ExecuteDBScript(sDsnName, sDBScriptName)
function NUMBER Process_DB_ExecuteDBScript(sDBScriptName)
NUMBER nResult;
string szDBDllPath, szDBScript;
begin
// Execute DB script to create the PDS database..................
SdShowMsg(DISPLAY_DB_CREATING + "[" + sDBScriptName + "]...", TRUE);
nResult = -1;
szDBDllPath = SUPPORTDIR^@FileName_DBDLL;
szDBScript = SUPPORTDIR^sDBScriptName;
szDBScript = szDBScript + ".sql";
nResult = UseDLL (szDBDllPath);
nResult = DBExecuteScript(g_DB_Host, g_DB_UserName, g_DB_PWD, szDBScript);
UnUseDLL(szDBDllPath);
if ( nResult == 0) then
return -1;
else
return 0;
endif;
end;
function SetEnvironment()
STRING szPath;
NUMBER nvSize,nvType;
begin
Disable(LOGGING);
RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE);
RegDBGetKeyValueEx("SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment","Path",nvType,szPath,nvSize);
if szPath!="" then
PathSet (szPath);
PathDelete("Common",PARTIAL);
PathAdd(TARGETDIR+"\\Common","", PARTIAL, AFTER);
PathGet(szPath);
//MessageBox(szPath,INFORMATION);
else
szPath=TARGETDIR+"\\Common";
endif;
RegDBDeleteValue("\\SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment","Path");
RegDBSetKeyValueEx("\\SYSTEM\\ControlSet001\\Control\\Session Manager\\Environment","Path",REGDB_STRING_EXPAND,szPath,-1);
Enable(LOGGING);
end;
2011年12月15日 08点12分 11
level 1
bladdck 楼主
谁帮我看看哪里可以优化的啊~~谢谢啊~
2011年12月15日 08点12分 12
1