public async Task <ProjectStateDTO> getProjectParameters(string projectName, string hash) { var storage = await _userResolver.GetProjectStorageAsync(projectName, ensureDir : false); var dto = _dtoGenerator.MakeProjectDTO <ProjectStateDTO>(storage, hash); var localNames = storage.GetLocalNames(hash); dto.Parameters = Json.DeserializeFile <Shared.InventorParameters>(localNames.Parameters); return(dto); }
/// <summary> /// Update project state with the parameters (or take it from cache). /// </summary> public async Task <(ProjectStateDTO dto, FdaStatsDTO stats, string reportUrl)> DoSmartUpdateAsync(InventorParameters parameters, string projectId, bool bForceUpdate = false) { var hash = Crypto.GenerateObjectHashString(parameters); _logger.LogInformation($"Incoming parameters hash is {hash}"); var storage = await _userResolver.GetProjectStorageAsync(projectId); FdaStatsDTO stats; var localNames = storage.GetLocalNames(hash); string reportUrl; // check if the data cached already if (Directory.Exists(localNames.SvfDir) && !bForceUpdate) { _logger.LogInformation("Found cached data."); // restore statistics var bucket = await _userResolver.GetBucketAsync(); var statsNative = await bucket.DeserializeAsync <List <Statistics> >(storage.GetOssNames(hash).StatsUpdate); stats = FdaStatsDTO.CreditsOnly(statsNative); reportUrl = null; } else { string resultingHash; (resultingHash, stats, reportUrl) = await UpdateAsync(storage, parameters, hash, bForceUpdate); if (!hash.Equals(resultingHash, StringComparison.Ordinal)) { _logger.LogInformation($"Update returned different parameters. Hash is {resultingHash}."); await CopyStateAsync(storage.Project, resultingHash, hash, storage.IsAssembly); // update hash = resultingHash; } } var dto = _dtoGenerator.MakeProjectDTO <ProjectStateDTO>(storage, hash); dto.Parameters = Json.DeserializeFile <InventorParameters>(localNames.Parameters); return(dto, stats, reportUrl); }
/// <summary> /// Update project state with the parameters (or take it from cache). /// </summary> public async Task <ProjectStateDTO> DoSmartUpdateAsync(InventorParameters parameters, string projectId, bool bForceUpdate = false) { var hash = Crypto.GenerateObjectHashString(parameters); //_logger.LogInformation(JsonSerializer.Serialize(parameters)); _logger.LogInformation($"Incoming parameters hash is {hash}"); var storage = await _userResolver.GetProjectStorageAsync(projectId); var project = storage.Project; var localNames = project.LocalNameProvider(hash); // check if the data cached already if (Directory.Exists(localNames.SvfDir) && !bForceUpdate) { _logger.LogInformation("Found cached data."); } else { var resultingHash = await UpdateAsync(project, storage, parameters, hash, bForceUpdate); if (!hash.Equals(resultingHash, StringComparison.Ordinal)) { _logger.LogInformation($"Update returned different parameters. Hash is {resultingHash}."); await CopyStateAsync(project, resultingHash, hash, storage.IsAssembly); // update hash = resultingHash; } } var dto = _dtoGenerator.MakeProjectDTO <ProjectStateDTO>(project, hash, storage.IsAssembly); dto.Parameters = Json.DeserializeFile <InventorParameters>(localNames.Parameters); return(dto); }