This article explains how to use the WATS Client .NET API's MES-Interface to access and increment your asset counters. Please see the article Using the WATS .NET api as a NuGet package for instructions on how to access the API.
Initializing the MES Interface
The functions related to asset management is found in the MES Interface. The below example code shows how you can create and initialize the MES Interface, as well as increment your asset counters.
The MES Interface is accessed by creating an object of the class Virinco.WATS.Interface.MES.MesInterface. If the WATS Client is installed an running, no further initialization is necessary.
Incrementing your asset counters
You can use the MES Interface object's .Asset.IncrementAssetUsageCount()-function. The function takes three parameters:
serialNumber(string) - The serial number for your asset
usageCount(int) - The count to be added (Optional - default = 1)
incrSubAsset(bool) - If true, the sub assets will also be incremented. (Optional - default = false)
The function returns an .Asset.AssetResponse object. If the call succeeded, the AssetResposes .Ok parameter will be true.
Example Class - C#
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
// WATS
using Virinco.WATS.Interface.MES.Asset;
namespace AssetManagement_ExampleCode
{
class MesIntegration
{
Virinco.WATS.Interface.MES.MesInterface mes;
public MesIntegration()
{
// Create the MesInterface object.
// No initialization is nessesary if the WATS Client is installed and running
mes = new Virinco.WATS.Interface.MES.MesInterface();
}
public void Test()
{
bool d_incr = IncrementAssetCounter("YourAssetSerialNumber");
bool c_incr = IncrementAssetCounter("YourAssetSerialNumber", 10, true);
}
// This functions will increase the counter by 1 and will not increment sub assets.
private bool IncrementAssetCounter(string assetSerial)
{
AssetResponse ar = mes.Asset.IncrementAssetUsageCount(assetSerial);
return ar.Ok;
}
// Use the optional parameters: int usageCount & incrementSubassets to increase by other number and/or to update sub assets.
private bool IncrementAssetCounter(string assetSerial, int usageCount, bool incrementSubAssets)
{
// This call succeded if the respons objects .Ok is true;
AssetResponse ar = mes.Asset.IncrementAssetUsageCount(assetSerial, usageCount, incrementSubAssets);
return ar.Ok;
}
}
}
Comments
0 comments
Please sign in to leave a comment.