Index
Accessing Scrubbed EDI Data
Developers can access all data from an EDI file that has been scrubbed with the EDIFileScrubber using the EDILightWeightDocument returned after calling the Scrub() method. The EDILightWeightDocumentreturned enables access the EDI file. There is only one main loop containing all the scrubbed segments and elements that exist in the EDI file.
Example
// Create a new instance of EDIFileScrubber
EDIFileScrubber scrubber = new EDIFileScrubber
// Set the EDI file path to scrub
scrubber.EDIFile = “C:\\EDIFile.txt
// Set the scrubbing rule (s)
// Set element 0,1,2,3 of the ISA segment to be replaced by the character ‘Q’
ScrubRule rule = new ScrubRule();
rule.SegmentName = “ISA”;
rule.ReplaceCharacter = ‘Q’;
rule.ScrubPositions.Add(new ScrubPosition(0));
rule.ScrubPositions.Add(new ScrubPosition(1));
rule.ScrubPositions.Add(new ScrubPosition(2));
rule.ScrubPositions.Add(new ScrubPosition(3));
// Set composite element 0 element 0 of the SVC segment to be replaced by the character ‘W’
ScrubRule rule2 = new ScrubRule();
rule2.SegmentName = “SVC”;
rule2.ReplaceCharacter = ‘W’;
rule2.ScrubPositions.Add(new ScrubPosition(0,0));
scrubber.ScrubRules.Add(rule);
scrubber.ScrubRules.Add(rule2);
// scrub the data
EDILightWeightDocument scrubbedDocument = scrubber.Scrub();
// Get the main loop. This loop contains the entire scrubbed EDI document
LightWeightLoop mainLoop = scrubbedDocument.Loop[0]; //the main loop
// Get all segments
Collection<LightWeightSegment> allSegments = mainLoop.Segments;