Documente Academic
Documente Profesional
Documente Cultură
Overview
Microsoft Dynamics AX setup includes SDK samples for Retail. These can be installed by selecting Retail SDK as part of the Microsoft Dynamics AX setup.
The Retail SDK samples are installed in the Retail SDK\POS Plug-ins folder, under the current users Documents folder, as shown below:
The installed files include sample projects for individual Services and Triggers, as well as a Tutorials folder with additional documentation and in-depth samples.
System.ComponentModel.Composition.ExportAttribute The argument for the attribute is the type of the contract interface that the class implements. See example below: Example:
using using using using using System.ComponentModel.Composition; Microsoft.Dynamics.Retail.Pos.Contracts; Microsoft.Dynamics.Retail.Pos.Contracts.BusinessObjects; Microsoft.Dynamics.Retail.Pos.Contracts.DataEntity; Microsoft.Dynamics.Retail.Pos.Contracts.Services;
namespace Microsoft.Dynamics.Retail.Pos.BlankOperations { [Export(typeof(IBlankOperations))] public sealed class BlankOperations : IBlankOperations { [Import] public IApplication Application { get; set; } #region IBlankOperations Members public void BlankOperation(IBlankOperationInfo operationInfo, IPosTransaction posTransaction) { // Application.RunOperation(PosisOperations.LogOff, null); } #endregion } }
with the class itself, may change due to product upgrades and successive releases. Because of this, it is recommended that custom solutions add new methods to only the RetailTransactionServiceEx class. Add a new method to RetailTransactionServiceEx class. In order to be compatible with Transaction Service, the new method must conform to the following rules: Scope of public static Return type of container o The first element of the container MUST be a bool to indicate success/failure. o The second element of the container MUST be a string, containing an optional message o The remaining elements may be used for any return data/results. o Example: *true, Success!, + Parameters should be primitive types.
/// <summary> /// An echo method that respond with a container of the first ten string parameters /// </summary> /// <returns> /// A container of the first 10 parameters /// </returns> public static container echoRequest(str parameter0 = , str parameter1 = , str parameter2 = , str parameter3 = , str parameter4 = , str parameter5 = , str parameter6 = , str parameter7 = , str parameter8 = , str parameter9 = ) { container results = [true, 'Successful.']; container parameters; str parameter; int i; // Append all the rest of parameters if available. parameters = [parameter0, parameter1, parameter2, parameter3, parameter4, parameter5, parameter6, parameter7, parameter8, parameter9]; for(i = 1; i <= conLen(parameters); i++) { parameter = conPeek(parameters, i); if(parameter) { results += parameter; } } return results; }
This example calls the echoRequest method that was created above. Note that the arguments for the AX method are passed as a params collection.
public void CallTransactionService() { try { ReadOnlyCollection<object> containerArray; ITransactionService service = PosApplication.Instance.TransactionServices; // Call the new TS method containerArray = service.InvokeExtension("echoRequest", 0, 1, 2, 3); //Note that AX containers are 1-based, so the first element is at index 1. bool retValue = (bool)containerArray[1]; string comment = containerArray[2].ToString(); Debug.WriteLine("Results:"); for (int i = 1; i < containerArray.Count; i++) { Debug.WriteLine(containerArray[i]); } } catch (Exception ex) { LSRetailPosis.ApplicationExceptionHandler.HandleException(this.ToString(), ex); throw; } }