How can I update a file type process data value within a custom WorkflowGen application?

Question

How can I update a file type process data value within a custom WorkflowGen application?

Solution

For file type process data you will be required to specify file reference details. The following sample code updates a File type process data parameter called REQUEST_FILE that is associated to a File type process data.

// Create a new WorkflowGen object for context parameters

WorkflowGen.My.Data.ContextParameters myWorkflowContextParameters = new WorkflowGen.My.Data.ContextParameters();

// instantiate a context parameter for REQUEST_FILE

ContextParameter myContextParam = new ContextParameter();

// Set the parameter name

myContextParam.Name = "REQUEST_FILE";

// Set the direction as OUT for the parameter

myContextParam.Direction = ContextParameter.Directions.Out;

// prepare myContextParam as file reference type 

myContextParam.Type = typeof(ContextFileReference);

// Create an object for the file reference to hold file details

ContextFileReference fileReference = new ContextFileReference();

// prepare a file to send to WFG as the REQUEST_FILE

FileInfo file = new FileInfo([THE_FILE_PHYSICAL_PATH]);

// Add the properties to the file reference object

fileReference.Name = file.Name;

fileReference.Size = file.Length;

fileReference.OriginalPath = file.FullName;

fileReference.DateLastModified = file.LastWriteTimeUtc;

fileReference.ContentType = "application/octet-stream";

fileReference.Path = file.FullName;

// update the context parameter "REQUEST_FILE" with this fileReference object

myContextParam.Value = fileReference;

// Update the Context with new file OUT param values

myWorkflowContextParameters.Update();