C# Class Microsoft.Dynamics.Integration.Adapters.DynamicCrm.CrmObjectProvider

Inheritance: ObjectProvider
显示文件 Open project: Microsoft/Instance-Adapter-for-Microsoft-Dynamics-CRM

Private Properties

Property Type Description
ApplyStateAndStatus void
CheckStateAndStatus void
CreateNewLines void
DetectDuplicates Entity
GetBaseCurrencyPriceLevel Entity
GetComplexTypeFromEntity ComplexType
GetDeletedChildren IEnumerable
GetDictionary object>.Dictionary
GetDynamicInstance Entity
GetDynamicInstance Entity
GetDynamicInstance Entity
GetDynamicInstanceToDelete Entity
GetKeys List
GetObjectDefinitionInternal ObjectDefinition
GetReferenceInstanceType Xrm.Sdk.EntityReference
InitCollectionFields void
IsValidGuidString bool
PopulateDictionary void
PopulateDictionary void
PopulateOptionSetValueDictionary void
PopulatePartyList void
PrepEntityForCreate void
PrepEntityForUpdate void
QueryByEntityKey Entity
RemoveProperties void
RemoveStateCode Xrm.Sdk.OptionSetValue
RemoveStatusCode Xrm.Sdk.OptionSetValue
RetrieveChildEntities List
RetrieveEntityReferenceValue Xrm.Sdk.EntityCollection
RetrieveMultipleDynamicEntities RetrieveMultipleResponse
SetOwner void
SetProperties void

Protected Methods

Method Description
AssignReferencePropertyValue ( Xrm.Sdk.EntityReference reference, Entity entity, string propertyToBeAssignedValue ) : void

Assigns an object to be the value for a property on a Entity.

If the object is null, nothing is assigned to the property

BuildCriteriaFields ( ) : ICollection

Builds up the ICollection of FieldInstances that are used in this object's criteria.

CallCrmExecuteWebMethod ( OrganizationRequest request ) : OrganizationResponse

Calls the target CrmService.

CallMetadataExecuteWebMethod ( OrganizationRequest request ) : OrganizationResponse

Calls the target MetadataService.

CreateNewCompoundEntity ( Entity entity, Entity children ) : void

Issues a CompundCreateRequest to the target CrmService.

CreateNewEntity ( Entity entity ) : void

Issues a CreateRequest to the target CrmService.

CreateUpdateChildEntities ( object>.Dictionary dictionary, Guid parentKey, FieldDefinition collectionField ) : void

Called by the WriteParentEntity method after the parent entity has been created to allow for the creation of any associated children entities.

CreateUpdateChildInstanceForField ( Guid parentKey, Entity childEntity, string collectionFieldName ) : void

Used to actually create instances of the child entities in an inherited class.

CrmObjectProvider ( ) : Common.System

Initializes a new instance of the CrmObjectProvider class.

DeleteEntity ( object value, string keyProperty ) : void

Issues an DeleteRequest to the target CrmService.

FindEntities ( ICriterion criterion ) : ICollection

Gets an array of Key objects that represent the Keys for entities provided by this provider that have been deleted since the date provided in the modifiedDate string.

GetDeletedEntityKeys ( DateTime modifiedDate ) : ICollection

Gets an array of Key objects that represent the Keys for entities provided by this provider that have been deleted since the date provided in the modifiedDate string.

GetModifiedEntityKeys ( DateTime modifiedDate, string keyPropertyName ) : Guid[]

Gets an array of Key objects that represent the Keys for entities provided by this provider that have been modified since the date provided in the modified Date string.

GetNewEntityInstance ( string propertyName, string propertyValue, string entityName ) : Entity

Get a new instance of a Entity with a property initialized.

GetSetStateRequest ( int stateToSet, int statusToSet, Guid entityId ) : OrganizationRequest

Gets the SetState request message for this entity.

MapActivityPartyReferences ( object>.Dictionary dictionary, Entity entity, string propertyName, FieldDefinition field ) : Xrm.Sdk.EntityCollection

Maps activity party references

MapEntityReference ( FieldDefinition field, object>.Dictionary mappedLookupObject ) : Xrm.Sdk.EntityReference

Gets a new EntityReference object that represents an instance of an entity within the target system.

MapLookup ( object>.Dictionary dictionary, Entity entity, string propertyName, ComplexType ct, FieldDefinition field, object>.Dictionary mappedValue ) : Xrm.Sdk.EntityReference

Gets a new Lookup object that represents an instance of an entity within the target system.

The overload can be used to map properties in a specific order.

