Class MTConnectorClient

Namespace
Datamine.MineTrustConnector.Core
Assembly
Datamine.MineTrustConnector.Core.dll

Client utility class for calling methods exposed via the pipe interface of the MT Connector Service

public static class MTConnectorClient
Inheritance
MTConnectorClient
Inherited Members

Fields

CallingPIDKey

The query parameter used to identify the calling process

public const string CallingPIDKey = "callingPID"

Field Value

string

PollEndpointKey

The query parameter used to provide a local endpoint which will be used by the client to poll for the result of the operation

public const string PollEndpointKey = "pollEndpoint"

Field Value

string

ShowUIKey

The query parameter used to show the UI

public const string ShowUIKey = "showUI"

Field Value

string

StateKey

The query parameter used to pass an optional 'state' object into the function call. When paired with the PollEndpointKey, the pipe server uses this value to tie the poll requests up to the original invocation

public const string StateKey = "state"

Field Value

string

UserSIDKey

The query parameter used to identify the current User SID

public const string UserSIDKey = "userSID"

Field Value

string

Methods

CreateVersion(string, string, bool, ProcessWindowStyle)

Creates a new version of the specified package, capturing all file versions as they currently exist for that package within MineTrust

public static CreateVersionResultCodes CreateVersion(string packageUID, string comment = "", bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

packageUID string

The UID of the package

comment string

The (optional) comment to attach to the created package version.

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

CreateVersionResultCodes

The result code

CreateVersionTask(string, string, bool, ProcessWindowStyle, CancellationToken)

public static Task<CreateVersionResultCodes> CreateVersionTask(string packageUID, string comment = "", bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

packageUID string

The UID of the package

comment string

The (optional) comment to attach to the created package version.

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<CreateVersionResultCodes>

The result code

EnablePackage(string, string, string, bool, ProcessWindowStyle)

Enables the package configuration for the specified package UID for synchronisation on the local machine. A local registration for the specified ServerURL is created if it doesn't already exist

public static EnablePackageResultCodes EnablePackage(string packageUID, string localRoot = "", string serverURL = "", bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

packageUID string

The UID of the package configuration to enable

localRoot string

The LocalRoot to set on the package configuration (ignored if already set)

serverURL string

The URL of the MineTrust Server

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

EnablePackageResultCodes

The result code

EnablePackageTask(string, string, string, bool, ProcessWindowStyle, CancellationToken)

public static Task<EnablePackageResultCodes> EnablePackageTask(string packageUID, string localRoot = "", string serverURL = "", bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

packageUID string

The UID of the package configuration to enable

localRoot string

The LocalRoot to set on the package configuration (ignored if already set)

serverURL string

The URL of the MineTrust Server

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<EnablePackageResultCodes>

The result code

GetLastEvent(LogEvent, LogEvent?)

Gets the event record for the last MineTrust Connector event matching the specified eventId. Optionally checks to see whether the event has occurred since the most recent instance of sinceEventId, returning null if it was not more recent.

public static EventLogRecord? GetLastEvent(LogEvent eventId, LogEvent? sinceEventId = null)

Parameters

eventId LogEvent

The event identifier.

sinceEventId LogEvent?

The since event identifier.

Returns

EventLogRecord

The most recent service event record

LockPackage(string, int, bool, ProcessWindowStyle)

Obtains an exclusive lock on the specified local package. Creates a version marker within MineTrust as a baseline, then performs an exclusive check out of all files within this version

public static LockPackageResultCodes LockPackage(string packageUID, int ownerProcess = 0, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

packageUID string

The UID of the package to be locked

ownerProcess int

The PID of the process which 'owns' this lock. If MT Connector detects that this process no longer exists, then the lock is automatically removed.

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

LockPackageResultCodes

The result code

LockPackageTask(string, int, bool, ProcessWindowStyle, CancellationToken)

public static Task<LockPackageResultCodes> LockPackageTask(string packageUID, int ownerProcess = 0, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

packageUID string

The UID of the package to be locked

ownerProcess int

The PID of the process which 'owns' this lock. If MT Connector detects that this process no longer exists, then the lock is automatically removed.

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<LockPackageResultCodes>

The result code

PrintDiagnostics(bool, ProcessWindowStyle)

Instructs MineTrust Connector to print the MineTrust HTTP Client diagnostic info to its local log file

public static PrintDiagnosticsResultCodes PrintDiagnostics(bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

PrintDiagnosticsResultCodes

The result code

PrintDiagnosticsTask(bool, ProcessWindowStyle, CancellationToken)

public static Task<PrintDiagnosticsResultCodes> PrintDiagnosticsTask(bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<PrintDiagnosticsResultCodes>

The result code

ReceiveFiles(IEnumerable<LocalFileRecord>, FilesReceivedCallback, CancellationToken)

Processes the incoming file records as a set of files to 'receive' from MineTrust. Received files are either located from their corresponding, locally synced package, or are otherwise temporarily synced from MineTrust and passed back as their temporary file locations. File records received in this manner are guaranteed to be populated by their LocalFilePath property, and temporary files may not persist after the callback has been invoked.

public static Task ReceiveFiles(IEnumerable<LocalFileRecord> selection, MTConnectorClient.FilesReceivedCallback filesReceivedCallback, CancellationToken cancel = default)

Parameters

selection IEnumerable<LocalFileRecord>

The selection.

filesReceivedCallback MTConnectorClient.FilesReceivedCallback

The callback which handles the received files.

cancel CancellationToken

The cancellation token.

Returns

Task

RegisterEvents(Action<MTConnectorEvent>, params LogEvent[])

Creates a registration for (optionally) the specified MineTrust Connector event IDs, where the event IDs supplied correspond to members of the LogEvent class. Invokes the specified callback when a matching event is received (subscribes to all Connector events if no event IDs are supplied).

public static MTConnectorEventRegistration RegisterEvents(Action<MTConnectorEvent> callback, params LogEvent[] eventIDs)

Parameters

callback Action<MTConnectorEvent>

The callback.

eventIDs LogEvent[]

The event IDs.

Returns

MTConnectorEventRegistration

The created registration.

RegisterServer(string, bool, ProcessWindowStyle)

Creates a local registration for the server with the specified ServerURL. Initialises the server configuration for this server, using the ServerUID obtained via the REST API

public static RegisterServerResultCodes RegisterServer(string serverURL, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

serverURL string

The URL of the MineTrust Server to register

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

RegisterServerResultCodes

The result code

RegisterServerTask(string, bool, ProcessWindowStyle, CancellationToken)

public static Task<RegisterServerResultCodes> RegisterServerTask(string serverURL, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

serverURL string

The URL of the MineTrust Server to register

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<RegisterServerResultCodes>

The result code

SendFiles(IEnumerable<LocalFileRecord>, PackageSelectionCallback, CancellationToken)

Processes the incoming file records as a set of files to 'send' to MineTrust. Each file to be sent is passed through the packageSelectionCallback which should determine the destination package of that file (null to indicate that the file can be skipped). Sent files are either added to their corresponding, locally synced package, or are otherwise resolved per-destination package to a partial synchronisation filter based on the tag metadata in their original package. This filter is then used to perform a temporary, partial synchronisation of the destination package, to which the respective file(s) are then added. Temporary packages are cleaned up after the operation completes.

public static Task SendFiles(IEnumerable<LocalFileRecord> selection, MTConnectorClient.PackageSelectionCallback packageSelectionCallback, CancellationToken cancel = default)

Parameters

selection IEnumerable<LocalFileRecord>

The selection.

packageSelectionCallback MTConnectorClient.PackageSelectionCallback

The callback which determines the destination package for a given file.

cancel CancellationToken

The cancellation token.

Returns

Task

SyncNow(string, bool, ProcessWindowStyle)

Synchronously invokes an execution cycle for the specified package, returning '0' when it has completed. If an execution cycle is already in flight then this method returns when it completes.

public static SyncNowResultCodes SyncNow(string packageUID, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

packageUID string

The UID of the package

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

SyncNowResultCodes

The result code

SyncNowTask(string, bool, ProcessWindowStyle, CancellationToken)

public static Task<SyncNowResultCodes> SyncNowTask(string packageUID, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

packageUID string

The UID of the package

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<SyncNowResultCodes>

The result code

UnlockPackage(string, bool, bool, ProcessWindowStyle)

Removes the exclusive lock on the specified local package. All files which were checked out as a part of the package lock will be automatically checked in (unless the 'discardChanges' switch is specified)

public static UnlockPackageResultCodes UnlockPackage(string packageUID, bool discardChanges = false, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

packageUID string

The UID of the package to be unlocked

discardChanges bool

Discards all local changes, automatically bringing all local files in line with the latest server copies

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

UnlockPackageResultCodes

The result code

UnlockPackageTask(string, bool, bool, ProcessWindowStyle, CancellationToken)

public static Task<UnlockPackageResultCodes> UnlockPackageTask(string packageUID, bool discardChanges = false, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

packageUID string

The UID of the package to be unlocked

discardChanges bool

Discards all local changes, automatically bringing all local files in line with the latest server copies

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<UnlockPackageResultCodes>

The result code

UpdateLocal(string, string, bool, ProcessWindowStyle)

Instructs MineTrust Connector to force-overwrite the specified local file with the contents of the corresponding server file

public static UpdateLocalResultCodes UpdateLocal(string packageUID, string filePath, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

packageUID string

The UID of the package containing the file

filePath string

The path of the file within the package

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

UpdateLocalResultCodes

The result code

UpdateLocalTask(string, string, bool, ProcessWindowStyle, CancellationToken)

public static Task<UpdateLocalResultCodes> UpdateLocalTask(string packageUID, string filePath, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

packageUID string

The UID of the package containing the file

filePath string

The path of the file within the package

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<UpdateLocalResultCodes>

The result code

UpdateServer(string, string, bool, ProcessWindowStyle)

Instructs MineTrust Connector to force-overwrite the specified server file with the contents of the corresponding local file

public static UpdateServerResultCodes UpdateServer(string packageUID, string filePath, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal)

Parameters

packageUID string

The UID of the package containing the file

filePath string

The path of the file within the package

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

Returns

UpdateServerResultCodes

The result code

UpdateServerTask(string, string, bool, ProcessWindowStyle, CancellationToken)

public static Task<UpdateServerResultCodes> UpdateServerTask(string packageUID, string filePath, bool showUI = false, ProcessWindowStyle windowStyle = ProcessWindowStyle.Normal, CancellationToken cancel = default)

Parameters

packageUID string

The UID of the package containing the file

filePath string

The path of the file within the package

showUI bool

If set to true, debug UI elements (a pop-up spinner / cancellation dialog and a visible console log) will be shown during the downstream function call.

windowStyle ProcessWindowStyle

Used to control the style of the console window in the downstream function call. The default is 'Normal'

cancel CancellationToken

Signals cancellation of the function call. WARNING: Exercise caution when triggering cancellation if windowStyle has a value other than 'Hidden' or showUI is true. Cancelling the task kills the underlying process, which may cause interactive windows to become unresponsive.

Returns

Task<UpdateServerResultCodes>

The result code