Ejemplo n.º 1
0
        /// <summary>Updates the given <see cref="SchemaDetail"/>.</summary>
        /// <param name="schemaDetail">The schema detail.</param>
        /// <param name="enableForBinaryFiles">Specifies whether to enable the schema for binary files.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>The task.</returns>
        /// <exception cref="ApiException">A server side error occurred.</exception>
        public async Task UpdateAndWaitForCompletionAsync(SchemaDetail schemaDetail, bool enableForBinaryFiles, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (enableForBinaryFiles && schemaDetail.Types.Contains(SchemaType.Layer))
            {
                var binarySchemas = new List <string>
                {
                    nameof(FileMetadata),
                    nameof(AudioMetadata),
                    nameof(DocumentMetadata),
                    nameof(ImageMetadata),
                    nameof(VideoMetadata),
                };

                schemaDetail.ReferencedInContentSchemaIds = binarySchemas;
            }

            var updateRequest = new SchemaUpdateRequest
            {
                Aggregations           = schemaDetail.Aggregations,
                Descriptions           = schemaDetail.Descriptions,
                DisplayPatterns        = schemaDetail.DisplayPatterns,
                Fields                 = schemaDetail.Fields,
                SchemaPermissionSetIds = schemaDetail.SchemaPermissionSetIds,
                Names  = schemaDetail.Names,
                Public = schemaDetail.Public,
                ReferencedInContentSchemaIds = schemaDetail.ReferencedInContentSchemaIds,
                Sort           = schemaDetail.Sort,
                SortOrder      = schemaDetail.SortOrder,
                Types          = schemaDetail.Types,
                LayerSchemaIds = schemaDetail.LayerSchemaIds
            };

            await UpdateAndWaitForCompletionAsync(schemaDetail.Id, updateRequest, cancellationToken).ConfigureAwait(false);
        }
        /// <summary>Updates the given <see cref="SchemaDetail"/>.</summary>
        /// <param name="schemaDetail">The schema detail.</param>
        /// <param name="enableForBinaryFiles">Specifies whether to enable the schema for binary files.</param>
        /// <param name="timeout">Maximum time to wait for the operation to complete.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>The task.</returns>
        /// <exception cref="ApiException">A server side error occurred.</exception>
        public async Task <SchemaUpdateResult> UpdateAsync(SchemaDetail schemaDetail, bool enableForBinaryFiles, TimeSpan?timeout = null, CancellationToken cancellationToken = default(CancellationToken))
        {
            if (enableForBinaryFiles && schemaDetail.Types.Contains(SchemaType.Layer))
            {
                var binarySchemas = new List <string>
                {
                    nameof(FileMetadata),
                    nameof(AudioMetadata),
                    nameof(DocumentMetadata),
                    nameof(ImageMetadata),
                    nameof(VideoMetadata),
                };

                schemaDetail.ReferencedInContentSchemaIds = binarySchemas;
            }

            var updateRequest = new SchemaUpdateRequest
            {
                Aggregations           = schemaDetail.Aggregations,
                Descriptions           = schemaDetail.Descriptions,
                DisplayPatterns        = schemaDetail.DisplayPatterns,
                Fields                 = schemaDetail.Fields,
                SchemaPermissionSetIds = schemaDetail.SchemaPermissionSetIds,
                Names      = schemaDetail.Names,
                ViewForAll = schemaDetail.ViewForAll,
                ReferencedInContentSchemaIds = schemaDetail.ReferencedInContentSchemaIds,
                Sort            = schemaDetail.Sort,
                LayerSchemaIds  = schemaDetail.LayerSchemaIds,
                FieldsOverwrite = schemaDetail.FieldsOverwrite
            };

            return(await UpdateAsync(schemaDetail.Id, updateRequest, timeout, cancellationToken).ConfigureAwait(false));
        }
Ejemplo n.º 3
0
        /// <summary>Updates a schema.</summary>
        /// <param name="schemaId">The schema ID.</param>
        /// <param name="updateRequest">The update request.</param>
        /// <param name="cancellationToken">The cancellation token.</param>
        /// <returns>The task.</returns>
        /// <exception cref="ApiException">A server side error occurred.</exception>
        public async Task UpdateAndWaitForCompletionAsync(string schemaId, SchemaUpdateRequest updateRequest, CancellationToken cancellationToken = default(CancellationToken))
        {
            var process = await UpdateAsync(schemaId, updateRequest, cancellationToken).ConfigureAwait(false);

            await _businessProcessClient.WaitForCompletionAsync(process.Id, cancellationToken : cancellationToken).ConfigureAwait(false);
        }