RemoveDeletedAddresses ( string childEntityName, ICollection childKeys, string compAttribute, Guid parentKey, string parentAttributeName, bool primaryAddressDelete, bool secondaryAddressDelete ) : void

Removes deleted addresses from contact and account entities

If the customeraddress detected for deletion is address number 1 or 2, it's values are blanked out except for it's name and integration key and the address is not deleted.

RemoveDeletedChildren ( string childEntityName, ICollection childEntities, Guid parentKey ) : void

Removes children from a parent that appear to be deleted in the source system.

RemoveDeletedChildren ( string childEntityName, ICollection childKeys, Guid parentKey ) : void

Removes children from a parent that appear to be deleted in the source system.

RemoveDeletedChildren ( string childEntityName, ICollection childKeys, string compAttribute, Guid parentKey, string parentAttributeName ) : void

Removes children from a parent that appear to be deleted in the source system.

RetrieveEntityAsDictionary ( Entity target ) : object>.Dictionary

Gets a Dictionary that contains the Entity instance that was retrieved using the supplied RetrieveTarget.

SetLookupType ( FieldDefinition field, Xrm.Sdk.EntityReference returnedLookup ) : void

Sets the type property on a given Lookup instance.

SetState ( Entity entity ) : void

Sets the state code for this instance.

UpdateCompoundEntity ( Entity entity, Entity children ) : void

Issues an UpdateCompoundRequest to the target CrmService.

UpdateEntity ( Entity entity ) : void

Issues an UpdateRequest to the target CrmService.

WriteParentEntity ( object value ) : void

Writes an object to the stream.

The entity's primaryKey property is set to a new random Guid which is then passed into the CreateUpdateChildren() method. This overload uses the DynamicsIntegrationKey constant as the property to be queried.

WriteParentEntity ( object value, string queryProperty, ICriterion criterion ) : void

Writes an object to the stream

The entity's primaryKey property is set to a new random Guid which is then passed into the CreateUpdateChildren() method.

Private Methods

Method Description
ApplyStateAndStatus ( Entity entity, Xrm.Sdk.OptionSetValue state, Xrm.Sdk.OptionSetValue status ) : void

Updates a DynmicEntity's state and status code property and then calls the service to persist the values

CheckStateAndStatus ( object>.Dictionary dictionary, Entity entity, string propertyName, DynamicCrmAdapter adapter ) : void

Checks if the state of an entity is already properly set and removes it if it is, otherwise it is set.

CreateNewLines ( Entity children ) : void

Sets the child line entities to be in a created state.

DetectDuplicates ( OrganizationRequest request ) : Entity

Detects if duplicates were encountered when sending a create request into CRM.

GetBaseCurrencyPriceLevel ( ) : Entity

Gets the CRM price level for the base currency of the organization.

GetComplexTypeFromEntity ( Entity entity ) : ComplexType

Gets the ComplexType for an Entity

GetDeletedChildren ( string childEntityName, ICollection childKeys, string compAttribute, Guid parentKey, string parentAttributeName ) : IEnumerable

Gets the children that are in CRM currently that were not in the supplied collection on an update operation

GetDictionary ( Entity entity, DynamicCrmAdapter adapter, List fieldDefinitions ) : object>.Dictionary

Gets a Dictionary that represents a DynamicEntity.

GetDynamicInstance ( string queryProperty, object>.Dictionary dictionary, string entityName ) : Entity

Gets an instance of the Entity class that contains either an instance of an object that exists in the system or a new instance of one if the requested key is not present in the system.

GetDynamicInstance ( string queryProperty, object>.Dictionary dictionary, string entityName, ICriterion criterion ) : Entity

Gets an instance of the DynamicsEntity class that contains either an instance of an object that exists in the system or a new instance of one if the requested key is not present in the system.

GetDynamicInstance ( string queryProperty, string queryValue, string entityName ) : Entity

Gets an instance of the DynamicsEntity class that contains either an instance of an object that exists in the system or a new instance of one if the requested key is not present in the system.

GetDynamicInstanceToDelete ( string queryValue, string keyProperty, string entityName ) : Entity

Gets an instance of the Entity class that can be used for delete operations

GetKeys ( RetrieveMultipleRequest request ) : List

Gets a List of entities that the keys can be retrieved from.

GetObjectDefinitionInternal ( ) : ObjectDefinition
GetReferenceInstanceType ( FieldDefinition field ) : Xrm.Sdk.EntityReference

Gets an instance of a EntityReference type that has its type property set.

InitCollectionFields ( ) : void

