diff --git a/CrmCodeGenerator.VSPackage/CrmCodeGenerator.VSPackage.csproj b/CrmCodeGenerator.VSPackage/CrmCodeGenerator.VSPackage.csproj index e7fcfce..b677485 100644 --- a/CrmCodeGenerator.VSPackage/CrmCodeGenerator.VSPackage.csproj +++ b/CrmCodeGenerator.VSPackage/CrmCodeGenerator.VSPackage.csproj @@ -80,9 +80,9 @@ True - + False - ..\lib\microsoft.crm.sdk.proxy.dll + ..\lib\Microsoft.Crm.Sdk.Proxy.dll @@ -109,9 +109,9 @@ False ..\lib\microsoft.xrm.client.dll - + False - ..\lib\microsoft.xrm.sdk.dll + ..\lib\Microsoft.Xrm.Sdk.dll @@ -325,5 +325,4 @@ --> - \ No newline at end of file diff --git a/CrmCodeGenerator.VSPackage/Model/MappingEntity.cs b/CrmCodeGenerator.VSPackage/Model/MappingEntity.cs index 6454deb..4882d12 100644 --- a/CrmCodeGenerator.VSPackage/Model/MappingEntity.cs +++ b/CrmCodeGenerator.VSPackage/Model/MappingEntity.cs @@ -71,7 +71,8 @@ public static MappingEntity Parse(EntityMetadata entityMetadata) if (entityMetadata.Description != null) if (entityMetadata.Description.UserLocalizedLabel != null) entity.Description = entityMetadata.Description.UserLocalizedLabel.Label; - + //var d = entityMetadata.Attributes.Where(p=>p.LogicalName.Contains("sii_")).ToList(); + //var d2 = entityMetadata.Attributes.Where(p=>p.LogicalName.Contains("sii_")).Select(p=>p.LogicalName).ToList(); var fields = entityMetadata.Attributes .Where(a => a.AttributeOf == null) .Select(a => MappingField.Parse(a, entity)).ToList(); @@ -91,7 +92,7 @@ public static MappingEntity Parse(EntityMetadata entityMetadata) entity.States = entityMetadata.Attributes.Where(a => a is StateAttributeMetadata).Select(a => MappingEnum.Parse(a as EnumAttributeMetadata)).FirstOrDefault(); entity.Enums = entityMetadata.Attributes - .Where(a => a is PicklistAttributeMetadata || a is StateAttributeMetadata || a is StatusAttributeMetadata || a is BooleanAttributeMetadata) + .Where(a => a is PicklistAttributeMetadata || a is StateAttributeMetadata || a is StatusAttributeMetadata || a is BooleanAttributeMetadata || a is MultiSelectPicklistAttributeMetadata) .Select(a => MappingEnum.Parse(a)).ToArray(); entity.PrimaryKey = entity.Fields.First(f => f.Attribute.LogicalName == entity.Attribute.PrimaryKey); diff --git a/CrmCodeGenerator.VSPackage/Model/MappingEnum.cs b/CrmCodeGenerator.VSPackage/Model/MappingEnum.cs index 78a18f3..958fc18 100644 --- a/CrmCodeGenerator.VSPackage/Model/MappingEnum.cs +++ b/CrmCodeGenerator.VSPackage/Model/MappingEnum.cs @@ -47,6 +47,7 @@ public static MappingEnum Parse(EnumAttributeMetadata picklist) return enm; } + public static MappingEnum Parse(BooleanAttributeMetadata twoOption) { var enm = new MappingEnum(); diff --git a/CrmCodeGenerator.VSPackage/Model/MappingField.cs b/CrmCodeGenerator.VSPackage/Model/MappingField.cs index 13e3beb..b681219 100644 --- a/CrmCodeGenerator.VSPackage/Model/MappingField.cs +++ b/CrmCodeGenerator.VSPackage/Model/MappingField.cs @@ -25,7 +25,7 @@ public class MappingField public bool IsDeprecated { get; set; } public bool IsOptionSet { get; private set; } public bool IsTwoOption { get; private set; } - public string DeprecatedVersion {get ; set; } + public string DeprecatedVersion { get; set; } public string LookupSingleType { get; set; } bool IsPrimaryKey { get; set; } public bool IsRequired { get; set; } @@ -68,12 +68,16 @@ public static MappingField Parse(AttributeMetadata attribute, MappingEntity enti result.IsOptionSet = attribute.AttributeType == AttributeTypeCode.Picklist; result.IsTwoOption = attribute.AttributeType == AttributeTypeCode.Boolean; result.DeprecatedVersion = attribute.DeprecatedVersion; - result.IsDeprecated = !string.IsNullOrWhiteSpace(attribute.DeprecatedVersion); - + result.IsDeprecated = !string.IsNullOrWhiteSpace(attribute.DeprecatedVersion); + if (attribute is PicklistAttributeMetadata) result.EnumData = MappingEnum.Parse(attribute as PicklistAttributeMetadata); + if (attribute is MultiSelectPicklistAttributeMetadata) + result.EnumData = + MappingEnum.Parse(attribute as MultiSelectPicklistAttributeMetadata); + if (attribute is LookupAttributeMetadata) { var lookup = attribute as LookupAttributeMetadata; @@ -86,6 +90,10 @@ public static MappingField Parse(AttributeMetadata attribute, MappingEntity enti if (attribute.AttributeType != null) result.FieldType = attribute.AttributeType.Value; + if (attribute.AttributeTypeName != null) + { + result.AttributeTypeName = attribute.AttributeTypeName.Value; + } result.IsPrimaryKey = attribute.IsPrimaryId == true; @@ -94,8 +102,8 @@ public static MappingField Parse(AttributeMetadata attribute, MappingEntity enti result.PrivatePropertyName = Naming.GetEntityPropertyPrivateName(attribute.SchemaName); result.HybridName = Naming.GetProperHybridFieldName(result.DisplayName, result.Attribute); - if(attribute.Description != null) - if(attribute.Description.UserLocalizedLabel != null) + if (attribute.Description != null) + if (attribute.Description.UserLocalizedLabel != null) result.Description = attribute.Description.UserLocalizedLabel.Label; if (attribute.DisplayName != null) @@ -195,11 +203,16 @@ private static string GetTargetType(MappingField field) case AttributeTypeCode.Virtual: case AttributeTypeCode.EntityName: case AttributeTypeCode.String: + if (field.AttributeTypeName == "MultiSelectPicklistType") + { + return "Microsoft.Xrm.Sdk.OptionSetValueCollection"; + } return "string"; case AttributeTypeCode.PartyList: return "System.Collections.Generic.IEnumerable"; case AttributeTypeCode.ManagedProperty: return "Microsoft.Xrm.Sdk.BooleanManagedProperty"; + default: return "object"; } @@ -249,6 +262,10 @@ public string TargetType case AttributeTypeCode.Virtual: case AttributeTypeCode.EntityName: case AttributeTypeCode.String: + if (AttributeTypeName == "MultiSelectPicklistType") + { + return "Microsoft.Xrm.Sdk.OptionSetValueCollection"; + } return "string"; default: @@ -291,6 +308,10 @@ public string SetMethodCall methodName = "SetLookup"; break; //methodName = "SetLookup"; break; case AttributeTypeCode.Virtual: + if (AttributeTypeName == "MultiSelectPicklistType") + { + return "SetValue"; + } methodName = "SetValue"; break; case AttributeTypeCode.Customer: methodName = "SetCustomer"; break; @@ -319,5 +340,7 @@ public string SetMethodCall return string.Format("{0}(\"{1}\", value);", methodName, this.Attribute.LogicalName); } } + + public string AttributeTypeName { get; private set; } } } diff --git a/CrmCodeGenerator.VSPackage/Properties/AssemblyInfo.cs b/CrmCodeGenerator.VSPackage/Properties/AssemblyInfo.cs index ea880f1..0127eb5 100644 --- a/CrmCodeGenerator.VSPackage/Properties/AssemblyInfo.cs +++ b/CrmCodeGenerator.VSPackage/Properties/AssemblyInfo.cs @@ -33,5 +33,5 @@ [assembly: AssemblyVersion("1.0.0.0")] [assembly: AssemblyFileVersion("1.0.0.0")] -[assembly: ProvideBindingRedirection(AssemblyName = "Microsoft.Xrm.Sdk", NewVersion = "8.0.0.0", OldVersionLowerBound = "1.0.0.0", OldVersionUpperBound = "7.0.0.0")] +[assembly: ProvideBindingRedirection(AssemblyName = "Microsoft.Xrm.Sdk", NewVersion = "9.0.0.0", OldVersionLowerBound = "1.0.0.0", OldVersionUpperBound = "7.0.0.0")] diff --git a/CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator.vsix b/CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator.vsix index 521f364..2f58dc3 100644 Binary files a/CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator.vsix and b/CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator.vsix differ diff --git a/CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator_1.0.4.0.vsix b/CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator_1.0.4.0.vsix deleted file mode 100644 index 5f6e66f..0000000 Binary files a/CrmCodeGenerator.VSPackage/bin/Debug/CrmCodeGenerator_1.0.4.0.vsix and /dev/null differ diff --git a/CrmCodeGenerator.VSPackage/source.extension.vsixmanifest b/CrmCodeGenerator.VSPackage/source.extension.vsixmanifest index b18bb52..cb8e07e 100644 --- a/CrmCodeGenerator.VSPackage/source.extension.vsixmanifest +++ b/CrmCodeGenerator.VSPackage/source.extension.vsixmanifest @@ -1,9 +1,9 @@  - + CrmCodeGenerator.VSPackage - Allows you to generate CRM 2011/2013/2015/ schema files. Much like CrmSrvUtil.exe but with a lot more features; select entities (smaller code/assembly), runs in VisualStudio, T4 templates for control of how code is generated (also allows other languages), Template is saved to project, connection info save to SUO & so that you can modify it as needed. + Allows you to generate CRM 2011/2013/2015/2016/ schema files. Much like CrmSrvUtil.exe but with a lot more features; select entities (smaller code/assembly), runs in VisualStudio, T4 templates for control of how code is generated (also allows other languages), Template is saved to project, connection info save to SUO & so that you can modify it as needed. https://crmcodegenerator.codeplex.com/ license.txt diff --git a/lib/microsoft.crm.sdk.proxy.dll b/lib/microsoft.crm.sdk.proxy.dll index e76ef26..2f32439 100644 Binary files a/lib/microsoft.crm.sdk.proxy.dll and b/lib/microsoft.crm.sdk.proxy.dll differ diff --git a/lib/microsoft.xrm.sdk.dll b/lib/microsoft.xrm.sdk.dll index 71c9e9d..f2953bf 100644 Binary files a/lib/microsoft.xrm.sdk.dll and b/lib/microsoft.xrm.sdk.dll differ