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

Utility class to hold various operations that are common when working with Dynamics CRM.
显示文件 Open project: Microsoft/Instance-Adapter-for-Microsoft-Dynamics-CRM Class Usage Examples

Public Methods

Method Description
ComplexTypeConvert ( AttributeTypeCode typeToConvert, ObjectDefinition objDef ) : ComplexType

Converts a CRM complex type into a ComplexType.

ConvertStateNameToValue ( string stateName, string entityName, DynamicCrmAdapter adapter ) : int

Converts all representations of the state property to an integer.

GetDynamicAddressInstance ( string addressIntegrationKeyValue, Guid parentKey, DynamicCrmAdapter adapter, string addressIntegrationKeyProperty ) : Entity

Gets an instance of the customeraddress class.

GetIntegratedEntities ( ) : string[]

Gets the array of entity names that have a dynamics_integrationkey property added to them

GetMultipartQueryExpression ( LogicalOperator operand, string entityName, string>.KeyValuePair propertyValues ) : QueryExpression

Gets a QueryExpression instance for retrieving a uom.

This method sets the Distinct property of the returned QueryExpression to true.

GetNameKeyedEntities ( ) : string[]

Gets the array of entity names that use the "name" property to represent a dynamics_integrationkey

GetObjectProviderName ( ObjectDefinition objDef ) : string

Returns the name of an object provider base on the type name specified in it's configuration file.

GetQueryExpression ( string entityName, ICriterion criterion, ColumnSet columnSet ) : QueryExpression

Gets a QueryExpression instance with it's properties set to the values supplied

This method sets the Distinct property of the returned QueryExpression to false

GetQueryExpression ( string entityName, string queryProperty, object propertyValue, ConditionOperator conditionOperator ) : QueryExpression

Gets a QueryExpression instance with it's properties set to the values supplied

This method sets the Distinct property of the returned QueryExpression to false

GetQueryExpression ( string entityName, string queryProperty, string propertyValue ) : QueryExpression

Gets a QueryExpression instance with it's properties set to the values supplied

This method sets the Distinct property of the returned QueryExpression to false. This overload also assume that the LogicalOperator is set to Equal

GetReaderQueryExpression ( string entityName, DateTime modifiedDate, DynamicCrmAdapter adapter, bool isDynamic, ColumnSet columnSet ) : QueryExpression

Gets a QueryExpression instance with it's properties set to the values supplied

The method generates a query that is retrieved by the modified date supplied as well as the IntegrationReady flag and the modified by property not being equal to the INTEGRATION user's id

GetSpecialAddressPicklistFields ( ) : string[]

Gets the array of Picklist fields that are on address1 and address2 attributes

GetUnmappedLookupFields ( ) : string[]

Gets the array of Lookup fields that are not mapped

MapCrmMoney ( object>.Dictionary mappedMoneyObject ) : Money

Maps a Dictionary containing CrmMoney information onto an instance of a CrmMoney entity.

MapPicklist ( Entity entity, FieldDefinition field, object>.Dictionary mappedLookupObject, DynamicCrmAdapter crm2011Adapter, string providedEntityName ) : OptionSetValue

Gets a Picklist instance who's values are set based on the parameters provided.

SetRelationshipValuesFromDictionary ( object>.Dictionary mappedLookupObject, object relationshipEntity ) : void

Sets the properties of an object that has a relationship to another BusinessEntity to the values contained in the supplied Dictionary.

SimpleTypeConvert ( AttributeTypeCode typeToConvert ) : Type

Converts a CRM AttributeType into a simple .NET type.

ValidateDictionary ( object>.Dictionary mappedType ) : void

Validates that a Dictionary not not contain 0 objects.

ValidateInventoriedProduct ( Entity product, string productKey ) : void

Validates that a product is not new when retrieving from the product catalog

Private Methods

Method Description
GenerateFieldAndAddType ( ObjectDefinition objDef, Type typeToGen, string name, string displayName, bool isRequired, bool isReadOnly ) : FieldDefinition
GenerateFieldAndAddType ( ObjectDefinition objDef, Type typeToGen, string name, string displayName, string typeName, bool isRequired, bool isReadOnly ) : FieldDefinition
GetComplexTypeForMoney ( ObjectDefinition objDef ) : ComplexType

Produces a ComplexType from the ObjectDefinition for the CRM Money type.

GetComplexTypeForPartyList ( ObjectDefinition objDef, string complexTypeName ) : ComplexType
GetComplexTypeForPicklist ( ObjectDefinition objDef ) : ComplexType

Produces a ComplexType from the ObjectDefinition for the CRM option set type.

