<commit_before>﻿using System;
using System.Configuration;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using FileAuditManager.Data;
using FileAuditManager.Data.Models;
using log4net;

namespace FileAuditManager.Hashing
{
    class ApplicationHashingManager : IApplicationHashingManager
    {
        private static ILog log = LogManager.GetLogger(typeof(ApplicationHashingManager));
        private readonly IApplicationRepository applicationRepository;
        private readonly IDeploymentRepository deploymentRepository;
        private readonly IAuditRepository auditRepository;

        public ApplicationHashingManager(IApplicationRepository applicationRepository, IDeploymentRepository deploymentRepository, IAuditRepository auditRepository)
        {
            var connectionString = ConfigurationManager.ConnectionStrings[FileAuditManagerHttpControllerActivator.ConnectionStringName].ConnectionString;
            this.applicationRepository = applicationRepository ?? new ApplicationRepository(connectionString);
            this.deploymentRepository = deploymentRepository ?? new DeploymentRepository(connectionString);
            this.auditRepository = auditRepository ?? new AuditRepository(connectionString, this.deploymentRepository);
        }

        public void HashAllActiveApplications()
        {
            var activeApplications = applicationRepository.GetAllApplicationsAsync().Result;
            foreach (var application in activeApplications)
            {
                var activeDeployments = deploymentRepository.GetActiveDeploymentsAsync(application.Name).Result;<commit_msg>ParalleTaskRunner.<commit_after>﻿using System;
using System.Configuration;
using System.IO;
using System.Security.Cryptography;
using System.Text;
using System.Threading;
using FileAuditManager.Data;
using FileAuditManager.Data.Models;
using log4net;

namespace FileAuditManager.Hashing
{
    class ApplicationHashingManager : IApplicationHashingManager
    {
        private static ILog log = LogManager.GetLogger(typeof(ApplicationHashingManager));
        private readonly IApplicationRepository applicationRepository;
        private readonly IDeploymentRepository deploymentRepository;
        private readonly IAuditRepository auditRepository;

        public ApplicationHashingManager(IApplicationRepository applicationRepository, IDeploymentRepository deploymentRepository, IAuditRepository auditRepository)
        {
            var connectionString = ConfigurationManager.ConnectionStrings[FileAuditManagerHttpControllerActivator.ConnectionStringName].ConnectionString;
            this.applicationRepository = applicationRepository ?? new ApplicationRepository(connectionString);
            this.deploymentRepository = deploymentRepository ?? new DeploymentRepository(connectionString);
            this.auditRepository = auditRepository ?? new AuditRepository(connectionString, this.deploymentRepository);
        }
        //TODO: refactor this with async so that multiple paths can execute simultaneously using ParallelTaskRunnerExtension:  https://gist.github.com/ctigeek/2f67df6f1a3a68be3ceb
        public void HashAllActiveApplications()
        {
            var activeApplications = applicationRepository.GetAllApplicationsAsync().Result;
            foreach (var application in activeApplications)
            {
                var activeDeployments = deploymentRepository.GetActiveDeploymentsAsync(application.Name).Result;
{'fraction_non_alphanumeric': 0.05530216647662486, 'fraction_numerical': 0.003135689851767389, 'mean_word_length': 4.561014263074485, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 1, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7307548', 'n_tokens_mistral': 755, 'n_tokens_neox': 738, 'n_words': 168}