Zip Archive

Show allHide all

Generates zip archives with files from the database or extracts files from an existing archive.

Component modes: Zip | Unzip

Component mode: Unzip

Extracts files from an existing archive.

File modes: Download | Save | Save and download

File mode: Download

The user downloads the file.

SQL

SQL Call: Get init data (mandatory)

Retrieves either the archive data or id values for subsequent calls to retrieve multiple archives.

May modify database: No

Parameters

@Action string
Will be set to "Init"

Resultset: Batch (optional)

Must be the first table in the result set.
Table count: repeated zero or one time
Row count: exactly one row

Columns

BatchId mandatory string
BatchId of this set of archives, will be sent back to the procedure for all calls.

Resultset: Archive data (optional)

The binary data of the zip archive to be unzipped. Only one of this and the Id values resultset may be used simultaneously.
Table count: repeated zero or one time
Row count: zero or one row

Columns

ZipArchive mandatory binary
The binary data to unzip.

Resultset: Id values (optional)

The id values that will be passed as a parameter in subsequent calls to retrieve the zip archive data. Only one of this and the Archive data resultset may be used simultaneously.
Table count: repeated zero or one time
Row count: zero or more rows

Columns

Id mandatory string
The id value.

SQL Call: Get archive

Retrieves the binary data for an archive with the given id. This will be called once for every id in the id values table from the Get init data call.

May modify database: No

Parameters

@Action string
Will be set to "GetArchive"
@BatchId string
Only used if a batch id was given in the get init data call.
@Id string
The id of the archive.

Resultset: Archive data

The binary data of the archive to be unzipped.
Table count:
Row count:

Columns

ZipArchive mandatory binary
The binary data to unzip.

SQL Call: Choose files (mandatory)

Selects which files to extract. Will be called once for every archive.

May modify database: No

Parameters

@Action string
Will be set to "ChooseFiles"
@BatchId string
Only used if a batch id was given in the get init data call.
@Id string
The id of the archive if it has one.

Resultset: #FileName

Temp table containing all files from the archive.
Table count: repeated exactly once
Row count: zero or more rows

Columns

FileName mandatory string
Full path of the file.

Resultset: Chosen files

The files that should be extracted.
Table count: repeated exactly once
Row count: zero or more rows

Columns

FileName mandatory string
Path of the file. Must correspond to a value in the #FileName table.

SQL Call: Save file (mandatory)

Will be called once for every extracted file.

May modify database: Yes

Parameters

@Action string
Will be set to "SaveFile"
@BatchId string
Only used if a batch id was given in the get init data call.
@File binary
The binary data of the file.
@FileName string
The name of the file.
@Id string
The id of the archive if it has one.

SQL Call: Finished (mandatory)

May modify database: No

Parameters

@Action string
Will be set to "Finished"

Resultset: Forwarding definitions (optional)

Table count: repeated zero or more times
Row count: exactly one row

Columns

<passing_field> optional string
Any column with no other specific meaning will pe passed along to the menu item you are forwarding to.
ADMIN_CancelCidStepsBack optional int
Number of steps in the page history to jump back if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelcidstepsback specified in the query string.
ADMIN_CancelReturnToMenuItem optional string
Jumps back to the menu item with this alias if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). If no prior menu item is found with the given alias, then an error is thrown.
ADMIN_CancelMenuItem optional string
Alias of the menu item to execute if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.
ADMIN_CancelMenuItemId optional int
Deprecated. Use ADMIN_CancelMenuItem instead.

Id of the menuitem to execute if the user clicks Cancel in an ADMIN_FORCE dialog (the default being none). This value overrides cancelmenuitemid specified in the query string.
ADMIN_CidStepsBack optional int
Number of steps in the page history to jump back after execution (the default being one step back). This value overrides any destination specified by the query string.
ADMIN_ReturnToMenuItem optional string
Jumps back to the menu item with this alias after execution. This value overrides any destination specified by the query string. If no prior menu item is found with the given alias, then an error is thrown.
ADMIN_Force optional string
Prompts the user with the specified text and the user may answer OK or cancel. If the user chooses OK the sql call will be rerun with the parameter @force set to 1.
ADMIN_Forward optional string
Displays a user friendly message and then forwards to the next menu item.
ADMIN_ForwardLink optional string
Alias of the link to forward to.
ADMIN_ForwardMenuGroupId optional int
Id of the menu group to show after execution (instead of former menu item). This value overrides any destination specified by the query string.
ADMIN_ForwardMenuItem optional string
Alias of the menu item to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
ADMIN_ForwardMenuItemId optional int
Deprecated. Use ADMIN_ForwardMenuItem instead.

