Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
create table Customers (
Id big int not null primary key,
Name varchar(50),
Line1 varchar(50),
Line2 varchar(50),
City varchar(50),
State varchar(50),
ZipCode int
)
internal class Program
{
private static void Main()
{
using (new Logging())
{
using (var process = new DatabaseToFileProcess())
{
process.Execute();
}
Console.ReadLine();
}
}
}
public class Logging : IDisposable
{
public Logging()
{
BasicConfigurator.Configure();
}
public void Dispose()
{
LogManager.Shutdown();
}
}
public class DatabaseToFileProcess : EtlProcess
{
protected override void Initialize()
{
var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "customers.csv");
Register(new ConventionInputCommandOperation("source")
{
Command = "select * from Customers"
})
.Register(new PutDataInFile(path));
}
}
public class PutDataInFile : AbstractOperation
{
private readonly string destinationFile;
public PutDataInFile(string destinationFile)
{
this.destinationFile = destinationFile;
}
public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
{
using (var file = FluentFile.For<Customer>().AppendTo(destinationFile))
{
foreach (var row in rows)
{
file.Write(row.ToObject<Customer>());
yield return row;
}
}
}
}
[DelimitedRecord(",")]
public class Customer
{
public long Id;
[FieldQuoted]
public string Name;
[FieldQuoted]
public string Line1;
[FieldQuoted]
public string Line2;
[FieldQuoted]
public string City;
[FieldQuoted]
public string State;
public int ZipCode;
}
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="source" connectionString="Server=.\SqlExpress;initial catalog=EtlSpike;Integrated Security=SSPI;" providerName="System.Data.SqlClient"/>
</connectionStrings>
</configuration>
public class PutDataInFileAndSendEmail : AbstractOperation
{
private readonly string destinationFile;
public PutDataInFile(string destinationFile)
{
this.destinationFile = destinationFile;
}
public override IEnumerable<Row> Execute(IEnumerable<Row> rows)
{
using (var file = FluentFile.For<Customer>().AppendTo(destinationFile))
{
foreach (var row in rows)
{
file.Write(row.ToObject<Customer>());
yield return row;
}
}
EmailFile();
}
private void EmailFile()
{
var message = new MailMessage
{
//to, from, body, header
};
message.Attachements.Add(new FileInfo(destinationFile));
new SmtpClient().AsyncSend(message);
}
}