<< <%SKIN-STRTRANS-SYNTOC%> >> Navigation: Scripting > Data Distribution Scripts |
Content Grabber has built-in support for data distribution by email or to an FTP server when data is exported to file formats such as CSV or Excel. A Data Distribution script can be used to customize data distribution or distribute data to an unsupported media. A Data Distribution script could also be used to run some custom functionality after data has been exported. For example, a script could run a stored procedure in a database after data has been exported to the database.
You can add a Data Distribution script to an agent by clicking the Script button in the Data ribbon menu.
The following example executes a stored procedure in a SQL Server database:
using System;
using Sequentum.ContentGrabber.Api;
public class Script
{
public static bool DeliverData(DataDeliveryArguments args)
{
args.GetDatabaseConnection("test").ExecuteNonQuery("exec updateData");
return true;
}
}
The script must have a static method which has the following signature:
public static bool DeliverData(DataDeliveryArguments args)
The function should return True if it succeeds and False if it fails.
An instance of the DataDeliveryArguments class is provided by Content Grabber and has the following functions and properties:
Property or Function |
Description |
Agent Agent |
The current agent. |
ScriptUtils ScriptUtilities |
A script utility class with helper methods. See Script Utilities for more information. |
string[] Files |
The exported files that need to be distributed. |
bool IsDebug |
True if the agent is running in debug mode. |
void WriteDebug(string debugMessage, DebugMessageType messageType = DebugMessageType.Information) |
Writes log information to the agent log. This method has no effect if agent logging is disabled, or if it is called during design time. |
void WriteDebug(string debugMessage, bool showMessageInDesignMode, DebugMessageType messageType = DebugMessageType.Information) |
Writes log information to the agent log. This method has no effect if agent logging is disabled, or if called during design time. |
void Notify(bool alwaysNotify) |
Triggers notification at the end of an agent run. If alwaysNotify is set to false, this method only triggers a notification if the agent has been configured to send notifications on critical errors. |
void Notify(string message, bool alwaysNotify) |
Triggers notification at the end of an agent run, and adds the message to the notification email. If alwaysNotify is set to false, this method only triggers a notification if the agent has been configured to send notifications on critical errors. |
GlobalDataDictionary GlobalData |
Global data dictionary that can be used to store data that needs to be available in all scripts and after agent restarts.
Input Parameters are also stored in this dictionary. |
IConnection GetDatabaseConnection(string connectionName) |
Returns the specified database connection. The database connection must have been previously defined for the agent or be a shared connection for all agents on the computer. Your script is responsible for opening and closing the connection by calling the OpenDatabase and CloseDatabase methods. |