GetComplexTypeForReference ( ObjectDefinition objDef, string complexTypeName ) : ComplexType

Gets a ComplexType for a CRM EntityReference.

GetComplexTypeForStatus ( ObjectDefinition objDef ) : ComplexType

Produces a ComplexType from the ObjectDefinition for the CRM status type.

GetConditionOperator ( BinaryComparisonOperator binaryComparisonOperator ) : ConditionOperator
GetContractCancelRequest ( int statusToSet, Guid contractEntityId ) : OrganizationRequest

Gets a CRM OrganizationRequest that can be used to cancel a contract.

GetDefaultStateCodeValue ( string stateName ) : int
GetErrorCode ( XmlNode errorInfo ) : string
GetIncidentCloseRequest ( int statusToSet, Guid incidentEntityId ) : OrganizationRequest

Gets a CRM OrganizationRequest that can be used to close an incident.

GetOpportunityLoseRequest ( int statusToSet, Guid opportunityEntityId ) : OrganizationRequest

Gets a CRM OrganizationRequest that can be used to lose an opportunity.

IsAddressOneOrTwo ( Entity childEntity ) : bool

Determines if the supplied CRM Entity is address 1 or 2.

IsSpecialAddressPicklist ( Entity entity, FieldDefinition field ) : bool

Determines if an option set is one of the customer address 1 or 2 option sets.

ValidatePropertyQueryParameters ( string entityName, string queryProperty ) : void

Validates query parameters

Method Details

ComplexTypeConvert() public static method

Converts a CRM complex type into a ComplexType.
public static ComplexTypeConvert ( AttributeTypeCode typeToConvert, ObjectDefinition objDef ) : ComplexType
typeToConvert AttributeTypeCode The CRM AttributeTypeCode to be converted.
objDef ObjectDefinition The that holds the type data.
return ComplexType

ConvertStateNameToValue() public static method

Converts all representations of the state property to an integer.
public static ConvertStateNameToValue ( string stateName, string entityName, DynamicCrmAdapter adapter ) : int
stateName string The state to get the integer value of as a string.
entityName string The name of the entity type to get the state code for.
adapter DynamicCrmAdapter The to use for calling into a CRM for resolving that state.
return int

GetDynamicAddressInstance() public static method

Gets an instance of the customeraddress class.
public static GetDynamicAddressInstance ( string addressIntegrationKeyValue, Guid parentKey, DynamicCrmAdapter adapter, string addressIntegrationKeyProperty ) : Entity
addressIntegrationKeyValue string The value of the address's dynamics_integrationkey property to query for.
parentKey Guid The parent of this address to use when querying for the existence of this address instance.
adapter DynamicCrmAdapter An instance of the CRM2011Adapter class to use when calling CRM.
addressIntegrationKeyProperty string The key attribute on the customeraddress that the supplied value is for.
return Entity

GetIntegratedEntities() public static method

Gets the array of entity names that have a dynamics_integrationkey property added to them
public static GetIntegratedEntities ( ) : string[]
return string[]

GetMultipartQueryExpression() public static method

Gets a QueryExpression instance for retrieving a uom.
This method sets the Distinct property of the returned QueryExpression to true.
Thrown if the unitName or scheduleId parameters are null or empty.
public static GetMultipartQueryExpression ( LogicalOperator operand, string entityName, string>.KeyValuePair propertyValues ) : QueryExpression
operand LogicalOperator The LogicalOperand to use for this query.
entityName string The logical name for the entity to be queried for.
propertyValues string>.KeyValuePair The array of KeyValuePairs that contains the properties and their values to be queried for.
return QueryExpression

GetNameKeyedEntities() public static method

Gets the array of entity names that use the "name" property to represent a dynamics_integrationkey
public static GetNameKeyedEntities ( ) : string[]
return string[]

GetObjectProviderName() public static method

Returns the name of an object provider base on the type name specified in it's configuration file.
public static GetObjectProviderName ( ObjectDefinition objDef ) : string
objDef ObjectDefinition The ObjectDefinition to get the type name from
return string

GetQueryExpression() public static method

Gets a QueryExpression instance with it's properties set to the values supplied
This method sets the Distinct property of the returned QueryExpression to false
Thrown if the ICriterion parameter is null
public static GetQueryExpression ( string entityName, ICriterion criterion, ColumnSet columnSet ) : QueryExpression
entityName string The name of the BusinessEntity as a string to be queried
criterion ICriterion An ICiterion instance to use for duplicate detection
columnSet ColumnSet A CRM ColumnSet containing the set of columns to be returned from the query.
return QueryExpression

GetQueryExpression() public static method

