The DeploymentManager
object is a scriptable interface to the Project Deployment engine. The DeploymentManager
object provides a collection of methods and properties that enable you to write highly customized scripts to control the deployment process.
For examples of DeploymentManager
Object syntax, see the "Sample deployment script".
CreateFolder: WordBool (read-write)
Boolean. Determins whether the deployment engine creates the missing folders on the target server.
EncryptCFML: WordBool (read-write)
Boolean. Determins whether the deployment engine encrypts all CFML files.
FolderCount: Integer (read-only)
The count of folders associated with the current open project.
ForceLowerCase: WordBool (read-write)
Boolean. Determines whether the deployment engine forces lower-case file names.
IsLocalDeployment: WordBool (read-write)
Boolean. Allows you to perform a local deployment by overriding the assigned deployment server list. Uses the actual deployment pathnames assigned to the folders.
ServerCount: Integer (read-only)
Counts the deployment servers associated with the current open project, including any new servers that were added temporarily using the AddServer
method.
UploadOnlyIfNewer: WordBool (read-write)
Boolean. Determines whether the deployment engine only uploads a file if it has a newer date/time stamp than the target file.
Server login failures result in an automatic cancellation of the deployment.
AddServer(const wsServerName:WideString,ITServerType:Integer);
Temporarily adds a machine-level server to the list of deployment servers. This server does not become part of the project's stored deployment server list, but is added temporarily for custom deployment tasks.
The following ITServerType values are allowed:
1 = FTP
2 = RDS
CheckServerFolders(sServerName: WideString);
Inserted in the generated VBScript/JScript deployment scripts at the appropriate points, the CheckServerFolders method iterates through all of the assigned deployment folders for a project, verifying their existence on the target server (sServerName
). Creates a folder if it does not exist.
Older scripts that do not contain the CheckServerFolders
call will still work. The CreateFolder
property gets passed to the internal CopyFileExtended
call and tells FileProxy
to create the directories that do not exist.
ClearServerList();
Clears the internal list of servers assigned to the project. Use this method to override the default project deployment server list.
CopyFile(const SourceFile: WideString; const TargetFile: WideString): Integer;
Copies the source file to the target file location.
CopyFileExtended(const SourceFile: WideString; const TargetFile: Wide-String; CreateFolder: WordBool; UploadOnlyIfNewer: WordBool; En-cryptCFML: WordBool): Integer;
Boolean. Copies the source file to the target file location and provides additional arguments.
CreateDir(PathName: WideString): Integer;
Directory creation primitive, returns 0 for success, or RDS error code for failure.
FileExists(const wsFileName: WideString): WordBool;
Boolean. Checks to see if a file exists.
GetDeployServer(nServer:integer): WideString;
Returns the name of the server in the server list based on the index nServer
. The internal server list array starts from a zero base.
GetDeployServerStatus(nServer:integer):WideString;
Returns the index of the server in the server list based on the index nServer
. The internal server list array starts from a zero base.
GetDeployTargetName(const wsServerName:Widestring, const wsFolder-Name:Widestring, nFileIndex:Integer): WideString;
Calculates the target deployment file name using the passed-in server name, folder name, and an integer representing the folder file to use. Use this method is mainly when iterating through all the files in a folder. It calculates a server file target path, such as "Rds://localhost/D:/main/images/TestImage.jpg" which you can pass as the second argument to the UploadFile
method.
GetFolderDeployPath(const wsFolderName:String): WideString;
Returns the deployment path of the passed folder name. Use this path in conjunction with the GetDeployServer
and GetFolderName
methods.
GetFolderFileCount(const wsFolderName:String): Integer;
Returns the number of files tracked by the passed-in project folder name.
GetFolderFileExt(const wsFolderName: WideString; nIndex: Integer): Wide-String;
Returns the extension of a folder file based on the passed folder name. For details, see "Project folder names".
GetFolderFileName(const wsFolderName: WideString; nIndex: Integer): WideString;
Returns the name of a folder file based on the passed folder name.
GetFolderName(nFolder:Integer): WideString;
Returns the project folder name of the folder represented by the position index nFolder
. Project folders are numbered consecutively.
GetLastErrorCode(): Integer;
Tests the result of an UploadFile
call by returning last error code as an integer. Use Both GetLastError
methods to programmatically abort a script or provide other forms of rudimentary error handing.
GetLastErrorMessage(): WideString;
Tests the result of an UploadFile
call by returning last associated RDS error message.
IsFolderDeployable(const wsFolderName:WideString): WordBool;
Boolean. Returns the deployment status of the passed folder name. Use this method to skip folders that are designated as Do Not Deploy folders.
OpenProject(const wsProjectName: WideString);
Opens the project specified in the passed OleString
. The project specification must be a fully qualified path to the existing project file.
PathExists(const wsFolderName: WideString): WordBool;
Boolean. Checks to see if a path exists.
SetDeployState(sServerName:WideString,bServerStatus: WordBool);
Boolean. Enables and disables the deployment server specified by sServerName
during deployment. This allows some servers to be turned on or off during the deployment process.
SetLogFileName(sLogFileName: String);
Changes the name of a generated deployment log file. The default name is Deployment.log and its default location is the Visual Tools' main installation directory. Specify a fully qualified path and file name.
SetLogging(bDoLogging: WordBool);
Boolean. Turns logging on and off. This method only has an effect prior to opening a project for deployment.
UploadFile(const wsFile:Widestring, sTargetFile: WideString);
Uploads an individual file to the server. The first OleString
represents the fully qualified path of an individual file to upload. The second OleString
represents the fully qualified target name, such as rds://localhost/main/index.html.
UploadProject(const wsProjectName: WideString);
Uploads an entire project based on the fully qualified project name passed as an OleString
. This triggers the default deployment engine processing loop which iterates through each server assigned to the project, each folder within the project, and uploads all the files contained within each folder. During this process, skips any folders that are configured as Do not deploy folders.
Project folder names are stored in the following format: Project/Folder/Subfolder1[/SubFolder2... SubFolderN], where:
Project represents the name of the project
Folder represents the topmost folder in the project
SubFolder1 represents a folder stored relative to Folder
SubFolder2..SubFolderN represent folders that are stored relative to SubFolder1 in a hierarchical fashion.
To use any of the existing folder-related DeploymentManager
calls, you must pass the fully qualified folder name starting from the project name itself. For example, if you have a project called Project1 and a Main folder that contains an Images folder, and you must retrieve the count of how many files you have in the Images folder, the proper call is:
ICount = GetFolderFileCount("MyProject/Main/Images");
// Returns count of files in Images
// ==================================================================
// This sample script was generated by the Deployment Wizard, // using the Project Element Script Iterator option. // =================================================================== // Project Name: // Date/Time Generated: // =================================================================== // Server List: // // Local Deployment // =================================================================== function Main() { var app = Application; var DeploymentManager = Application.DeploymentManager; var i,j,n, sServerName,sFolderName,sDeployPath,sFromFile,sTargetFile; //================================================================== // Logging Options //================================================================== DeploymentManager.SetLogging(true); DeploymentManager.SetLogFileName("C:\\Program Files\\Macromedia\\ColdFusion Studio 5\\Deployment.log"); //================================================================== // End Logging Options // ================================================================ // ================================================================= // Open the project... //================================================================== DeploymentManager.OpenProject("D:\\Projects\\Release Notes\\version 5\\CFS\\Test1.apf"); //================================================================== // Bypass servers and perform local deployment //================================================================== DeploymentManager.IsLocalDeployment = true; //================================================================== // Project Server Selections // ================================================================= // Project Server DeploymentManager.SetDeployState("",true); //================================================================== // Set Deployment Flags... //================================================================== DeploymentManager.CreateFolder = true; DeploymentManager.UploadOnlyIfNewer = true; DeploymentManager.EncryptCFML = false; DeploymentManager.ForceLowerCase = false; //================================================================== // Iterate through Deployment Servers //================================================================== for (i = 0; i <= DeploymentManager.ServerCount-1; i++) { if (DeploymentManager.GetDeployServerStatus(i)) { sServerName = DeploymentManager.GetDeployServername(i); DeploymentManager.CheckServerFolders(sServerName); // =========================================================== // Iterate through Project Folders //=========================================================== for (j=0; j <= DeploymentManager.FolderCount-1; j++) { sFolderName = DeploymentManager.GetFolderName(j); sDeployPath = DeploymentManager.GetFolderDeployPath(j); //========================================================= // isFolderDeployable reflects the Deployment Options you chose for the folder //========================================================== if (DeploymentManager.IsFolderDeployable(sFolderName)) { // ===================================================== // Iterate through Folder Files //======================================================= for (n=0; n <= DeploymentManager.GetFolderFileCount(sFolderName)-1; n++) { sFromFile = DeploymentManager.GetFolderFileName(sFolderName,n); sTargetFile = DeploymentManager.GetDeployTargetName(sServerName,sFolderName,n); DeploymentManager.UploadFile(sFromFile,sTargetFile); } // n... } // if (IsFolderDeployable(sFolderName))... } // j... } // if GetDeployServerStatus... } // i... DeploymentManager.CloseProject(); }