C#, ASP.NET…

WebService – Cơ bản về SOAP, WSDL và ASP.NET Web Service

Web Serivce là một công nghệ cho phép client truy xuất để thực hiện mọi tác vụ như một Web Application. Về bản chất, Web service dựa trên XML và HTTP, trong đó XML làm nhiệm vụ mã hóa và giải mã dữ liệu và dùng SOAP để truyền tải. Web Service không phụ thuộc vào platform nào, do đó bạn có thể dùng Web Service để truyền tải dữ liệu giữa các ứng dụng hay giữa các platform.

SOAP – Simple Object Access Protocol

SOAP – Một tiêu chuẩn của W3C, là giao thức sử dụng XML để định nghĩa dữ liệu dạng thuần văn bản (plain text) thông qua HTTP. SOAP là cách mà Web Service sử dụng để truyền tải dữ liệu. Vì dựa trên XML nên SOAP là một giao thức không phụ thuộc platform cũng như bất kì ngôn ngữ lập trình nào.

Một thông điệp SOAP được chia thành hai phần là header và body. Phần header chỉ ra địa chỉ Web Service, host, Content-Type, Content-Length tương tự như một thông điệp HTTP.

WSDL – Web Services Description Language

WSDL là ngôn ngữ được sử dụng để mô tả đầy đủ về Web Service theo chuẩn XML như các phương thức, kiểu dữ liệu,… dựa trên XML schema.

1. Sự khác nhau giữa các lớp Trace và Debug?

– Trace dùng để theo dõi các hành động xảy ra. Nó hoạt động trong các đóng gói cả Debug lẫn Release. Trace là khả năng của chương trình tự đưa ra các thông tin về hành động của mình.

– Debug dùng để tìm và sửa các lỗi trong chương trình. Nó chỉ hoạt động trong đóng gói Debug.

2. Sự khác nhau giữa static readonly và const?

– Static readonly là hằng số được khởi tạo khi thực thi chương trình.

– Const là hằng số được khởi tạo khi biên dịch chương trình.

3. Sự khác nhau giữa String và StringBuilder?

– String là lớp không thay đổi. Mọi phương thức sẽ tạo ra một biến String mới.

– StringBuilder là lớp thay đổi. Các phương thức của biến sẽ ảnh hưởng đến đến biến StringBuilder hiện tại.

4. Sự khác nhau giữa “” và String.Empty?

– “” sẽ tạo thêm 1 đối tượng khi làm việc với nó (so sánh, copy…)

– String.Empty không tạo đối tượng nào cả. String.Emtpy nằm trong mscorlib.

Khi kiểm tra 1 String có rỗng hay không nên dùng String.Length == 0 để có tốc độ nhanh nhất.

5. Có thể gán một struct bằng null hay không?

– Có thể nếu bạn lập trình với C# 2.0. Ví dụ: int? var = 1; var = null;

6. Sự khác nhau giữa == và phương thức Equals?

– == so sánh theo kiểu giá trị.

– Equals so sánh theo kiểu tham chiếu.

7. Sự khác nhau giữa throw và throw ex?

– throw đế đưa lại toàn bộ các tầng theo dõi của lỗi ra.

– throw ex bỏ bớt các tầng theo dõi bên dưới phương thức gọi throw ex.

8. Connection Pooling dùng để làm gì?

– Cho phép tăng tốc độ của các ứng dụng Web bằng cách dùng lại các kết nối thay vì tạo các kết nối mới với mỗi yêu cầu.

9. .NET có hỗ trợ thừa kế từ nhiều lớp hay không (multiple inheritance)? Tại sao?

– Không. Vì sẽ không hiểu được khi gọi 1 phương thức mà 2 lớp cha cùng override nó.

10. Sự khác nhau giữa abstract class và interface?

– Có thể thừa kế từ nhiều interface nhưng chỉ có thể thừa kế từ 1 abstract class.

– Có thể viết sẵn các thực thi trong Abstract class, nhưng interface thì không.

– Interface dùng để gom các hành động cần được hiện thực , các khả năng của một đối tượng (ví dụ con người và xe cộ cùng có khả năng đi lại, nhưng con người không cùng tính chất với xe cộ), còn abstract class cho các lớp thừa kế cùng 1 loại, tính chất hay trạng thái (ví dụ đàn ông, phụ nữ, trẻ con, người già đều là con người).

– Abstract class có tốc độ thực thi nhanh hơn interface.

– Thêm 1 tính năng mới vào interface sẽ phá vỡ toàn bộ các lớp hiện thực, còn abstract thì không.

11. Hàm GetHasCode() trong System.Object dùng để làm gì?

– Trả về giá trị của một đối tượng. Chú ý hàm này mặc định không trả về giá trị duy nhất hoặc không đổi. Hàm này có thể override.

12. Sự khác nhau giữa DataSet và DataReader?
– DataSet có thể đọc và ghi trong khi DataReader chỉ có thể đọc.
– DataSet có thể chứa nhiều bảng còn DataReader chỉ có thể chứa 1 bảng.
– DataSet làm việc ở chế độ không kết nối còn DataReader làm việc ở chế độ kết nối.
– DataSet có thể di chuyển tới và trở lại còn DataReader thì chỉ có thể di chuyển tới.
– DataSet truy cập chậm hơn DataReader.

13. Sự khác nhau giữa các phuơng thức Copy và Clone?
– Clone chỉ copy cấu trúc trong khi Copy copy cả cấu trúc lẫn dữ liệu.

14. Sự khác nhau giữa Dispose, Destructor và Finalize?
– Destructor sẽ được chuyển thành Finalize khi biên dịch. Hàm Finalize được gọi bởi .NET Runtime và chúng ta không thể đoàn được nó được gọi khi nào, nhưng nó chắc chắn sẽ được gọi.
– Dispose sẽ giải phóng bộ nhớ ngay khi nó được gọi. Lưu ý nếu lớp nào override Dispose mà quên gọi thì các đối tượng sẽ không tự giải phóng bộ nhớ.

15. Serialization là gì?
– Là sự chuyển chuyển đối tượng thành 1 luồng các bytes.

16. Sự khác nhau giữa XmlSerializer, BinaryFormatter và SoapFormatter?
– XmlSerializer dùng cho dịch vụ Web.
– BinaryFormatter/SoapFormatter dùng cho Remoting.
– SoapFormatter dùng để tuần tự hóa 1 đối tượng thành SOAP.
– BinaryFormatter dùng để tuần tự hóa 1 đối tượng thành dạng nhị phân.
– XmlSerializer chỉ chuyển đổi các tính chất public còn BinaryFormatter/SoapFormatter chuyển đổi cả public lẫn private.

