Feedback

  • Contents
 

Sample Pre-processing Code

The following sample code adds the current date in MMDDCCYY format to the end of any line that starts with an “A” in a fixed-length file format:  

using GSS.Common.Code;

using System.IO;

using System;

using System.Data;

using System.Data.SqlClient;

using System.Xml;

public class CodeProcessor : ICodePreprocessor

{

public string Execute (string fileContents)

{

string newFile = Path.GetTempFileName();

string record = string.Empty;

// fileContents is the path to the file..

using (StreamReader reader = new StreamReader (@fileContents)){

using (StreamWriter writer = new StreamWriter (@newFile)){

while ((record = reader.ReadLine()) !=null){

// If the record is an A record then append the

// current date to the

// record and write it to the new file.

if (record.Substring(0,1) == "A")

record += DateTime.Now.ToString("MMddyyy");

writer.WriteLine(record);

}

}

}

return newFile;

}

// Have to Implement this method this is as ICodePreprocessor implements IDisposable

public void Dispose(){

}

}

Assembly Examples

Examples of assemblies you can use when writing a pre-process script are:

.NET Framework assemblies

mscorlib.dll

System.dll

System.Data.dll

System.Xml.dll

Latitude proprietary assemblies:

GSSI.Latitude.Library.dll

GSS Common.dll

Related Topics

Add a Regex Replacement

Configure Code Pre-processing

General Configuration