Gets a QueryExpression instance with it's properties set to the values supplied
This method sets the Distinct property of the returned QueryExpression to false
Thrown if the entityName or queryProperty parameters are null or empty
public static GetQueryExpression ( string entityName, string queryProperty, object propertyValue, ConditionOperator conditionOperator ) : QueryExpression
entityName string The name of the BusinessEntity as a string to be queried
queryProperty string The property on the BusinessEntity to be queried
propertyValue object The value for the property being queried for
conditionOperator ConditionOperator A logical condition operator to use for the condition expression
return QueryExpression

GetQueryExpression() public static method

Gets a QueryExpression instance with it's properties set to the values supplied
This method sets the Distinct property of the returned QueryExpression to false. This overload also assume that the LogicalOperator is set to Equal
Thrown if the entityName or queryProperty parameters are null or empty
public static GetQueryExpression ( string entityName, string queryProperty, string propertyValue ) : QueryExpression
entityName string The name of the BusinessEntity as a string to be queried
queryProperty string The property on the BusinessEntity to be queried
propertyValue string The value for the property being queried for
return QueryExpression

GetReaderQueryExpression() public static method

Gets a QueryExpression instance with it's properties set to the values supplied
The method generates a query that is retrieved by the modified date supplied as well as the IntegrationReady flag and the modified by property not being equal to the INTEGRATION user's id
public static GetReaderQueryExpression ( string entityName, DateTime modifiedDate, DynamicCrmAdapter adapter, bool isDynamic, ColumnSet columnSet ) : QueryExpression
entityName string The name of the BusinessEntity as a string to be queried
modifiedDate DateTime The string value for the date to be queried from
adapter DynamicCrmAdapter An instance of a CRM2011Adapter used to retrieve the INTEGRATION user's Guid
isDynamic bool True if the object provider calling into this method is a DynamicObbjectProvider and false otherwise
columnSet ColumnSet A CRM ColumnSet that contains the columns to be returned from the query.
return QueryExpression

GetSpecialAddressPicklistFields() public static method

Gets the array of Picklist fields that are on address1 and address2 attributes
public static GetSpecialAddressPicklistFields ( ) : string[]
return string[]

GetUnmappedLookupFields() public static method

Gets the array of Lookup fields that are not mapped
public static GetUnmappedLookupFields ( ) : string[]
return string[]

MapCrmMoney() public static method

Maps a Dictionary containing CrmMoney information onto an instance of a CrmMoney entity.
public static MapCrmMoney ( object>.Dictionary mappedMoneyObject ) : Money
mappedMoneyObject object>.Dictionary The Dictionary containing the CrmMoney information.
return Money

MapPicklist() public static method

Gets a Picklist instance who's values are set based on the parameters provided.
Thrown if the requested value is not currently in the Picklist within the CRM system.
public static MapPicklist ( Entity entity, FieldDefinition field, object>.Dictionary mappedLookupObject, DynamicCrmAdapter crm2011Adapter, string providedEntityName ) : OptionSetValue
entity Entity The current Entity.
field FieldDefinition The current DefinitionField for the property being mapped to this Picklist.
mappedLookupObject object>.Dictionary The Dictionary containing the lookup information for the Picklist.
crm2011Adapter DynamicCrmAdapter The CRM2011Adapter to use when calling the CRM web service.
providedEntityName string The name of the Entity that the current object provider is for.
return OptionSetValue

SetRelationshipValuesFromDictionary() public static method

Sets the properties of an object that has a relationship to another BusinessEntity to the values contained in the supplied Dictionary.
public static SetRelationshipValuesFromDictionary ( object>.Dictionary mappedLookupObject, object relationshipEntity ) : void
mappedLookupObject object>.Dictionary The Dictionary that hold the values to be set.
relationshipEntity object The CrmReference that needs its values set.
return void

SimpleTypeConvert() public static method

Converts a CRM AttributeType into a simple .NET type.
public static SimpleTypeConvert ( AttributeTypeCode typeToConvert ) : Type
typeToConvert AttributeTypeCode The CRM AttributeType to be converted.
return Type

ValidateDictionary() public static method

Validates that a Dictionary not not contain 0 objects.
Thrown if the Count property of the Dictionary supplied is 0.
public static ValidateDictionary ( object>.Dictionary mappedType ) : void
mappedType object>.Dictionary The Dictionary to validate
return void

ValidateInventoriedProduct() public static method

Validates that a product is not new when retrieving from the product catalog
public static ValidateInventoriedProduct ( Entity product, string productKey ) : void
product Entity The Entity that contains the product that was retrieved
productKey string The value of the product's dynamics_integrationkey
return void