Example #1
0
 public void FolderService(FileModelClass fileModelToWrite)
 {
     if (!Directory.Exists(fileModelToWrite.FilePath))
     {
         Directory.CreateDirectory(fileModelToWrite.FilePath);
     }
 }
Example #2
0
 public void Writing(FileModelClass fileModelToWrite)
 {
     using (var writeText = new StreamWriter(fileModelToWrite.FilePath + fileModelToWrite.FileName))
     {
         writeText.WriteLine("Text example");
     }
 }
Example #3
0
        public void FileWritingWorker(FileModelClass fileModelToWrite)
        {
            FolderService(fileModelToWrite);

            if (WriteFile(fileModelToWrite))
            {
                WritingReport(fileModelToWrite);
            }
        }
Example #4
0
 private void InitializeComponents()
 {
     _fileEntity = new FileModelClass()
     {
         FilePath = FilePath
     };
     _fileWriter  = new FileWriter(_fileEntity);
     QueueService = new QueueService();
 }
Example #5
0
        // 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);
            }
        }
Example #6
0
 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);
 }
Example #7
0
 public FileWriter(FileModelClass fileModelClass)
 {
     _fileModelClass = fileModelClass;
 }
Example #8
0
 public void EnqueueEntity(FileModelClass fileEntity)
 {
     EntityQueue.Enqueue(fileEntity);
 }
Example #9
0
 public void WritingReport(FileModelClass fileModelToWrite)
 {
     Console.WriteLine("File {0} was created successfully!", fileModelToWrite.FileName);
 }