Esempio n. 1
0
        public async Task <string> Refresh()
        {
            string returnValue            = "";
            List <ObjectDetails> ossFiles = await _forgeOSS.GetBucketObjectsAsync(_bucket.BucketKey, "cache/");

            foreach (ObjectDetails file in ossFiles)
            {
                string[] fileParts = file.ObjectKey.Split('/');
                string   project   = fileParts[1];
                string   hash      = fileParts[2];
                string   fileName  = fileParts[3];
                if (fileName == "parameters.json")
                {
                    returnValue += "Project " + project + " (" + hash + ") is being updated\n";
                    string paramsFile = Path.Combine(_localCache.LocalRootName, "params.json");
                    await _bucket.DownloadFileAsync(file.ObjectKey, paramsFile);

                    InventorParameters inventorParameters = Json.DeserializeFile <InventorParameters>(paramsFile);
                    try
                    {
                        await _projectWork.DoSmartUpdateAsync(inventorParameters, project, true);

                        returnValue += "Project " + project + " (" + hash + ") was updated\n";
                    } catch (Exception e)
                    {
                        returnValue += "Project " + project + " (" + hash + ") update failed\nException: " + e.Message + "\n";
                    }
                }
            }

            return(returnValue);
        }
Esempio n. 2
0
        public override async Task ProcessJobAsync(IResultSender resultSender)
        {
            using var scope = Logger.BeginScope("Update Model ({Id})");

            Logger.LogInformation($"ProcessJob (Update) {Id} for project {ProjectId} started.");

            ProjectStateDTO updatedState = await ProjectWork.DoSmartUpdateAsync(Parameters, ProjectId);

            Logger.LogInformation($"ProcessJob (Update) {Id} for project {ProjectId} completed.");

            // send that we are done to client
            await resultSender.SendSuccessAsync(updatedState);
        }
        private async Task GenerateConfiguration(string logId)
        {
            _bucketProvider.SetBucketKeyFromOld(bucket.BucketKey);
            _logger.LogInformation($"{logId}: Generating config for project {projectInfo.Name} in bucket {bucket.BucketKey}");

            OssBucket bucketNew = await _userResolver.GetBucketAsync();

            try
            {
                await _projectWork.DoSmartUpdateAsync(parameters, projectInfo.Name);

                _logger.LogInformation($"{logId}: Configuration {parameters} for project {projectInfo.Name} was generated.");
            }
            catch (Exception e)
            {
                _logger.LogError(e, $"{logId}: Configuration {parameters} for project {projectInfo.Name} was NOT generated.");
            }

            return;
        }
Esempio n. 4
0
        /// <summary>
        /// https://jira.autodesk.com/browse/INVGEN-45256
        /// </summary>
        /// <param name="payload">project configuration with parameters</param>
        /// <returns>project storage</returns>
        public async Task <ProjectDTO> AdoptProjectWithParametersAsync(AdoptProjectWithParametersPayload payload)
        {
            if (!await DoesProjectAlreadyExistAsync(payload.Name))
            {
                var bucket = await _userResolver.GetBucketAsync();

                var signedUrl = await TransferProjectToOssAsync(bucket, payload);

                await _projectWork.AdoptAsync(payload, signedUrl);
            }
            else
            {
                _logger.LogInformation($"project with name {payload.Name} already exists");
            }

            var updateDto = (await _projectWork.DoSmartUpdateAsync(payload.Config, payload.Name)).dto;
            // use update hash for projectDto generation
            var projectDto = _dtoGenerator.ToDTO(await _userResolver.GetProjectStorageAsync(payload.Name), updateDto.Hash);

            return(projectDto);
        }