17. Sự khác nhau giữa overriding và shadowing?
– Overriding cung cấp sự hiện thực mới của 1 hàm ở lớp thừa kế nhưng không thay đổi số biến, kiểu trả về, mức truy cập còn shadowing thì có thể thay đổi (từ khóa new trong C#).

18. Sự khác nhau giữa class, object, struct và interface?
– Class là cấu trúc dữ liệu định nghĩa bởi người dùng chứa các tính chất và phương thức. Object là một trường hợp cụ thể của class. Class không chiếm bộ nhớ, còn Object được tạo trong bộ nhớ.
– Class là cấu trúc dữ liệu định nghĩa bởi người dùng chứa các tính chất và phương thức. Struct là kiểu giá trị được lưu trữ trong stack còn class là kiểu tham chiếu (các object) được lưu trữ trong heap.
– Khi struct được khởi tạo không bằng hàm khởi tạo người dùng sẽ phải khởi tạo tất cả các Fields trước khi sử dụng nó.

– Interface là một hợp đồng gồm một nhóm các phương thức cần được hiện thực.

19. Sự khác nhau giữa Property và Field?
– Property dùng để quản lý sự truy cập đến Field. Dùng Property để đảm bảo Field không bị gán các giá trị không hợp lệ.

20. Sự khác nhau giữa static Method, static constructor với method và constructor thông thường?
– Static method có thể gọi mà không cần khởi tạo biến. Static constructor chỉ được gọi đúng một lần khi object đầu tiên được khởi tạo.

21. Các biến tĩnh và chỉ dẫn chương trình được lưu ở đâu?
– Ở 1 vùng bộ nhớ đặc biệt gọi là Permanent Storage area.

22. Sự khác nhau giữa stack và heap?
– Stack và heap là các vùng bộ nhớ. Heap nằm giữa stack và Permanent Storage area, và độ lớn có thể thay đổi khi thực thi chương trình.

23. Sự khác nhau giữa Boxing and Un-Boxing?
– Boxing là chuyển đổi kiểu giá trị thành kiểu tham chiếu. Un-Boxing ngược lại.

24. Mục đích của thừa kế (inheritance)?
– Để tái sử dụng.

25. Mục đích của đa hình (poymophism)?
– Một hành động có thể xảy ra theo nhiều cách khác nhau.

26. Sự khác nhau giữa Compile Time Polymorphism và Run Time Polymorphism?
– Compile Time Polymorphism – ví dụ Overloading, một hàm có thể có nhiều cách biểu diễn.
– Run Time Polymorphism – ví dụ Overriding, một hàm có thể có nhiều cách xử lý.

27. Sự khác nhau giữa delegate và event?
– delegate là một lớp (class) đại diện cho hàm con trỏ kiểu an toàn hoặc hàm gọi (call backs) chỉ đến địa chỉ tham chiếu của một (hay nhiều) hàm. Con trỏ hàm chứa trong delegate được gắn vào một đối tượng đích (target) và khi delegate được kích hoạt phương thức sẽ được gọi ở đối tượng đích. Sự hữu ích của delegate không nằm ở chỗ giữ địa chỉ tham chiếu của các hàm mà để định nghĩa và dùng các tên hàm khi runtime thay vì compile time.
– event cho phép xác định một delegate sẽ được gọi khi có sự xuất hiện của “sự kiện” nào đó. event là một modifier trong khi delegate là một lớp. event cho phép một delegate được khai báo trong interface.

29. AppDomain là gì?
– Là một miền riêng biệt lưu trữ code và dữ liệu cho một application. Một process có thể chứa nhiều AppDomains.
Khi bạn copy một DLL mới vào bin, ASP.NET runtime sẽ không thể đưa nó vào một AppDomain đang chạy.Nó sẽ dừng từ từ AppDomain cũ (dừng hẳn khi nó dừng tất cả các requests) và mở một AppDomain mới.

30. Sự khác nhau giữa publish và published interfaces.
– publish interface là interface mà bạn có thể sửa tất cả những code nào dùng nó còn published interface là interface mà bạn không thể sửa code dùng nó.

31. Sự khác nhau giữa try{}catch{} và try{}catch{Exception ex}?
– Chúng giống hệt nhau.

32. Sự khác nhau giữa 1/0; và try{1/0;} catch {throw;}
– Chúng giống hệt nhau. Vì vậy nếu không xử lý catch thì đừng catch.

33. Sự khác nhau giữa Remoting và Web service?
– Web service không có trạng thái, không cần biết đến client chỉ sử dụng trên HTTP, hỗ trợ không đồng nhất các môi trường, tốc độ chậm hơn Remoting.
– Remoting có trạng thái kết nối, hỗ trợ nhiều giao thức hơn HTTP, TCP…, đòi hỏi môi trường đồng nhất, tốc độ nhanh đặc biệt khi dùng trên TCP.

34. Sự khác nhau giữa error và exception?
– Error là lỗi của chương trình còn exception là lỗi chương trình được phát hiện và có thể xử lý.

35. Sự khác nhau giữa Procedure và OO?
– Procedure gồm các hàm và các biến, tất cả các hàm đều có thể truy cập đến tất cả các biến. Không thể quản lý các biến.
– OO gom hàm và biến vào các đơn vị object. Các hàm và biến được quản lý trong nội bộ object. Các object tương tác với nhau thông qua các interfaces.

36. CLR, CTS, CLS, MSIL, JIT, PE, GAC là viết tắt của những gì?
– Là Common Language Runtime: môi trường để chạy các ứng dụng .NET
– Là Common Type System: mô tả các loại dữ liệu trong .NET.
– Là Common Language Specification: mô tả các quy định và chuẩn cho các ngôn ngữ trong .NET
– Là Microsoft Intermediate Language: ngôn ngữ thông dịch của .NET.
– Là Just In Time: trình biên dịch MSIL thành mã máy.
– Là Portable Executable: file chứa MSIL.
– Là Global Assembly Cache: nơi lưu trữ các Asembly dùng chung.

37. Các mâu thuẫn giữa OO và RDBMS?
– Cấu trúc cấp bậc trong OO có thể là vô tận trong khi ở RDBMS chỉ có 4 loại table, row, column, cell.
– Các đối tượng trong OO bản thân là phân biệt trong khi trong RDBMS cần phải có primary-key.
– Các đối tượng trong OO có thể tham chiếu đến nhau rất đơn giản nhưng trong RDBMS thì phức tạp thông qua JOIN
– Sự thừa kế trong OO là đơn giản trong khi trong RDBMS hầu như không có khái niệm đó. Một bảng cần chứa tất cả các tính chất, có khi là thừa.
– Các đối tượng trong OO có thể có các hành động tác động đến tối tương khác.trong RDBMS thì phức tạp thông qua TRIGGER
– Khả năng truy cập trong OO là hạn chế trong khi ở RDBMS là không giới hạn.

38. Sự khác nhau giữa Response.Redirect và Server.Transfer.
– Response.Redirect đơn thuần là chuyển bạn đến một trang mới giống như bạn gõ địa chỉ trang đó trên browser và request đến server.
– Server.Transfer cũng chuyển bạn đến trang mới nhưng ở phía server, làm giảm request đến server, giữa nguyên URL của bạn và có thể chuyển cả các query string và biến trên form đên địa chỉ mới, chỉ thực hiện giữa các trang trên cùng 1 host.

39. Vai trò của ASPX page và ASPX page code-behind trong MVC.
– ASPX page là View còn ASPX page code-behind là Controller.

40. Làm thế nào để try/catch trên toàn bộ 1 ASPX page.
– Dùng Page_Error event.

41. Sự khác nhau giữa Cohesion và Coupling
– Cohesion là sự liên kết giữa các thành phần trong một module. Một thiết kế tốt nên có sự liên kết giữa các thành phần thật chặt chẽ.
– Coupling là sự kết nối giữa các module với nhau. Một thiết kế tốt nên có sự kết nối thật lỏng lẽo giữa các module.

42. Refractoring là gì?
– Là sự thiết kế lại cấu trúc của code bằng cách thay đổi cấu trúc bên trong mà không ảnh hưởng đến các hành vi bên ngoài (interface) của đoạn code (module, system) đó.

43. Phân biệt HttpApplication, Session, ViewSate và HttpContext?
– Cả 4 thành phần trên đều dùng để lưu dữ liệu của một Web Application.
– HttpApplication có tác dụng trong toàn bộ quá trình thực thi của Web Application.
– Session có tác dụng trong 1 lần ghé thăm (visit) của người dùng. Nó kết thúc khi gặp timeout.
– ViewState có tác dụng trong trong 1 trang web.
– HttpContext có tác dụng trong 1 request.

Contact

All Images forimage004 me.

Nhận đóng gói các phần mền (application, website….) bằng InstallShield
Phone Number : 01685750016
YM: Chat with AVA

InstallShield Script

//=========================================================================== // //  File Name:    Setup.rul // //  Description:  Blank setup main script file // //  Comments:     Blank setup is an empty setup project. If you want to //                  create a new project via. step-by step instructions use the //                  Project Assistant. //                SETUP_FILE //===========================================================================

// Included header files ---------------------------------------------------- #include "ifx.h" #include "check.rul" #include "getcustomerkey.rul" #include "get_server_username_pass.rul" #include "get_server_username_pass_delete_db.rul" #include "getloginnameandpass.rul"

prototype CheckCustomerKey(); prototype CreateRegistryKey(STRING, STRING, NUMBER, STRING, NUMBER,BOOL); prototype STRING GetRegistryValue(STRING, STRING, NUMBER,NUMBER); prototype InformFinish(); prototype int CheckSQLInstallAndInstall(); prototype BOOL CheckSQl2005ProOrExpressInstalled(); prototype NUMBER GetServerNameAndInstallDB(); prototype STRING GetRealSqlInstallPath(STRING,STRING,STRING,STRING,STRING,STRING); prototype BOOL CheckIf2DBExist(STRING); prototype InstallDB(STRING,STRING,STRING,STRING); prototype INT GetInstanceNamePassAndInstall(); prototype STRING GetServerName(); prototype TestDB(STRING,STRING,STRING); prototype Delete1DB(STRING); prototype NUMBER ExcuteSqlFile(STRING); prototype string GetPathToOsql(); prototype CleanTempFiles(); prototype NUMBER AskCreateNewLogin(); prototype InstalledSQLExpress(STRING); prototype BOOL InsSQLExpress(STRING,STRING); prototype CheckInstallSuccess(STRING); prototype DeleteAndCopyFile(); prototype CreateShortCut(STRING,STRING,STRING,STRING,BOOL); prototype DeleteDB_SQLServer(); prototype STRING GetInstallPath(); prototype BOOL CheckApplicationRunning(STRING,BOOL); prototype GetProcessID(STRING, STRING); prototype CheckRuningProcess(); prototype ActionUpdater(); prototype STRING UpdaterScript(STRING,STRING,STRING,STRING,STRING,STRING); prototype STRING GetRegistryValue2(STRING,STRING);

BOOL bByPassCustomerKey,bInstallAborted,bCheckSetup; BOOL bvInstallData,bvInstallDB; BOOL  bvDataDB,bvSystemDB,installEXpressGoodOrBad; STRING svSQLDataRoot; STRING svServer,svUserName,svPassword; STRING DB_NAME; STRING DEFAULTUSERLOGIN; STRING DEFAULTPASSLOGIN; STRING sqlExpressInstanceName,svPassword2,svConfirmPassword2; BOOL bByPassConfig, bIsSQLExpress,bvCreateNewLogin; BOOL bCheckYesNoLicenseCustomerkey,bCheckYesNoDB; STRING EZLICENSE; STRING oldInstalledPath; BOOL bvLaunchLicense; STRING SQLPATH ; STRING SQLDATAROOT; STRING REGPATHSQL2000; STRING REGPATHSQL2005; STRING DBName;

#define FEATURE            "" #define SDASKOPTSTITLE     "Component Selection" #define SDASKOPTSMSG1      "Select components to install." #define SDASKOPTSMSG2      "Your selections will be used to effect file transfer." #define APPBASE_PATH       "Your Company Name\\Your Product Name"

//=========================================================================== // //  Topic:    OnBegin // //  Description: // //  My Name    : // //=========================================================================== function OnBegin() STRING szWritePath,szProcessName; begin

szWritePath=WINDISK +"\\LogProcess.txt"; DeleteAndCopyFile(); szProcessName=@PRODUCT_NAME; GetProcessID(szWritePath,szProcessName);

if LaunchAppAndWait (SUPPORTDIR ^"Encode_Decode.exe", "1.Check IIS             : NO", LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN)==0 then //MessageBox(" Encode_Decode thanh cong",WARNING);

else //MessageBox(" Encode_Decode fail",WARNING);

endif;

bvDataDB=TRUE; bvSystemDB=TRUE; bvInstallDB=TRUE; svPassword=""; bvCreateNewLogin=TRUE; bIsSQLExpress=FALSE; DEFAULTUSERLOGIN="DatabaseName"; //svRapidApplicationPools="PoolRapidEPM"; DEFAULTPASSLOGIN="123456"; installEXpressGoodOrBad=FALSE; sqlExpressInstanceName="SQLExpress"; EZLICENSE = PROGRAMFILES ^ "ACOM Solutions\\EZLicense"; REGPATHSQL2000 = "SOFTWARE\\Microsoft\\MSSQLServer\\Setup"; REGPATHSQL2005 = "SOFTWARE\\Microsoft\\Microsoft SQL Server\\MSSQL.1\\Setup"; bCheckYesNoLicenseCustomerkey=FALSE; bCheckYesNoDB=FALSE; DetectSoftWare();

end;

//=========================================================================== // //  Topic:    GetProcessID // //  Description: // //  My Name    : // //=========================================================================== function GetProcessID(szWritePath,szProcessName) STRING para; begin

para="\"" + szWritePath + "\" \""+szProcessName+"\""; if LaunchAppAndWait (SUPPORTDIR ^"GetProcessIDTest.exe",para, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN)==0 then //MessageBox(" GetProcessID thanh cong" + "\n\n" + para,WARNING); else //MessageBox(" GetProcessID fail" + "\n\n" + para,WARNING); endif; end;

//=========================================================================== // //  Topic:    CheckRuningProcess // //  Description: // //  My Name    : // //===========================================================================

function CheckRuningProcess() STRING szWritePath; NUMBER nResult; STRING szMsg1,szMsg2,szMsg3,szMsg4;

begin

szWritePath=WINDISK +"\\LogProcess.txt";

nResult  = Is (FILE_EXISTS,szWritePath );

if(nResult=TRUE) then

szMsg1="Uninstalling process cannot be continued because"; szMsg2=" "+@PRODUCT_NAME + " "; szMsg3="is in use. Please close it and try again."; szMsg4=szMsg1+szMsg2+szMsg3; //MessageBox("Uninstalling process cannot be continued because " @PRODUCT_NAME " is in use. Please close it and try again.",WARNING); MessageBox(szMsg4,WARNING); DeleteFile(WINDISK +"\\LogProcess.txt"); abort; else endif; end;

//=========================================================================== // //  Topic:    OnFirstUIBefore // //  Description: // //  My Name    : // //=========================================================================== function OnFirstUIBefore() NUMBER  nResult, nLevel, nSize, nSetupType; STRING  szTitle, szMsg, szOpt1, szOpt2, szLicenseFile; STRING  szName, szCompany, szTargetPath, szDir, szFeatures; BOOL    bLicenseAccepted; NUMBER  nFlag, nFileHandle; LIST   listID; STRING svPath,svFile; BOOL bResult; STRING szKey, szNumName, szNumValue, svNumValue,szValueData; NUMBER nType; STRING svDir; STRING    nKeyValue,svEdit1; STRING path; begin //Check Application Running (file *.exe) CheckRuningProcess();

path=GetInstallPath(); oldInstalledPath=path   ; CheckApplicationRunning(path,TRUE);

nSetupType = COMPLETE; szDir = TARGETDIR; szName = ""; szCompany = ""; bLicenseAccepted = FALSE; bvDataDB=TRUE;

//Create Path in Registry key values. szNumName  = "Path"; szNumValue = TARGETDIR; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

//Create InstallPath in Registry key values. szNumName="InstallPath"; svEdit1=EZLICENSE ^"EZLicense.exe"; CreateRegistryKey(szKey, szNumName, nType, svEdit1, nSize,FALSE)  ;

// Beginning of UI Sequence Dlg_Start: nResult = 0; Dlg_SdWelcome: szTitle = ""; szMsg = ""; nResult = SdWelcome( szTitle, szMsg ); if (nResult = BACK) goto Dlg_Start; Dlg_LicenseCustomerkey: //Show License and Customerkey listID = ListCreate (STRINGLIST); // Set the file mode to normal. OpenFileMode (FILE_MODE_NORMAL); // Open the file for editing. svPath=SRCDIR; svFile="Config.ini"; OpenFile (nFileHandle, svPath, svFile); // Get lines from the file into the list. while (GetLine (nFileHandle, svLine) = 0)

ListAddString (listID, svLine, AFTER); StrSub ( svReadLine, svLine, 25,40); StrSub(svReadLineNumber,svLine,0,1); if(svReadLineNumber=="5" && svReadLine== " YES") then bCheckYesNoLicenseCustomerkey=TRUE; Dlg_SdLicense2: nResult=SdLicense2Rtf  (TITLES, "", "",SRCDIR^ LICENSE_PATH,TRUE); if (nResult = BACK)then goto Dlg_SdWelcome; endif; Dlg_CheckCustomerKeys: nResult=CheckCustomerKey(); if(nResult = BACK) then goto  Dlg_SdLicense2; endif; endif; if(svReadLineNumber=="6" && svReadLine== " YES") then bCheckYesNoDB=TRUE; Dlg_GetDBOptions: nResult= CheckSQLInstallAndInstall(); if(nResult=BACK) then if(bCheckYesNoLicenseCustomerkey=TRUE) then goto  Dlg_CheckCustomerKeys; else goto  Dlg_SdWelcome; endif; endif; if CheckSQl2005ProOrExpressInstalled()==FALSE then MessageBox("Please install Microsoft SQL Server 2005 before running Rapid EPM setup.",SEVERE); InformFinish(); endif;

//GetInstallDB Dlg_SdAskInstallDB: nResult= GetServerNameAndInstallDB(); if (nResult = BACK) goto Dlg_GetDBOptions; if bvDataDB|| bvSystemDB then svSQLDataRoot=GetRealSqlInstallPath(svServer,svUserName,svPassword,"master",SUPPORTDIR,"sqlPath.txt"); if CheckIf2DBExist(DB_NAME)==TRUE then SdShowMsg("Install Database ['"+DB_NAME+"']" ,TRUE); InstallDB(DB_NAME,svServer,svUserName,svPassword); SdShowMsg("",FALSE); endif; endif;

szNumName  = "ServerName"; szNumValue =svServer; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

szNumName  = "RapidEPMDBName"; szNumValue =DB_NAME; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

szNumName  = "Version"; szNumValue =@PRODUCT_VERSION; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

szNumName  = "KeyValueVersion"; szNumValue =nKeyValue; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

endif; endwhile; // Close the file. CloseFile (nFileHandle); // Remove the list from memory. ListDestroy (listID);

Dlg_SdAskDestPath2: szTitle = ""; szMsg = ""; if (nSetupType = CUSTOM) then nResult = SdAskDestPath2( szTitle, szMsg, szDir ); TARGETDIR = szDir; endif; if (nResult = BACK) then if(bCheckYesNoDB=TRUE) then goto  Dlg_SdAskInstallDB; else goto  Dlg_SdWelcome; endif; endif; Dlg_SdFeatureTree: if ((nResult = BACK) && (nSetupType != CUSTOM)) goto Dlg_SdAskDestPath2; szTitle = ""; szMsg = ""; szFeatures = ""; nLevel = 2; if (nSetupType = CUSTOM) then nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, szFeatures, nLevel ); if (nResult = BACK) goto Dlg_SdAskDestPath2; endif; Dlg_ObjDialogs: nResult = ShowObjWizardPages( nResult ); if (nResult = BACK) goto Dlg_SdFeatureTree; Dlg_SdStartCopy2: szTitle = ""; szMsg = ""; nResult = SdStartCopy2( szTitle, szMsg ); if (nResult = BACK) goto Dlg_ObjDialogs; // Added in 11.0 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_FIRSTUI ) ); FeatureSetTarget( MEDIA , "<EZLICENSE>" , EZLICENSE ); return 0; end;

