Exemple #1
0
        public void TransformData(IConnection connection, IDatabaseInterface databaseInterface, IDatastore dataObject, ReportProgressMethod reportProgress)
        {
            Dictionary <StringTransformationType, Type> stringTransformationMapping = Helpers.LoadAllTransformationTypes();

            foreach (var transformation in this.Configuration.Transformations)
            {
                reportProgress(new SimpleProgressReport("Start stringtranformation of type " + transformation.TransformationType + " on column " + transformation.ColumnName));

                if (dataObject.Metadata.Columns.Values.Where(t => t.ColumnName == transformation.ColumnName).Count() == 0)
                {
                    throw new Exception("Column " + transformation.ColumnName + " was not found in the sourcedata");
                }

                int columnIndex = dataObject.Metadata.Columns[transformation.ColumnName].ColumnIndex;
                ITransformationExecutor transformer = Activator.CreateInstance(stringTransformationMapping[transformation.TransformationType]) as ITransformationExecutor;

                for (int i = 0; i < dataObject.Count; i++)
                {
                    string transformedValue = transformer.ExecuteTransformation(dataObject[i][columnIndex].ToString(), transformation);
                    dataObject.SetValue(i, columnIndex, transformedValue);
                }

                reportProgress(new SimpleProgressReport("Finished stringtranformation of type " + transformation.TransformationType + " on column " + transformation.ColumnName));
            }
        }
Exemple #2
0
 public TransformTaskFunction(
     ITransformationExecutor executor,
     IPnPContextFactory pnpContextFactory,
     ITransformationStateManager transformationStateManager,
     ClientContext sourceContext)
 {
     this.executor                   = executor;
     this.pnpContextFactory          = pnpContextFactory;
     this.transformationStateManager = transformationStateManager;
     this.sourceContext              = sourceContext;
 }
        /// <summary>
        /// Creates a new transformation process for SharePoint and waits for its completion
        /// </summary>
        /// <param name="transformationExecutor">The executor to use</param>
        /// <param name="sourceContext">The source context</param>
        /// <param name="targetContext">The target context</param>
        /// <param name="token">The cancellation token, if any</param>
        /// <returns>The status of the transformation process</returns>
        public static Task <TransformationProcessStatus> TransformSharePointAsync(
            this ITransformationExecutor transformationExecutor,
            ClientContext sourceContext,
            PnPContext targetContext,
            CancellationToken token = default)
        {
            if (transformationExecutor == null)
            {
                throw new ArgumentNullException(nameof(transformationExecutor));
            }

            // Create the provider
            var sourceProvider = new SharePointSourceProvider(sourceContext);

            return(transformationExecutor.TransformAsync(sourceProvider, targetContext, token));
        }
Exemple #4
0
        /// <summary>
        /// Creates a new transformation process and waits for its completion
        /// </summary>
        /// <param name="transformationExecutor">The executor to use</param>
        /// <param name="sourceProvider">The source provider</param>
        /// <param name="targetContext">The target context</param>
        /// <param name="token">The cancellation token, if any</param>
        /// <returns>The status of the process</returns>
        public static async Task <TransformationProcessStatus> TransformAsync(
            this ITransformationExecutor transformationExecutor,
            ISourceProvider sourceProvider,
            PnPContext targetContext,
            CancellationToken token = default)
        {
            if (transformationExecutor == null)
            {
                throw new ArgumentNullException(nameof(transformationExecutor));
            }

            var process = await transformationExecutor.CreateTransformationProcessAsync(token).ConfigureAwait(false);

            using (process as IDisposable)
            {
                return(await process.StartAndWaitProcessAsync(sourceProvider, targetContext, token).ConfigureAwait(false));
            }
        }
        /// <summary>
        /// Creates a new transformation process for SharePoint and waits for its completion
        /// </summary>
        /// <param name="transformationExecutor">The executor to use</param>
        /// <param name="pnpContextFactory">The context factory to use</param>
        /// <param name="sourceContext">The source context</param>
        /// <param name="targetName">The target site name</param>
        /// <param name="token">The cancellation token, if any</param>
        /// <returns></returns>
        public static async Task <TransformationProcessStatus> TransformSharePointAsync(
            this ITransformationExecutor transformationExecutor,
            IPnPContextFactory pnpContextFactory,
            ClientContext sourceContext,
            string targetName,
            CancellationToken token = default)
        {
            if (transformationExecutor == null)
            {
                throw new ArgumentNullException(nameof(transformationExecutor));
            }
            if (pnpContextFactory == null)
            {
                throw new ArgumentNullException(nameof(pnpContextFactory));
            }

            // Create contexts
            var targetContext = await pnpContextFactory.CreateAsync(targetName).ConfigureAwait(false);

            token.ThrowIfCancellationRequested();

            return(await transformationExecutor.TransformSharePointAsync(sourceContext, targetContext, token).ConfigureAwait(false));
        }