How do I use the COM API in C#?


THE INFORMATION IN THIS ARTICLE APPLIES TO:
  • EFT Server (All Versions)

QUESTION

How do I use the COM API in C#?

ANSWER

To start using the COM API, you create the SFTPCOMInterface.CIServer class object, and then apply the methods and properties in the object.

Below is the general sequence:

  1. Add a COM library reference to your project (e.g. ‘Solution Explorer’ => Right click on ‘References’ => ‘Add Reference…’ => ‘COM tab’ => ‘SFTPCOMInterface 1.0 Type Library’)

  2. Add a using directive to your sources:

    using SFTPCOMINTERFACELib;

  3. Create the Server object:

    CIServer server = new CIServer();

  4. Connect to EFT Server:

    server.Connect("Server_host", Server_port, "Admin_login", "Admin_Password");

  5. Retrieve/modify sites, commands, users, event rules, and so on.

To deal with Event Action statements (‘If’ statement and ‘Action’ statement), first determine their exact types and cast to it:

ICIEventRule rule = . . .;

if (((ICIEventRuleStatement)rule.Statement(0)).type == EventRuleStatementType.ActionStatement)

{

ICIActionStatement actionStatement = (ICIActionStatement)rule.Statement(0);

// manipulate with action

}

 

else

{

ICIIfStatement ifStatement = (ICIIfStatement)rule.Statement(0);

// manipulate with condition

}

MORE INFORMATION

The COM API does not allow changing Event Rules if the change violates the rule’s integrity (invariant):

  • You cannot use an Action/Condition if it is forbidden for this Event (e.g., the AS2 Send Action is forbidden for On Server Stopped events).

  • You cannot change a Condition’s value/operator if the value/operator is inconsistent with the Condition (e.g., If Server Status Condition does not allow the Is One Of operator).

  • You cannot change an Action’s parameters if new ones are inconsistent (e.g., 'action.Params = PGPParams’ where PGPParams contains an empty file path or inconsistent pair, ‘Operation = Encrypt’ + ‘Empty Key ID list’).