Пример #1
0
        /// <summary>
        ///     Initializes a new Execution result for success case.
        /// </summary>
        /// <param name="context">
        ///     <see cref="ExecutionContext"/> from the processing state.
        /// </param>
        /// <param name="dataSourceInfo">
        ///     <see cref="DataSourceInfo"/> from the custom data source being processed.
        /// </param>
        /// <param name="dataSourceInfoFailure">
        ///     <see cref="Exception"/> for the processing state (if available).
        /// </param>
        /// <param name="processor">
        ///     <see cref="ICustomDataProcessor"/> associated to the processing state.
        /// </param>
        /// <param name="enableFailures">
        ///     Dictionary representing the failures for <see cref="TableDescriptor"/> (if any).
        /// </param>
        /// <param name="metadataName">
        ///     Name of the custom data source being processed.
        /// </param>
        /// <param name="builtMetadataTables">
        ///     Collection of <see cref="MetadataTableBuilder"/>.
        /// </param>
        /// <param name="metadataException">
        ///     <see cref="Exception"/> for creating metadata tables (if available).
        /// </param>
        public ExecutionResult(
            ExecutionContext context,
            DataSourceInfo dataSourceInfo,
            Exception dataSourceInfoFailure,
            ICustomDataProcessor processor,
            IDictionary <TableDescriptor, Exception> enableFailures,
            string metadataName,
            IEnumerable <MetadataTableBuilder> builtMetadataTables,
            Exception metadataException)
            : this(enableFailures, context.TablesToEnable)
        {
            Guard.NotNull(context, nameof(context));
            Guard.NotNull(dataSourceInfo, nameof(dataSourceInfo));
            Guard.NotNull(processor, nameof(processor));
            Guard.NotNullOrWhiteSpace(metadataName, nameof(metadataName));
            Guard.NotNull(builtMetadataTables, nameof(builtMetadataTables));

            this.AssociatedWithCustomDataSource = true;

            // Exception may be null.

            this.Context               = context;
            this.Processor             = processor;
            this.DataSourceInfo        = dataSourceInfo;
            this.DataSourceInfoFailure = dataSourceInfoFailure;

            this.MetadataName         = metadataName;
            this.BuiltMetadataTables  = new ReadOnlyCollection <MetadataTableBuilder>(builtMetadataTables.ToList());
            this.MetadataTableFailure = metadataException;

            Debug.Assert(this.RequestedTables != null);

            // If the processor contains tables that were generated while processing the data source, then add them to our RequestedTables.
            // todo: RequestedTables - should we rename this? Just make it AvailableTables or something similar?
            if (processor is IDataDerivedTables postProcessTables &&
                postProcessTables.DataDerivedTables != null)
            {
                // do some extra validation on these table descriptors, as they might have been generated by hand
                // rather than our usual library
                //

                foreach (var tableDescriptor in postProcessTables.DataDerivedTables)
                {
                    if (tableDescriptor.PrebuiltTableConfigurations is null)
                    {
                        var tableConfigurations = new TableConfigurations(tableDescriptor.Guid)
                        {
                            Configurations = Enumerable.Empty <TableConfiguration>()
                        };

                        tableDescriptor.PrebuiltTableConfigurations = tableConfigurations;
                    }
                }

                // combine these new tables with any existing requested tables for this processor
                this.RequestedTables = this.RequestedTables.Concat(postProcessTables.DataDerivedTables);
            }
        }
Пример #2
0
        /// <summary>
        ///     Initializes a new faulting ExecutionResult.
        /// </summary>
        /// <param name="context">
        ///     <see cref="ExecutionContext"/> from the processing state.
        /// </param>
        /// <param name="processor">
        ///     <see cref="ICustomDataProcessor"/> associated to the processing state.
        /// </param>
        /// <param name="processorFault">
        ///      Faulting <see cref="Exception"/>.
        /// </param>
        public ExecutionResult(
            ExecutionContext context,
            ICustomDataProcessor processor,
            Exception processorFault)
        {
            Guard.NotNull(context, nameof(context));
            Guard.NotNull(processor, nameof(processor));
            Guard.NotNull(processorFault, nameof(processorFault));

            this.Context         = context;
            this.DataSourceInfo  = DataSourceInfo.None;
            this.Processor       = processor;
            this.RequestedTables = context.TablesToEnable.ToList().AsReadOnly();
            this.ProcessorFault  = processorFault;

            this.EnableFailures       = new ReadOnlyDictionary <TableDescriptor, Exception>(new Dictionary <TableDescriptor, Exception>());
            this.BuiltMetadataTables  = new List <MetadataTableBuilder>().AsReadOnly();
            this.MetadataTableFailure = null;
        }