private async Task UpdateAssetsByTransferAsync(string transferIdentifier, IList <PictureparkAsset> updatedTargetAssets) { try { _logger.LogInformation($"Starting import of transfer {transferIdentifier}..."); foreach (PictureparkAsset updatedTargetAsset in updatedTargetAssets) { var contentDetail = await _client.Content.GetAsync(updatedTargetAsset.TargetAssetUuid, new ContentResolveBehavior[] { ContentResolveBehavior.Metadata }); var smintIoContentLayer = contentDetail.Layer <SmintIoContentLayer>("smintIoContentLayer"); int?binaryVersion = smintIoContentLayer.BinaryVersion; if (binaryVersion != updatedTargetAsset.BinaryVersion) { var transferResult = await UpdateFileTransferAsync(updatedTargetAsset); await _client.Content.UpdateFileAsync(updatedTargetAsset.TargetAssetUuid, new ContentFileUpdateRequest() { FileTransferId = transferResult.Transfer.Id }); } } var contentMetadataUpdateManyRequest = new ContentMetadataUpdateManyRequest(); foreach (PictureparkAsset assetForUpdate in updatedTargetAssets) { var contentMetadataUpdateItem = new ContentMetadataUpdateItem() { Id = assetForUpdate.TargetAssetUuid, LayerSchemaIds = new[] { nameof(SmintIoContentLayer), nameof(SmintIoLicenseLayer) }, Metadata = assetForUpdate.GetMetadata(), LayerSchemasUpdateOptions = UpdateOption.Merge, ContentFieldsUpdateOptions = UpdateOption.Replace }; contentMetadataUpdateManyRequest.Items.Add(contentMetadataUpdateItem); } var result = await _client.Content.UpdateMetadataManyAsync(contentMetadataUpdateManyRequest); await _client.BusinessProcess.WaitForCompletionAsync(result.BusinessProcessId); _logger.LogInformation($"Finished import of transfer {transferIdentifier}"); } catch (Exception ex) { _logger.LogError(ex, $"Error importing files for transfer {transferIdentifier}"); await TryDeleteTransferAsync(transferIdentifier); throw; } }
/// <inheritdoc /> public async Task <ContentBatchOperationResult> UpdateMetadataManyAsync(ContentMetadataUpdateManyRequest updateRequest, TimeSpan?timeout = null, CancellationToken cancellationToken = default(CancellationToken)) { var businessProcess = await UpdateMetadataManyCoreAsync(updateRequest, cancellationToken).ConfigureAwait(false); return(await WaitForBusinessProcessAndReturnResult(businessProcess.Id, timeout, cancellationToken).ConfigureAwait(false)); }