public void FolderService(FileModelClass fileModelToWrite) { if (!Directory.Exists(fileModelToWrite.FilePath)) { Directory.CreateDirectory(fileModelToWrite.FilePath); } }
public void Writing(FileModelClass fileModelToWrite) { using (var writeText = new StreamWriter(fileModelToWrite.FilePath + fileModelToWrite.FileName)) { writeText.WriteLine("Text example"); } }
public void FileWritingWorker(FileModelClass fileModelToWrite) { FolderService(fileModelToWrite); if (WriteFile(fileModelToWrite)) { WritingReport(fileModelToWrite); } }
private void InitializeComponents() { _fileEntity = new FileModelClass() { FilePath = FilePath }; _fileWriter = new FileWriter(_fileEntity); QueueService = new QueueService(); }
// Adding files to the queue public void PopulateQueue() { InitializeComponents(); for (var i = 0; i < FilesToWrite; i++) { Console.WriteLine("Please, enter file name: "); var fileName = Console.ReadLine(); var fileEntityNewElement = new FileModelClass { FilePath = FilePath, FileName = fileName + ".txt" }; QueueService.EnqueueEntity(fileEntityNewElement); } }
public bool WriteFile(FileModelClass fileModelToWrite) { try { Writing(fileModelToWrite); } catch (Exception e) { Console.WriteLine("We are having some issues writing your file, writing to app root folder."); } finally { fileModelToWrite.FilePath = ""; Writing(fileModelToWrite); } return(true); }
public FileWriter(FileModelClass fileModelClass) { _fileModelClass = fileModelClass; }
public void EnqueueEntity(FileModelClass fileEntity) { EntityQueue.Enqueue(fileEntity); }
public void WritingReport(FileModelClass fileModelToWrite) { Console.WriteLine("File {0} was created successfully!", fileModelToWrite.FileName); }