Files Sync Providers

Hi All,

Acumatica architecture is very extensible and many functions can be extended
just with new class of specific interface/base class.
Import Data Providers, Dashboards, Credit Card Processing, Bank Statement Import and so on. Most of them already described in different sources.

However today I want to show you how to create a custom File Sync Provider. The list of providers that you can see in the Synchronization Types is actually dynamic. That means you can add there more functions without changing base code of Acumatica.

Acumatica File Sync Provider

To add a new File Sync Provider you need to to 2 things:

  1. Create a Provider class that can handle files Export/Import
  2. Extend Combo-box to register provider type

This function can be really userful if you want to have a new file storage type support (like AWS, Asure, Web-Service) or need to embed Encryption/Description in the sync process.

Define Provider

To define the new Provider, you need to implement IFileExchange interface. You can also use BaseFileExchange as a base class that simplifies interface implementation, but interface is till required.
Here you can find minimum required methods if you use BaseFileExchange and IFileExchange;

public class MyFTPProvider: BaseFileExchange, IFileExchange
{
	public String Name { get { return "M"; } }
	public String Code { get { return "My FTP Provider"; } }

	public MyFTPProvider(String login, String password)
		: base(login, password)
	{  }

	public override ExternalFileInfo GetInfo(String path) { ... }
	public override IEnumerable<ExternalFileInfo> ListFiles(String path) { ... }
	public override Stream UploadStream(String path) { ... }
	public override Stream DownloadStream(String path) { ... }
}

The main methods here are:

  • GetInfo – returns the file version (timestamp) for incremental sync
  • ListFiles – gets list of files for folder content sync
  • UploadStream – returns a stream to write file to the remote system
  • DownloadStream – returns a stream to read file from the remote server.

Acumatica automatically discovers types from all loaded dll’s in the application domain based on IFileExchange interface, so you have to use it on your class.

You also can use existing classes in the “PX.Data.Wiki.ExternalFiles” namespace of PX.Data.dll. 4 providers current exist in Acumatica:

  • FTPFileExchange – works with FTP
  • SFTPFileExchange – works with encrypted FTP
  • ShareFileExchange – works with windows shared folders
  • HttpFileExchange – works over Http protocol

Register Provider

Second thing that we need to do is to change an attribute on the Sync Type combo-box on File Sync settings. As for now, Acumatica unfortunately does not do this automatically.

[PXMergeAttributes(Method = MergeMethod.Merge)]
[PXStringListAttribute(new string[]
{
	"M",
	PX.Data.Wiki.ExternalFiles.Codes.ExchangeFTPCode,
	PX.Data.Wiki.ExternalFiles.Codes.ExchangeHTTPCode,
	PX.Data.Wiki.ExternalFiles.Codes.ExchangeShareCode 
},
new string[]
{
	"My FTP Client",
	PX.Data.Wiki.ExternalFiles.Messages.ExchangeFTP, 
	PX.Data.Wiki.ExternalFiles.Messages.ExchangeHTTP,
	PX.Data.Wiki.ExternalFiles.Messages.ExchangeShare
})]

This will add a new value to combo-box from the first image. Basically we just add a combo-box value here, that also can be done thought Automation steps.

Please try to make your value unique. Values that are used in Acumatica: Sharered Foder – “S”; FTP – “F”; SFTP – “C”; HTTP – “H”;

Really hope it helps and have a fast integration!

Leave a Reply

Your email address will not be published. Required fields are marked *