//=========================================================================== // //  Topic:    GetInstallPath // //  Description: // //  My Name    : // //===========================================================================

function STRING GetInstallPath() string szIgnore, szMsg; number nResult; BOOL bOpt1, bOpt2; STRING szKey, szNumName, szNumValue, svNumValue, szTitle; NUMBER nType, nSize, nvType, nvSize; NUMBER nLocation; STRING  svSubStr; STRING RESULT; STRING szPathRegistry; begin

RESULT=""; szNumName  = "Path"; szNumValue = ""; nType      = REGDB_STRING; nSize      = -1; szPathRegistry ="\\"+@PRODUCT_NAME+"\\"; szKey = "SOFTWARE\\ACOM Solutions\\" + @PRODUCT_NAME ;

RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then else RESULT= svNumValue;

endif; return RESULT;

end;

//=========================================================================== // //  Topic:    CheckApplicationRunning // //  Description: // //  My Name    : // //=========================================================================== function BOOL CheckApplicationRunning(svNumValue,install) string szIgnore, szMsg; number nResult; BOOL bOpt1, bOpt2; NUMBER nType, nSize, nvType, nvSize; NUMBER nLocation; STRING  svSubStr,svExistingVersion; NUMBER resultDeleteFormLib; STRING svResult; BOOL FormsLibExist; STRING szRuningFile; STRING szMsg1,szMsg2,szMsg3,szMsg4;

begin szRuningFile="\\"+@SETUP_FILE+""; if FindFile(svNumValue,@SETUP_FILE,svResult)==0 then VerGetFileVersion(svNumValue^@SETUP_FILE,svExistingVersion); if VerCompare ( svExistingVersion, "2.6.0.0", VERSION )==LESS_THAN then bvLaunchLicense=TRUE; endif;

CopyFile(svNumValue+"\\EZRetrieve.exe",svNumValue+"\\EZDesigner4001.exe"); if DeleteFile(svNumValue+"\\EZRetrieve.exe")!=0 then DeleteFile(svNumValue+"\\EZDesigner4001.exe"); if install==FALSE then szMsg1="Uninstalling process cannot be continued because"; szMsg2=" "+@PRODUCT_NAME + " "; szMsg3="is in use. Please close it and try again."; szMsg4=szMsg1+szMsg2+szMsg3; MessageBox(szMsg4,WARNING); abort; return FALSE; else szMsg1=" "+@PRODUCT_NAME + " "; szMsg2="cannot be upgraded because it is in use. Please close it and try again."; MessageBox(szMsg1+szMsg2,WARNING); abort; return FALSE; endif; else endif; else bvLaunchLicense=TRUE; endif; end; //=========================================================================== // //  Topic:    CheckSQLInstallAndInstall // //  Description: // //  My Name    : // //=========================================================================== function int CheckSQLInstallAndInstall() STRING szMsg, szText1, szText2, szText3, szText4, szText5; STRING szText6, szText7, szText8, szText9; NUMBER nReturn, nValue,  nvCheck1, nvCheck2, nvCheck3, nvCheck4; NUMBER nvCheck5, nvCheck6, nvCheck7, nvCheck8, nvCheck9; INT nLocation; begin if  CheckSQl2005ProOrExpressInstalled()==TRUE then GetOptions: szMsg = "Database Server Choice"; szText1 = "Use an existing SQL Server"; szText2 = "Install SQL Server 2005 Express now"; nvCheck1 = TRUE; nvCheck2 = FALSE; nValue = EXCLUSIVE; nReturn=AskOptions (nValue, szMsg, szText1, nvCheck1, szText2, nvCheck2); if(nReturn==BACK) then return nReturn; else endif;

