private AnalysisEntity CreateAnalysisEntity(AnalysisSpecification analysis, DatabaseEntity database)
        {
            var queryId        = Guid.NewGuid();
            var analysisEntity = new AnalysisEntity(queryId);

            analysisEntity.Name                    = analysis.Name;
            analysisEntity.JobId                   = queryId.ToString();
            analysisEntity.InputContainer          = queryId.ToString();
            analysisEntity.OutputContainer         = queryId.ToString();
            analysisEntity.DatabaseId              = analysis.DatabaseName;
            analysisEntity.DatabaseType            = database.Type;
            analysisEntity.DatabaseContainer       = database.ContainerName;
            analysisEntity.Executable              = analysis.Executable;
            analysisEntity.ExecutableArgs          = analysis.ExecutableArgs;
            analysisEntity.ExecutableArgsSanitised = analysis.ExecutableArgs;
            analysisEntity.State                   = AnalysisState.StagingData;
            analysisEntity.StartTime               = DateTime.UtcNow;
            analysisEntity.PoolId                  = analysis.PoolId;
            analysisEntity.PoolDisplayName         = analysis.PoolDisplayName;
            analysisEntity.TargetDedicated         = analysis.TargetDedicated;
            analysisEntity.VirtualMachineSize      = analysis.VirtualMachineSize;
            analysisEntity.CompletedTasks          = 0;
            analysisEntity.TotalTasks              = analysis.AnalysisInputFiles.Count();
            ParseExecutableArgs(analysis, analysisEntity);
            _tableStorageProvider.InsertEntity(analysisEntity);
            return(analysisEntity);
        }
        private SearchEntity CreateSearchEntity(SearchSpecification search, DatabaseEntity database)
        {
            var queryId      = Guid.NewGuid();
            var searchEntity = new SearchEntity(queryId);

            searchEntity.Name                    = search.Name;
            searchEntity.JobId                   = queryId.ToString();
            searchEntity.InputContainer          = "job-" + queryId.ToString();
            searchEntity.OutputContainer         = "job-" + queryId.ToString();
            searchEntity.DatabaseId              = search.DatabaseName;
            searchEntity.DatabaseType            = database.Type;
            searchEntity.DatabaseContainer       = database.ContainerName;
            searchEntity.Executable              = search.Executable;
            searchEntity.ExecutableArgs          = search.ExecutableArgs;
            searchEntity.ExecutableArgsSanitised = search.ExecutableArgs;
            searchEntity.State                   = SearchState.StagingData;
            searchEntity.StartTime               = DateTime.UtcNow;
            searchEntity.PoolId                  = search.PoolId;
            searchEntity.PoolDisplayName         = search.PoolDisplayName;
            searchEntity.TargetDedicated         = search.TargetDedicated;
            searchEntity.VirtualMachineSize      = search.VirtualMachineSize;
            searchEntity.CompletedTasks          = 0;
            searchEntity.TotalTasks              = search.SearchInputFiles.Count();
            ParseExecutableArgs(search, searchEntity);
            _tableStorageProvider.InsertEntity(searchEntity);
            return(searchEntity);
        }