protected void ReadCsv(ReadFile message) { // Open files var evenFilePathAppConfig = new EvenOpenFile(ConfigurationManager.AppSettings["EvenFilePath"]); _csvWriterActor.Tell(evenFilePathAppConfig); var oddFilePathAppConfig = new OddOpenFile(ConfigurationManager.AppSettings["OddFilePath"]); _csvWriterActor.Tell(oddFilePathAppConfig); // Write to them using (StreamReader reader = _streamReaderFactory.Create(message.FilePath)) { while (!reader.EndOfStream) { var strline = reader.ReadLine(); if (strline != null) { var values = strline.Split(','); foreach (var item in values) { var writeNumberMessage = new WriteNumber(Int32.Parse(item)); _csvWriterActor.Tell(writeNumberMessage); } } } } // Close the files var evenCloseFileMessage = new EvenCloseFile(); _csvWriterActor.Tell(evenCloseFileMessage); var oddCloseFileMessage = new OddCloseFile(); _csvWriterActor.Tell(oddCloseFileMessage); }
protected void StartWritingEven(EvenOpenFile message) { _evenWriter = _streamWriterFactory.Create(message.EvenFilePath); }