Created
March 21, 2011 01:42
-
-
Save PaulStovell/878893 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class CsvExportMessageHandler : IHandleMessages<BeginCsvExportMessage> | |
{ | |
public IExportFileCreator FileCreator { get; set; } | |
public IExportFormatter Formatter { get; set; } | |
public IBus Bus { get; set; } | |
public ILog Log { get; set; } | |
public void Handle(BeginCsvExportMessage message) | |
{ | |
Log.Info("Performing CSV Export on: " + message.Assessment.AssessmentReportGuid); | |
var path = FileCreator.CreateExportFile(message.Assessment.AssessmentReportGuid); | |
using (var writer = new StreamWriter(path)) | |
using (var csv = new CsvWriter(writer)) | |
{ | |
Formatter.Export(message.Assessment.AssessmentReportGuid, csv); | |
} | |
var reply = message.CreateReply(); | |
reply.ExportFileLocation = path; | |
Bus.Reply(reply); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment