PreviousNext
Help > Easycom .NET > Easycom namespace > EacXML > Example 3
Example 3

 

This example is provided with demo samples.

PCML decriptions are used. PCML file is on Windows side or on IBMi IFS.

           EacXML myEacXML = new EacXML(ConnectionIBM);

 

            //Load program prototypes

            XDocument doc = XDocument.Load("define.xml");

 

            string stringXMLOut = myEacXML.XmlExecRequest(XMLToString(doc));

 

myEacXML.XmlLoadDefinition("PCML", "/usr/local/easycom/PCML/QSYRUSRI.pcml");

 

            // Call QGYOLAUS system API

            doc = XDocument.Load("program.xml");

            stringXMLOut = myEacXML.XmlExecRequest(XMLToString(doc));

 

//Parse XML out to retrieve the following values:totalRcds, rcdLength, rqsHandle

XElement root = XElement.Parse(stringXMLOut).Element("Program").Element("ParameterList").Element("listInfo");

            string requestHandle = (string)root.Element("rqsHandle");

            int rcdsToReturn = (int)root.Element("totalRcds");

            int rcdLength = (int)root.Element("rcdLength");

            int receiverLength = rcdLength * rcdsToReturn;

 

            // Call qgygtl program

            doc = XDocument.Load("program2.xml");

            XElement Elmt = doc.Root.Element("Program");

 

Elmt.Element("parameterList").Add(new XElement("receiverLength", receiverLength.ToString()));

Elmt.Element("parameterList").Add(new XElement("requestHandle", requestHandle));

Elmt.Element("parameterList").Add(new XElement("rcdsToReturn", rcdsToReturn.ToString()));

            Elmt.Element("parameterList").Add(new XElement("STARTINGRCD", "1"));

 

            stringXMLOut = myEacXML.XmlExecRequest(XMLToString(doc));

 

//Parse XML out to create list of Users. Retrieve the following values: NAME

            XElement root2 = XElement.Parse(stringXMLOut);

            List<string> userList = new List<string>();

 

            IEnumerable<XElement> item2 =

from el in root2.Element("Program").Element("ParameterList").Element("receiver").Elements("item")

                select el.Element("NAME");

           

       foreach (XElement el in item2)

            {

                userList.Add(el.Value);

            }

 

            BindingSource bs = new BindingSource();

            bs.DataSource = userList;

            checkedListBoxUsers.DataSource = bs;

 

 

 

 

 

define.xml :

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">

  <define>

    <file type="PCML" stmf="/usr/local/easycom/PCML/QGYOLAUS.pcml" />

  </define>

</Easycom>

 

program.xml :

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">

  <Program Name="QGYOLAUS">

    <parameterList></parameterList>

  </Program>

</Easycom>

 

program2.xml:

 

<?xml version="1.0" encoding="utf-8" standalone="yes"?><Easycom LogFile="/tmp/xml_demo_cedrick.log" DebugLog="259">

  <Program Name="qgygtle">

    <parameterList></parameterList>

  </Program>

</Easycom>