C# API for Windows
Requirements
Please see the readme.txt
file that accompanies Instream for Instream requirements information.
You will also need:
-
Access to persons with knowledge of C# and Instream
-
Microsoft Windows. There is no UNIX version of this API
-
Microsoft Visual Studio 2010 or later
Setting up your Environment
-
Put Instream's Bin directory in your path.
-
The DllImport attribute is used to specify the name of the DLL (
CSInstreamAPI.dll
) that contains the methods that are available in the API. This attribute is set when Instream is installed. There are several examples in the C# sample (i.e., fsInstreamAPI.cs).The example below references the Instream_info method in the
CSInstreamAPI.dll
.[ DllImport(@"d:\Foresight\instream\8.7\Bin\CSInStreamAPI.dll",
CharSet=CharSet.Ansi, CallingConvention=CallingConvention.StdCall)]
public static extern int InStream(UpdateMessage myCallBack, *ref InStream_info *mobj, string edibuf );Note: If you moveCSInStreamAPI.dll
to a different location, you must change the path name in the values property of the DllImport attribute.
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:
-
You must customize the Report section at the very end if you want to use memory output.
-
If you move
CSInStreamAPI.dll
, update the path to it in this file. -
Do not change anything else.
fsInStreamAPI
Method | Details |
---|---|
DocInValidEdi (memory output only) |
Memory buffer for the Docsplitter invalid EDI output |
Example:
|
|
DocReport (memory output only) | Memory buffer for the Docsplitter output report |
Example:
|
|
DocValidEdi (memory output only) | Memory buffer for the Docsplitter valid EDI output |
Example:
|
|
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:
|
|
DS_DebugOptions |
0 turns off debug Docsplitter messages 1 turns on debug Docsplitter messages |
Example:
|
|
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:
|
|
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:
|
|
DS_outputfile | Gives the name of the validation detail results file for Docsplitter input. |
Example:
|
|
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:
|
|
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:
|
|
DSUB_guideline | Points to Docsplitter input guideline. This is needed when Docsplitter is being used in the mode that calls Instream. |
Example:
|
|
DSUB_EDIOutputFile | Points to Docsplitter EDI output file. |
Example:
|
|
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:
|
|
DSUB_szInStreamFile | Points to the Instream detail results file that is to be used for Docsplitter input. |
Example:
|
|
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:
|
|
envelop |
Definition of the ISA and GS if DocumentOnly is used. |
Example: static string
static string
|
|
ErrorMessage | Returns the text of the last program error encountered by Instream validation, Docsplitter, or Response Generator. |
Example:
|
|
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:
|
|
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 |
Example:
|
|
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:
or
|
|
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:
|
|
Instream DocSplit RespGen DataSubstitution |
Procedures that run validation, Docsplitter, Response Generator, and Docsplitter. |
Example:
|
|
OutputBuf997 OutputBuf277 OutputBuf824 OutputBufTA1 OutputBufCus |
(Response Generator memory output only) These are the buffer names for the Response Generator output. |
Example:
|
|
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:
|
|
profile | Gives the name of the validation profile file. |
Example:
|
|
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:
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:
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:
|
|
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:
|
|
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:
|
|
respGenOutputOption |
Specifies that the Response Generator output is to go to memory or to a file. It can be set to: OutputByMemory OutputbyFile |
Example:
|
|
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:
|
|
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:
|
|
SummaryMessage | Sends the summary report to memory when OutputByMemory is used. |
Example:
|
|
userMessage |
Specifies free-form text to be inserted in a GEN record with number 15078. Example:
|
Example:
|