Пример #1
0
        public async Task <string> GetReadWriteSasTokenForUpdatedDatasetContent(Guid id, IPrincipal user, CancellationToken token)
        {
            var dataset = await GetDatasetEditById(id, user, token);

            var containerToken = string.Empty;

            if (dataset.EditStatus == DatasetEditStatus.ContentsModified)
            {
                containerToken = (await SasTokens.GenerateSasTokenForUpdatingDatasetContainer(dataset.ContentEditAccount, dataset.ContentEditContainer)).ToString();
            }

            return(containerToken);
        }
        public async Task <DatasetImportProperties> GetDatasetImportPropertiesForNomination(Guid id, CancellationToken cancellationToken)
        {
            var nomination = await GetByIdAsync(id, cancellationToken);

            if (nomination == null)
            {
                return(null);
            }

            var contentLink = CreateUserDataDocumentAttachmentUri(id, "Content");
            var options     = new RequestOptions
            {
                PartitionKey = new PartitionKey(WellKnownIds.DatasetNominationDatasetId.ToString())
            };
            var response = await Client.ReadAttachmentAsync(contentLink.ToString(), options).ConfigureAwait(false);

            var resource = response?.Resource;

            if (resource == null)
            {
                return(null);
            }

            var accountName   = resource.GetPropertyValue <string>("account");
            var containerName = resource.GetPropertyValue <string>("container");
            var accessToken   = await SasTokens.GenerateSasTokenForUpdatingDatasetContainer(accountName, containerName);

            return(new DatasetImportProperties
            {
                Id = nomination.Id,
                DatasetName = nomination.Name,
                AccessToken = accessToken.ToString(),
                ContainerName = containerName,
                AccountName = accountName,
            });
        }