Example #1
0
        /// <summary>
        /// Transforms a SharePoint page uri
        /// </summary>
        /// <param name="pageTransformator">The page transformator to use</param>
        /// <param name="sourceContext">The source context</param>
        /// <param name="targetContext">The destination context</param>
        /// <param name="sourceUri">The source URI</param>
        /// <returns>The resulting URI</returns>
        public static Task <Uri> TransformSharePointAsync(this IPageTransformator pageTransformator, ClientContext sourceContext, PnPContext targetContext, Uri sourceUri)
        {
            if (pageTransformator == null)
            {
                throw new ArgumentNullException(nameof(pageTransformator));
            }
            if (sourceContext == null)
            {
                throw new ArgumentNullException(nameof(sourceContext));
            }
            if (targetContext == null)
            {
                throw new ArgumentNullException(nameof(targetContext));
            }
            if (sourceUri == null)
            {
                throw new ArgumentNullException(nameof(sourceUri));
            }

            var sourceItemId = new SharePointSourceItemId(sourceUri);

            var sourceProvider = new SharePointSourceProvider(sourceContext);

            return(pageTransformator.TransformAsync(new PageTransformationTask(sourceProvider, sourceItemId, targetContext)));
        }
Example #2
0
        /// <summary>
        /// Public constructor
        /// </summary>
        /// <param name="id">The id of the process</param>
        /// <param name="logger">A custom logger</param>
        /// <param name="transformationDistiller">The Page Transformation Distiller to collect items to process</param>
        /// <param name="pageTransformator">The Page Transformator instance to use</param>
        public InProcessTransformationProcess(
            Guid id,
            ILogger <InProcessTransformationProcess> logger,
            ITransformationDistiller transformationDistiller,
            IPageTransformator pageTransformator)
        {
            this.logger = logger ?? throw new ArgumentNullException(nameof(logger));
            this.transformationDistiller = transformationDistiller ?? throw new ArgumentNullException(nameof(transformationDistiller));
            this.pageTransformator       = pageTransformator ?? throw new ArgumentNullException(nameof(pageTransformator));

            Id = id;

            status        = new TransformationProcessStatus(Id, TransformationExecutionState.Pending);
            tasksStatuses = new ConcurrentDictionary <Guid, TransformationProcessTaskStatus>();
        }