Custom DataService actions

The DataService contract contains two methods that make it possible to call a universal action:

byte[] CustomGet(string operationCode, byte[] args)
void CustomExecute(string operationCode, byte[] args)

Both the argument and the returned type (CustomGet only) is an array of bytes so that any structure can be sent as well as received.

Calling in POS

Methods for calling universal actions are found in the ISynchronizationService service. In your own module, you only need to inject instances of the abovementioned service and call the desired operation.

Handling in DataService

To support a universal action, it needs to be registered in an extension module.

Note
A class that is assigned an attribute must be static!
[DataServiceBusinessModule]
public static class Module    
{
   [MethodInitializer]
   public static void Initialize()        
   {
      var customOpsService = IoC.Container.Resolve<ICustomOperationsService>();
      customOpsService.RegisterCustomGet("my_op", MyCustomGet);
   }
   private static byte[] MyCustomGet(byte[] data)        
   {
     //code   
   }
}

Czy ten artykuł był pomocny?