C# API for Windows

Requirements

Please see the readme.txt file that accompanies Instream for Instream requirements information.

You will also need:

Setting up your Environment

Demo Files

Instream’s API\InStreamCSharpAPISample or API\ C#Sample directory contains a sample project. csharpDemo.cs is an example program.

TIBCO Foresight’s C# API is in fsInStreamAPI.cs. Changes to this file:

fsInStreamAPI

Method Details

DocInValidEdi (memory output only)

Memory buffer for the Docsplitter invalid EDI output

Example:

sw.Write(InStreamAPI.fsInStreamAPI.DocInValidEdi.ToString());

DocReport (memory output only) Memory buffer for the Docsplitter output report

Example:

sw.Write(InStreamAPI.fsInStreamAPI.DocReport.ToString());

DocValidEdi (memory output only) Memory buffer for the Docsplitter valid EDI output

Example:

sw.Write(InStreamAPI.fsInStreamAPI.DocValidEdi.ToString())

DocumentOnly This says that the EDI has no enveloping, or its enveloping should be ignored. It will be processed with the ISA and GS definitions specified in the envelope. DocumentOnly and the envelope must both be present if you want the enveloping to be processed this way. Another method for document-only processing is to use ignoreENV

Example:

insObj.flag |= fsInStreamAPI.DocumentOnly;

DS_DebugOptions

0 turns off debug Docsplitter messages

1 turns on debug Docsplitter messages

Example:

docSp.DS_DebugOptions = 1;

DS_inputFile

When using InputByFile, this gives the full path and name of the EDI data file that will be validated.

When using InputByMemory, this gives a name or title for the data to be output in the Start Message.

Example:

docSp.DS_inputFile = insObj.inputFile;

insObj.inputFile=INSTREAMROOT + @"DemoData\837I-Demo3.txt";

DS_Options

Docsplitter options to create valid and/or invalid EDI files using one of these:

DS_ReportValidOnly

DS_

ReportInvalidOnly

DS_ReportBoth

DS_ReportInvalidFile

Gives the path and filename of the Docsplitter invalid EDI file.

DS_ReportValidFile

Gives the path and filename of the Docsplitter valid EDI file.

Example:

docSp.DS_Options = fsInStreamAPI.DS_ReportBoth;

docSp.DS_ReportInvalidFile = INSTREAMROOT +@"Output\Doc_csharp_InValidFile.txt";

docSp.DS_ReportValidFile = INSTREAMROOT +@"Output\Doc_csharp_ValidFile.txt";

DS_outputfile Gives the name of the validation detail results file for Docsplitter input.

Example:

insObj.outputfile=INSTREAMROOT +@"Output\instreamcsharp_API_result1.TXT";

docSp.DS_outputfile = insObj.outputfile;

DS_ReportFile Gives the path and filename of the Docsplitter report. It will contain XML if the filename ends with .xml. It will be a delimited report if the filename ends with .csv.

Example:

instObj.DS_ReportFile=OUTPUTDIR+"My_Report.xml";

DSUB_EDIInputSourceOption

Sets Docsplitter’s EDI input to memory or file; used when Docsplitter is being used in the mode that calls Instream.

Docsplitter can input from memory if it calls Instream, but not if it accepts validation detail results as input. This can be set to:

InputByMemory

InputByFile

Example:

dsubObj.DSUB_EDIInputSourceOption = fsInStreamAPI.InputByMemory;

DSUB_guideline Points to Docsplitter input guideline. This is needed when Docsplitter is being used in the mode that calls Instream.

Example:

dsubObj.DSUB_guideline = "PDSA835";

DSUB_EDIOutputFile Points to Docsplitter EDI output file.

Example:

dsubObj.DSUB_EDIOutputFile = INSTREAMROOT +@"Output\C#APIExample6_DataSwapper_EDI2.txt";

DSUB_EDIOutputSourceOption

Sets Docsplitter report and EDI output to file.

Currently, Docsplitter can output to file, but not to memory.

This is set to:

OutputbyFile

Example:

