예제 #1
0
 public static DirectoryInfo CreateDirectory(string path)
 {
     if (_provider == null)
     {
         return(Directory.CreateDirectory(path));
     }
     return(_provider.CreateDirectory(path));
 }
예제 #2
0
 private void AssureTestRunIdFolderCreated(string newTestRunDirectoryPath)
 {
     if (!_directoryProvider.DoesDirectoryExists(newTestRunDirectoryPath))
     {
         _directoryProvider.CreateDirectory(newTestRunDirectoryPath);
     }
 }
예제 #3
0
 private void EnsureResultsDirectoryExists(string testResultsFolder)
 {
     if (!_directoryProvider.DoesDirectoryExists(testResultsFolder))
     {
         _directoryProvider.CreateDirectory(testResultsFolder);
     }
 }
예제 #4
0
        private void ProcessArchive(Archive archive, DateTime yesterday)
        {
            //add in older than yesterdays .log files
            var archiveFilesToCompress = _fileGatherer.FilesOlderThan(archive.FilePath, yesterday);

            if (!archiveFilesToCompress.Any())
            {
                Log.Info($"No files found to be archived. FilePath: {archive.FilePath}");
                return;
            }

            var fileListToCompress = _fileBatchProvider.Batch(archiveFilesToCompress);

            foreach (var filesToCompress in fileListToCompress)
            {
                var filesTo   = _archiveNameProvider.DecideArchiveName(archive, yesterday);
                var filesFrom = filesToCompress.ToArray();

                if (!_directoryProvider.Exists(archive.ArchivePath))
                {
                    Log.Warn($"Archive folder does not exist. Creating... {archive.ArchivePath}");
                    _directoryProvider.CreateDirectory(archive.ArchivePath);
                }

                var failed = _compressor.Compress(filesTo, filesFrom);
                //Deletes old logs if there were no error from the compression process
                if (!failed)
                {
                    _fileDeleter.TryDeleteFiles(filesFrom, archive.DeleteArchivedFiles);
                }
            }
        }
예제 #5
0
        private string GetAppDataMeissaFolder()
        {
            var appData             = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
            var meissaAppDataFolder = _pathProvider.Combine(appData, "MEISSA");

            _directoryProvider.CreateDirectory(meissaAppDataFolder);
            return(meissaAppDataFolder);
        }
예제 #6
0
        public async Task <string> CreateDumpAsync(string dumpLocation)
        {
            var dumpFileLocation = dumpLocation;

            if (string.IsNullOrEmpty(dumpFileLocation))
            {
                dumpFileLocation = _reflectionProvider.GetRunningAssemblyPath();
            }
            else
            {
                if (!_directoryProvider.DoesDirectoryExists(dumpLocation))
                {
                    try
                    {
                        _directoryProvider.CreateDirectory(dumpLocation);
                        _consoleProvider.WriteLine($"{dumpLocation} doesn't exists.");
                        _consoleProvider.WriteLine($"{dumpLocation} created.");
                    }
                    catch (IOException e)
                    {
                        _consoleProvider.WriteLine(e.ToString());
                        _consoleProvider.WriteLine($"{dumpLocation} cannot be created.");
                        throw;
                    }
                }
            }

            var exceptionLogs = (await _logRepository.GetAllAsync()).ToList();
            var sb            = new StringBuilder();

            foreach (var exceptionLog in exceptionLogs)
            {
                sb.AppendLine($"{exceptionLog.Date} {exceptionLog.Message} {exceptionLog.Exception}");
            }

            var uniqueFileName = string.Concat(GenerateUniqueText(), ".txt");
            var filePath       = _pathProvider.Combine(dumpFileLocation, uniqueFileName);

            _fileProvider.WriteAllText(filePath, sb.ToString());
            _consoleProvider.WriteLine($"dump file created successfully - {filePath}");

            return(filePath);
        }
예제 #7
0
        private IEnumerable <TPluginService> LoadPlugins <TPluginService>()
        {
            string path = _pathProvider.Combine(_reflectionProvider.GetRunningAssemblyPath(), "Plugins");

            if (!_directoryProvider.Exists(path))
            {
                _directoryProvider.CreateDirectory(path);
            }

            var allAssemblies = new List <Assembly>();

            foreach (string dll in _directoryProvider.GetFiles(path, "*.dll"))
            {
                allAssemblies.Add(_assemblyProvider.LoadFile(dll));
            }

            var configuration = new ContainerConfiguration().WithAssemblies(allAssemblies);
            var container     = configuration.CreateContainer();
            var services      = container.GetExports <TPluginService>();

            return(services);
        }
        private void InitializeSampleTemplate()
        {
            var templateContent = new EmbeddedFileProvider().GetContentsForFile("Commands.InitContent.Sample.template");
            var folder          = "Templates";
            var fileName        = "Sample.template";

            var folderPath   = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, folder);
            var templatePath = Path.Combine(folderPath, fileName);

            if (!_directoryProvider.Exists(folderPath))
            {
                _directoryProvider.CreateDirectory(folderPath);
            }

            if (_fileProvider.Exists(templatePath))
            {
                _logger.Info($"{folder}/{fileName} file already exists.");
            }
            else
            {
                File.WriteAllText(templatePath, templateContent);
                _logger.Info($"{fileName} created under the {folder} folder.");
            }
        }