|
|
Macro Scripting
OverviewLinnworks macro engine allows you to inject your own automation behaviour into Linnworks by creating a Macro script that runs every time the system synchronizes. A script is essentially a set of commands written in .Net C# that gets executed during every synchronization. Generic Macro scripting is used to run a set of automated tasks, unlike Order Scripting (see Scripting – Orders), which is executed against every open or processed order on the system, the generic script is executed once during the synchronization – which means it is ideal candidate for doing things in a batch. Here are some examples of what Macro Script can be used for
Create new macro script
The script can be enabled/disabled
The script has execution order
Writing a macroThe syntax of the code is standard C# with most common namespaces attached in the compilation, so you have access to file system, networking components etc. But most importantly you have direct access to commondata library – which exposes most of the data queries and manipulations. In addition you have ActiveConnection parameter, this is supplied in the Initialize method as a parameter and you can use it to run data queries against your system. Since this documentation is not intended to describe every method, field and function in C# and linnworks data adapter, we can only give some pointers as to how to work with scripts. The scripting has full InteliSense – meaning that when you type the code, the method, function or a property of the object will have a comment, which describes what it does. The code syntax is .Net C# (version 2 compile). The script has access to the following namespaces
The code must be placed inside public void Initialize(..) method.
DebuggingWhen writing a script it is sometimes necessary to output some debugging text to show value of certain variable. Initialize method provides a debug class variable. debug.AddEntry("[my text]");
To output script progress debug.Progress(50,"We are at 50%");
The script progress propagates to Linnworks Synchronization progress. When running long scripts it is a good idea to keep the user informed of the progress. See Also
|