dsubObj.DSUB_EDIOutputSourceOption = fsInStreamAPI.OutputByFile;
DSUB_ReportFile Points to Docsplitter report output file.
dsubObj.DSUB_ReportFile = INSTREAMROOT +@"Output\C#APIExample6_DataSwapper_Report2.txt";
DSUB_szEDIInputFile Points to Docsplitter EDI output file.

Example:

dsubObj.DSUB_szEDIInputFile = insObj.inputFile;

DSUB_szInStreamFile Points to the Instream detail results file that is to be used for Docsplitter input.

Example:

dsubObj.DSUB_szInStreamFile = insObj.outputfile;

edibuffer Input parameter pointing to memory buffer where input EDI data is to be found. This parameter is required when InputByMemory is specified in the flag parameter (see below), and ignored otherwise.
Edi_outputOption

Specifies that the Docsplitter valid and invalid EDI output is to go to memory or file.

Settings can be:

OutputByFile

OutputByMemory

Example:

docSp.Edi_outputOption=fsInStreamAPI.OutputByMemory;

envelop

Definition of the ISA and GS if

DocumentOnly is used.

Example:

static string

envlopISA="ISA*00* *00* *01*9012345720000 *01*9088877320000 *020108*1042*U*00200*000000001*0*T*:!";

static string

envGS="GS*HP*901234572000*908887732000*20020108*1615*1*X*004010X091!";

insObj.envelop=envlopISA+"\n"+envGS;

insObj.flag |= fsInStreamAPI.DocumentOnly;

ErrorMessage Returns the text of the last program error encountered by Instream validation, Docsplitter, or Response Generator.

Example:

if(retVal != 100)

{

Console.WriteLine(fsInStreamAPI.ErrorMessage);

}

fileInfo_mon

fileInfo_dayfile

Info_year

fileInfo_hour

fileInfo_min

fileInfo_sec

origFile_fsize OrigFilePathName

Specifies the month, day, year, hour, minute, second, size, and path of the original EDI file.

Example:

insObj.fileInfo_mon=2;

insObj.fileInfo_day=25;

insObj.fileInfo_year=2005;

insObj.fileInfo_hour=14;

insObj.fileInfo_min=12;

insObj.fileInfo_sec=34;

insObj.origFile_fsize = 9999989;

insObj.OrigFilePathName=@"C:\Documents and Settings\xxx\My Documents\abc.txt";

flag

Describes whether the input and output is by memory or file. Set this flag before you run validation.

InputByFile - The inputFile parameter contains a file name.

OutputByFile - The outputFile parameter contains a file name.

InputByMemory - (Instream validation only) the input EDI data is located in memory. The edibuffer parameter must also be set to point to the input buffer as described above.

OutputByMemory - (Instream validation only) the detail and summary output are to go to memory. Use the Report routine (at the end of fsInStreamAPI.cs) to perform the actual update to memory. This routine must be customized.

Example:

insObj.flag= fsInStreamAPI.InputByMemory | fsInStreamAPI.OutputByMemory;

guideline Gives the name of the guideline to be used for validation. If omitted, Instream uses the first guideline encountered that matches the data’s Version/Release Identifier code (Segment GS Element 08). If you are using Docsplitter, be sure it is a GuidelinePlus or is based on a GuidelinePlus (one that starts with PD).

Example:

insObj.guideline=@"PDSA837I";

or

insObj.guideline=@"MY850";

inputFile

When using InputByFile, this gives the full path and name of the EDI data file that will be validated.

When using InputByMemory, this gives a name or title for the data to be output in the Start Message.

Example:

insObj.inputFile=INSTREAMROOT + @"DemoData\837I-Demo3.txt";

Instream

DocSplit

RespGen

DataSubstitution

Procedures that run validation, Docsplitter, Response Generator, and Docsplitter.

Example:

int retVal=myObj.InStream(ref insObj);

retVal=myObj.DocSplit(ref docSp)

retVal=myObj.RespGen(ref respgen);

retVal=apiObj.DataSubstitution(ref dsubObj);

OutputBuf997

OutputBuf277

OutputBuf824

OutputBufTA1

OutputBufCus

(Response Generator memory output only) These are the buffer names for the Response Generator output.

Example:

sw.Write(InStreamAPI.fsInStreamAPI.OutputBuf997.ToString());

outputFile

