Promotic
WikipediaLinkedInYoutubeTwitterFacebook

onAppStopBegin - event of the PmaRoot object

Description:
The event is triggered after the command for halting the application.
Parameters:
pMe(Object) Reference to the PmaRoot object where the event rises.
pEvent(Object) Reference to object describing detailed information about the specific event.
pEvent.Type - (String) Application stopping type.
"Stop" - Normal application stopping called by the Pm.AppStop(0) method or by closing the main application window. This normal application stopping can still be supressed by the confirmation dialog or in the PmaRoot.onAppStopBegin event.
"HardStop" - Stopping the application by calling the Pm.AppStop(1) method or by malfunction of internal component or licence. This application stopping can not be supressed by a confirmation dialog or in the PmaRoot.onAppStopBegin event.
"Logoff" - Logging off the user logged in the OS Windows, see Pm.ShutDown(0, false) The applications will be terminated with confirmation dialog.
"HardLogoff" - Logging off the user logged in the OS Windows, see Pm.ShutDown(0, true) The applications will be terminated by force without any confirmation dialog (data loss may occur).
"Reboot" - Rebooting the computer with OS Windows, see Pm.ShutDown(1, false) The applications will be terminated with confirmation dialog.
"HardReboot" - Rebooting the computer with OS Windows, see Pm.ShutDown(1, true) The applications will be terminated by force without any confirmation dialog (data loss may occur).
"Shutdown" - Shutting down the computer with OS Windows, see Pm.ShutDown(2, false) The applications will be terminated with confirmation dialog.
"HardShutdown" - Shutting down the computer with OS Windows, see Pm.ShutDown(2, true) The applications will be terminated by force without any confirmation dialog (data loss may occur).
pEvent.Error - (Long) If the value of the parameter is 0, then the application is stopped by the user (designer) command - i.e. by calling the Pm.AppStop or Pm.AppQuit method. Otherwise (the value is no-zero), the application is stopped from the failure cause of some component (e.g. ActiveX object, etc.).
pEvent.Enabled - (Boolean) Enable/disable normal application termination. The value of this parameter is preset to true. If the value of the property is true, then the normal application termination is enabled. If the value of the property is false, then the normal application termination is disabled. This way it is for example possible to enable/disable normal application termination conditionally or execute delayed termination, etc.
Note:
After the event Pma objects are deleted sequentially (the onStop event is triggered for each object) and finally the onAppStopEnd event is triggered.
 
Application termination can be disabled by "PmaRoot > Permissions > AppStop" permission.
See also:
Example1:
Delays application stop so the designer's "SaveConfigApp" method can finish its necessary procedures
JavaScriptSelect and copy to clipboard

function onTimeOut()
{
Pm.AppStop(1);  //will by called "onAppStopBegin" with pEvent.Type == "HardStop"
}

if (pEvent.Type == "Stop")
{
pEvent.Enabled = false;
pMe.Root.AddEventTimer(5000, 1, onTimeOut);
pMe.Methods.SaveConfigApp();  //user method
}
Example2:
Displays a PmForm window with countdown to application stop. The application can be stopped immediately by confitrming the dialog.
JavaScriptSelect and copy to clipboard

var nSecStop = 15;  //number of seconds until the application stops
var oPmfTimeout;

function onTimeOut()
{
if (nSecStop <= 0)
Pm.AppStop(1);  //will by called "onAppStopBegin" with pEvent.Type == "HardStop"

oPmfTimeout.Value = "Application stops in " + nSecStop + " seconds";
nSecStop--;
}

function onViewClose(ev)
{
if (ev.CloseReason == "ok")
nSecStop = 0;
else
pMe.Root.RemoveEventTimer(onTimeOut, 0);
}

function onViewLoad(ev)
{
var oForm = ev.Form;
oForm.Title = "Application stop";

oForm.CreateItem("separ", "separ", "", "Subtype:space;TitlePos:no;BodyHeightIni:1;");

oPmfTimeout = oForm.CreateItem("string", "msg", "", "Subtype:static;TitlePos:no;Multiline:1;ValueHorzAlign:center;");
oPmfTimeout.Value = "Application stops in " + nSecStop + " seconds";
}

if (pEvent.Type == "Stop")
{
pEvent.Enabled = false;
pMe.Root.AddEventTimer(1000, -1, onTimeOut);

var oCreator = Pm.CreateView(pMe.PmPanel, "/#glob/form", "", "target:_blank;modal:1;");
oCreator.View.onLoad = onViewLoad;
oCreator.View.onClose = onViewClose;
oCreator.Open();
pMe.Methods.SaveConfigApp();  //user method
}
PROMOTIC 9.0.12 SCADA system documentation - MICROSYS, spol. s r.o.

Send page remarkContact responsible person
© MICROSYS, spol. s r. o.Tavičská 845/21 703 00 Ostrava-Vítkovice