if nvCheck1==TRUE then endif; if nvCheck2==TRUE then nReturn=GetInstanceNamePassAndInstall(); if  nReturn=BACK then goto GetOptions; endif; endif; else if AskYesNo("Microsoft SQL Server 2005 Express was not installed in your system. \n\nWould you like to install it now?",YES)==YES  then nReturn=GetInstanceNamePassAndInstall(); if  nReturn=BACK then return nReturn; endif; else endif;

endif; end; //=========================================================================== // //  Topic:    CheckSQLInstallAndInstall // //  Description: // //  My Name    : // //===========================================================================

function BOOL CheckSQl2005ProOrExpressInstalled() BOOL result; begin

RegDBSetDefaultRoot(HKEY_LOCAL_MACHINE); result=FALSE; if RegDBKeyExist ("SOFTWARE\\Microsoft\\Microsoft SQL Server\\90")==1 then result=TRUE; //MessageBox("co",WARNING); else result=FALSE; // MessageBox("khong",WARNING); endif; return result; end; //=========================================================================== // //  Topic:    GetServerNameAndInstallDB // //  Description: // //  My Name    : // //=========================================================================== function NUMBER GetServerNameAndInstallDB() NUMBER nResult; STRING svUpperDBName1,svUpperDBName2; begin Dlg_AskDBInformation: if svServer="" then svServer=GetServerName(); endif; if svUserName="" then svUserName="sa"; endif; if DB_NAME="" then DB_NAME="DatabaseName"; endif; if installEXpressGoodOrBad then svServer=svServer; endif; nResult = Get_Server_UserName_Pass("Database Login Information",bvInstallDB,svServer, svUserName,svPassword,DB_NAME,DB_NAME,bvDataDB,bvSystemDB); if nResult != BACK then if bvInstallDB =TRUE then SdShowMsg("",FALSE); SdShowMsg("Testing database connection and permissions for " + svUserName + "...",TRUE); if !TestDB(svServer,svUserName,svPassword) then MessageBox("Cannot connect to "+svServer+". \n\nPlease check the entered information again.", WARNING); SdShowMsg("",FALSE); goto Dlg_AskDBInformation; endif; SdShowMsg("",FALSE); StrToUpper(svUpperDBName1,DB_NAME); StrReplace(svUpperDBName1," ","",0); StrReplace(svUpperDBName2," ","",0); if(bvDataDB==TRUE && svUpperDBName1=="") || ( bvSystemDB==TRUE && svUpperDBName1=="") then MessageBox("Please enter Database Name.", WARNING); goto Dlg_AskDBInformation; endif; if  StrCompare(svUpperDBName1,svUpperDBName2)=0 && bvDataDB==TRUE && bvSystemDB==TRUE then MessageBox("Data Database Name must be different from System Database Name.\n\nPlease try again.", WARNING); goto Dlg_AskDBInformation; endif; endif; endif; return nResult; end; //=========================================================================== // //  Topic:    GetRealSqlInstallPath // //  Description: // //  My Name    : // //===========================================================================

function STRING GetRealSqlInstallPath(svServer0,svUser1,svPass2,dbName,svFilePath,svFileName) string para; STRING  szFileName, szPath, szText, svLine,fullPath,svResult; NUMBER  nFlag, nFileHandle; LIST   listID; begin

svResult=""; fullPath= svFilePath^ svFileName; para="\"" + svServer0 + "\" \""+svUser1+"\" \""+svPass2+"\" \""+dbName+"\" \""+fullPath+"\""; if LaunchAppAndWait (SUPPORTDIR ^ "GetSqlPath.exe", para, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN)==0 then //MessageBox("thanh cong",WARNING); else //MessageBox("fail",WARNING); endif; OpenFileMode (FILE_MODE_NORMAL); if OpenFile (nFileHandle, svFilePath, svFileName)==0 then //MessageBox("moduoc"+svFilePath+svFileName,WARNING); else //MessageBox("khong moduoc"+svFilePath+svFileName,WARNING);

endif; while (GetLine (nFileHandle, svLine) = 0) // MessageBox(svLine,WARNING); svResult=svLine  ; endwhile; // Close the file. CloseFile (nFileHandle); DeleteFile(fullPath); return svLine; end; //=========================================================================== // //  Topic:    CheckIf2DBExist // //  Description: // //  My Name    : // //=========================================================================== function BOOL CheckIf2DBExist(svDBName1) NUMBER nResult; begin if GetRealSqlInstallPath(svServer,svUserName,svPassword,DB_NAME,SUPPORTDIR,"sqlPath.txt")!="" then

nResult = MessageBox( "Database [" + svDBName1 + "] has already existed, do you want to delete?", MB_YESNO ); if (nResult == IDYES ) then SdShowMsg("Delete Database ["+svDBName1+"]",TRUE); if( Delete1DB(svDBName1) <0) then SdShowMsg("",FALSE); return  FALSE; endif; SdShowMsg("",FALSE); else return FALSE; endif; else if (Is (FILE_EXISTS, svSQLDataRoot + svDBName1  + "_Log.ldf" )==TRUE) then DeleteFile(svSQLDataRoot + svDBName1  + "_Log.ldf"); DeleteFile(svSQLDataRoot + svDBName1  + ".mdf"); return FALSE; endif; endif; return TRUE; end; //=========================================================================== // //  Topic:    Delete1DB // //  Description: // //  My Name    : // //=========================================================================== function Delete1DB(svDBName) STRING szPath, szFileName; NUMBER nResult, nvFileHandle, nvType, nvSize, nvIndex; begin // Write the batch file to the TEMP directory szPath = WINDISK + "\\"; szFileName = "deleteDB.sql"; CreateFile(nvFileHandle, szPath, szFileName); WriteLine(nvFileHandle, "USE master"); WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'" + svDBName + "')"); WriteLine(nvFileHandle, "DROP DATABASE [" + svDBName + "]"); WriteLine(nvFileHandle, "GO"); CloseFile(nvFileHandle); // Run the batch file nResult = ExcuteSqlFile(szPath  + szFileName); // Check if database was installed if(nResult < 0 ) then MessageBox("Cannot drop the database ["+svDBName+"] because it is currently in use.", SEVERE); endif; SdShowMsg("",FALSE); return nResult; end; //=========================================================================== // //  Topic:    ExcuteSqlFile // //  Description: // //  My Name    : // //=========================================================================== function NUMBER ExcuteSqlFile(fileSql) STRING szPath, szFileName; NUMBER nResult, nvFileHandle; begin szPath = WINDISK + "\\"; szFileName = "excutesql.bat"; CreateFile(nvFileHandle, szPath, szFileName);

WriteLine(nvFileHandle, "@echo off"); WriteLine(nvFileHandle, "echo This window will close itself when it is finished."); WriteLine(nvFileHandle, ""); WriteLine(nvFileHandle, "echo Excute sql"); WriteLine(nvFileHandle, GetPathToOsql()+" -b -n -U " + svUserName + " -P " + svPassword + " -i \"" + fileSql + "\" -S " + svServer); WriteLine(nvFileHandle, "if errorlevel 1 goto pauseError"); WriteLine(nvFileHandle, "echo All Done"); WriteLine(nvFileHandle, "exit"); WriteLine(nvFileHandle, ":pauseError"); WriteLine(nvFileHandle, "echo DB Error > \"" + szPath ^ "\\deleteDB.fail\""); // WriteLine(nvFileHandle, "pause"); CloseFile(nvFileHandle); //thuc hien chay file bat nResult = LaunchAppAndWait(szPath ^ szFileName, "", WAIT |LAAW_OPTION_HIDDEN ); // Check if database was installed if( Is (FILE_EXISTS, szPath ^ "deleteDB.fail")==TRUE ) then CleanTempFiles(); return -1; endif; return 0; end; //=========================================================================== // //  Topic:    GetPathToOsql // //  Description: // //  My Name    : // //=========================================================================== function string GetPathToOsql() STRING szKey, szNumName, szNumValue, svNumValue; STRING result; NUMBER    nResult, nType, nMediaFlags,nSize; begin

nType      = REGDB_STRING; nSize      = -1; result=""; result=GetRegistryValue("SOFTWARE\\Microsoft\\Microsoft SQL Server\\90\\Tools\\ClientSetup","Path",nType,nSize); result="\""    +  result+"\\osql.exe\""; return result;

end; //=========================================================================== // //  Topic:    InstallDB // //  Description: // //  My Name    : // //=========================================================================== function InstallDB(svDBName1,DB_SERVER_NAME,DB_ADMIN_USER,DB_ADMIN_PASS) STRING szPath, svFileName; STRING svSQLDataLogRoot; NUMBER nResult, nvFileHandle, nvType, nvSize; STRING strDescription1,strDescription2; STRING svRapidEPMData,svEZConnectExpressSystem; STRING archive_folder,error_folder,receive_folder,send_folder,setup_folder; INT nLocation; NUMBER nType; STRING sz_Data,sz_Log; begin

