[ <- Previous Page ] | [ ^ Table Of Contents ^ ] | [ Next Page -> ] |
The zwebit library routines are generic functions for processing the core ptrkeys and idata tables. These routines encapsulate common functionality used by the acquisition and delivery programs as they need to update these tables.
Method/Function | Description | Return Codes |
---|---|---|
int initDbms (zLog &log, const zString &host, const zString &port, const zString &db) | Sets up the database connections and a ptr to the logfile object | -1=Error 0=Success |
int ifaceSts (const zString &iface, int TranSw) | Determines if a particular interface is turned on or off in the ptrkeys table | -1=Error 0=Interface off 1=Interface on |
int insertIfaceRec (const zString &iface, const zString &type, const zString &fmt, const zString &data) | Used by acquisition programs to insert an inbound transaction; parameter optseqno is optional and returns the seqno of the transmission, inserted into the engine | -1=Error 0=Success |
int getSeqNo (const zString & iface, zString & SeqNo | Returns the current sequence number SeqNo for a given interface iface | -1=Error 0=Success |
int updateIfaceSeqNo (const zString &iface, const zString &seqno, int TranSw = 0) | Updates sequence number seqno for interface iface | -1=Error 0=Success |
void prepDataString (zString& data) | Prepares a string of data for insertion into database; call before using insertIfaceRec ( ) | |
int getNextIfaceRec (const zString &iface, zString &seqno, zString &data, const zString & query) | Used by delivery programs to extract the next record from the engine to process | -1=Error 1=Success, record retrieved 0=No data found |
Before running the zwebit test program, you will need to add a test record to the ptrkeys table.
/* zwebit test program Copyright (c) 2000 HSC GNU/GPL */ #includeusing namespace std; #include "../../base/zstring.cpp" #include "../../base/zlog.cpp" #include "../../base/zwebit.cpp" int main() { int rc; zLog log; zWebit webit; zString ws; /* work string */ zString dataIn; /* data to send into the engine */ zString dataOut; /* data pulled out of the engine */ zString wsn; /* work seqence number */ /* set up the log file action */ log.setLogSize( 100000 ); log.setLogCount( 3 ); log.setBufSize( 32768 ); // 32K rc = log.openLog( "webitlog" ); if( rc != 0 ){ cout << "Error opening log file\n"; return -1; } log << "Program zwebit initializing"; /* initialize */ if( webit.initDbms( log, "localhost", "5432", "test" )) exit(1); rc = webit.ifaceSts( "TESTIFACE1", 1 ); switch( rc ){ case 1: cout << "TESTIFACE1 is ON" << endl; log << "TESTIFACE1 is ON"; break; case 0: cout << "TESTIFACE1 is OFF" << endl; log << "TESTIFACE1 is OFF"; break; default: cout << "Error " << rc << " with TESTIFACE1" << endl; log.writeFmtLog( "Error %d with TESTIFACE1", rc ); break; } if( webit.getSeqNo( "TESTIFACE1", ws, 1 )){ cout << "Error in getSeqNo" << endl; log << "Error in getSeqNo"; } else{ cout << "SeqNo for TESTIFACE1 =>" << ws << endl; log.writeFmtLog( "SeqNo for TESTIFACE1 = %s", ws.getData()); } /* next is the special key that is used for controlling the seq numbers */ if( webit.getSeqNo( "NEXT", ws, 1 )){ cout << "Error in getSeqNo" << endl; log << "Error in getSeqNo"; } else{ cout << "SeqNo for NEXT =>" << ws << endl; log.writeFmtLog( "SeqNo for NEXT = %s", ws.getData()); } dataIn = "Some Test dataIn with a ' and a \\ in it "; log.writeFmtLog( "Posting transaction to engine=>%s", dataIn.getData()); cout << "Posting transaction to engine=>" << dataIn << endl; webit.prepDataString( dataIn ); if( webit.insertIfaceRec( "TESTIFACE1", "TESTTYPE", "TESTFMT", dataIn )){ cout << "Error in insertIfaceRec" << endl; log << "Error in insertIfaceRec"; } else{ cout << "Posted transaction to engine" << endl; log << "Posted transaction to engine"; } /* pull out a dataIn transaction as if we were going to send it or do something with it */ if( webit.getNextIfaceRec( "TESTIFACE2", wsn, dataOut )){ cout << "Error in getNextIfaceRec" << endl; log << "Error in getNextIfaceRec"; } else { cout << "Pulled transaction from engine" << endl; cout << "seqno = " << wsn << endl; cout << "data = " << dataOut << endl; log << "Pulled transaction from engine"; log.writeFmtLog( "seqno = %s", wsn.getData()); log.writeFmtLog( "data = %s", dataOut.getData()); } /* clean up */ log.closeLog(); return 0; }
[ <- Previous Page ] | [ ^ Table Of Contents ^ ] | [ ^ Top Of Page ^ ] | [ Next Page -> ] |
Visit the GNU home page.
FSF & GNU inquiries & questions to
gnu@gnu.org.
Comments on these web pages to
info@zhsac.com.
Copyright (C) 2003 HealthCare Systems and Consulting
Verbatim copying and distribution of this entire article is
permitted in any medium, provided this notice is preserved.
Last updated: 07/21/2003