date : 04/14/2010
customer name : John doe
address : 2014 apple st. Chicago, IT 30000
sale order : 04/15/2010
confirmation tag : abcdefghi
date : 12/14/2010
customer name : reza rad
address : Tehran Iran
sale order : 02/15/2010
confirmation tag : rererererere
date : 06/14/2009
customer name : Abolfazl rad goudarzi
address : Tehran Iran
sale order : 02/05/2010
confirmation tag : fasgfsagas
public override void Input0_ProcessInput(Input0Buffer Buffer)
{
while (Buffer.NextRow())
{
Input0_ProcessInputRow(Buffer);
}
if (Buffer.EndOfRowset())
{
myFlatOutputBuffer.SetEndOfRowset();
}
}
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
if(Row.Column0.ToLower().Trim() == "date")
{
myFlatOutputBuffer.AddRow();
}
switch(Row.Column0.ToLower().Trim())
{
case "date":
myFlatOutputBuffer.date = DateTime.ParseExact(Row.Column1.Trim(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
break;
case "customer name":
myFlatOutputBuffer.customername = Row.Column1.Trim();
break;
case "address":
myFlatOutputBuffer.address = Row.Column1.Trim();
break;
case "sale order":
myFlatOutputBuffer.saleorder = DateTime.ParseExact(Row.Column1.Trim(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
break;
case "confirmation tag":
myFlatOutputBuffer.confirmationtag = Row.Column1.Trim();
break;
}
}
/* Microsoft SQL Server Integration Services Script Component
* Write scripts using Microsoft Visual C# 2008.
* ScriptMain is the entry point class of the script.*/
using System;
using System.Data;
using Microsoft.SqlServer.Dts.Pipeline.Wrapper;
using Microsoft.SqlServer.Dts.Runtime.Wrapper;
[Microsoft.SqlServer.Dts.Pipeline.SSISScriptComponentEntryPointAttribute]
public class ScriptMain : UserComponent
{
public override void PreExecute()
{
base.PreExecute();
/*
Add your code here for preprocessing or remove if not needed
*/
}
public override void PostExecute()
{
base.PostExecute();
/*
Add your code here for postprocessing or remove if not needed
You can set read/write variables here, for example:
Variables.MyIntVar = 100
*/
}
public override void Input0_ProcessInputRow(Input0Buffer Row)
{
if(Row.Column0.ToLower().Trim() == "date")
{
myFlatOutputBuffer.AddRow();
}
switch(Row.Column0.ToLower().Trim())
{
case "date":
myFlatOutputBuffer.date = DateTime.ParseExact(Row.Column1.Trim(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
break;
case "customer name":
myFlatOutputBuffer.customername = Row.Column1.Trim();
break;
case "address":
myFlatOutputBuffer.address = Row.Column1.Trim();
break;
case "sale order":
myFlatOutputBuffer.saleorder = DateTime.ParseExact(Row.Column1.Trim(), "MM/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture);
break;
case "confirmation tag":
myFlatOutputBuffer.confirmationtag = Row.Column1.Trim();
break;
}
}
public override void Input0_ProcessInput(Input0Buffer Buffer)
{
while (Buffer.NextRow())
{
Input0_ProcessInputRow(Buffer);
}
if (Buffer.EndOfRowset())
{
myFlatOutputBuffer.SetEndOfRowset();
}
}
public override void CreateNewOutputRows()
{
/*
Add rows by calling the AddRow method on the member variable named "<Output Name>Buffer".
For example, call MyOutputBuffer.AddRow() if your output was named "MyOutput".
*/
}
}
Have a question about something in this article? You can receive help directly from the article author. Sign up for a free trial to get started.
Comments (0)