<compilation debug="true" /><customErrors mode="Off" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>using WorkflowGen.My.Data;protected void Page_Load(object sender, EventArgs e)
{
// Call the main function
RemoteProcessLaunch();
}
/// <summary>
/// RemoteProcessLaunch
/// </summary>
private void RemoteProcessLaunch()
{
...
}<appSettings>
<add key="WorkflowGenLaunchUrl" value="https://localhost/wfgen/requests/new?remote=true"/>
<add key="WorkflowGenUsername" value="wfgen_admin"/>
<add key="WorkflowgenUserPassword" value="Advantys123"/>
<add key="WorkflowGenUserDomain" value=""/>
<add key="ProcessName" value="SDK_CS_REMOTE_LAUNCH"/>
<add key="Language" value="en-US"/>
<add key="RequesterUsername" value="wfgen_admin"/>
<add key="Test" value="Y"/>
</appSettings><appSettings>
<add key="WorkflowGenLaunchUrl" value="https://localhost/wfgen/show.aspx?QUERY=PROCESS_START_REMOTE"/>
<add key="WorkflowGenUsername" value="wfgen_admin"/>
<add key="WorkflowgenUserPassword" value="Advantys123"/>
<add key="WorkflowGenUserDomain" value=""/>
<add key="ProcessName" value="SDK_CS_REMOTE_LAUNCH"/>
<add key="Language" value="en-US"/>
<add key="RequesterUsername" value="wfgen_admin"/>
<add key="Test" value="Y"/>
</appSettings>// Variables Declaration
System.Net.HttpWebRequest httpWebReq = null; // Http web request object
System.Net.HttpWebResponse httpWebResp = null; // Http web response object
System.Net.NetworkCredential myCred = null; // To hold credential information
System.Net.CredentialCache myCache = null; // credential cache
System.Text.ASCIIEncoding encoding = null; // for encoding
System.IO.Stream myStream = null; // To get request data
System.IO.StreamReader myReader = null; // To read response stream
string respCode; // string used to get response status code
string workflowContextXml; // string to get the xml context data
string appUrl = string.Empty; // string used to Approval URL
string postData = null; // string used to put the data for request
string response = null; // string used to display response
byte[] buffer; // byte used to get the encoded data
// Get values into Configuration constants
// Get the Launch URL
workflowGenLaunchUrl = ConfigurationManager.AppSettings["WorkflowGenLaunchUrl"].ToString();
// Get the WorkflowGen user username
workflowGenUsername = ConfigurationManager.AppSettings["WorkflowGenUsername"].ToString();
// Get the WorkflowGen user password
workflowgenUserPassword = ConfigurationManager.AppSettings["WorkflowgenUserPassword"].ToString();
// Get the WorkflowGen user domain
workflowGenUserDomain = ConfigurationManager.AppSettings["WorkflowGenUserDomain"].ToString();
// Get the process name
processName = ConfigurationManager.AppSettings["ProcessName"].ToString();
// Get the culture information
language = ConfigurationManager.AppSettings["Language"].ToString();
// Get the requester name, default is wfgen_admin
requesterUsername = ConfigurationManager.AppSettings["RequesterUsername"].ToString();
// Get the launch test mode status
test = Convert.ToChar(ConfigurationManager.AppSettings["Test"].ToString());// Create a new WorkflowGen object for context parameters
WorkflowGen.My.Data.ContextParameters myWorkflowContextParameters = new
WorkflowGen.My.Data.ContextParameters();
// Create a new AMOUNT context parameter object
WorkflowGen.My.Data.ContextParameter contextParamAmount = new
WorkflowGen.My.Data.ContextParameter();
// Set the parameter name
contextParamAmount.Name = "AMOUNT";
// Set the direction for the parameter
contextParamAmount.Direction = WorkflowGen.My.Data.ContextParameter.Directions.In;
// Set parameter type as double
contextParamAmount.Type = typeof(double);
// Set parameter value
contextParamAmount.Value = Convert.ToDouble(10000);
// Adding the parameter to the context parameters
myWorkflowContextParameters.Add(contextParamAmount);
// Updating the context parameters
myWorkflowContextParameters.Update();
WorkflowGen.My.Data.ContextParameter contextParamName = new
WorkflowGen.My.Data.ContextParameter();
// Set the parameter name
contextParamName.Name = "NAME";
// Set the direction for the parameter
contextParamName.Direction = WorkflowGen.My.Data.ContextParameter.Directions.In;
// Set parameter type as string
contextParamName.Type = typeof(string);
// Set parameter value
contextParamName.Value = "SDK SAMPLE TEXT";
// Adding the parameter to the context parameters
myWorkflowContextParameters.Add(contextParamName);
// Updating the context parameters
myWorkflowContextParameters.Update();
// Get the xml context data into variable
workflowContextXml = myWorkflowContextParameters.GetXml();// Call WorkflowGen to instantiate the process
// Prepare the URL
appUrl = workflowGenLaunchUrl + "&l=" + language + "&process=" + processName + "&requester_username=" + requesterUsername + "&test=" + test;
// Submit the parameters
myCred = new System.Net.NetworkCredential(workflowGenUsername,workflowgenUserPassword, workflowGenUserDomain);
myCache = new System.Net.CredentialCache();
myCache.Add(new Uri(workflowGenLaunchUrl), "Basic", myCred);
// Prepare a request
httpWebReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(appUrl);
httpWebReq.Method = "POST";
// Set authentication information
httpWebReq.Credentials = myCache;
// Set CONTEXT content
postData = "CONTEXT=" + HttpUtility.UrlEncode(workflowContextXml.ToString());
encoding = new System.Text.ASCIIEncoding();
buffer = encoding.GetBytes(postData);
// Set the content type of the data being posted.
httpWebReq.ContentType = "application/x-www-form-urlencoded";
// Set the content length of the string being posted.
httpWebReq.ContentLength = postData.Length;
// Send the CONTEXT
myStream = httpWebReq.GetRequestStream();
myStream.Write(buffer, 0, buffer.Length);
// Close the Stream object.
myStream.Close();// Try block to handle exception
try
{
// Check the WorkflowGen response status
httpWebResp = (System.Net.HttpWebResponse)httpWebReq.GetResponse();
}
// Catch the exception
catch (WebException e)
{
// Display the error message
Response.Write(e.ToString());
return;
}
respCode = "OK"; // response code variable
// Check the response status code is OK
if (respCode != httpWebResp.StatusCode.ToString())
{
// Display the Error details
Response.Write("Error:" + httpWebResp.StatusCode);
}
else
{
// Gets the stream associated with the response
httpWebResp = (System.Net.HttpWebResponse)httpWebReq.GetResponse();
myReader = new System.IO.StreamReader(httpWebResp.GetResponseStream());
response = myReader.ReadToEnd();
httpWebResp.Close();
// Display response message
Response.Write(response);
}