For more information about C# Library API Reference, refer to "C# Library API Reference".
See "Using the C# program"Please for more information)
Both libraries are in the References property "Local Copy" to "True" should be set.
using System;
(Omitted)
// Specify the C# Library namespace to using directive
using Appresso.DataSpider.Service;
public class AppFabricTriggerTest
{
(Omitted)
public void ExecuteDataSpiserService ()
{
/ / AppFabricTriggerService instantiation
AppFabricTriggerService service = new AppFabricTriggerService (
"ServiceNamespace", / / Service Namespace (Service Namespace) specification
"ServicePath", / / Service path (Service Path) specification
"defaultIssuer", / / Default Issuer (Default Issuer) specification
"defaultKey"); / / Default Key (Default Key) specification
// Set parameters to pass to string script input variables "string_in"
string string_in = "Input string";
service.PutParam("string_in", string_in);
// Set parameters to pass to integer script input variables "int_in"
int int_in = 200;
service.PutParam("int_in", int_in);
// Set parameters to pass to Boolean script input variables "boolean_in"
bool boolean_in = True;
service.PutParam("boolean_in", boolean_in);
// Call Execute method, fire the trigger and get ExecutionResponse
ExecutionResponse response = service.Execute();
// Get the exit status from ExecutionResponse
int exitStatus = response.ExitStatus;
//Get whether the process was successful from ExecutionResponse
bool succeeded = response.Succeeded;
if (succeeded)
{
// If the operation was successful
// Get Dictionary type instance with information of script output variables by Results property of ExecutionResponse .
Dictionary<string, object> results = response.Results;
//Get value from String type script output variable "string_out"
string string_out = (string )results["string_out"];
//Get value from integer type script output variable "int_out"
int int_out = (int)results["int_out"];
//Get value from Boolean type script output variable "boolean_out"
bool boolean_out = (bool)results["boolean_out"];
\\\( Omit the process of using the retrieved values) \\\
}
else
{
// If the operation fails
//Get the ExecutionFailure instance with error information from Failure property of ExecutionResponse
ExecutionFailure failure = response.Failure;
/ Get the error type
string failureType = faillure.Type;
// Get the error message
string failureMessage = faillure.Message;
// Get the error details
string failureMessage = faillure.Message;
\\\( Omit the process of using the retrieved error info) \\\
}
}
(Omitted)
}
| Script input variable type | Corresponding C# type | Remarks |
|---|---|---|
| String | string | |
| Integer | int | |
| Decimal | decimal | |
| Date/Time | System.DateTime | The value less than Ms digit is truncated. |
| Boolean | bool | |
| Binary | byte[] | |
| XML | System.Xml.XmlDocument |
| Type of script output variable | Corresponding C# type | Remarks |
|---|---|---|
| String | string | |
| Integer | int | |
| Decimal | decimal | |
| Date/Time | System.DateTime | |
| Boolean | bool | |
| Binary | byte[] | |
| XML | System.Xml.XmlDocument |
| Exception Name | Causes | Solution |
|---|---|---|
| System.IdentityModel.Tokens.SecurityTokenException
The token provider was unable to provide a security token. |
Azure Service Bus failed to connect with the service. | Check Service Namespace specified at AppFabricTriggerService. |
| System.ServiceModel.EndpointNotFoundException
Message could not be created: NotFound, No service is hosted at the specified address. |
Azure Service Bus service could not be found. | Check the following.
|
| System.IdentityModel.Tokens.SecurityTokenException
The token provider was unable to provide a security token. Error:Code:401:SubCode:T2001:Detail:The issuer does not exist, or the secret or signature is invalid. |
Azure Service Bus Service authentication failed. | Check Default Issuer and the Default Key specified at AppFabricTriggerService. |
| System.TimeoutException
Message could not be retrieved: NoContent, No message available within the specified timeout. |
Azure Service Bus failed to receive messages from the trigger. | Check the following.
|