]]> _
Public Class ScriptMain
Inherits UserComponent
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Overrides Sub CreateNewOutputRows()
' Retrieve entity metadata.
Dim connection As ICrmConnection = CType( _
Me.Connections.CrmConnection.AcquireConnection(Nothing), _
ICrmConnection)
Try
Call connection.Connect()
Dim service As Object = connection.GetService(0) ' 0 - CRM Service
Dim service2011 As CRM2011.OrganizationServiceClient = TryCast( _
service, _
CRM2011.OrganizationServiceClient)
Dim service4 As CRM4.CrmService = TryCast(service, CRM4.CrmService)
Dim service3 As CRM3.CrmService = TryCast(service, CRM3.CrmService)
If Not service2011 Is Nothing Then
' CRM 2011.
Call Process2011_(service2011)
ElseIf Not service4 Is Nothing Then
' Will use metadata service.
Dim meta4 As Meta4.MetadataService = CType( _
connection.GetService(1), _
Meta4.MetadataService)
Call Process4_(meta4)
ElseIf Not service3 Is Nothing Then
' Will use metadata service.
Dim meta3 As Meta3.MetadataService = CType( _
connection.GetService(1), _
Meta3.MetadataService)
Call Process3_(meta3)
Else
Throw New Exception("Unhandled service object.")
End If
Catch ex As Exception
Call FireError_(ex.Message)
Finally
Call connection.Close()
End Try
End Sub ' CreateNewOutputRows
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Public Function Validate(ByRef errMessage As String) As Boolean
Dim result As Boolean
Try
If String.IsNullOrEmpty(Me.CrmConnection) Then
Throw New Exception("Select Dynamics CRM Connection.")
End If
' Store connection information in the runtime connection collection, too.
' Cannot directly use RuntimeConnectionCollection in the property get/set
' because of issues with multi-threading.
Me.ComponentMetaData.RuntimeConnectionCollection("CrmConnection").ConnectionManagerID = Me.CrmConnection
result = True
Catch ex As Exception
result = False
errMessage = ex.Message
End Try
Validate = result
End Function 'Validate
#Region "Properties"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
_
_
Public Property CrmConnection() As String
Get
CrmConnection = m_crmConnection
End Get
Set(ByVal value As String)
m_crmConnection = value
End Set
End Property ' CrmConnection
#End Region ' Properties
#Region "Internals"
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private ReadOnly Property CrmConnectionType() As String()
Get
CrmConnectionType = New String() {"DYNAMICS-CRM"}
End Get
End Property ' CrmConnectionType
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub FireError_(ByVal message As String)
Dim cancel As Boolean = False
Call MyBase.ComponentMetaData.FireError( _
0, _
"Dynamics CRM Entity Source", _
message, _
String.Empty, _
0, _
cancel)
End Sub ' FireError_
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Process2011_(ByVal service As CRM2011.OrganizationServiceClient)
Dim req As New CRM2011.OrganizationRequest()
req.RequestName = "RetrieveAllEntities"
req("RetrieveAsIfPublished") = False
req("EntityFilters") = CRM2011.EntityFilters.Entity
Dim res As CRM2011.OrganizationResponse = service.Execute(req)
Dim entities() As CRM2011.EntityMetadata = CType( _
res("EntityMetadata"), _
CRM2011.EntityMetadata())
For Each entity As CRM2011.EntityMetadata In entities
With MyBase.OutputBuffer
Call .AddRow()
If entity.ActivityTypeMask.HasValue Then
.ActivityTypeMask = entity.ActivityTypeMask.Value
End If
If entity.AutoRouteToOwnerQueue.HasValue Then
.AutoRouteToOwnerQueue = entity.AutoRouteToOwnerQueue.Value
End If
.CanBeInManyToMany = entity.CanBeInManyToMany.Value
.CanBePrimaryEntityInRelationship = entity.CanBePrimaryEntityInRelationship.Value
.CanBeRelatedEntityInRelationship = entity.CanBeRelatedEntityInRelationship.Value
.CanCreateAttributes = entity.CanCreateAttributes.Value
.CanCreateCharts = entity.CanCreateCharts.Value
.CanCreateForms = entity.CanCreateForms.Value
.CanCreateViews = entity.CanCreateViews.Value
.CanModifyAdditionalSettings = entity.CanModifyAdditionalSettings.Value
If entity.CanTriggerWorkflow.HasValue Then
.CanTriggerWorkflow = entity.CanTriggerWorkflow.Value
End If
If entity.Description.LocalizedLabels.Count > 0 Then
.Description = entity.Description.LocalizedLabels(0).Label
End If
If entity.DisplayCollectionName.LocalizedLabels.Count > 0 Then
.DisplayCollectionName = entity.DisplayCollectionName.LocalizedLabels(0).Label
End If
If entity.DisplayName.LocalizedLabels.Count > 0 Then
.DisplayName = entity.DisplayName.LocalizedLabels(0).Label
End If
.IconLargeName = entity.IconLargeName
.IconMediumName = entity.IconMediumName
.IconSmallName = entity.IconSmallName
If entity.IsActivity.HasValue Then
.IsActivity = entity.IsActivity.Value
End If
If entity.IsActivityParty.HasValue Then
.IsActivityParty = entity.IsActivityParty.Value
End If
.IsAuditEnabled = entity.IsAuditEnabled.Value
If entity.IsAvailableOffline.HasValue Then
.IsAvailableOffline = entity.IsAvailableOffline.Value
End If
If entity.IsChildEntity.HasValue Then
.IsChildEntity = entity.IsChildEntity.Value
End If
.IsConnectionsEnabled = entity.IsConnectionsEnabled.Value
If entity.IsCustomEntity.HasValue Then
.IsCustomEntity = entity.IsCustomEntity.Value
End If
.IsCustomizable = entity.IsCustomizable.Value
If entity.IsDocumentManagementEnabled.HasValue Then
.IsDocumentManagementEnabled = entity.IsDocumentManagementEnabled.Value
End If
.IsDuplicateDetectionEnabled = entity.IsDuplicateDetectionEnabled.Value
If entity.IsEnabledForCharts.HasValue Then
.IsEnabledForCharts = entity.IsEnabledForCharts.Value
End If
If entity.IsImportable.HasValue Then
.IsImportable = entity.IsImportable.Value
End If
If entity.IsIntersect.HasValue Then
.IsIntersect = entity.IsIntersect.Value
End If
.IsMailMergeEnabled = entity.IsMailMergeEnabled.Value
If entity.IsManaged.HasValue Then
.IsManaged = entity.IsManaged.Value
End If
.IsMappable = entity.IsMappable.Value
If entity.IsReadingPaneEnabled.HasValue Then
.IsReadingPaneEnabled = entity.IsReadingPaneEnabled.Value
End If
.IsRenameable = entity.IsRenameable.Value
If entity.IsValidForAdvancedFind.HasValue Then
.IsValidForAdvancedFind = entity.IsValidForAdvancedFind.Value
End If
.IsValidForQueue = entity.IsValidForQueue.Value
.IsVisibleInMobile = entity.IsVisibleInMobile.Value
.LogicalName = entity.LogicalName
If entity.ObjectTypeCode.HasValue Then
.ObjectTypeCode = entity.ObjectTypeCode.Value
End If
If entity.OwnershipType.HasValue Then
.OwnershipType = entity.OwnershipType.Value.ToString()
End If
.PrimaryIdAttribute = entity.PrimaryIdAttribute
.PrimaryNameAttribute = entity.PrimaryNameAttribute
.RecurrenceBaseEntityLogicalName = entity.RecurrenceBaseEntityLogicalName
.ReportViewName = entity.ReportViewName
.SchemaName = entity.SchemaName
End With
Next
End Sub ' Process2011_
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Process4_(ByVal service As Meta4.MetadataService)
Dim req As New Meta4.RetrieveAllEntitiesRequest
req.MetadataItems = Meta4.MetadataItems.EntitiesOnly
Dim res As Meta4.RetrieveAllEntitiesResponse = CType( _
service.Execute(req), _
Meta4.RetrieveAllEntitiesResponse)
For Each entity As Meta4.EntityMetadata In res.CrmMetadata
With MyBase.OutputBuffer
Call .AddRow()
If Not entity.CanTriggerWorkflow.IsNull Then
.CanTriggerWorkflow = entity.CanTriggerWorkflow.Value
End If
If entity.Description.LocLabels.Length > 0 Then
.Description = entity.Description.LocLabels(0).Label
End If
If entity.DisplayCollectionName.LocLabels.Length > 0 Then
.DisplayCollectionName = entity.DisplayCollectionName.LocLabels(0).Label
End If
If entity.DisplayName.LocLabels.Length > 0 Then
.DisplayName = entity.DisplayName.LocLabels(0).Label
End If
If Not entity.IsActivity.IsNull Then
.IsActivity = entity.IsActivity.Value
End If
If Not entity.IsAvailableOffline.IsNull Then
.IsAvailableOffline = entity.IsAvailableOffline.Value
End If
If Not entity.IsChildEntity.IsNull Then
.IsChildEntity = entity.IsChildEntity.Value
End If
If Not entity.IsCustomEntity.IsNull Then
.IsCustomEntity = entity.IsCustomEntity.Value
End If
If Not entity.IsCustomizable.IsNull Then
.IsCustomizable = entity.IsCustomizable.Value
End If
If Not entity.IsImportable.IsNull Then
.IsImportable = entity.IsImportable.Value
End If
If Not entity.IsIntersect.IsNull Then
.IsIntersect = entity.IsIntersect.Value
End If
If Not entity.IsMailMergeEnabled.IsNull Then
.IsMailMergeEnabled = entity.IsMailMergeEnabled.Value
End If
If Not entity.IsValidForAdvancedFind.IsNull Then
.IsValidForAdvancedFind = entity.IsValidForAdvancedFind.Value
End If
.LogicalName = entity.LogicalName
If Not entity.ObjectTypeCode.IsNull Then
.ObjectTypeCode = entity.ObjectTypeCode.Value
End If
If Not entity.OwnershipType.IsNull Then
.OwnershipType = entity.OwnershipType.Value.ToString()
End If
.PrimaryIdAttribute = entity.PrimaryKey
.PrimaryNameAttribute = entity.PrimaryField
.ReportViewName = entity.ReportViewName
.SchemaName = entity.SchemaName
End With
Next
End Sub ' Process4_
'''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
Private Sub Process3_(ByVal service As Meta3.MetadataService)
Dim res As Meta3.Metadata = service.RetrieveMetadata(Meta3.MetadataFlags.EntitiesOnly)
For Each entity As Meta3.EntityMetadata In res.Entities
With MyBase.OutputBuffer
Call .AddRow()
.Description = entity.Description
.DisplayCollectionName = entity.DisplayCollectionName
.DisplayName = entity.DisplayName
.IsCustomEntity = entity.IsCustomEntity
.IsCustomizable = entity.IsCustomizable
.LogicalName = entity.Name
.ObjectTypeCode = entity.ObjectTypeCode
.OwnershipType = entity.OwnershipType.ToString()
.PrimaryIdAttribute = entity.PrimaryKey
.PrimaryNameAttribute = entity.PrimaryField
.ReportViewName = entity.ReportViewName
End With
Next
End Sub ' Process3_
#End Region ' Internals
#Region "Attributes"
Private m_crmConnection As String
#End Region ' Attributes
End Class ' CreateNewOutputRows
]]>
ScriptComponent_16bdf9b8dcbd4172a3fc51cbfc50adfe
true
CozyRoc.SqlServer.SSIS.ScriptComponentHostPlus, CozyRoc.SSISPlus, Version=1.0.0.0, Culture=neutral, PublicKeyToken=16cf490bb80c34ea