Show / Hide Table of Contents

Class SerialNumberHandler

Interface to handle serialnumbers from WATS MES. Written by Ragnar Engnes, Virinco as - 2016

Inheritance
System.Object
SerialNumberHandler
Inherited Members
System.Object.ToString()
System.Object.Equals(System.Object)
System.Object.Equals(System.Object, System.Object)
System.Object.ReferenceEquals(System.Object, System.Object)
System.Object.GetHashCode()
System.Object.GetType()
System.Object.MemberwiseClone()
Namespace: Virinco.WATS.Interface.MES.Production
Assembly: Virinco.WATS.Interface.MES.dll
Syntax
public class SerialNumberHandler

Constructors

SerialNumberHandler(String)

Constructor, creates an object reference

Declaration
public SerialNumberHandler(string serialNumberTypeName)
Parameters
Type Name Description
System.String serialNumberTypeName

Type of serial number, e.g. MACAddress

Methods

CancelReservations(Guid)

Cancels any reservations that is not taken from the local store on the server.

Declaration
public void CancelReservations(Guid token)
Parameters
Type Name Description
System.Guid token

Special Guid needed to perform this function, contact support@virinco.com

FormatAsMAC(Int64, Char)

Converts from Int to MAC string

Declaration
public string FormatAsMAC(long i, char separator)
Parameters
Type Name Description
System.Int64 i
System.Char separator
Returns
Type Description
System.String

GenerateAndUploadSerialNumbers(String, String, Int64, Int64, Char, out Int32, out Int32, Guid)

Generates and uploads serialnumbers to server.MACToInt(String) can be used to convert a MAC string

Declaration
public List<string> GenerateAndUploadSerialNumbers(string tokenID, string serviceUrl, long fromSN, long toSN, char separator, out int uploaded, out int rejected, Guid token)
Parameters
Type Name Description
System.String tokenID
System.String serviceUrl
System.Int64 fromSN
System.Int64 toSN
System.Char separator

Use to format mac string

System.Int32 uploaded

Successfully uploaded

System.Int32 rejected

Already exists

System.Guid token

Secret token support@virinco.com

Returns
Type Description
System.Collections.Generic.List<System.String>

A list of serialnumbers that already existed

GetFreeLocalSerialNumbers()

Returns the number of local serial numbers that are not taken.

Declaration
public int GetFreeLocalSerialNumbers()
Returns
Type Description
System.Int32

Free local serialnumbers

GetPoolInfo(out Boolean, out Int32, out Int32, out String, out String)

Returns information about the current pool when type is Reserve

Declaration
public void GetPoolInfo(out bool onlyInSequence, out int batchSize, out int fetchWhenLessThan, out string startFromSerialNumber, out string siteName)
Parameters
Type Name Description
System.Boolean onlyInSequence
System.Int32 batchSize
System.Int32 fetchWhenLessThan
System.String startFromSerialNumber
System.String siteName

GetSerialNumber(String, String)

Returns one serial number, see also GetSerialNumbers(Int32, String, String)

Declaration
public string GetSerialNumber(string serialnumberRef, string partnumberRef)
Parameters
Type Name Description
System.String serialnumberRef

Associate this serial number to this serialnumber

System.String partnumberRef

Associate this serial number to this partnumber

Returns
Type Description
System.String

Serial number as string

GetSerialNumbers(Int32, String, String)

Retrieves serialnumber from local store or server

Declaration
public string[] GetSerialNumbers(int numToGet, string serialnumberRef, string partnumberRef)
Parameters
Type Name Description
System.Int32 numToGet

Number of serialnumbers wanted

System.String serialnumberRef

Reference to a serial number

System.String partnumberRef

Reference to a part number

Returns
Type Description
System.String[]

String array with serial numbers

GetStatus()

Returns the status of a SerialnumberType

Declaration
public SerialNumberHandler.Status GetStatus()
Returns
Type Description
SerialNumberHandler.Status

