//Validate Inputs Both InputColumns and ExternalColumns private DTSValidationStatus ValidateInputs() { bool cancel; //Component should have a single input if (this.ComponentMetaData.InputCollection.Count != 1) { ErrorSupport.FireErrorWithArgs(HResults.DTS_E_INCORRECTEXACTNUMBEROFINPUTS, out cancel, 1); return(DTSValidationStatus.VS_ISCORRUPT); } //Check input has columns var input = ComponentMetaData.InputCollection[INPUT_NAME]; if (input.ExternalMetadataColumnCollection.Count == 0) { return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } //Check input columns are valid if (!this.ComponentMetaData.AreInputColumnsValid) { input.InputColumnCollection.RemoveAll(); return(DTSValidationStatus.VS_NEEDSNEWMETADATA); } //Input truncation disposition not supported if (input.TruncationRowDisposition != DTSRowDisposition.RD_NotUsed) { ErrorSupport.FireError(HResults.DTS_E_ADODESTINPUTTRUNDISPNOTSUPPORTED, out cancel); return(DTSValidationStatus.VS_ISBROKEN); } return(DTSValidationStatus.VS_ISVALID); }
public override void PrimeOutput(int outputs, int[] outputIDs, PipelineBuffer[] buffers) { IDTSOutput100 output = ComponentMetaData.OutputCollection[0]; PipelineBuffer buffer = buffers[0]; try { foreach (ManagementObject row in ExecWQL(false)) { object[] row_values = new object[m_columnInfo.Count]; int i = 0; foreach (ColumnInfo ci in m_columnInfo) { PropertyData wmiColumn = row.Properties[ci.ColumnName]; row_values[i++] = row[wmiColumn.Name]; } // lets unwind wmi row ( unwind array in any column ) // we use the same approach to handle WMI arrays as WMI ODBC driver // for details see msdn : // http://msdn.microsoft.com/en-us/library/aa392328(VS.85).aspx#_hmm_mapping_wmi_arrays_to_odbc foreach (object[] unwinded_row in RowUnwinder.UnwindRow(row_values)) { buffer.AddRow(); i = 0; foreach (ColumnInfo ci in m_columnInfo) { PropertyData wmiColumn = row.Properties[ci.ColumnName]; SetBufferColumn(buffer, row, wmiColumn, ci.BufferColumnIndex, unwinded_row[i++]); } } } // set end of data on all of the buffers buffer.SetEndOfRowset(); } catch (Exception e) { bool bCancel; ErrorSupport.FireErrorWithArgs(HResults.DTS_E_PRIMEOUTPUTFAILED, out bCancel, ComponentMetaData.IdentificationString, e.Message); throw new PipelineComponentHResultException(HResults.DTS_E_PRIMEOUTPUTFAILED); } }
public override void AcquireConnections(object transaction) { if (m_scope != null && m_scope.IsConnected) { bool bCancel; ErrorSupport.FireError(HResults.DTS_E_ALREADYCONNECTED, out bCancel); throw new PipelineComponentHResultException(HResults.DTS_E_ALREADYCONNECTED); } IDTSRuntimeConnection100 conn; try { // get the runtime connection conn = ComponentMetaData.RuntimeConnectionCollection[CONNECTION_NAME]; } catch (Exception) { bool bCancel; ErrorSupport.FireErrorWithArgs(HResults.DTS_E_CANNOTTFINDRUNTIMECONNECTIONOBJECT, out bCancel, CONNECTION_NAME); throw new PipelineComponentHResultException(HResults.DTS_E_CANNOTTFINDRUNTIMECONNECTIONOBJECT); } // get the connection manager from the connection IDTSConnectionManager100 conn_mgr = conn.ConnectionManager; if (conn_mgr == null) { bool bCancel; ErrorSupport.FireErrorWithArgs(HResults.DTS_E_CONNECTIONMANANGERNOTASSIGNED, out bCancel, CONNECTION_NAME); throw new PipelineComponentHResultException(HResults.DTS_E_CONNECTIONMANANGERNOTASSIGNED); } m_scope = (conn_mgr.AcquireConnection(transaction)) as ManagementScope; if (m_scope == null) { bool bCancel; ErrorSupport.FireError(HResults.DTS_E_CANNOTACQUIREMANAGEDCONNECTIONFROMCONNECTIONMANAGER, out bCancel); throw new PipelineComponentHResultException(HResults.DTS_E_CANNOTACQUIREMANAGEDCONNECTIONFROMCONNECTIONMANAGER); } }