Gives the name of the validation detail results file.

When using OutputByFile, this specifies the full path name to the output detail file.

When using OutputByMemory, this is a file name to be used if needed due to failure of memory output.

Example:

insObj.outputfile=INSTREAMROOT +@"Output\instreamcsharp_API_result1.TXT";

profile Gives the name of the validation profile file.

Example:

insObj.Profile = "users.apf";

Report

This writes EDI to memory.

Please see the Report routine at the end of fsInStreamAPI.cs. You must override this routine to perform the actual output as desired.

If you want to terminate validation, return the constant false.

If you want to continue validation, return the constant true.

Report_FormatOption

(memory output only)

Specifies the format of the Docsplitter report, one of these:

DocXMLFormat

DocCSVFormat

The XML format slows performance more than the CSV format.

Report_outputOption

Specifies that the Docsplitter report is to be output to memory or file. Settings can be:

OutputByFile

OutputByMemory

RG_fs997Report

RG_fs999Report

RG_fs824ReportRG_fs277ReportRG_fsTA1ReportRG_fsTextReport

(memory output only)

If set to 1, these create the specific types of Response Generator output in memory.

Example:

instObj.fs999Report = true;

Since RG_fs824Report is set to 1, this example creates 824 output in memory.

It does not create TA1 output.

RG_Options Response Generator options, which can include any options mentioned in TIB_fsp-instream_<n.n.n>_RespGen.pdf.

Example:

respgen.RG_Options="-ge -y";

This example specifies that group enveloping is to be included in the response documents and that Response Generator can overwrite files if they exist.

Note: When specifying Response Generator options via the API, leave no space between the option and its value. For example, use -er3 instead of -er 3. Spaces may cause the API response generator call to fail.
RG_outputfile Gives the name of the validation detail results file for Response Generator input.

Example:

insObj.outputfile=INSTREAMROOT +@"Output\instreamcsharp_API_result1.TXT";

respgen.RG_outputfile = insObj.outputfile;

RG_Rep277

RG_Rep824

RG_Rep997

Gives the name of the EDI file(s) to be created by Response Generator.

(For TA1 generation, use RG_Options with -gTA1 n.)

Example:

respgen.RG_Rep997=INSTREAMROOT +@"Output\RespGen_csharp_997.txt";

respGenInputOption

Specifies that the Instream detail results file that serves as input to Response Generator is in memory or in a file. It can be set to:

InputByMemory

InputByFile

Example:

respgen.RG_respGenInputOption = fsInStreamAPI.InputByMemory;

respGenOutputOption

Specifies that the Response Generator output is to go to memory or to a file. It can be set to:

OutputByMemory

OutputbyFile

Example:

respgen.RG_respGenOutputOption = fsInStreamAPI.OutputByMemory;

RG_repText

RG_Reptemp

RG_repText gives the name of a custom text report to be created by Response Generator.

RG_Reptemp gives the name of the template that controls the format of the custom text report.

If you use one of these, use both.

Example:

respgen.RG_repText=INSTREAMROOT +@"Output\RespGen_csharp_text.txt";

respgen.RG_Reptemp=INSTREAMROOT + @"DemoData\RGtemplate837I_c.txt";

seg_separator

elm_separator

comp_separator

Separators for “document-only” validation - when the data does not have ISA or GS enveloping, or when the enveloping is to be ignored.

They can be in these formats:

integer example: 29

hexadecimal example: 0x1E

character example: ~

ignoreENV

Validation is to ignore ISA and GS enveloping and use the separators provided with seg_separator, elm_separator, and comp_separator.

This requires that seg_separator, and comp_separator be provided, and it must come AFTER them.

Another method for document-only processing is to use DocumentOnly (see page C# API for Windows).

Example:

insObj.seg_separator='~';

insObj.elm_separator='*';

insObj.comp_separator=':';

insObj.ignoreENV=true;

SummaryMessage Sends the summary report to memory when OutputByMemory is used.

Example:

Console.WriteLine(fsInStreamAPI.summaryMessage);

userMessage

Specifies free-form text to be inserted in a GEN record with number 15078.

Example:

GEN 015078 1 0Sock 2

Example:

insObj.userMessage="Sock 2";