CleanTempFiles(); svSQLDataRoot=GetRealSqlInstallPath(DB_SERVER_NAME,DB_ADMIN_USER,DB_ADMIN_PASS,"master",SUPPORTDIR,"sqlPath.txt"); szPath = WINDISK + "\\"; if(szPath="") then MessageBox("Installed DB failed on Server Other!",WARNING); InformFinish(); endif; VarSave(SRCTARGETDIR); //svRapidEPMData="Lib_EDI"; svRapidEPMData=@DATABASE_NAME; SRCDIR =  SRCDIR + "\\DB"; TARGETDIR = WINDISK + "\\"; if bvDataDB then nResult = XCopyFile(svRapidEPMData+".mdf", "", COMP_NORMAL); // In 7.0 its ok to szPath as target... if nResult < 0 then MessageBox("DB could not be copied from the DB subdirectory of the installation media.", SEVERE); CleanTempFiles(); //abort; InformFinish(); endif; endif; VarRestore(SRCTARGETDIR); svFileName = "installdb.bat"; //GetSqlDataRootExpress(svSQLDataRoot); if StrCompare(svSQLDataRoot, "") == 0 then MessageBox("You do not have the database server components\ninstalled on this machine. You will need to\ninstall these before your can install the database.", SEVERE); CleanTempFiles(); //abort; InformFinish(); endif; svSQLDataRoot=svSQLDataRoot; if Is(FILE_EXISTS,svSQLDataRoot)!=TRUE then CreateDir(svSQLDataRoot); endif;

svSQLDataLogRoot=svSQLDataRoot; svSQLDataLogRoot=svSQLDataLogRoot+"\\"; svSQLDataRoot=svSQLDataRoot+"\\";

svFileName = "installdb.sql"; OpenFileMode(FILE_MODE_NORMAL); nResult = CreateFile(nvFileHandle, szPath, svFileName); if nResult < 0 then MessageBox("SQL script not created!", SEVERE); CleanTempFiles(); //abort; InformFinish(); endif; sz_Data=@DATABASE_DATA; sz_Log=@DATABASE_LOG; WriteLine(nvFileHandle, "USE master"); if bvDataDB then WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "RESTORE DATABASE " + svDBName1); WriteLine(nvFileHandle, "FROM DISK = '" + szPath + "\\"+svRapidEPMData+".mdf'"); //WriteLine(nvFileHandle, "WITH  MOVE '" + svRapidEPMData + "' TO '" + svSQLDataRoot + svDBName1 + ".mdf', "); //WriteLine(nvFileHandle, "MOVE '" + svRapidEPMData + "_Log' TO '" + svSQLDataLogRoot +  svDBName1 + "_Log.ldf'"); //WriteLine(nvFileHandle, "WITH  MOVE '" + "aa" + "' TO '" + svSQLDataRoot + svDBName1 + ".mdf', "); //WriteLine(nvFileHandle, "MOVE '" + "aa_Log" + "' TO '" + svSQLDataLogRoot +  svDBName1 + "_Log.ldf'"); WriteLine(nvFileHandle, "WITH  MOVE '" + "Lib_EDI_Data" + "' TO '" + svSQLDataRoot + svDBName1 + ".mdf', "); WriteLine(nvFileHandle, "MOVE '" + "Lib_EDI_Log" + "' TO '" + svSQLDataLogRoot +  svDBName1 + "_Log.ldf'"); //WriteLine(nvFileHandle, "    MOVE '" + svRapidEPMData + "_Data' TO '" + SQLPATH + "\\Data\\" + svDBName1  + "_Data.mdf', "); //WriteLine(nvFileHandle, "    MOVE '" + svRapidEPMData + "_Log' TO '" + SQLPATH  + "\\Data\\" + svDBName1  + "_Log.ldf'"); //WriteLine(nvFileHandle, "WITH  MOVE '" + sz_Data + "' TO '" + svSQLDataRoot + svDBName1 + ".mdf', "); //WriteLine(nvFileHandle, "MOVE '" + sz_Log + "' TO '" + svSQLDataLogRoot +  svDBName1 + "_Log.ldf'");

WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "USE " + svDBName1); WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "EXEC sp_updatestats"); WriteLine(nvFileHandle, "GO"); endif; WriteLine(nvFileHandle, "USE master"); WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "if (select count(*) from sys.syslogins where name = '"+ DEFAULTUSERLOGIN + "') < 1"); WriteLine(nvFileHandle, "BEGIN"); WriteLine(nvFileHandle, "    EXEC sp_addlogin '" + DEFAULTUSERLOGIN + "', '"+ DEFAULTPASSLOGIN + "', '" + svDBName1 + "', NULL, NULL"); WriteLine(nvFileHandle, "END"); WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "USE " + svDBName1); WriteLine(nvFileHandle, "EXEC sp_grantdbaccess '"+ DEFAULTUSERLOGIN +"'"); WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "EXEC sp_addrolemember 'db_owner', '" + DEFAULTUSERLOGIN + "'"); WriteLine(nvFileHandle, "GO"); CloseFile(nvFileHandle); svFileName = "installdb.bat"; OpenFileMode(FILE_MODE_NORMAL); nResult = CreateFile(nvFileHandle, szPath, svFileName); if nResult < 0 then MessageBox("Batch not created!", SEVERE); CleanTempFiles(); InformFinish(); endif; WriteLine(nvFileHandle, "@echo off"); WriteLine(nvFileHandle, "echo This window will close itself when it is finished."); WriteLine(nvFileHandle, ""); WriteLine(nvFileHandle, "echo Creating Database"); WriteLine(nvFileHandle, GetPathToOsql() + " -b -n -U " + DB_ADMIN_USER + " -P " + DB_ADMIN_PASS + " -i \"" + szPath + "\\installdb.sql\" -S " + DB_SERVER_NAME); WriteLine(nvFileHandle, "if errorlevel 1 goto pauseError"); WriteLine(nvFileHandle, "echo All Done"); WriteLine(nvFileHandle, "exit"); WriteLine(nvFileHandle, ":pauseError"); WriteLine(nvFileHandle, "echo DB Error > " + szPath + "installdb.fail"); WriteLine(nvFileHandle, ""); WriteLine(nvFileHandle, "echo The database could not be created.  Please see error message above"); WriteLine(nvFileHandle, "echo to address the problem."); //WriteLine(nvFileHandle, "pause"); WriteLine(nvFileHandle, "exit"); CloseFile(nvFileHandle); // Run the batch file nResult = LaunchAppAndWait(szPath ^ svFileName, "", WAIT |LAAW_OPTION_HIDDEN ); if( Is (FILE_EXISTS, szPath ^ "installdb.fail") ==TRUE) then MessageBox("DB Installation failed.\n\nPlease make sure that SQL Server 2005 is installed and that\nyou have the correct database connection information.\n\nAfter you have done that, please try the installation again.", SEVERE); CleanTempFiles(); InformFinish(); endif; CleanTempFiles(); return nResult; end; //=========================================================================== // //  Topic:    CleanTempFiles // //  Description: // //  My Name    : // //=========================================================================== function CleanTempFiles() STRING szFileName; begin

szFileName=@DATABASE_NAME; VarSave(SRCTARGETDIR); TARGETDIR = WINDISK + "\\"; DeleteFile(szFileName+".mdf"); DeleteFile("RapidEPM.mdf"); DeleteFile("installdb.sql"); DeleteFile("installdb.bat"); DeleteFile("installdb.fail"); DeleteFile("excutesql.bat"); DeleteFile("deleteDB.fail"); DeleteFile("aspnet_regiis.exe"); DeleteFile("deleteDB.sql"); DeleteFile("YServer.txt"); DeleteFile("LogfileEncode.txt"); //DeleteFile("updater.sql"); VarRestore(SRCTARGETDIR);

end; //=========================================================================== // //  Topic:    GetInstanceNamePassAndInstall // //  Description: // //  My Name    : // //=========================================================================== function INT GetInstanceNamePassAndInstall() INT nReturn; begin

Start_GetDBInfo: nReturn=AskCreateNewLogin(); if nReturn==BACK then return nReturn; endif; if  sqlExpressInstanceName="" || svPassword2="" then MessageBox("Please input Server and Admin Password.",WARNING); goto  Start_GetDBInfo; endif; if( InstalledSQLExpress(sqlExpressInstanceName)==TRUE) then MessageBox("The " + sqlExpressInstanceName + " instance already exists on SQLExpress. \n\nPlease choose another instance of SQLExpress to continue with this install.", WARNING); goto Start_GetDBInfo; endif; InsSQLExpress(sqlExpressInstanceName,svPassword2) ; CheckInstallSuccess(sqlExpressInstanceName); end; //////////////////////////////////////////////////////////////////////////// // //  Function: InsSQLExpress // //  Purpose: Install new instance SQLExpress /////////////////////////////////////////////////////////////////////////////// function BOOL InsSQLExpress(SQLInstallName,DB_ADMIN_PASS) STRING szPath, szFileNameIni, szFileNameBat, svResult, svNewResult; NUMBER nResult, nvFileHandle, nvIdx; NUMBER nvType, nvSize; STRING svSQLDataRoot,DB_SERVER_NAME,svPathSQL; STRING fullPath,fultPathWinlater;

begin

OpenFileMode (FILE_MODE_APPEND); szPath = WINDISK + "\\"; szFileNameIni = "installsQLExpress.ini"; //szFileNameBat = "installSQLExpress.bat"; if svPathSQL =="" then svPathSQL = PROGRAMFILES +"\\Microsoft SQL Server"; endif; if ! Is (PATH_EXISTS, svPathSQL)  then CreateDir(svPathSQL); endif; if CreateFile(nvFileHandle, szPath, szFileNameIni) == 0 then WriteLine(nvFileHandle, "[Options]"); WriteLine(nvFileHandle, "USERNAME=User"); WriteLine(nvFileHandle, "COMPANYNAME=Company"); WriteLine(nvFileHandle, "INSTALLSQLDIR=" + svPathSQL); WriteLine(nvFileHandle, "ADDLOCAL=ALL"); WriteLine(nvFileHandle, "INSTANCENAME="+SQLInstallName); WriteLine(nvFileHandle, "SECURITYMODE=SQL"); WriteLine(nvFileHandle, "DISABLENETWORKPROTOCOLS=0"); WriteLine(nvFileHandle, "SAPWD="+DB_ADMIN_PASS); CloseFile(nvFileHandle); endif; fullPath =  SRCDIR + "\\SQL2005 Express\\SQLEXPR32.EXE"; if Is(FILE_EXISTS, fullPath)==FALSE then MessageBox("File SQLEXPR32.EXE not exist on 'SQL2005 Express' folder.", WARNING); //abort; InformFinish(); endif; nResult=LaunchAppAndWait(fullPath ,"/qb /settings " +  WINDISK ^ szFileNameIni, WAIT|LAAW_OPTION_HIDDEN); DeleteFile(WINDISK ^ szFileNameIni); return nResult; end; //=========================================================================== // //  Topic:    CheckInstallSuccess // //  Description: // //  My Name    : // //===========================================================================