Ready/NotInitialized

Initialize(String, String, SerialNumberHandler.RequestType, Boolean, Int32, Int32, String, String, Guid)

Initialize a client and make it ready for serial number retrieval.

Declaration
public void Initialize(string tokenID, string serviceUrl, SerialNumberHandler.RequestType requestType, bool onlyInSequence, int batchSize, int fetchWhenLessThan, string startFromSerialNumber, string siteName, Guid token)
Parameters
Type Name Description
System.String tokenID

Authentication token generated on the WATS server according to this procedure:

https://virinco.zendesk.com/hc/en-us/articles/207424253-Authentication ///

System.String serviceUrl

The service address, e.g.:

http://localhost/SerialnumberAdmin/api/SerialNumber/

SerialNumberHandler.RequestType requestType

Legal Values SerialNumberHandler.RequestType :

Take: Client must be online and requested number of serialnumbers will be marked as Taken in the SN database

Reserve: Client download a batchSize number of serialnumbers and makes a reservation in the SN database.

The downloaded serial numbers are stored and maintained in an XML file on the client (C:\ProgramData\Virinco\WATS\AddressStore)

When there are fetchWhenLessThan serialnumbers left in the local store, new serialnumbers are downloaded from server

System.Boolean onlyInSequence

If set to true, requested serialnumbers will be contiguous (NB: Only MAC addresses)

System.Int32 batchSize

How many serialnumbers that are reserved on the server (When requestType=Resvere)

System.Int32 fetchWhenLessThan

Number of remaining offline serialnumbers before server is polled for a new batch

System.String startFromSerialNumber

If specified, will restrict serial numbers retrieved to be greater or equal this value

System.String siteName

Serial numbers will be registered to a site with this name (NB: Must be defined on the server, can be null)

System.Guid token

Special Guid needed to perform this function, contact support@virinco.com

MACToInt(String)

Converts MAC string to int

Declaration
public long MACToInt(string mac)
Parameters
Type Name Description
System.String mac

MAC String, supported separators are -,:,blank

Returns
Type Description
System.Int64

Int64

SetReuseOnDuplicateRequest(Boolean)

Change the behaviour of the serialnumber handler to re-use serialnumbers if referencedSN and referencedPN and number requested has been requested earlier (in the same call)

Declaration
public void SetReuseOnDuplicateRequest(bool on)
Parameters
Type Name Description
System.Boolean on

Turns on this functionality (default is off)

UploadSerialNumbersFromFile(String, String, String, out Int32, out Int32, Guid)

Uploads a text file with serialnumbers to the server, one sn per line - separated by CR/LF

Declaration
public List<string> UploadSerialNumbersFromFile(string tokenID, string serviceUrl, string fileName, out int uploaded, out int rejected, Guid token)
Parameters
Type Name Description
System.String tokenID
System.String serviceUrl
System.String fileName
System.Int32 uploaded
System.Int32 rejected
System.Guid token
Returns
Type Description
System.Collections.Generic.List<System.String>
In This Article
  • Constructors
    • SerialNumberHandler(String)
  • Methods
    • CancelReservations(Guid)
    • FormatAsMAC(Int64, Char)
    • GenerateAndUploadSerialNumbers(String, String, Int64, Int64, Char, out Int32, out Int32, Guid)
    • GetFreeLocalSerialNumbers()
    • GetPoolInfo(out Boolean, out Int32, out Int32, out String, out String)
    • GetSerialNumber(String, String)
    • GetSerialNumbers(Int32, String, String)
    • GetStatus()
    • Initialize(String, String, SerialNumberHandler.RequestType, Boolean, Int32, Int32, String, String, Guid)
    • MACToInt(String)
    • SetReuseOnDuplicateRequest(Boolean)
    • UploadSerialNumbersFromFile(String, String, String, out Int32, out Int32, Guid)
Back to top View how-to articles, videos and more at support.virinco.com Send comments on this topic to support@virinco.com