Initializes this provider's list of collection fields

IsValidGuidString ( string guidString ) : bool

Checks a supplied string to determine if it can be converted into a Guid.

PopulateDictionary ( Entity dynamicEntity, object>.Dictionary complexTypeDictionary, object>.KeyValuePair property ) : void

Populates a Dictionary with the values contained in a DynamicEntity.

PopulateDictionary ( Entity dynamicEntity, object>.Dictionary complexTypeDictionary, object>.KeyValuePair property, DynamicCrmAdapter adapter, FieldDefinition definition ) : void

Populates a Dictionary with the values contained in a DynamicEntity.

PopulateOptionSetValueDictionary ( Entity dynamicEntity, object>.Dictionary complexTypeDictionary, object>.KeyValuePair property, DynamicCrmAdapter adapter ) : void

Populates a Dictionary with the values contained in a DynamicEntity.

PopulatePartyList ( Entity dynamicEntity, object>.Dictionary complexTypeDictionary, object>.KeyValuePair property, DynamicCrmAdapter adapter, FieldDefinition definition ) : void

Populates the activity party list for a given CRM Entity.

PrepEntityForCreate ( Entity entity ) : void

Sets the owning user and override created on entity attributes.

PrepEntityForUpdate ( Entity entity ) : void

Removes properties and sets state for an entity

QueryByEntityKey ( string entityUniqueId, string entityName ) : Entity

Queries CRM for the entity with the supplied id.

RemoveProperties ( Entity entity, object>.Dictionary dictionary ) : void

Removes properties from the Entity that are not needed.

RemoveStateCode ( Entity entity ) : Xrm.Sdk.OptionSetValue

Removes the state code from a Entity

RemoveStatusCode ( Entity entity ) : Xrm.Sdk.OptionSetValue

Removes the status code from a Entity

RetrieveChildEntities ( object>.Dictionary dictionary, Guid parentKey, FieldDefinition collectionField ) : List
RetrieveEntityReferenceValue ( FieldDefinition field, XmlAttribute lookupName, XmlAttribute lookupFields, object>.Dictionary dictionary ) : Xrm.Sdk.EntityCollection
RetrieveMultipleDynamicEntities ( string queryValue, string keyProperty, string entityName ) : RetrieveMultipleResponse

Calls the CRM service and retrieves the entities that match the modifiedDateValue expression that is built up based on the supplied values

SetOwner ( Entity entity ) : void

Sets the assignee to be the owning user.

SetProperties ( object>.Dictionary dictionary, Entity entity ) : void

Method Details

AssignReferencePropertyValue() protected static method

Assigns an object to be the value for a property on a Entity.
If the object is null, nothing is assigned to the property
protected static AssignReferencePropertyValue ( Xrm.Sdk.EntityReference reference, Entity entity, string propertyToBeAssignedValue ) : void
reference Xrm.Sdk.EntityReference The object be assigned as the value
entity Entity The Entity to be assigned to
propertyToBeAssignedValue string The name of the property on the Entity to assign the supplied object to
return void

BuildCriteriaFields() protected method

Builds up the ICollection of FieldInstances that are used in this object's criteria.
protected BuildCriteriaFields ( ) : ICollection
return ICollection

CallCrmExecuteWebMethod() protected method

Calls the target CrmService.
Thrown if there is a SoapException thrown during the call to the web service.
protected CallCrmExecuteWebMethod ( OrganizationRequest request ) : OrganizationResponse
request OrganizationRequest The Request object to use when calling the target CrmService.
return OrganizationResponse

CallMetadataExecuteWebMethod() protected method

Calls the target MetadataService.
Thrown if there is a SoapException thrown during the call to the web service.
protected CallMetadataExecuteWebMethod ( OrganizationRequest request ) : OrganizationResponse
request OrganizationRequest The Request object to use when calling the target MetadataService.
return OrganizationResponse

CreateNewCompoundEntity() protected method

Issues a CompundCreateRequest to the target CrmService.
protected CreateNewCompoundEntity ( Entity entity, Entity children ) : void
entity Entity The Entity to be created.
children Entity The Array of Entity objects that contains the children.
return void

CreateNewEntity() protected method

Issues a CreateRequest to the target CrmService.
protected CreateNewEntity ( Entity entity ) : void
entity Entity The Entity to be created.
return void

CreateUpdateChildEntities() protected method

