DeploymentManager Object

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".

Properties

CreateFolder

Syntax

CreateFolder: WordBool (read-write) 

Description

Boolean. Determins whether the deployment engine creates the missing folders on the target server.

EncryptCFML

Syntax

EncryptCFML: WordBool (read-write) 

Description

Boolean. Determins whether the deployment engine encrypts all CFML files.

FolderCount

Syntax

FolderCount: Integer (read-only) 

Description

The count of folders associated with the current open project.

ForceLowerCase

Syntax

ForceLowerCase: WordBool (read-write) 

Description

Boolean. Determines whether the deployment engine forces lower-case file names.

IsLocalDeployment

Syntax

IsLocalDeployment: WordBool (read-write) 

Description

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

Syntax

ServerCount: Integer (read-only) 

Description

Counts the deployment servers associated with the current open project, including any new servers that were added temporarily using the AddServer method.

UploadOnlyIfNewer

Syntax

UploadOnlyIfNewer: WordBool (read-write) 

Description

Boolean. Determines whether the deployment engine only uploads a file if it has a newer date/time stamp than the target file.

Methods

Server login failures result in an automatic cancellation of the deployment.

AddServer

Syntax

AddServer(const wsServerName:WideString,ITServerType:Integer); 

Description

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

Syntax

CheckServerFolders(sServerName: WideString); 

Description

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

Syntax

ClearServerList(); 

Description

Clears the internal list of servers assigned to the project. Use this method to override the default project deployment server list.

CopyFile

Syntax

CopyFile(const SourceFile: WideString; const TargetFile: WideString): Integer; 

Description

Copies the source file to the target file location.

CopyFileExtended

Syntax

CopyFileExtended(const SourceFile: WideString; const TargetFile: Wide-String; CreateFolder: WordBool; UploadOnlyIfNewer: WordBool; En-cryptCFML: WordBool): Integer; 

Description

Boolean. Copies the source file to the target file location and provides additional arguments.

CreateDir

Syntax

CreateDir(PathName: WideString): Integer; 

Description

Directory creation primitive, returns 0 for success, or RDS error code for failure.

FileExists

Syntax

FileExists(const wsFileName: WideString): WordBool; 

Description

Boolean. Checks to see if a file exists.

GetDeployServerName

Syntax

GetDeployServer(nServer:integer): WideString; 

Description

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

Syntax

GetDeployServerStatus(nServer:integer):WideString; 

Description

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

Syntax

GetDeployTargetName(const wsServerName:Widestring, const wsFolder-Name:Widestring, nFileIndex:Integer): WideString; 

Description

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

Syntax

GetFolderDeployPath(const wsFolderName:String): WideString; 

Description

Returns the deployment path of the passed folder name. Use this path in conjunction with the GetDeployServer and GetFolderName methods.

GetFolderFileCount

Syntax

GetFolderFileCount(const wsFolderName:String): Integer; 

Description

Returns the number of files tracked by the passed-in project folder name.

GetFolderFileExt

Syntax

GetFolderFileExt(const wsFolderName: WideString; nIndex: Integer): Wide-String; 

Description

Returns the extension of a folder file based on the passed folder name. For details, see "Project folder names".

GetFolderFileName

Syntax

GetFolderFileName(const wsFolderName: WideString; nIndex: Integer): WideString; 

Description

Returns the name of a folder file based on the passed folder name.

GetFolderName

Syntax

GetFolderName(nFolder:Integer): WideString; 

Description

Returns the project folder name of the folder represented by the position index nFolder. Project folders are numbered consecutively.

GetLastErrorCode

Syntax

GetLastErrorCode(): Integer;  

Description

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

Syntax

GetLastErrorMessage(): WideString;  

Description

Tests the result of an UploadFile call by returning last associated RDS error message.

IsFolderDeployable

Syntax

IsFolderDeployable(const wsFolderName:WideString): WordBool; 

Description

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

Syntax

OpenProject(const wsProjectName: WideString); 

Description

Opens the project specified in the passed OleString. The project specification must be a fully qualified path to the existing project file.

PathExists

Syntax

PathExists(const wsFolderName: WideString): WordBool; 

Description

Boolean. Checks to see if a path exists.

SetDeployState

Syntax

SetDeployState(sServerName:WideString,bServerStatus: WordBool); 

Description

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

Syntax

SetLogFileName(sLogFileName: String); 

Description

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

Syntax

SetLogging(bDoLogging: WordBool); 

Description

Boolean. Turns logging on and off. This method only has an effect prior to opening a project for deployment.

UploadFile

Syntax

UploadFile(const wsFile:Widestring, sTargetFile: WideString); 

Description

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

Syntax

UploadProject(const wsProjectName: WideString); 

Description

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

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

Sample deployment script

// ==================================================================
// 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();

 
}

Comments