File Management

A common solution pattern in custom code for EngageIP is moving files.  This includes local file management as well as remote file management tasks.  EngageIP has a File Mover service that runs at a configurable period (15 minutes by default) to move or copy files from one location to another.

There are four types of transports available:

  • FTP

  • SFTP

  • Email

  • Local Folder copy

To use the File Mover Service a custom code file needs to implement the C# IGetFileMoverSettings interface. This interface is used to provide a collection of setting values to the File Mover Service every time it is run.

Consider the example of using FTP to send updates of all generated reports in a folder to a remote document server.

using Logisense.Boss.Logic.FileMover; using System.Collections.Generic; public class ExampleFtpFileMover : IGetFileMoverSettings { public string Name { get {return "ExampleFtpFileMover";} } public List<FileMoverSettings> GetFileMoverSettings() { var settings = new List<FileMoverSettings>(); settings.Add(new FileMoverSettings { SourceSettings = new FileMoverDestinationSettings { MoveType = "FTP", Folder = "e:\\reports" }, DestinationSettings = new FileMoverDestinationSettings { MoveType = "Folder", Address = "reportserverexample.com", CompressionType = "NONE", UserName = "admin", Password = "password", Port = 21, Folder = "/www/ReportServer/Reports", } } ); return settings; } }

There are two main settings that must be added for this example: SourceSettings and DestinationSetings.  In this simple example all the values are hard coded but a real world implementation might use dynamic data pulled from User accounts or Profile Answers.

Interfaces

The following interfaces are available to be used:

  • IGetFileMoverSettings - Used to provide FileMover settings in addition to the FileMover configuration file.

/// <summary> /// Represent the settings for how a files in the source folder should be moved /// </summary> public class FileMoverSetting { public string MoveType { get; set; } public string Folder { get; set; } public string Address { get; set; } public string Password { get; set; } public string UserName { get; set; } public string RSAHostKey { get; set; } public int KeySize { get; set; } public int Port { get; set; } public string FileRegexFilter { get; set; } } public class FileMoverDestinationSettings : FileMoverSetting { public string Subject { get; set; } public string Body { get; set; } public int EmailSettingsOwnerID { get; set; } public string CompressionType { get; set; } public string LocalCopyPath { get; set; } public bool LocalCopyOriginal { get; set; } public bool RenameFileOnMove { get; set; } public bool RenameFileOnLocalCopy { get; set; } public FileMoverDestinationSettings() { RenameFileOnMove = true; RenameFileOnLocalCopy = true; } } public class FileMoverSettings { public bool RemoveFromRemote { get; set; } public string ConfigUniqueIdentifier { get; set; } public FileMoverSetting SourceSettings { get; set; } public FileMoverDestinationSettings DestinationSettings { get; set; } } public interface IGetFileMoverSettings { string Name { get; } List<FileMoverSettings> GetFileMoverSettings();

Â