<ADCS-VT100-Log> <datablock direction="to NAVISION" timeStamp="2015-01-30 16:40.16,55"> <ADCS> <Header ID="49676947" Sequence="0" UseCaseCode="hello" /> </ADCS> </datablock> <datablock direction="to TERMINAL" timeStamp="2015-01-30 16:40.16,566"> <ADCS> <Header ID="49676947" Sequence="0" UseCaseCode="LOGIN" StackCode="" RunReturn="0" FormTypeOpt="Card" NoOfLines="2" InputIsHidden="0"> <Comment /> <Functions> <Function>ESC</Function> </Functions> </Header> <Lines> <Header> <Field Type="Text" MaxLen="19">Herzlich Willkommen</Field> </Header> <Body> <Field FieldID="1" Type="Input" MaxLen="20" Descrip="Benutzer ID" /> <Field FieldID="2" Type="OutPut" MaxLen="250" Descrip="Kennwort:" /> </Body> </Lines> </ADCS> </datablock> <datablock direction="to NAVISION" timeStamp="2015-01-30 16:41.03,887"> <ADCS> <Header ID="49676947" Sequence="14" UseCaseCode="LOGIN" StackCode="" RunReturn="0" FormTypeOpt="Card" NoOfLines="2" InputIsHidden="0"> <Functions> <Function Key1="27">ESC</Function> </Functions> <Input FieldID="1">kommiss_Md07</Input> </Header> <Lines> <Header> <Field Type="Text" MaxLen="19">Herzlich Willkommen</Field> </Header> <Body> <Field FieldID="1" Type="Input" MaxLen="20" Descrip="Benutzer ID" /> <Field FieldID="2" Type="OutPut" MaxLen="250" Descrip="Kennwort:" /> </Body> </Lines> </ADCS> </datablock> <datablock direction="to TERMINAL" timeStamp="2015-01-30 16:41.03,902"> <ADCS> <Header ID="49676947" Sequence="14" UseCaseCode="LOGIN" StackCode="" RunReturn="0" FormTypeOpt="Card" NoOfLines="2" InputIsHidden="1" LoginID="KOMMISS_MD07"> <Comment /> <Functions> <Function>ESC</Function> </Functions> </Header> <Lines> <Header> <Field Type="Text" MaxLen="19">Herzlich Willkommen</Field> </Header> <Body> <Field FieldID="1" Type="OutPut" MaxLen="20" Descrip="Benutzer ID">KOMMISS_MD07</Field> <Field FieldID="2" Type="Input" MaxLen="250" Descrip="Kennwort:" /> </Body> </Lines> </ADCS> </datablock> </ADCS-VT100-Log>Inside the <datablock>-tag you see the original xml data which is exchanged between VT100 and NAV. New datablocks are always appended at the end.
PROCEDURE LogData@1000000000(pSend@1000000000 : Boolean;VAR vDocument@1000000001 : Text); VAR LXmlDoc@1000000002 : DotNet "'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument"; LXmlDoc1@1000000003 : DotNet "'System.Xml, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlDocument"; LRootNode@1000000004 : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"; LImportNode@1000000005 : DotNet "'System.Xml, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089'.System.Xml.XmlNode"; LXMLDOMMgt@1000000006 : Codeunit 6224; LDocument@1000000007 : Text; LDirection@1000000008 : Text; LFilename@1000000009 : Text; LPath@1000000010 : Text; BEGIN LPath := 'C:\Temp\'; LFilename := 'Protocol.xml'; IF NOT EXISTS(LPath+LFilename) THEN BEGIN LXmlDoc := LXmlDoc.XmlDocument; LXmlDoc.LoadXml('<ADCS-VT100-Log></ADCS-VT100-Log>'); LXmlDoc.Save(LPath+LFilename); CLEAR(LXmlDoc); END; IF pSend THEN LDirection := 'to TERMINAL' ELSE LDirection := 'to NAVISION'; LDocument := '<datablock direction="'+LDirection+'" timeStamp="'+FORMAT(CURRENTDATETIME,0,'<Year4>-<Month,2>-<Day,2> <Hours24,2>:<Minutes,2>.<Seconds,2><Second dec.><Comma,,>')+'">' + vDocument + '</datablock>'; // Load new data part LXmlDoc1 := LXmlDoc1.XmlDocument; LXmlDoc1.LoadXml(LDocument); LXmlDoc := LXmlDoc.XmlDocument; // Load existing Protocol LXmlDoc.Load(LPath+LFilename); LRootNode := LXmlDoc.DocumentElement; // Append new data part in existing protocol LImportNode := LXmlDoc.ImportNode(LXmlDoc1.DocumentElement,TRUE); LRootNode.AppendChild(LImportNode); // save and that's all LXmlDoc.Save(LPath+LFilename); END;You can easily change the location of the file and its name.
PROCEDURE ProcessDocument(...); BEGIN LogData(FALSE,Document); // <<<<<<<<<<<<<<<< log data from VT100 InputXmlDocument := InputXmlDocument.XmlDocument; InputXmlDocument.LoadXml(Document); ADCSManagement.ProcessDocument(InputXmlDocument); ADCSManagement.GetOutboundDocument(OutputXmlDocument); Document := OutputXmlDocument.OuterXml; LogData(TRUE,Document); // <<<<<<<<<<<<<<<< log data from NAV END;