function  CheckInstallSuccess(SQLInstallName) NUMBER  nResult, nvType; NUMBER  nLevel; NUMBER  nvSize, nSetupType; NUMBER  nId; STRING  szTitle, szMsg, szMsg1, szMsg2; STRING  szOpt1, szOpt2, szLicenseFile; STRING  szName, szCompany; STRING  szTargetPath; STRING  svDir; STRING  szFeatures, szTargetdir; STRING  szId; BOOL bvCheck1, bvCheck2, bvNewInstanceSQL; NUMBER bvOpt1 , bvOpt2;

begin if RegDBKeyExist("SOFTWARE\\Microsoft\\Microsoft SQL Server\\"+ SQLInstallName)==1 then installEXpressGoodOrBad=TRUE; else MessageBox("SQL Server 2005 Express install did not successfully",SEVERE); //abort; InformFinish(); endif; end; //=========================================================================== // //  Topic:    InformFinish // //  Description: // //  My Name    : // //=========================================================================== function InformFinish() NUMBER  nResult, nLevel, nSize, nSetupType; STRING  szTitle, szMsg, szOpt1, szOpt2, szLicenseFile; STRING  szName, szCompany, szTargetPath, szDir, szFeatures; BOOL    bLicenseAccepted; STRING   szProductName; STRING   szMsg1, szMsg2; BOOL     bvOpt1, bvOpt2; NUMBER   nReturn; NUMBER     nType, nMediaFlags; STRING    szIgnore,svOldPath; STRING szKey, szNumName, szNumValue, svNumValue;

begin szTitle =@PRODUCT_NAME + " Installation is not Completed."; szMsg1  =@PRODUCT_NAME + " Installation is not Completed. Please setup again." ; szMsg2  = "Click Finish to complete %P Setup."; SdFinish (szTitle, szMsg1, szMsg2, szOpt1, szOpt2, bvOpt1, bvOpt2); abort;

end; //=========================================================================== // //  Topic:    InstalledSQLExpress // //  Description: // //  My Name    : // //=========================================================================== function InstalledSQLExpress(IntantSQLName) NUMBER nvType, nvSize; STRING svSQLDataRoot; begin RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); if RegDBKeyExist("SOFTWARE\\Microsoft\\Microsoft SQL Server\\"+IntantSQLName)==1 then return TRUE; else return FALSE; endif; end; //=========================================================================== // //  Topic:    AskCreateNewLogin // //  Description: // //  My Name    : // //=========================================================================== function NUMBER AskCreateNewLogin() NUMBER nResult; begin GetLoginNameAndPass: nResult=Get_UserName_Pass("",bvCreateNewLogin,sqlExpressInstanceName,svPassword2,svConfirmPassword2); if nResult==BACK then return BACK;

endif;

if nResult!=BACK then if bvCreateNewLogin==TRUE then if svPassword2!=svConfirmPassword2 then MessageBox("The password and confirm password fields do not match.",WARNING); goto GetLoginNameAndPass;

endif; endif; else

endif; return nResult; end; //=========================================================================== // //  Topic:    GetServerName // //  Description: // //  My Name    : // //=========================================================================== function STRING GetServerName() NUMBER nvResult, nResult, nvType, nvSize, nvFileHandle; STRING svServerName; begin

svServerName=""; RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); nvType = REGDB_STRING; //GetSqlDataRootExpress(svSQLDataRoot); RegDBGetKeyValueEx ("SYSTEM\\CurrentControlSet\\Control\\ComputerName\\ActiveComputerName", "ComputerName", nvType, svServerName, nvSize); if bIsSQLExpress then svServerName = svServerName + "\\SQLExpress";

endif; return svServerName; end; //=========================================================================== // //  Topic:    TestDB // //  Description: // //  My Name    : // //=========================================================================== function TestDB(svServer,svUserName,svPassword) STRING svFileName, szPath; NUMBER nvFileHandle, nResult, nvType, nvSize; begin

CleanTempFiles(); szPath = WINDISK + "\\"; RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); nvType = REGDB_STRING; // Create / Drop database SQL script svFileName = "installdb.sql"; OpenFileMode(FILE_MODE_NORMAL); nResult = CreateFile(nvFileHandle, szPath, svFileName); if nResult < 0 then MessageBox("SQL script not created!", SEVERE); CleanTempFiles(); //abort; InformFinish(); endif; WriteLine(nvFileHandle, "USE master"); WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "CREATE DATABASE EZPMTESTME123"); WriteLine(nvFileHandle, "GO"); WriteLine(nvFileHandle, "DROP DATABASE EZPMTESTME123"); WriteLine(nvFileHandle, "GO"); CloseFile(nvFileHandle);

// Call SQL and detect error or not svFileName = "installdb.bat"; OpenFileMode(FILE_MODE_NORMAL); nResult = CreateFile(nvFileHandle, szPath, svFileName); if nResult < 0 then MessageBox("Batch not created!", SEVERE); CleanTempFiles(); //abort; InformFinish(); endif; WriteLine(nvFileHandle, "@echo off"); WriteLine(nvFileHandle, "echo Testing database connection and permissions for " + svUserName + "..."); WriteLine(nvFileHandle, GetPathToOsql()+" -b -n -U " + svUserName + " -P " + svPassword + " -i \"" + szPath ^ "installdb.sql\" -S " + svServer); WriteLine(nvFileHandle, "if errorlevel 1 goto pauseError"); WriteLine(nvFileHandle, "exit"); // Fatal! WriteLine(nvFileHandle, ":pauseError"); WriteLine(nvFileHandle, "echo Connection/Permission Error > " + szPath + "installdb.fail"); WriteLine(nvFileHandle, "exit"); CloseFile(nvFileHandle); // Run the batch file nResult = LaunchAppAndWait(szPath ^ svFileName, "",WAIT|LAAW_OPTION_HIDDEN); if( Is (FILE_EXISTS, szPath ^ "installdb.fail") ==TRUE) then CleanTempFiles(); return FALSE; endif; CleanTempFiles(); return TRUE; end; //=========================================================================== // //  Topic:    DeleteAndCopyFile // //  Description: // //  My Name    : // //===========================================================================

function DeleteAndCopyFile() NUMBER nResult; STRING fullParth; STRING pathToAsp; NUMBER  nvFileHandle; STRING  svLine,svPath,svUseDatabase ; STRING svDatabaseName,szInsertLine,szPathCopy; STRING   xCopyFile,svDisk; begin

DeleteFile(SUPPORTDIR+"\\GetSqlPath.exe"); DeleteFile(SUPPORTDIR+"\\UpdateWebconfig.exe"); DeleteFile(SUPPORTDIR+"\\aspnet_regiis.exe"); DeleteFile(SUPPORTDIR+"\\UpdateDatabase.exe"); DeleteFile(SUPPORTDIR+"\\LinkWeb.exe"); DeleteFile(SUPPORTDIR+"\\RapidEPMWebconfig.exe"); DeleteFile(SUPPORTDIR+"\\Uninstall.exe"); DeleteFile(SUPPORTDIR+"\\EditBeforWebconfig.exe"); DeleteFile(SUPPORTDIR+"\\RapidBitmap.bmp"); DeleteFile(SUPPORTDIR+"\\RemoveWebconfig.exe"); DeleteFile(SUPPORTDIR+"\\AssignPool.vbs"); DeleteFile(SUPPORTDIR+"\\GetProcessIDTest.exe"); DeleteFile(SUPPORTDIR+"\\Encode_Decode.exe");

xCopyFile=SRCDIR+"sqlscript\\updater.sql"; svDisk=WINDISK +"\\"; CopyFile(xCopyFile ,svDisk^"updater.sql"); //After Copy File in others into SUPPORTDIR XCopyFile(SRCDIR+"\\others\\*.*",SUPPORTDIR+"\\*.*",COMP_NORMAL); end; /////////////////////////////////////////////////////////////////////////////// // // Function: CheckCustomerKey // //  Purpose: This function checks the registry, CD file called CustomerKey.txt //           and then prompts user if not found. //

/////////////////////////////////////////////////////////////////////////////// function CheckCustomerKey() NUMBER nvType, nvSize, nFileHandle, nResult; STRING szTitle, szMsg; begin

RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); nvType = REGDB_STRING; // Check registry if StrCompare(CUSTOMER_KEY,"") = 0 then RegDBGetKeyValueEx(@LICENSE_BASE, "CustomerKey", nvType, CUSTOMER_KEY, nvSize); if StrLength(CUSTOMER_KEY) > 0 && StrLength(CUSTOMER_KEY) != 36 then MessageBox("The Customer Key in the registry was not 36 characters" , WARNING); CUSTOMER_KEY = ""; elseif StrLength(CUSTOMER_KEY) == 36 then bByPassCustomerKey = TRUE; endif; // Check file if StrCompare(CUSTOMER_KEY,"") = 0 && Is(FILE_EXISTS, SRCDIR ^ "CustomerKey.txt") then OpenFileMode(FILE_MODE_BINARYREADONLY); OpenFile(nFileHandle, SRCDIR + "\\", "CustomerKey.txt"); ReadBytes(nFileHandle, CUSTOMER_KEY, 0, 36); CloseFile(nFileHandle);

