How to implement a blank operation
Blank operations are used by the partners so that they have the potential to add countless additional operations to the POS. They are triggered from the user interface and have supporting parameters. Partners can use blank operations to add functionality and operations that are missing from the LS One POS.
The default functionality of the Blank Operations dll is to display a message saying that the operation has not been implemented.
The text below will go through the implementation of a blank operation step-by-step. In this case, an operation will be created that retrieves the first retail item.
Creating a blank operation in site manager
- Open the Visual Studio solution provided in the development pack.
- Source > Solution.sln
- Configure the solution for the current machine
- Right-click on the SMStartProject project and select Properties.
- Click on the Debug tab.
- Check the Start external program option. And click the … button.
- Navigate to the location where you put the development pack. In the development pack, navigate to the SM Build path and select Site Manager.exe.
Source > SM > Build > Site Manager.exe - Right-click on the SMStartProject and click Set as StartUp Project.
- Create a new Blank operation
- Select the Tools tab in the top ribbon and click on the Options.
- Select the Blank operations tab and add a new blank operation.
- Set the Operation name as FirstRetailItemOperation and press OK. Optionally you can set parameters for the operation that can be used when the operation is executed.
- Close the Site Manager
Implementing the operation
- Open the Visual Studio solution provided in the development pack.
- Source > Solution.sln
- Configure the solution for the current machine
- Right-click on the POSStartProject project and select Properties.
- Click on the Debug tab.
- Check the Start external program option. And click the … button.
- Navigate to the location where you put the development pack. In the development pack, navigate to the POS Build path and select POS.exe.
Source > POS > Build > LS One POS.exe - Right-click on the POSStartProject and click Set as StartUp Project.
- Navigate to the BlankOperationsService project in the solution explorer
- POS > Services > BlankOperationsService
- Adding code to the Blank operation
- Open up BlankOperationService.cs from the BlankOperationsService project.
- Replace the current BlankOperation function with the following function.
- GetFirstRetailItem function is just an example. If the methods used for the new blank operation do not exist, they must be created.
- Log on to the POS.
- Right-click on the button that you want to assign the blank operation to and select Button properties.
- Select Blank Operation in the Operation combo box.
- Select your blank operation in the Blank operation combo box.
- Click on OK.
- If the operation was correctly set up then a dialog with the first retail item should pop up once the blank operation button was pressed.
- Exception handling and logging
- The LS One POS framework provides support for trace and error logging.
- The ErrorLogger in the database entry provides functionality for logging trace and error messages. The type of logging is controlled by a type enum showed in the code example below.
public IPosTransaction BlankOperation(IConnectionManager entry, ISession session,
OperationInfo operationInfo, IPosTransaction posTransaction)
{
string comment = string.Empty;
// Check for our new blank operation
if(operationInfo.OperationId.Contains("FirstRetailItemOperation"))
{
RetailItem item = Interfaces.Services.InventoryService(entry).GetFirstRetailItem(entry);
if(item != null)
{
comment = "The first retail item is: " + item.Text;
}
else
{
comment = "No retail items found.";
}
}
else //Default functionality
{
comment = "This operation has not been implemented."
+ "\r\n\r\n"
+ "Operation Id received: " + operationInfo.OperationId
+ "\r\n"
+ "Parameter received: " + operationInfo.Parameter;
}
BlankOperation blankOperation = Providers.BlankOperationData.Get(entry, operationInfo.OperationId);
Interfaces.Services.DialogService(entry).ShowMessage(comment,
blankOperation != null ? blankOperation.OperationDescription : "",
MessageBoxButtons.OK, MessageBoxIcon.Information);
return posTransaction;
}
For best practice, the methods that execute the logic of the operation should not be in the blank operations dll itself, but rather in a different service solution that is responsible for the current operation.
public void PreVoidTransaction(IConnectionManager entry
PreTriggerResults results,
PosTransaction posTransaction)
{
try
{
entry.ErrorLogger.LogMessage(LogMessageType.Trace,
"Before voiding the transaction...",
"TransactionTriggers.PreVoidTransaction");
}
catch (Exception x)
{
entry.ErrorLogger.LogMessage(LogMessageType.Error, this.ToString(), x);
throw x;
}
}
Avoiding resetting the POS layout and concluding internal transactions
If no retail transaction is created (there are no items on the transaction yet), a result callback will be called at the end of the operation, concluding the transaction and resetting the POS layout to its default state.
To avoid this, you can set the flag SkipResultCallback before returning from the BlankOperation function in the BlankOperationService.
operationInfo.SkipResultCallback = true;
An example when you might want to do this would be if you want to give the user a choice (e.g. in a message box dialog) and then open a different button menu depending on the reply from the user.
Demo operations
In the TrainingSolution of the development pack, you can find an example with multiple blank operations similar to the one below.
if (operationInfo.OperationId.ToUpper() == "NEWSHIFT") { RunNewShift(operationInfo, posTransaction); }
Below you can find a detailed description of each blank operation from the TrainingSolution.
Operation |
Description |
---|---|
NEWSHIFT |
Starts a new shift |
ITEMSALE |
Perform an item sale operation |
PRICEOVERRIDE |
Override the price of an item |
PRICECHECK |
Open a window where the price of an item can be checked |
VOIDITEM |
Void or unvoid the selected item |
ITEMCOMMENT |
Add a comment to the current item |
SETQUANTITY |
Set the quantity of the current item |
CLEARQUANTITY |
Reset the quantity of the current item to the default value |
INVOICECOMMENT |
Add an invoice comment to the transaction |
CHANGEUOM |
Change the unit of measurement of an item |
ICONREQUEST |
Request info codes for the current item |
CLEARITEMCOMMENTS |
Clear all comments for the current item |
CHANGEITEMCOMMENTS |
Change the comments for the current item |
LINEDISCOUNTAMOUNT |
Give a discount amount for the current item |
LINEDISCOUNTPERCENT |
Give a discount percent for the current item |
TOTALDISCOUNTPERCENT |
Give a total discount percent |
TOTALDISCOUNTAMOUNT |
Give a total discount amount |
SUSPENDTRANSACTION |
Suspend a retail transaction which can be retrieved and finished at a later time |
CUSTOMERCLEAR |
Clears the customer from the current transaction |
LOGOFF |
Perform a log off operation |
LOCKTERMINAL |
Locks the terminal by the current user |
MINIMIZEPOS |
Minimizes the POS window |
ENDOFDAY |
Perform an end of day operation |
ENDOFSHIFT |
Perform an end of shift operation |
TENDERDECLARATION |
Perform a tender declaration operation |
DECLARESTARTAMOUNT |
Perform a declare start amount operation |
FLOATENTRY |
Perform a float entry operation |
TENDERREMOVAL |
Perform a tender removal operation |
SAFEDROP |
Perform a safe drop operation |
BANKDROP |
Perform a bank drop operation |
SAFEDROPREVERSAL |
Perform a safe drop reversal operation |
BANKDROPREVERSAL |
Perform a bank drop reversal operation |