/// <summary> /// Converts a CRM complex type into a <see cref="ComplexType"/>. /// </summary> /// <param name="typeToConvert">The CRM <c>AttributeTypeCode</c> to be converted.</param> /// <param name="objDef">The <see cref="ObjectDefinition"/> that holds the type data.</param> /// <returns>A <see cref="ComplexType"/> that contains the converted CRM type information.</returns> public static ComplexType ComplexTypeConvert(AttributeTypeCode typeToConvert, ObjectDefinition objDef) { switch (typeToConvert) { case AttributeTypeCode.Customer: case AttributeTypeCode.Lookup: case AttributeTypeCode.Owner: return(GetComplexTypeForReference(objDef, "EntityReference")); case AttributeTypeCode.Money: return(GetComplexTypeForMoney(objDef)); case AttributeTypeCode.Picklist: case AttributeTypeCode.State: return(GetComplexTypeForPicklist(objDef)); case AttributeTypeCode.PartyList: return(GetComplexTypeForPartyList(objDef, typeToConvert.ToString())); case AttributeTypeCode.Status: return(GetComplexTypeForPicklist(objDef)); // Added support for the Status Code field for any entity with a status code setting default: return(null); } }
/// <summary> /// Gets the sql datatype name for the attribute type. /// </summary> /// <param name="metadata"></param> /// <returns></returns> public static string GetSqlDataTypeName(this AttributeTypeCode attType, AttributeTypeDisplayName attTypeDisplayName) { switch (attType) { case AttributeTypeCode.String: case AttributeTypeCode.Memo: case AttributeTypeCode.EntityName: return("nvarchar"); case AttributeTypeCode.Lookup: case AttributeTypeCode.Owner: case AttributeTypeCode.Customer: case AttributeTypeCode.Uniqueidentifier: return("uniqueidentifier"); case AttributeTypeCode.Virtual: if (attTypeDisplayName != null && attTypeDisplayName.Value == AttributeTypeDisplayName.ImageType.Value) { return("image"); } return("nvarchar"); case AttributeTypeCode.Double: return("float"); case AttributeTypeCode.Decimal: return("decimal"); case AttributeTypeCode.State: case AttributeTypeCode.Status: case AttributeTypeCode.Picklist: case AttributeTypeCode.Integer: return("int"); case AttributeTypeCode.Boolean: case AttributeTypeCode.ManagedProperty: return("bit"); case AttributeTypeCode.DateTime: return("datetime"); case AttributeTypeCode.Money: return("money"); case AttributeTypeCode.BigInt: return("bigint"); default: return(attType.ToString().ToLower()); } }
string GetDataType(AttributeTypeCode atc) { var dataType = "string"; switch (atc) { case AttributeTypeCode.Virtual: case AttributeTypeCode.State: case AttributeTypeCode.Integer: case AttributeTypeCode.BigInt: case AttributeTypeCode.Money: case AttributeTypeCode.Decimal: case AttributeTypeCode.Double: dataType = "number"; break; } LogMessage(string.Format("Get attribute script datatype: {0} => {1}", atc.ToString(), dataType), EnumLoggingLevel.Verbose); return(dataType); }
/// <summary> /// Converts a CRM complex type into a <see cref="ComplexType"/>. /// </summary> /// <param name="typeToConvert">The CRM <c>AttributeTypeCode</c> to be converted.</param> /// <param name="objDef">The <see cref="ObjectDefinition"/> that holds the type data.</param> /// <returns>A <see cref="ComplexType"/> that contains the converted CRM type information.</returns> public static ComplexType ComplexTypeConvert(AttributeTypeCode typeToConvert, ObjectDefinition objDef) { switch (typeToConvert) { case AttributeTypeCode.Customer: case AttributeTypeCode.Lookup: case AttributeTypeCode.Owner: return GetComplexTypeForReference(objDef, "EntityReference"); case AttributeTypeCode.Money: return GetComplexTypeForMoney(objDef); case AttributeTypeCode.Picklist: case AttributeTypeCode.State: return GetComplexTypeForPicklist(objDef); case AttributeTypeCode.PartyList: return GetComplexTypeForPartyList(objDef, typeToConvert.ToString()); case AttributeTypeCode.Status: return GetComplexTypeForPicklist(objDef); // Added support for the Status Code field for any entity with a status code setting default: return null; } }
private object GetValue(AttributeTypeCode? type) { switch (type) { case AttributeTypeCode.String: case AttributeTypeCode.Memo: return cmbValue.Text; break; case AttributeTypeCode.BigInt: case AttributeTypeCode.Integer: return int.Parse(cmbValue.Text); break; case AttributeTypeCode.Picklist: case AttributeTypeCode.State: case AttributeTypeCode.Status: var value = ((OptionsetItem)cmbValue.SelectedItem).meta.Value; return new OptionSetValue((int)value); break; default: throw new Exception("Attribute of type " + type.ToString() + " is currently not supported."); } }