if StrLength(CUSTOMER_KEY) != 36 then MessageBox("The Customer Key \"" + CUSTOMER_KEY + "\" in CustomerKey.txt on the CD was not 36 characters" , WARNING); CUSTOMER_KEY = ""; else bByPassCustomerKey = TRUE; endif; endif; elseif StrLength(CUSTOMER_KEY) != 36 then CUSTOMER_KEY = ""; endif; szTitle  = ""; szMsg    = "What is your Customer Key?\nIf you are not sure, please contact ACOM support.\nTel: (800)217-2266  Email: support@acom.com"; nResult=GetCustomerKey( szTitle,szMsg,CUSTOMER_KEY,"Customer Key Information","Please enter your Customer Key information."); if (nResult = BACK) then return BACK; endif; return NEXT; end; /////////////////////////////////////////////////////////////////////////////// // // Function: CreateRegistryKey // //  Purpose: This function checks the registry, CD file called CustomerKey.txt //           and then prompts user if not found. // /////////////////////////////////////////////////////////////////////////////// function CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,blnWillBeDeleteWhenUninstall) STRING szMsg; begin

RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); if blnWillBeDeleteWhenUninstall=FALSE then Disable(LOGGING); endif; if (RegDBCreateKeyEx (szKey, "") < 0) then else if (RegDBSetKeyValueEx (szKey, szNumName, nType, szNumValue, nSize) < 0) then else endif; endif; if blnWillBeDeleteWhenUninstall=FALSE then Enable(LOGGING); endif; end; /////////////////////////////////////////////////////////////////////////////// // // Function: CreateRegistryKey // //  Purpose: This function checks the registry, CD file called CustomerKey.txt //           and then prompts user if not found. // /////////////////////////////////////////////////////////////////////////////// function STRING GetRegistryValue(szKey,szNumName,nvType,nvSize) STRING RESULT,svNumValue; begin

RESULT=""; RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then else RESULT= svNumValue;

endif; return RESULT;

end; /////////////////////////////////////////////////////////////////////////////// // // Function: CreateRegistryKey // //  Purpose: This function checks the registry, CD file called CustomerKey.txt //           and then prompts user if not found. ///////////////////////////////////////////////////////////////////////////////

function CreateShortCut(szProgramFolder,szItemName,szProgram,szWorkingDir,willBeDeleteWhenUninstall) STRING  szCommandLine; STRING  szIconPath, szShortCutKey, szParam; STRING szKey, szNumName, szNumValue, svNumValue, szMsg; NUMBER  nIcon, nFlag, nFlag2, nResult; begin LongPathToQuote (szProgram, TRUE); szCommandLine = szProgram; //szWorkingDir  = TARGETDIR; szIconPath    = ""; nIcon         = 0; szShortCutKey = ""; nFlag         = NULL; if willBeDeleteWhenUninstall==TRUE then

nResult = AddFolderIcon (szProgramFolder, szItemName, szCommandLine, szWorkingDir, szIconPath, nIcon, szShortCutKey, nFlag); else Disable(LOGGING); nResult = AddFolderIcon (szProgramFolder, szItemName, szCommandLine, szWorkingDir, szIconPath, nIcon, szShortCutKey, nFlag);

Enable(LOGGING); endif; end; //=========================================================================== // //  Topic:    DeleteDB_SQLServer // //  Description: // //  My Name    : // //===========================================================================

function DeleteDB_SQLServer() STRING szPath, szFileName; NUMBER nResult, nvFileHandle, nvType, nvSize, nvIndex; begin

// Write the batch file to the TEMP directory szPath = WINDISK + "\\"; szFileName = "deleteDB.sql"; CreateFile(nvFileHandle, szPath, szFileName); WriteLine(nvFileHandle, "USE master"); WriteLine(nvFileHandle, "GO"); if DB_NAME!="" && bvDataDB==TRUE then WriteLine(nvFileHandle, "IF EXISTS (SELECT name FROM master.dbo.sysdatabases WHERE name = N'" + DB_NAME + "')"); WriteLine(nvFileHandle, "DROP DATABASE [" + DB_NAME + "]"); WriteLine(nvFileHandle, "GO"); endif; CloseFile(nvFileHandle); // Run the batch file nResult = ExcuteSqlFile(szPath  + szFileName); // Check if database was installed if(nResult < 0 ) then MessageBox("Cannot drop the database because it is currently in use.", SEVERE); endif; SdShowMsg("",FALSE); return nResult; end;

//--------------------------------------------------------------------------- // OnMaintUIBefore // // Maintenance UI Sequence - Before Move Data // // The OnMaintUIBefore event is called by OnShowUI when the setup is // running in maintenance mode. By default this event displays UI that // allows the end user to add or remove features, repair currently // installed features or uninstall the application. // // Note: This event will not be called automatically in a // program...endprogram style setup. //--------------------------------------------------------------------------- function OnMaintUIBefore() NUMBER    nResult, nType, nMediaFlags,nSize; STRING    szTitle, szMsg, szIgnore; STRING szPathPrograms; STRING szKey, szNumName, szNumValue, svNumValue,szValueData; STRING    svOldPath,svPAT; NUMBER  nFlag, nFileHandle; LIST   listID; STRING svPath,svFile; BOOL bResult; STRING svDir; STRING szDir; STRING    nKeyValue,svEdit1; STRING path; STRING szID; STRING svUpperDBName1,svUpperDBName2; begin

nType = REMOVEALL; //Initialize SQL OnSQLServerInitializeMaint();

// Beginning of UI Sequence Dlg_Start:

// Added in Version 9.5 - Support for REMOVEONLY option. if( !REMOVEONLY ) then // In standard mode show maintenance dialog Disable( BACKBUTTON ); nType = SdWelcomeMaint( szTitle, szMsg, nType ); //nType = SdRemoveAndRepair( szTitle, szMsg, nType );

Enable( BACKBUTTON ); nResult = NEXT; else // Hide the initial progress dialog as otherwise the user can // click on it, and hide the MessageBox. Disable( DIALOGCACHE );

// In RemoveOnly mode, set to remove. nType = REMOVEALL; endif;

// Show Uninstall Confirmation Dialog if ( nType = REMOVEALL ) then nResult = MessageBox( SdLoadString( IFX_MAINTUI_MSG ), MB_YESNO ); if (nResult != IDYES ) then

if( REMOVEONLY ) then // In REMOVEONLY mode, abort the setup. abort; else // In non-REMOVEONLY mode, redisplay the previous dialog. goto Dlg_Start; endif;

endif; endif;

Dlg_SdFeatureTree: if ( nType = MODIFY ) then szTitle = ""; szMsg = SdLoadString( SD_STR_COMPONENT_MAINT_MSG ); nResult = SdFeatureTree( szTitle, szMsg, TARGETDIR, "", -1 ); if ( nResult = BACK ) goto Dlg_Start; endif;

Dlg_ObjDialogs: nResult = ShowObjWizardPages( nResult ); if ( ( nResult = BACK ) && ( nType != MODIFY ) ) goto Dlg_Start; if ( ( nResult = BACK ) && ( nType = MODIFY ) ) goto Dlg_SdFeatureTree;

switch(nType)

case REMOVEALL:

CheckRuningProcess(); //svPAT=GetInstallPath(); //CheckApplicationRunning(svPAT,FALSE); // Ensure that all previously installed features are removed // for media that supports updating. MediaGetData( MEDIA, MEDIA_FIELD_MEDIA_FLAGS, nMediaFlags, szIgnore );

if( nMediaFlags & MEDIA_FLAG_UPDATEMODE_SUPPORTED ) then FeatureRemoveAllInMediaAndLog(); else FeatureRemoveAllInMedia(); endif;

// Added in 11.0 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REMOVEALL ) ); case REPAIR: CheckRuningProcess(); listID = ListCreate (STRINGLIST); // Set the file mode to normal. OpenFileMode (FILE_MODE_NORMAL); // Open the file for editing. svPath=SRCDIR; svFile="Config.ini"; OpenFile (nFileHandle, svPath, svFile); while (GetLine (nFileHandle, svLine) = 0) ListAddString (listID, svLine, AFTER); StrSub ( svReadLine, svLine, 25,40); StrSub(svReadLineNumber,svLine,0,2); if(svReadLineNumber=="10" && svReadLine== " YES") then //MessageBox("vao chua ??",WARNING); //    Dialog Select install Dlg_SelectInstallDataAndDB: svDir   = TARGETDIR; szTitle = @PRODUCT_NAME+" "+"Feature Selection"; szMsg   = "Select the features you want to update on your computer."; Dlg_ChoseTaget:

nResult=SdAskOptions (SDASKOPTSTITLE, SDASKOPTSMSG1, SDASKOPTSMSG2,"", FEATURE, NONEXCLUSIVE);

if(nResult==BACK) then goto Dlg_Start: endif;

bvInstallData = FeatureIsItemSelected(MEDIA, "Update Project"); bvInstallDB = FeatureIsItemSelected(MEDIA, "Update  Project Database"); if  bvInstallData==FALSE && bvInstallDB==FALSE then MessageBox("No feature selected. You have to select at least one feature to be installed into your PC. ",SEVERE); goto Dlg_ChoseTaget; endif; if bvInstallData==TRUE then //MessageBox(" Bat dau update Du lieu.",WARNING);

if( ADDREMOVE ) then FeatureUpdate( "" );  // disk1 features. else FeatureReinstall();  // Reinstall all previously installed features. endif;

// Added in 11.0 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) ); endif; if bvInstallDB==TRUE then if svServer="" then svServer=GetServerName(); endif; if svUserName="" then svUserName="sa"; endif; DBName=GetRegistryValue2("SOFTWARE\\ACOM Solutions\\EDIViewer","RapidEPMDBName"); if DBName="" then DBName="DatabaseName"; endif; //MessageBox(" hay Code updater script cho data base di.",WARNING); Dlg_UpdaterDB: nResult = Get_Server_UserName_Pass("Database Login Information",bvInstallDB,svServer, svUserName,svPassword,DBName,DB_NAME,bvDataDB,bvSystemDB); if nResult != BACK then if bvInstallDB =TRUE then SdShowMsg("",FALSE); SdShowMsg("Testing database connection and permissions for " + svUserName + "...",TRUE); if !TestDB(svServer,svUserName,svPassword) then //MessageBox("The Server/Username/Password you supplied cannot be used to create a database.\n\nPlease try again.", WARNING); MessageBox("Cannot connect to "+svServer+". \n\nPlease check the entered information again.", WARNING);

