Table of Contents

Class LabelPrintDefinitionBase

Namespace
Acuit.Pinpoint.Workstation.LabelPrinting
Assembly
Acuit.Pinpoint.Workstation.Interfaces.dll

A base class to simplify creating ILabelPrintDefinition implementations.

public abstract class LabelPrintDefinitionBase : ILabelPrintDefinition, IInitializableOptions
Inheritance
LabelPrintDefinitionBase
Implements
Inherited Members

Remarks

This class does the following:

  • If there are any options initialization problems, then when a label print is initiated, it will throw an InvalidOperationException with an appropriate message.

Derived classes should do the following:

Constructors

LabelPrintDefinitionBase()

Initializes a new instance of the LabelPrintDefinitionBase class.

protected LabelPrintDefinitionBase()

Methods

DoInitializeOptionsAsync(IOptionsLoader)

Initializes options.

protected virtual Task DoInitializeOptionsAsync(IOptionsLoader optionsLoader)

Parameters

optionsLoader IOptionsLoader

The options loader, which provides services for recording health problems or retrieving files from Acuit Pinpoint Server.

Returns

Task

Remarks

Base classes should override this if they have any options initialization to perform.

See the remarks for InitializeOptionsAsync(IOptionsLoader) for more information.

DoPrintLabelAsync(IDictionary<string, string>, CancellationToken)

Prints a label, after verifying that options are valid.

protected abstract Task DoPrintLabelAsync(IDictionary<string, string> placeholders, CancellationToken cancellationToken = default)

Parameters

placeholders IDictionary<string, string>

The optional placeholders to replace, as a dictionary of items where each key is the placeholder name (without '{' and '}') and each value is the replacement value. This can be null.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task that represents the asynchronous operation.

Exceptions

Exception

The label could not be printed. Actual exception types vary depending on the label definition type.

InitializeOptionsAsync(IOptionsLoader)

Initializes options.

public Task InitializeOptionsAsync(IOptionsLoader optionsLoader)

Parameters

optionsLoader IOptionsLoader

The options loader, which provides services for recording health problems or retrieving files from Acuit Pinpoint Server.

Returns

Task

Remarks

This is typically used to allow options classes to perform further initialization after they have been constructed and initialized from configuration settings, performing tasks like:

  • Retrieving files from Acuit Pinpoint Server.
  • Calculating derived options values.

Any problems that occur while performing this initialization should be handled by calling RecordHealthCheckProblem(HealthCheckResult) of optionsLoader. Any exception thrown from this method will result in an unhandled application exception.

This will be called even if there was a problem binding or validating the options from the configuration settings. The HealthCheckResult property of optionsLoader can be checked to determine whether there were any problems.

Note that this will only be called on the top-level options type (e.g., the type specified via RegisterOptions<TOptions>(string, string) or RegisterDeviceType(Type, DeviceTypeRegistrationOptions)). If any members within the top-level options type member hierarchy also implement this class, then the top-level options type should implement this class and explicitly call the contained member(s) implementation.

This will be called from the main application dispatcher thread.

Exceptions

ArgumentNullException

optionsLoader is null.

PrintLabelAsync(IDictionary<string, string>, CancellationToken)

Prints a label.

public Task PrintLabelAsync(IDictionary<string, string> placeholders, CancellationToken cancellationToken = default)

Parameters

placeholders IDictionary<string, string>

The optional placeholders to replace, as a dictionary of items where each key is the placeholder name (without '{' and '}') and each value is the replacement value. This can be null. UnitPlaceholdersDictionary can be used to generate the default set of placeholders for a unit.

cancellationToken CancellationToken

The cancellation token.

Returns

Task

A task that represents the asynchronous operation.

Remarks

How values from placeholders are used depends on the specific label print definition implementation. Within Zebra ZPL label templates and within Loftware variable values, placeholders should be specified as named items surrounded by '{' and '}'. Each placeholder may occur zero, once, or multiple times.

Exceptions

Exception

The label could not be printed. Actual exception types vary depending on the label definition type.