This Action Map create a zip-file with the images from selected products. An example on how to starts an external application with specific settings.
This example is provided as inspiration only. It must be adapted to your Perfion environment to work. Perfion Support does not assist with such adaptations. Please contact your Perfion Partner or your Perfion consultant if you need assistance.
Action Map
- All lines containing a Command are created as virtuals. This is a recommended best practice
- The Action invokes the Application "7z.exe", which is a third party tool available on https://www.7-zip.org/ used to work with compressing files.
- The command EXECUTE.SCRIPT with the related script starts the application
Sample data for building Action Map
Data must be adapted to your Perfion environment to work.
| Action Map - From | To | Command | Action | Script | Note |
| SET | |||||
| C:\TMP | $TempPath | ||||
| C:\EXPORT | $ExportPath | ||||
| SELECT.PERFION | <Query> <Select languages='EN'> <Feature id='*' view='Config' /> </Select> <From id ='100'/> <Where> <Clause id='NoOfCups' operator='>' value='3' /> </Where> </Query> |
||||
| table | @FORMAT | ||||
| SELECT | |||||
| _Value | ItemNumber | ||||
| EANCode | EAN | ||||
| HeightCM | Height | ||||
| Image | Product Image | if( !HasValue ){ Value = ""; return; } string id = Path.GetFileNameWithoutExtension( ""+Value ); var info = Perfion.WriteFile( id:id, file:"{@filename}{@par}", par:"size=300x300&format=jpg&fit=crop", root:"{=$TempPath}" ); Value = info.OutFileName; |
The script writes the images from the feature called "Image" from the selected products. It uses the Perfion script method "WriteFile" with customized parameters. Please refer to the documentation for details on using this method.
The written filename are set to the output Value for reference if needed later. |
||
| ItemName_EN | Name | ||||
| NoOfCups | Number of cups | ||||
| EXECUTE.SCRIPT |
string command = "a"; ProcessStartInfo ps = new ProcessStartInfo(); ps.FileName = "7z.exe"; ps.Arguments = string.Format("\"{0}\" \"{1}\" \"{2}\" \"{3}\" \"{4}\"", command, zipformat, zipfile, files, moveoption); Process.Start(ps); |
This script uses the .NET core script methods for working with processes. It demonstrates the powers of using external applications. Please note the potential risks of executing external applications that you don't control.
The script also sets process arguments for the "7z.exe" application for demonstration. |
Comments
0 comments
Please sign in to leave a comment.