コード例 #1
0
        public static bool DoesInputColumnMatchVirtualInputColumns(IDTSInput100 input)
        {
            if (input == null)
            {
                throw new ArgumentNullException("input");
            }

            IDTSVirtualInput100 vInput = input.GetVirtualInput();
            bool Cancel             = false;
            bool areAllColumnsValid = true;

            //	Verify that the columns in the input, have the same column metadata
            // as the matching virtual input column.
            foreach (IDTSInputColumn100 column in input.InputColumnCollection)
            {
                //	Get the upstream column.
                IDTSVirtualInputColumn100 vColumn
                    = vInput.VirtualInputColumnCollection.GetVirtualInputColumnByLineageID(column.LineageID);
                if (!ComponentValidation.DoesColumnMetaDataMatch(column, vColumn))
                {
                    areAllColumnsValid = false;
                    input.Component.FireError(
                        0,
                        input.Component.Name,
                        @"The input column metadata for column" + column.IdentificationString + @" does not match its upstream column.",
                        @"",
                        0,
                        out Cancel);
                }
            }

            return(areAllColumnsValid);
        }
コード例 #2
0
        //=================================================================================================

        /// <summary>
        /// Validate the component by checking the inputs, outputs, custom properties, and column metadata.
        /// </summary>
        /// <returns>A value from the DTSValidationStatus indicating the result of validation.</returns>
        public override DTSValidationStatus Validate()
        {
            IDTSOutput100 output = ComponentMetaData.OutputCollection[0];

            bool bCancel;

            if (ComponentMetaData.InputCollection.Count != 0)
            {
                ComponentMetaData.FireError(0, ComponentMetaData.Name, "Has an input when no input should exist.", "", 0, out bCancel);
                return(DTSValidationStatus.VS_ISCORRUPT);
            }

            if (ComponentMetaData.RuntimeConnectionCollection[0].ConnectionManager == null)
            {
                ComponentMetaData.FireError(0, ComponentMetaData.Name, "No WMI ConnectionManager specified.", "", 0, out bCancel);
                return(DTSValidationStatus.VS_ISBROKEN);
            }

            // check for the wql query
            IDTSCustomProperty100 wqlQuery = ComponentMetaData.CustomPropertyCollection[WQL_QUERY];

            if (wqlQuery.Value == null || ((string)wqlQuery.Value).Length == 0)
            {
                ComponentMetaData.FireError(0, ComponentMetaData.Name, "WQL query not specified.", "", 0, out bCancel);
                return(DTSValidationStatus.VS_ISBROKEN);
            }
            else if (m_scope != null && m_scope.IsConnected)
            {
                // Validate the WQL quesry by attempting to retreive the metadata.
                this.ExecWQL(true);
            }

            if (ComponentMetaData.OutputCollection[0].OutputColumnCollection.Count == 0)
            {
                return(DTSValidationStatus.VS_NEEDSNEWMETADATA);
            }

            // Validate the output columns against the external metadata?
            if (ComponentMetaData.ValidateExternalMetadata)
            {
                // Does the output column collection match the columns at the data source?
                if (!this.AreOutputColumnsValid())
                {
                    // No, post a warning, and fix the errors in reinitializemetadata.
                    ComponentMetaData.FireWarning(0, ComponentMetaData.Name, "The output columns do not match the external data source.", "", 0);
                    return(DTSValidationStatus.VS_NEEDSNEWMETADATA);
                }

                if (!ComponentValidation.DoesExternalMetaDataMatchOutputMetaData(output))
                {
                    ComponentMetaData.FireWarning(0, ComponentMetaData.Name, "The ExternalMetaDataColumns do not match the output columns.", "", 0);
                    return(DTSValidationStatus.VS_NEEDSNEWMETADATA);
                }
            }
            else
            {
                // Don't validate the output columns against the external source,
                // instead validate them against the external meta data collection.
                // Do the output columns match the external metadata columns?

                if (!ComponentValidation.DoesOutputColumnMetaDataMatchExternalColumnMetaData(ComponentMetaData.OutputCollection[0]))
                {
                    // No, post a warning, and fix the errors in ReintializeMetaData.
                    ComponentMetaData.FireWarning(0, ComponentMetaData.Name, "Output columns do not match external metadata.", "", 0);
                    return(DTSValidationStatus.VS_NEEDSNEWMETADATA);
                }
            }

            // Return base class validation result.
            return(base.Validate());
        }