Esempio n. 1
0
        public AutoAddPlugin(ILogger <AutoAddPlugin> logger,
                             ITimerFactory timerFactory,
                             IAutoAddRepository repository,
                             IFolderScanner folderScanner)
        {
            if (logger == null)
            {
                throw new ArgumentNullException("logger");
            }
            if (timerFactory == null)
            {
                throw new ArgumentNullException("timerFactory");
            }
            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }
            if (folderScanner == null)
            {
                throw new ArgumentNullException("folderScanner");
            }

            _logger        = logger;
            _repository    = repository;
            _folderScanner = folderScanner;
            _timer         = timerFactory.Create(5000, CheckFolders);
        }
Esempio n. 2
0
        public async Task <List <string> > CheckPath(string path, IFolderScanner scanner, IConverter converter)
        {
            if (path != null)
            {
                List <string> FilesList = await scanner.GetFilesList(path);

                if (FilesList.Count > 0)
                {
                    List <string> tmpList = new List <string>();

                    foreach (string item in FilesList)
                    {
                        tmpList.Add(item.Remove(0, path.Length));
                    }

                    FilesList = Revers(tmpList);

                    return(FilesList);
                }
                else
                {
                    return(FilesList);
                }
            }

            return(new List <string>());
        }
Esempio n. 3
0
 public ExplorerViewModel(IFolderController folderController, IFileController fileController, IMediaFileController mediaFileController, IMediaFactory factory, IFolderScanner scanner, IUserInput input, IMediaBroadcaster broadcaster)
 {
     FolderController    = folderController;
     FileController      = fileController;
     Scanner             = scanner;
     Input               = input;
     MediaFileController = mediaFileController;
     Factory             = factory;
     Broadcaster         = broadcaster;
     Folders             = new ObservableCollection <IFolder>(FolderController.GetList());
 }
Esempio n. 4
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                var createScope = _serviceScopeFactory.CreateScope();

                _folderScanner = createScope.ServiceProvider.GetRequiredService <IFolderScanner>();

                await Task.Run(() => _folderScanner.StartFolderScanAsync(), stoppingToken);
            }
        }
 public MainViewModel(IFolderScanner folderScanner, ICodeParser codeParser, IAnalysisManager analysisManager)
 {
     _folderScanner             = folderScanner;
     _codeParser                = codeParser;
     _analysisManager           = analysisManager;
     SourceCodeFilesCollection  = new ObservableCollection <DocumentData>();
     ViolationSummaryCollection = new ObservableCollection <SummaryData>();
     CodeRootLocation           = string.Empty;//@"b:\samplefile";
     InitializeCommands();
     PointLabel = chartPoint =>
                  string.Format("{0} ({1:P})", chartPoint.Y, chartPoint.Participation);
     InitializePieChartProperties();
 }
Esempio n. 6
0
        public string GetResultList()
        {
            IController    _controller = _creator.GetController(_command);
            IFolderScanner _scanner    = _creator.GetScanner();
            IConverter     _converter  = _creator.GetConverter(_command);

            List <string> list = _controller.CheckPath(_directory, _scanner, _converter).GetAwaiter().GetResult();

            IWriter writer           = _creator.GetWriter();
            string  pathToFileResult = writer.Save(list);

            return(pathToFileResult);
        }
Esempio n. 7
0
        public async Task <List <string> > CheckPath(string path, IFolderScanner scanner, IConverter converter)
        {
            if (path != null)
            {
                List <string> FilesList = await scanner.GetFilesList(path);

                FilesList = converter.ConvertList(FilesList, path);

                return(FilesList);
            }

            return(new List <string>());
        }
Esempio n. 8
0
        public AutoAddPlugin(ILogger<AutoAddPlugin> logger,
            ITimerFactory timerFactory,
            IAutoAddRepository repository,
            IFolderScanner folderScanner)
        {
            if (logger == null) throw new ArgumentNullException("logger");
            if (timerFactory == null) throw new ArgumentNullException("timerFactory");
            if (repository == null) throw new ArgumentNullException("repository");
            if (folderScanner == null) throw new ArgumentNullException("folderScanner");

            _logger = logger;
            _repository = repository;
            _folderScanner = folderScanner;
            _timer = timerFactory.Create(5000, CheckFolders);
        }
Esempio n. 9
0
        /// <summary>
        /// Mains the specified arguments.
        /// </summary>
        /// <param name="args">The arguments.</param>
        public static void Main(string[] args)
        {
            try
            {
                var builder = new ConfigurationBuilder()
                              .SetBasePath(Directory.GetCurrentDirectory())
                              .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true);

                IConfiguration configuration = builder.Build();

                using (var services = new ServiceCollection()
                                      .AddLogging(logBuilder =>
                {
                    logBuilder.AddConsole();
                    logBuilder.AddConfiguration(configuration.GetSection("Logging"));
                })
                                      .AddTransient <ICSVFileReader, CSVFileReader>()
                                      .AddTransient <IFolderScanner, FolderScanner>()
                                      .AddTransient <ICSVProcessor, CSVProcessor>()
                                      .AddSingleton(configuration)
                                      .BuildServiceProvider())
                {
                    var logger = services.GetService <ILogger <Program> >();

                    logger.LogInformation("CSV reader starting");
                    IFolderScanner      fs         = services.GetService <IFolderScanner>();
                    List <FoundCSVItem> filesFound = fs.FindCSVFiles();

                    List <Task <TaskResult> > processingTasks = new List <Task <TaskResult> >();
                    foreach (FoundCSVItem item in filesFound)
                    {
                        ICSVProcessor fp = services.GetService <ICSVProcessor>();
                        fp.Init(item);

                        processingTasks.Add(fp.ProcessAsync());
                    }

                    using (Task <TaskResult[]> concatTask = Task.WhenAll(processingTasks.ToArray()))
                    {
                        foreach (TaskResult taskResult in concatTask.Result)
                        {
                            logger.LogDebug(taskResult.ToString());

                            logger.LogInformation(
                                $"------------------------------------------------------\n" +
                                $"Lower Bound Entries of {taskResult.FileName} (Count : {taskResult.LowerBoundsValues.Count})\n" +
                                $"------------------------------------------------------\n" +
                                $"{taskResult.LowerBoundsValues.ToPrintableString(taskResult.FileName, taskResult.Median.ToString())}");

                            logger.LogInformation(
                                $"------------------------------------------------------\n" +
                                $"Upper Bound Entries of {taskResult.FileName} (Count : {taskResult.UpperBoundsValues.Count})\n" +
                                $"------------------------------------------------------\n" +
                                $"{taskResult.UpperBoundsValues.ToPrintableString(taskResult.FileName, taskResult.Median.ToString())}");
                        }
                    }
                }

                Console.WriteLine("Press any key to exit ......");
                Console.ReadKey();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"Uncaught Exception occured : {ex.Message}");
                Console.WriteLine($"Stack Trace : {ex.StackTrace}");
                if (ex.InnerException != null)
                {
                    Console.WriteLine($"Uncaught Exception occured : {ex.InnerException.Message}");
                    Console.WriteLine($"Stack Trace : {ex.InnerException.StackTrace}");
                }

                Console.ReadKey();
            }
        }