Executes a command on the IBM i's Job associated with the database connection by calling IBM's QCMDEXC
.
Syntax
BegFunc IvokeQCmdExc Access(*Public) Type(*String) DclSrParm name Type (*String)
Parameters
-
name
- The name of the object whose value is to be returned.
Return Value
A string containing a value for the named entry from the jobs' local data collection.
Exceptions
The following exceptions may be encountered during the execution of this method.
Value | Condition |
---|---|
MonarchJobEndedException | The Monarch Job has ended in an exception. |
MonarchJobUnavailableException | There is no Monarch Job available to accept commands. |
Remarks
This method (added in 8.0) executes a command on the IBM i's Job associated with the database connection
by calling IBM's QCMDEXC
.
The WingsJob or MobileRPG Job should have suspended its execution by calling either AcceptCommands
or ShowPage
(see http://devnet.asna.com/documentation/Help140/MonarchFX/_HTML/amfconEnhancingWithNonDisplayFileASPX.htm).
While the executing thread is in this suspended state, a method in the code-behind of the web site can call InvokeQCmdExc
,
which will forward the command to the IBM i Job for its execution.
public string QCmdExc(string command, string callbackPage)
QCmdExc
executes a command on the IBM i's Job associated with the database connection.
If during the execution of the command a screen is displayed, control does not return to the caller, instead,
control is transferred to the page on the callbackPageCaller
parameter.
public string QCmdExc(string command)
QCmdExc
executes a command on the IBM i's Job associated with the database connection.
The execution of the command should not involve any screen I/O.
Wings Example
public partial class Menu : System.Web.UI.Page
{
protected void btnGo_Click(object sender, EventArgs e)
{
ASNA.Monarch.Command command = new ASNA.Monarch.Command(Context);
int option = int.Parse(txtOption.Text);
switch (option)
{
case 1:
{
command.InvokeQCmdExc("CHGCURLIB ERNUEXPRES");
command.InvokeQCmdExc("CALL CUSTINQ", "~/Menu.aspx");
break;
}
case 2:
{
command.InvokeQCmdExc("DSPLIBL", "~/Menu.aspx");
break;
}
case 3:
{
Response.Redirect("~/CommandLine.aspx");
break;
}
case 4:
{
command.Return("SIGNOFF");
break;
}
}
}
}
The resulting WingsJob will resemble the following.
public partial class WingsJob : ASNA.Monarch.WebJob
{
private AVRRuntime.Database myDatabase;
override protected AVRRuntime.Database getDatabase()
{
return myDatabase;
}
override public void Dispose( bool disposing )
{
if( disposing )
myDatabase.Close();
base.Dispose( disposing );
}
protected override void ExecuteStartupProgram()
{
myDatabase = new AVRRuntime.Database("", AVRRuntime.VirtualTerminal.MonarchWeb, AVRRuntime.OpenAccessDspF.Wings);
myDatabase.Server = "MyServer";
myDatabase.Label = "DB2";
myDatabase.Port = 5042;
myDatabase.User = LDC["UserName"] as string;
myDatabase.Password = LDC["Password"] as string;
LDC["Password"] = "";
try
{
myDatabase.Open();
}
catch (Exception e)
{
string error = e.Message;
}
string rv = AcceptCommands();
}
}
Requirements
Namespace: ASNA.Monarch.WebDspF
Assembly: ASNA.Monarch.WebDspF.DLL
Platforms: Windows Server 2012, Windows Server 2012 R2, Windows Server 2016, Windows 7, Windows 8 Pro, Windows 8.1 Pro, Windows 10 Pro