Called by the WriteParentEntity method after the parent entity has been created to allow for the creation of any associated children entities.
protected CreateUpdateChildEntities ( object>.Dictionary dictionary, Guid parentKey, FieldDefinition collectionField ) : void
dictionary object>.Dictionary The Dictionary that contains the parent entity's data.
parentKey Guid The Key that was used in creating the parent entity.
collectionField FieldDefinition The DefinitionField that defines the collection.
return void

CreateUpdateChildInstanceForField() protected method

Used to actually create instances of the child entities in an inherited class.
protected CreateUpdateChildInstanceForField ( Guid parentKey, Entity childEntity, string collectionFieldName ) : void
parentKey Guid The Key of the parent entity.
childEntity Entity The child entity to be created in the form of a Entity.
collectionFieldName string The name of the field in the ObjectProvider's configuration file that is being mapped currently.
return void

CrmObjectProvider() protected method

Initializes a new instance of the CrmObjectProvider class.
protected CrmObjectProvider ( ) : Common.System
return Common.System

DeleteEntity() protected method

Issues an DeleteRequest to the target CrmService.
protected DeleteEntity ( object value, string keyProperty ) : void
value object The dictionary that contains the entity to be deleted.
keyProperty string The property on the entity that holds the entity's key.
return void

FindEntities() protected method

Gets an array of Key objects that represent the Keys for entities provided by this provider that have been deleted since the date provided in the modifiedDate string.
protected FindEntities ( ICriterion criterion ) : ICollection
criterion ICriterion The string representation of a DateTime to be used as the modified on criteria for the retrieve request.
return ICollection

GetDeletedEntityKeys() protected method

Gets an array of Key objects that represent the Keys for entities provided by this provider that have been deleted since the date provided in the modifiedDate string.
protected GetDeletedEntityKeys ( DateTime modifiedDate ) : ICollection
modifiedDate DateTime The string representation of a DateTime to be used as the modified on criteria for the retrieve request.
return ICollection

GetModifiedEntityKeys() protected method

Gets an array of Key objects that represent the Keys for entities provided by this provider that have been modified since the date provided in the modified Date string.
protected GetModifiedEntityKeys ( DateTime modifiedDate, string keyPropertyName ) : Guid[]
modifiedDate DateTime The DateTime to be used as the modified on criteria for the retrieve request.
keyPropertyName string The name of the property on the provided entity that hold the primary key.
return Guid[]

GetNewEntityInstance() protected method

Get a new instance of a Entity with a property initialized.
protected GetNewEntityInstance ( string propertyName, string propertyValue, string entityName ) : Entity
propertyName string The name of the property to initialize.
propertyValue string The value to set the property to be initialized to.
entityName string The logical name of the entity type to create.
return Entity

GetSetStateRequest() protected method

Gets the SetState request message for this entity.
protected GetSetStateRequest ( int stateToSet, int statusToSet, Guid entityId ) : OrganizationRequest
stateToSet int An int that represents the statecode to set.
statusToSet int An int that represents the Ststus to set.
entityId Guid The Guid the refers to this instance.
return OrganizationRequest

MapActivityPartyReferences() protected method

Maps activity party references
protected MapActivityPartyReferences ( object>.Dictionary dictionary, Entity entity, string propertyName, FieldDefinition field ) : Xrm.Sdk.EntityCollection
dictionary object>.Dictionary Contains the root entity as a Dictionary.
entity Entity The entity to map the activity parties to, if the property that is being mapped is an option set.
propertyName string The property that the activities are associated to on the root entity.
field FieldDefinition The that contains the activity parties.
return Xrm.Sdk.EntityCollection

MapEntityReference() protected method

Gets a new EntityReference object that represents an instance of an entity within the target system.
protected MapEntityReference ( FieldDefinition field, object>.Dictionary mappedLookupObject ) : Xrm.Sdk.EntityReference
field FieldDefinition The field that is currently being set to a EntityReference.
mappedLookupObject object>.Dictionary The Dictionary that contains the data for populating the returned EntityReference.
return Xrm.Sdk.EntityReference

MapLookup() protected method

Gets a new Lookup object that represents an instance of an entity within the target system.
The overload can be used to map properties in a specific order.
protected MapLookup ( object>.Dictionary dictionary, Entity entity, string propertyName, ComplexType ct, FieldDefinition field, object>.Dictionary mappedValue ) : Xrm.Sdk.EntityReference
dictionary object>.Dictionary The Dictionary that contains the data to be used in mapping this entity.
entity Entity The Entity that is currently being mapped.
propertyName string The name of the current property from the ObjectDefinition.
ct ComplexType An instance of a ComplexType for this field.
field FieldDefinition The field that is currently being set to a Lookup.
mappedValue object>.Dictionary The Dictionary that contains the data for populating the returned Lookup.
return Xrm.Sdk.EntityReference

