As400Program class
Estimated reading time: 8 minutes
Represents a program in the ASNA DataGate client.
Namespace: ASNA.DataGate.Client Assembly: ASNA.QSys.DataGate.Client.dll
Inheritance: Object
Thread Safety
Any public static (Shared) members of this type are safe for multithreaded operations. Any instance members are not guaranteed to be thread safe.
Remarks
This class provides methods and properties to manage a program in the ASNA DataGate client. It includes methods to set the program path and connection, execute the program, get and append parameters, convert parameters to and from objects, set parameters to zero value, and read and write parameters in XML format. It also implements the IDisposable interface, which provides a mechanism for releasing unmanaged resources.
Constructors
| Name | Description |
|---|---|
| As400Program() | Initializes a new instance of the class. |
| As400Program(AdgConnection) | Initializes a new instance of the class with the specified connection. |
| As400Program(AdgConnection, String) | Initializes a new instance of the class with the specified connection and program path. |
Methods
| Signature | Description |
|---|---|
| AppendParm(ProgParm) | Appends a parameter to the program. |
| AppendParm(ProgParm) | Appends a parameter to the specified list of parameters. |
| AppendParms(ProgParm[]) | Appends an array of parameters to the program. |
| Dispose() | Releases all resources used by the current instance of the class. |
| Dispose(Boolean) | Releases the unmanaged resources used by the and optionally releases the managed resources. |
| Execute() | Executes the program with the current parameters. |
| Finalize() | Finalizes an instance of the class. |
| GetParameters() | Gets the parameters of the program. |
| GetParmByName(String) | Gets the parameter with the specified name. |
| GetParmByName(String) | Gets the parameter with the specified name from the specified list of parameters. |
| ObjectToParm(ProgParm, Object, Int32) | Converts the specified object to a parameter of the specified type. |
| ObjectToParm(ProgParm, Object) | Converts the specified object to a parameter. |
| ObjectToParm(Object, String, Int32[]) | Converts the specified object to a parameter of the specified name and element indices. |
| ObjectToParm(Object, String) | Converts the specified object to a parameter of the specified name. |
| ParmToObject(ProgParm, Type, Int32) | Converts the specified parameter to an object of the specified type. |
| ParmToObject(ProgParm, Type) | Converts the specified parameter to an object of the specified type. |
| ParmToObject(Type, String, Int32[]) | Converts the specified parameter to an object of the specified type. |
| ParmToObject(Type, String) | Converts the specified parameter to an object of the specified type. |
| ReadParmXml(XmlReader) | Reads the parameters of the program from an XML reader. |
| SetConnection(AdgConnection) | Sets the connection to be used by the program. |
| SetParmsZeroValue() | Sets all parameters of the program to their zero value. |
| SetProgramPath(String) | Sets the path of the program to be executed. |
| WriteParmXml(XmlWriter) | Writes the parameters of the program to an XML writer. |
Example 1. As400Program constructor method example.
/* Here, "ProdDB" is an initialized AdgConnection and
* Call400 is a valid IBM i program file. */
As400Program prog = new As400Program(ProdDB, "*Libl/Call400");
Example 2. As400Program constructor method example 2.
//Here, "ProdDB" is an initialized AdgConnection.
As400Program prog = new As400Program(ProdDB);
prog.SetProgramPath( "*Libl/Call400" );
Example 3. As400Program constructor method example 3.
//Here, "ProdDB" is an initialized AdgConnection.
As400Program prog = new As400Program();
prog.SetConnection( ProdDB );
prog.SetProgramPath("*Libl/Call400");
Example 4. ParmToObject method example.
/* Here, Prog is an initialized As400Program object
* and CustName, TimeOfDay, and Quit400App are valid
* string, decimal, and char types respectively. */
ProgParm[] Parms = new ProgParm[3];
Parms[0] = new ProgParm(
new ProgParmType("CustName", 0, FieldType.NewChar(40)), DataDirection.Output);
Parms[1] = new ProgParm(
new ProgParmType("TimeOfDay", 0, FieldType.NewPacked(6, 0)), DataDirection.Output);
Parms[2] = new ProgParm(
new ProgParmType("Quit400App", 0, FieldType.NewChar(1)), DataDirection.Input);
prog.AppendParms(Parms);
prog.ObjectToParm(Parms[2], Quit400App, 0);
prog.Execute();
/* After calling the last two values in the parameter list
* will have new values in it. To read them, we set our local
* variables to the returned values in the parameters list. */
CustName = Convert.ToString(
prog.ParmToObject(System.Type.GetType("System.String"),
"CustName",
0));
TimeOfDay = Convert.ToDecimal( prog.ParmToObject(System.Type.GetType("System.Decimal"),
"TimeOfDay",
0));
Example 5. ObjectToParm method example.
/* Here, "prog" is an initialized As400Program object.
* The first two lines creates a IBM i character data type whose
* length is one, and then appends it to "prog"'s parameter list. */
ProgParm QuitParm = new ProgParm(
new ProgParmType("Quit400App", 0, FieldType.NewChar(1)),
DataDirection.InputOutput );
prog.AppendParm(QuitParm);
char QuitChar = '1';
/* This next line assigns the .NET value, CustName, to the
* IBM i data type of the same name in the parameter list. */
prog.ObjectToParm(QuitParm, QuitChar, 0);
Example 6. as400Program Connection property example.
As400Program prog = new As400Program();
prog.SetConnection( createAdgConnection("YourIBMi") );
prog.SetProgramPath( "*Libl/Call400" );
Example 7. as400Program AppendParms method example.
/* Here, Prog is an initialized As400Program object,
* and CustName, TimeOfDay, and Quit400App are valid
* string, decimal, and char types respectively. */
ProgParm[] Parms = new ProgParm[]
{
new ProgParm(new ProgParmType("CustName", 0, FieldType.NewChar(40)),
DataDirection.Output),
new ProgParm(new ProgParmType("TimeOfDay", 0, FieldType.NewPacked(6, 0)),
DataDirection.Output),
new ProgParm(new ProgParmType("Quit400App", 0, FieldType.NewChar(1)),
DataDirection.Input)
};
prog.AppendParms(Parms);
prog.ObjectToParm(Quit400App, "Quit400App", new int[]{});
prog.Execute();
CustName = Convert.ToString(
prog.ParmToObject(System.Type.GetType("System.String"),
"CustName",
new int[]{}));
TimeOfDay = Convert.ToDecimal(
prog.ParmToObject(System.Type.GetType("System.Decimal"),
"TimeOfDay",
new int[]{}));
Example 8. as400Program AppendParm method example.
/* Here, prog is an initialized As400Program.
* We add the field "CustName" to the parm list, and a local
* string variable by the same name into it. After calling the
* program, we then set the local variable to the returned
* value in the parms list. */
prog.AppendParm( new ProgParm(
new ProgParmType("CustName", 0, FieldType.NewChar(40)),
DataDirection.InputOutput
));
//Store the value to pass in.
prog.ObjectToParm( CustName, "CustName", new int[]{} );
prog.Execute();
//Fetch the returned value.
CustName = Convert.ToString(
prog.ParmToObject(System.Type.GetType("System.String"), "CustName",
new int[]{}));
Example 9. as400Program SetProgramPath method example.
As400Program prog = new As400Program();
prog.SetConnection( createAdgConnection("YourIBMi") );
prog.SetProgramPath = "*Libl/Call400";
See AdgConnection Example for an implementation of
createAdgConnection()