Id of the menu item to execute after execution (instead of former menu item). This value overrides any destination specified by the query string.
ADMIN_Message optional string
Displays a user friendly message to the user.
ADMIN_PasteHtmlFromPopup optional string
Pastes HTML into an HTML editor. See ADMIN_SetFieldValueFromPopup.
ADMIN_SetFieldValueFromPopup optional string
Sets the value of the field specified in the menuitempopup call. Only select this column if menu item is opened in a popup.
ADMIN_ClosePopup optional bit
If this column is anything but NULL the popup will be closed. Only select this column if the menu item is opened in a popup.
Default: The default behavior is to step back inside the popup window and close it if there is nothing to step back to.
ADMIN_ClearHistory optional any
When the value is not NULL all navigation history is cleared and the user can't navigate back. This is only supported when forwarding to another menu item.
ADMIN_RefreshMenu optional bit
Will trigger a reload of the sidebar if the column is anything but NULL.
Cache optional string
Cache key to be cleared. Supports wildcards.
CacheUserId optional string
Either a user id or '%'.

Clears all caches (e.g. access permissions) related to the specified user id.

Use '%' to clear caches for all users.
CancelButtonText optional string
Changes the text of the Cancel button when used with ADMIN_Force.
OkButtonText optional string
Changes the text of the OK button when used with ADMIN_Message, ADMIN_Force, or ADMIN_Forward.

SQL Call: Validate parameters

Allows you to validate the parameters supplied by the user before any other SQL is run in the component. This call is only made if the component has visible parameters, the SQL is a stored procedure, and 'Validate parameters' is checked.

May modify database: No

Parameters

@Force bit
Set to 1 if the last call to validate parameters used admin_force and the user clicked OK in the OK/Cancel dialog.
@ValidateParams bit
Set to 1 when this call is made.

Resultset: Messages (optional)

Table count: repeated zero or one time
Row count: zero or one row

Columns

ADMIN_Force optional string
Message asking the end user to confirm their parameters.
ADMIN_Message optional string
Message explaining why the parameters are rejected.

Custom access control and logging

SQL Call: Custom access control and logging

Use this call to restrict which entries a user is allowed to view and edit, and to log which entries a user views.

Access to a menu item is normally controlled through functions and roles alone but some entities need more fine grained control. For example, a user may have access to the View Member menu item for normal members but not for members with a protected identity.

The menu items a user visits are always logged (in ADMINLogMenuItem) but for sensitive data you may need to log exactly what entries are viewed. Do the logging in this call as the common ways of viewing data (grid and InfoSQL) are not allowed to modify the database.

If you bind a scalar function instead of a stored procedure to this call then its name must end with '_GrantAccess'.

May modify database: Yes

Resultset: Access permissions

Return whether the user is allowed to visit the menu item with the current parameters.
Table count: repeated exactly once
Row count: exactly one row

Columns

GrantAccess mandatory bit
1 if the user is allowed to view the menu item, 0 if the user should not be allowed to view the menu item.

If 0 then an error will be logged as the user should not have been able to reach the menu item with the given parameters in the first place.

Examples

Unzip single source file

CREATE OR ALTER PROCEDURE Example.Unzip_SingleSource
	@Action varchar(300) = NULL,
	@File varbinary(max) = NULL,
	@FileName varchar(300) = NULL
AS
BEGIN
	IF @Action = 'Init'
	BEGIN
		SELECT
			F.ZipArchive AS ZipArchive
		FROM
			Example.ZipFile F
		WHERE
			F.ZipFileId = 1;

		RETURN;
	END;

	IF @Action = 'ChooseFiles'
	BEGIN
		SELECT
			F.FileName
		FROM
			#FileName F;

		RETURN;
	END;

	IF @Action = 'SaveFile'
	BEGIN
		INSERT INTO Example.ExtractedFile
		(
			ExtractedFile,
			ExtractedFileName
		)
		VALUES
		(
			@File,
			@FileName
		);

		RETURN;
	END;

	IF @Action = 'Finished'
	BEGIN
		RETURN;
	END;
END;

Unzip multiple source files

CREATE OR ALTER PROCEDURE Example.Unzip
	@Action varchar(300) = NULL,
	@File varbinary(max) = NULL,
	@FileName varchar(300) = NULL,
	@Id varchar(300) = NULL
AS
BEGIN
	IF @Action = 'Init'
	BEGIN
		SELECT
			F.ZipFileId AS Id
		FROM
			Example.ZipFile F;

		RETURN;
	END;

	IF @Action = 'GetArchive'
	BEGIN
		SELECT
			F.ZipArchive AS ZipArchive
		FROM
			Example.ZipFile F
		WHERE
			F.ZipFileId = @Id;

		RETURN;
	END;

	IF @Action = 'ChooseFiles'
	BEGIN
		SELECT
			F.FileName
		FROM
			#FileName F;

		RETURN;
	END;

	IF @Action = 'SaveFile'
	BEGIN
		INSERT INTO Example.ExtractedFile
		(
			ExtractedFile,
			ExtractedFileName
		)
		VALUES
		(
			@File,
			@FileName
		);

		RETURN;
	END;

	IF @Action = 'Finished'
	BEGIN
		RETURN;
	END;
END;