Data
There is a TypeScript class for each SimTrans transaction—including the generic all-purpose transaction. The attributes are documented in the SimTrans manual from SigmaTEK. The main difference is that these classes include an attribute for a security token that is not recorded in the SimTrans documentation. All the classes are installed in a data sub-folder of the client installation. There is also a commondata-plain.js file in the same location that includes all the transactions as plain JavaScript classes in one file.
The data JavaScript classes are included with:
import * as data from "./commondata-plain.js"
or wherever you chose to place the file within the client project structure.
WebClient
The WebClient class is included with:
import {WebClient} from "./WebClient.js"
or wherever you chose to place the file within the client project structure.
Properties
HostName(): string
- Get the host name component of the server's URI.
HostName(Name: string )
- Set the host name component of the server's URI.
Port(): string
- Get the port component of the server's URI.
Port(PortNumber: string)
- Set the port component of the server's URI.
Status(): number
- Get the status of an HTTP operation. It is only defined after the execution of a send, get feedback or delete feedback operation.
Result(): string
- Get the result of an HTTP operation. It is only defined after the execution of a send, get feedback or delete feedback operation.
Token(value: string)
- Sets a security token to place in a SimTrans data transaction before sending it to the server and to be used by the GetFeedback and DeleteFeedback functions. There is no JavaScript function to create a token locally, so one must be obtained from the server using the encrypted HTTPS protocol. That result of that call is stored here.
SharedId: string
- Before a security token can be obtained from the server, using the encrypted HTTPS protocol, the shared ID must be set to the same value thate is placed in the server's configuration file.
Constructors
WebClient(UriString: string)
- Creates a WebClient instance. In addition to the URI string parameter, the SharedId property is required before calling the GetToken method and it is require before any other method is called.
- UriString: string
- The full URI, including protocol and port to reach the server (e.g. https://server.domain:port). If it is not specified it defaults to https://localhost:5071, which is only suitable for local testing.
Methods
async Send(TransactionType: string, JsonTransaction: string):Promise<boolean>
- Asynchronously sends a SimTrans transaction to the server. It returns True if the operation succeeded; Otherwise False. The status and result are obtained from the corresponding properties.
- TransactionType: string
- This is the type of SimTrans transaction in the JsonTransaction parameter (e.g. "SN60", "SN7A", etc.). It is not case sensitive. For the genric transaction specify an empty string ("").
- JsonTransaction: string
- The contents of the SimTrans transaction that corresponds to the TransactionType in Json format.
async GetFeedbackAsync (FeedbackType: string): Promise<boolean>
- Asynchronously gets feedback from the specified SimTrans feedback table. It returns True if the operation succeeded; Otherwise False. The status and result are obtained from the corresponding properties. The result is a Json string containing an array of feedback rows. The security token set in the Token property is used, so it is not necessary to submit one.
- FeedbackType: string
- The SimTrans feedback table or type to get feedback from. Accepted values are {"pip", "PartsInProcess", "prg", "Programs", "prt", "CompletedParts", "rem", "Remnants", "sht", "Sheets", "wo", "WorkOrders"}. That values are not case sensitive.
async DeleteFeedbackAsync (FeedbackType: string, JsonFeedback: string): Promise<boolean>
- Asynchronously removes the feedback, received from a previous GetFeedBack call, from the specified SimTrans feedback table. If only some of the returned rows are processed correctly on the client, then only those rows should be returned to be deleted. The others should remain to be retrieved and retried later. It returns True if the operation succeeded; Otherwise False. The status and result are obtained from the corresponding properties. The security token set in the Token property is used, so it is not necessary to submit one.
- FeedbackType: string
- The SimTrans feedback table or type to get feedback from. Accepted values are {"pip", "PartsInProcess", "prg", "Programs", "prt", "CompletedParts", "rem", "Remnants", "sht", "Sheets", "wo", "WorkOrders"}. That values are not case sensitive.
- JsonFeedback: string
- The array of feedback rows returned from a previous GetFeedback call that were processed correctly on the client. These are the rows that are deleted.
async GetToken(): Promise<string>
- Gets a security token from the server, because there is no JavaScript function to generate one locally. If the connection is across a public network, then the HTTPS protocol must be used.The ShardId property must be set before this method is called. A token must be obtained and set in the Token property before any other functions are called. Since a token is only valid for 60 seconds, a new token must be obtained and updated for each cluster of method calls.
Examples
For examples, refer to the Examples page.