This sample script demonstrates how to log in to EPC using local or global settings. It returns a boolean value indicating whether the login was successful or not. An additional method returns a list of errors if some settings are not valid.

The Login() method shares the same EPC session for all calls from all users on the server.

Syntax

// Login to EPC using local settings
bool Login(string baseUrl, string userName, string password, out List<‍string‍> errors)
// Login to EPC using global settings
bool Login(out List<‍string‍> errors)

Applicability

This functionality is available anywhere users can write C# code.

Code Samples

var sb = new StringBuilder();
sb.AppendLine("Connect to EPC using local settings");
var settings = bpmAppService.BPMSServices.DomainObjectService.GetFirst<‍Ray.BPMApp.Playground.Model.BPMAPP_Playground_EPCSettings‍>();
if (settings == null)
  sb.AppendLine("EPC settings do not exist");
sb.AppendLine(string.Format("EPC URL: 0 as 1", settings.URL, settings.UserName));
var errors = new List<‍string‍>();
if (bpmAppService.BPMSServices.EPCService.Login(settings.URL, settings.UserName, settings.Password, out errors))
  sb.AppendLine("Successfully!");
else
 {
	sb.AppendLine("Login failed!");
	foreach (var e in errors)
		sb.AppendLine(e);
}
formObject.Log = sb.ToString();

var sb = new System.Text.StringBuilder();
sb.AppendLine("Connect to EPC using global settings");
sb.AppendLine(string.Format("EPC URL: 0 as 1", bpmAppService.BPMSServices.EPCService.EPCGlobalURL, bpmAppService.BPMSServices.EPCService.EPCGlobalUser));
var errors = new List<‍string‍>();
if (bpmAppService.BPMSServices.EPCService.Login(out errors))
	sb.AppendLine("Successfully!");
else
{
	sb.AppendLine("Login failed!");
	foreach (var e in errors)
		sb.AppendLine(e);
}
formObject.Log = sb.ToString();