SdShowMsg("",FALSE); goto Dlg_UpdaterDB: abort; endif; SdShowMsg("",FALSE); StrToUpper(svUpperDBName1,DBName); StrReplace(svUpperDBName1," ","",0); StrReplace(svUpperDBName2," ","",0); if(bvDataDB==TRUE && svUpperDBName1=="") || ( bvSystemDB==TRUE && svUpperDBName1=="") then MessageBox("Please enter Database Name.", WARNING); goto Dlg_UpdaterDB; endif; if  StrCompare(svUpperDBName1,svUpperDBName2)=0 && bvDataDB==TRUE && bvSystemDB==TRUE then MessageBox("Data Database Name must be different from System Database Name.\n\nPlease try again.", WARNING); goto Dlg_UpdaterDB; endif; ActionUpdater();    //Dua hµm thuc thi script vao day /*Dlg_SQLServer:

nResult = OnSQLServerInitialize( nResult ); if( nResult = BACK ) goto Dlg_SdFeatureTree;*/

endif; else goto Dlg_SelectInstallDataAndDB; //abort; endif; endif; endif; endwhile;

// Close the file. CloseFile (nFileHandle); // Remove the list from memory. ListDestroy (listID); //svPAT=GetInstallPath(); //CheckApplicationRunning(svPAT,FALSE); if( ADDREMOVE ) then FeatureUpdate( "" );  // disk1 features. else FeatureReinstall();  // Reinstall all previously installed features. endif;

// Added in 11.0 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_REPAIR ) ); // szNumName  = "Path"; szNumValue = TARGETDIR; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

szNumName  = "ServerName"; szNumValue =svServer; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

szNumName  = "RapidEPMDBName"; szNumValue =DB_NAME; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

szNumName  = "Version"; szNumValue =@PRODUCT_VERSION; nType      = REGDB_STRING; nSize      = -1; szKey = "SOFTWARE\\ACOM Solutions\\"+@PRODUCT_NAME; CreateRegistryKey(szKey, szNumName, nType, szNumValue, nSize,TRUE);

szPathPrograms="\\"+@PRODUCT_NAME+"\\"; CreateShortCut(FOLDER_DESKTOP,@PRODUCT_NAME,TARGETDIR^@SETUP_FILE,TARGETDIR,TRUE); //CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME+"\\EPM\\Link localhost EPM",EZLICENSE^"LinkWeb.exe",EZLICENSE,TRUE); CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME +szPathPrograms+ @PRODUCT_NAME,TARGETDIR^@SETUP_FILE,TARGETDIR,TRUE); //CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME+"\\EPM\\Config EPM",EZLICENSE^"RapidEPMWebconfig.exe",EZLICENSE,TRUE); //CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME +szPathPrograms+ @PRODUCT_NAME,TARGETDIR^"EZconfig.exe",TARGETDIR,TRUE); CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME +szPathPrograms+"\\EZconfig",TARGETDIR^"EZconfig.exe",TARGETDIR,TRUE);

case MODIFY:

// Added in 11.0 - Set appropriate StatusEx static text. SetStatusExStaticText( SdLoadString( IDS_IFX_STATUSEX_STATICTEXT_MAINTUI_MODIFY ) );

endswitch;

end; //=========================================================================== // //  Topic:    GetRegistryValue2 // //  Description: // //  My Name    : // //=========================================================================== function STRING GetRegistryValue2(szKey,szNumName) STRING RESULT,svNumValue; NUMBER  nvType, nvSize; begin

RESULT=""; RegDBSetDefaultRoot (HKEY_LOCAL_MACHINE); if (RegDBGetKeyValueEx (szKey, szNumName, nvType, svNumValue, nvSize) < 0) then else RESULT= svNumValue;

endif; return RESULT;

end; //=========================================================================== // //  Topic:    ActionUpdater // //  Description: // //  My Name    : // //=========================================================================== function ActionUpdater()

STRING svlogfiles,svsqlfile,sverrorfile; STRING xCopy; STRING    szFFile,szDDir; NUMBER nvFileHandle; STRING svPath,svFolder,xCopyFile,svDisk,svReplaceDB; STRING svLogFileName,svfileName; begin

svFolder=WINDISK+"\\Log File"; DeleteDir(svFolder,ALLCONTENTS); szDDir=WINDISK +"\\Log File";

//CreateFile (nvFileHandle, EXAMPLE_DIR, EXAMPLE_FILE); CreateDir (svPath ^ szDDir);

svLogFileName=WINDISK+"\\LogFile.txt";

svfileName=WINDISK+"\\updater.sql";

sverrorfile=WINDISK+"\\CheckFile.txt";

svReplaceDB="RapidEPM123456789";

//UpdateDatabase(svServer,svUserName,svPassword,RapidEPMDBName,svlogfiles,svsqlfile ,sverrorfile,svReplaceDB); UpdaterScript(svServer,DBName,svUserName,svPassword,svfileName,svLogFileName ); xCopy=WINDISK + "\\";

// MessageBox(svFolder,WARNING);

//CopyFile(xcopy ^ "Web.config",TARGETDIR ^"Web.config"); CopyFile(xCopy ^ "LogFile.txt",svFolder^"LogFile.txt"); CopyFile(xCopy ^ "updater.sql",svFolder^"updater.sql"); CopyFile(xCopy ^ "CheckFile.txt",svFolder^"CheckFile.txt");

DeleteFile(xCopy ^ "LogFile.txt"); DeleteFile(xCopy ^ "updater.sql"); DeleteFile(xCopy ^ "CheckFile.txt"); end; //=========================================================================== // //  Topic:    UpdaterScript // //  Description: // //  My Name    : // //=========================================================================== function STRING UpdaterScript(svServerName,dbName,svUserName,svPassword,svfileName,svlogFileName)

STRING  szFileName, szPath, szText, svLine,fullPath,svResult; NUMBER  nFlag, nFileHandle; LIST   listID; STRING para,svDisk,xCopyFile; begin //para="\"" + svServerName + "\" \""+svUserName+"\" \""+svPassword+"\" \""+dbName+"\" \""+svfileName+"\" \""+svlogFileName+"\ \""; para="\"" + svServerName + "\" \""+dbName+"\" \""+svUserName+"\" \""+svPassword+"\" \""+svfileName+"\" \""+svlogFileName+"\ \"";

xCopyFile=SRCDIR+"others\\TestDB.exe"; svDisk=WINDISK +"\\"; CopyFile(xCopyFile ,svDisk^"TestDB.exe"); if LaunchAppAndWait (WINDISK ^ "TestDB.exe", para, LAAW_OPTION_WAIT|LAAW_OPTION_HIDDEN)<0 then //MessageBox(" khong thanh cong"+"\n"+para,WARNING); else //MessageBox("thanh cong roi" +"\n" + para,WARNING); endif; DeleteFile(svDisk ^ "TestDB.exe"); end; //--------------------------------------------------------------------------- // OnFirstUIAfter // // First Install UI Sequence - After Move Data // // The OnFirstUIAfter event called by OnShowUI after the file transfer // of the setup when the setup is running in first install mode. By default // this event displays UI that informs the end user that the setup has been // completed successfully. // // Note: This event will not be called automatically in a // program...endprogram style setup. //--------------------------------------------------------------------------- function OnFirstUIAfter() STRING szTitle, szMsg1, szMsg2, szOpt1, szOpt2; NUMBER bvOpt1, bvOpt2; NUMBER bShowUpdateServiceDlg; STRING szPathPrograms; begin

ShowObjWizardPages(NEXT);

szTitle = ""; szMsg1 = ""; szMsg2 = ""; szOpt1 = ""; szOpt2 = ""; bvOpt1   = FALSE; bvOpt2   = FALSE; szPathPrograms="\\"+@PRODUCT_NAME+"\\"; CreateShortCut(FOLDER_DESKTOP,@PRODUCT_NAME,TARGETDIR^@SETUP_FILE,TARGETDIR,TRUE); //CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME+"\\EPM\\Link localhost EPM",EZLICENSE^"LinkWeb.exe",EZLICENSE,TRUE); CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME +szPathPrograms+ @PRODUCT_NAME,TARGETDIR^@SETUP_FILE,TARGETDIR,TRUE); //CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME+"\\EPM\\Config EPM",EZLICENSE^"RapidEPMWebconfig.exe",EZLICENSE,TRUE); CreateShortCut(FOLDER_PROGRAMS,@COMPANY_NAME +szPathPrograms+"\\EZconfig",TARGETDIR^"EZconfig.exe",TARGETDIR,TRUE);

// Set this to true if you have the update service enabled, and if you want to check for updates. // Note: the ISUS Starter Edition does not support checking for updates programatically.  So, // only set this to true if you have at least the ISUS Professional Edition. bShowUpdateServiceDlg = FALSE; if ( BATCH_INSTALL ) then SdFinishReboot ( szTitle , szMsg1 , SYS_BOOTMACHINE , szMsg2 , 0 ); else

// If the update service is enabled, show finish dialog that includes // update check option. if( bShowUpdateServiceDlg && ( ENABLED_ISERVICES & SERVICE_ISUPDATE ) ) then if( SdFinishUpdateEx( szTitle, szMsg1, szMsg2, szOpt1, szOpt2, TRUE ) ) then if( MODE != SILENTMODE ) then UpdateServiceCheckForUpdates( "", FALSE ); endif; endif; else SdFinish ( szTitle , szMsg1 , szMsg2 , szOpt1 , szOpt2 , bvOpt1 , bvOpt2 ); endif; endif; end;
Create your own website, free on WordPress.com.Create your own website.
Start free