Skip to main content

system.mes.util.restore

Description

Imports multiple entities from a zip file provided as raw bytes. The service layer will parse the file content and create or update entities.

Recommended to use files created from the backup method to ensure correct zip file format.

Syntax

system.mes.util.restore(bytes)

Parameters

ParameterTypeNullableDescription
bytesbyte[]TrueThe zip file entity data as a byte array.

Returns

An ApiResponse object indicating success or failure. The data attribute contains a RestoreResponseDTO object which the contains the number of entities imported and queued for each entity type as well as the total imported and queued entities.

Code Examples

import system.file

# Path to the zip file
filePath = "C:/path/to/entities.zip"

try:
# Read the file content as bytes
fileBytes = system.file.readFileAsBytes(filePath)

# Import the entities
result = system.mes.util.restore(fileBytes)

if result.get('success'):
print "Successfully imported {} OEE modes.".format(result.get('data'))
else:
print "Import failed: {}".format(result.get('message'))

except Exception as e:
print "An error occurred: {}".format(str(e))