Description
Configures various settings for the PowerClient- or
PowerServer-deployed applications, such as pictures loaded via URL,
DataWindow SQLPreview support, HTTP request header etc.
Syntax
Integer CloudAppSet (string n, string v)
Argument
|
Description
|
n
|
The name of the setting that is case insensitive. The
setting can be:
-
picturecachepath -- The directory where pictures are
cached after downloaded from Web. The default value is
"/picturecache". The leading forward slash (/ or //)
indicates the root of the current application
directory.
Both the relative path and absolute path are
supported. The path can also contain the system environment
variable such as %appdata%\picturecache.
-
clearpicturecacheonclose -- Whether to delete pictures
from the cache directory when the application is
closed.
-
checkpictureforupdate -- Whether to check updates for
the existing pictures. If pictures on Web have been updated,
they will be downloaded again to the cache directory,
otherwise, the picture in the cache directory will be
used.
The file size of the picture on Web will be obtained
and compared with the file size of the picture in the cache
directory. If the size is different, it indicates the
picture has been updated on Web, and the picture will be
downloaded again to the cache directory.
-
enablesqlpreview -- Whether to fully or partially
support DataWindow SQLPreview. When fully supporting
DataWindow SQLPreview, the performance may be compromised
under the PowerServer architecture.
-
When the "enablesqlpreview" setting is "false",
the sqltype parameter
supports PreviewSelect only and the request argument supports
PreviewFunctionRetrieve only.
The support for SQLPreview event is limited (the
sqltype parameter does
not support Previewlnsert, PreviewDelete, &
PreviewUpdate; and the request argument does not support
PreviewFunctionReselectRow and
PreviewFunctionUpdate).
-
When the "enablesqlpreview" setting is "true", the
sqltype parameter
supports PreviewSelect, Previewlnsert, PreviewDelete,
& PreviewUpdate; and the request argument supports
PreviewFunctionRetrieve, PreviewFunctionReselectRow, and
PreviewFunctionUpdate.
The SQLPreview event is fully supported; however,
the performance may be compromised. When
"enablesqlpreview" is "true", DataWindow Update uses the
line-by-line commit approach (for each line of code, a
separate request is sent to the server) rather than
committing the entire DataWindow data to the server in
one request, therefore, in the PowerServer architecture,
the performance is easily affected by the network. If
there is batch data update in the DataWindow, it is
recommended to set "enablesqlpreview" to "false".
By default, the "enablesqlpreview" setting is
"false".
You can consider setting "enablesqlpreview" to "true"
for only some DataWindow Updates. Here is a code
example:
//Enable SQLPreview support before update, and then disable it after update.
CloudAppSet ("enablesqlpreview", "true")
if dw_1.update() = 1 then
commit;
else
rollback;
end if
CloudAppSet ("enablesqlpreview", "false")
-
multipartformdataminsize -- Uses the multipart/form-data header or
application/json header
when sending HTTP request to PowerServer. Choosing the
appropriate header based on the data being sent ensures that
your requests are correctly formatted and can be effectively
processed by the server.
Note
All of the PowerServer HTTP request types support
multipart/form-data,
except the following: ValidationData and
VerificationFailed.
-
Use application/json when you need to
send structured data, such as objects or arrays. This
format is ideal for PowerServer Web APIs which expects
JSON, as it allows for easier parsing and processing on
the server side.
By default, application/json is used.
-
Use multipart/form-data (by setting
"multipartformdataminsize" to "0" or any positive value)
when you need to send large structured data, blobs, or
files or a combination of them in a single request. This
format is particularly useful for scenarios where
network conditions are poor or slow, and you need to
send substantial amounts of data to PowerServer (for
example, for batch updates or UpdateBlob operations).
When multipart/form-data is used, data
will be compressed when sending requests from the client
PC to PowerServer, to reduce network transmission time.
However, keep in mind that this process requires
additional resources in the client PC and PowerServer
for compressing and decompressing the data. Please
carefully consider the benefits and trade-offs when
choosing this format.
|
v
|
The value of the setting to be set.
-
When the name of the setting is "picturecachepath",
the value can be a directory.
-
When the name of the setting is
"clearpicturecacheonclose", this value can be "true" or
"false".
-
When the name of the setting is
"checkpictureforupdate", this value can be "true" or
"false".
-
When the name of the setting is "enablesqlpreview",
this value can be "true" or "false".
-
When the name of the setting is
"multipartformdataminsize", this value can be 0, -1, or any
positive value.
-
0 -- Uses the multipart/form-data header in all
requests.
-
-1 -- (Default) Uses the application/json header in all
requests.
-
any positive value -- Uses the multipart/form-data header only
when the data in the request is larger than the
specified size (in KB), for example, 128.
|
Return value
Integer.
Returns 1 if the function succeeds and the following negative value
if an error occurs.
-1 The application is not a PowerClient- or PowerServer-deployed
app.
-2 The name of the setting does not exist or is invalid.
-3 The value of the setting is invalid. The value that was
successfully set last time or the default value will be used
instead.
Examples
CloudAppSet ("picturecachepath", "/picturecache");
CloudAppSet ("clearpicturecacheonclose", "true");
CloudAppSet ("checkpictureforupdate", "true");
CloudAppSet ("enablesqlpreview", "true")
CloudAppSet ("multipartformdataminsize", "128");
See also
CloudAppGet