RemoveDeletedAddresses() protected method

Removes deleted addresses from contact and account entities
If the customeraddress detected for deletion is address number 1 or 2, it's values are blanked out except for it's name and integration key and the address is not deleted.
protected RemoveDeletedAddresses ( string childEntityName, ICollection childKeys, string compAttribute, Guid parentKey, string parentAttributeName, bool primaryAddressDelete, bool secondaryAddressDelete ) : void
childEntityName string The name of the child entity to be deleted
childKeys ICollection An ICollection of strings that contains the valid child keys (the ones that have not been deleted).
compAttribute string The attribute to use when determining if a child in the collection has been deleted or not
parentKey Guid The Key of the parent entity
parentAttributeName string The name of the parent entities key attribute
primaryAddressDelete bool Determines whether or not the address1 fields are blanked out.
secondaryAddressDelete bool Determines whether or not the address2 fields are blanked out.
return void

RemoveDeletedChildren() protected method

Removes children from a parent that appear to be deleted in the source system.
protected RemoveDeletedChildren ( string childEntityName, ICollection childEntities, Guid parentKey ) : void
childEntityName string The name of the child entity to be deleted
childEntities ICollection An ICollection of DynamicEntities that contains the child entities currently in CRM
parentKey Guid The Key of the parent entity
return void

RemoveDeletedChildren() protected method

Removes children from a parent that appear to be deleted in the source system.
protected RemoveDeletedChildren ( string childEntityName, ICollection childKeys, Guid parentKey ) : void
childEntityName string The name of the child entity to be deleted
childKeys ICollection An ICollection of strings that contains the valid child keys (the ones that have not been deleted).
parentKey Guid The Key of the parent entity
return void

RemoveDeletedChildren() protected method

Removes children from a parent that appear to be deleted in the source system.
protected RemoveDeletedChildren ( string childEntityName, ICollection childKeys, string compAttribute, Guid parentKey, string parentAttributeName ) : void
childEntityName string The name of the child entity to be deleted
childKeys ICollection An ICollection of strings that contains the valid child keys (the ones that have not been deleted).
compAttribute string The attribute to use when determining if a child in the collection has been deleted or not
parentKey Guid The Key of the parent entity
parentAttributeName string The name of the parent entities key attribute
return void

RetrieveEntityAsDictionary() protected method

Gets a Dictionary that contains the Entity instance that was retrieved using the supplied RetrieveTarget.
protected RetrieveEntityAsDictionary ( Entity target ) : object>.Dictionary
target Entity A TargetRetrive to use when calling the CRM web service.
return object>.Dictionary

SetLookupType() protected method

Sets the type property on a given Lookup instance.
protected SetLookupType ( FieldDefinition field, Xrm.Sdk.EntityReference returnedLookup ) : void
field FieldDefinition The field who's name will determine that type of the Lookup.
returnedLookup Xrm.Sdk.EntityReference The Lookup to set the type property on.
return void

SetState() protected method

Sets the state code for this instance.
protected SetState ( Entity entity ) : void
entity Entity The Entity to set the state code for.
return void

UpdateCompoundEntity() protected method

Issues an UpdateCompoundRequest to the target CrmService.
protected UpdateCompoundEntity ( Entity entity, Entity children ) : void
entity Entity The Entity to be created.
children Entity The Array of Entity objects that contains the children.
return void

UpdateEntity() protected method

Issues an UpdateRequest to the target CrmService.
protected UpdateEntity ( Entity entity ) : void
entity Entity The Entity to be updated.
return void

WriteParentEntity() protected method

Writes an object to the stream.
The entity's primaryKey property is set to a new random Guid which is then passed into the CreateUpdateChildren() method. This overload uses the DynamicsIntegrationKey constant as the property to be queried.
Thrown if the object to be written is not of the correct type for this provider.
protected WriteParentEntity ( object value ) : void
value object The object to be written.
return void

WriteParentEntity() protected method

Writes an object to the stream
The entity's primaryKey property is set to a new random Guid which is then passed into the CreateUpdateChildren() method.
Thrown if the object to be written is not of the Dictionary of stringobject type
protected WriteParentEntity ( object value, string queryProperty, ICriterion criterion ) : void
value object The object to be written
queryProperty string The property to be queried to discover if this is a new instance or an existing one.
criterion ICriterion The ICriterion to use in duplicate detection, or null to not use duplicate detection.
return void