private StringAttributeMetadata BuildAttribute()
        {
            AttributeRequiredLevel requiredLevel = AttributeRequiredLevel.ApplicationRequired;

            if (AttributeRequired == CrmRequiredLevel.Required)
            {
                requiredLevel = AttributeRequiredLevel.ApplicationRequired;
            }
            if (AttributeRequired == CrmRequiredLevel.Recommended)
            {
                requiredLevel = AttributeRequiredLevel.Recommended;
            }
            if (AttributeRequired == CrmRequiredLevel.Optional)
            {
                requiredLevel = AttributeRequiredLevel.None;
            }

            StringAttributeMetadata attribute = new StringAttributeMetadata();

            if (!IsActivity)
            {
                attribute.SchemaName    = AttributeName;
                attribute.RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel);
                attribute.MaxLength     = AttributeLength ?? 100;
                attribute.DisplayName   = new Label(AttributeDisplayName, CrmContext.Language);
                attribute.Description   = new Label(AttributeDescription ?? string.Empty, CrmContext.Language);
                attribute.Format        = StringFormat.Text;
            }
            else
            {
                attribute.SchemaName = "Subject";
                attribute.MaxLength  = 100;
            }
            return(attribute);
        }
Example #2
0
        /// <summary>
        /// 创建Two Options字段
        /// </summary>
        public OrganizationResponse CreateTwoOptionsField(
            string entityName,
            string schemName,
            string displayName,
            string decription,
            IDictionary <string, int> options,
            AttributeRequiredLevel requiredLevel)
        {
            if (options.Count != 2)
            {
                throw new ArgumentException("The options argument should have two options");
            }
            OptionMetadataCollection collection = GetOptionMetadataCollection(options);
            var request = new CreateAttributeRequest
            {
                EntityName = entityName,
                Attribute  = new BooleanAttributeMetadata()
                {
                    SchemaName    = schemName,
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                    DisplayName   = new Label(displayName, 1033),
                    Description   = new Label(decription, 1033),
                    OptionSet     = new BooleanOptionSetMetadata(
                        collection[0],  // true option
                        collection[1]   // false option
                        )
                }
            };

            return(Service.Execute(request));
        }
Example #3
0
        /// <summary>
        /// 创建OptionSet字段
        /// </summary>
        public OrganizationResponse CreateOptionSetField(
            string entityName,
            string schemName,
            string displayName,
            string decription,
            IDictionary <string, int> options,
            bool isGlobal,
            AttributeRequiredLevel requiredLevel)
        {
            OptionMetadataCollection collection = GetOptionMetadataCollection(options);

            var request = new CreateAttributeRequest
            {
                EntityName = entityName,
                Attribute  = new PicklistAttributeMetadata()
                {
                    SchemaName    = schemName,
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                    DisplayName   = new Label(displayName, 1033),
                    Description   = new Label(decription, 1033),
                    OptionSet     = new OptionSetMetadata(collection)
                    {
                        IsGlobal = isGlobal
                    }
                }
            };

            return(Service.Execute(request));
        }
        private AttributeMetadata generalFieldCreation(string[] row, AttributeMetadata attrMetadata)
        {
            AttributeRequiredLevel attributeRequiredLevel = AttributeRequiredLevel.None;

            String reqLevelstring = row[ExcelColumsDefinition.REQUIREDLEVELEXCELCOL];

            if (Enum.IsDefined(typeof(AttributeRequiredLevel), reqLevelstring))
            {
                attributeRequiredLevel = (AttributeRequiredLevel)Enum.Parse(typeof(AttributeRequiredLevel), reqLevelstring, true);
            }
            else
            {
                attributeRequiredLevel = AttributeRequiredLevel.None;
            }
            bool parseresult;

            attrMetadata.SchemaName             = Utils.addOrgPrefix(row[ExcelColumsDefinition.SCHEMANAMEEXCELCOL], organizationPrefix, currentOperationCreate);
            attrMetadata.DisplayName            = new Microsoft.Xrm.Sdk.Label(row[ExcelColumsDefinition.DISPLAYNAMEEXCELCOL], languageCode);
            attrMetadata.Description            = new Microsoft.Xrm.Sdk.Label(row[ExcelColumsDefinition.DESCRIPTIONEXCELCOL], languageCode);
            attrMetadata.RequiredLevel          = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel);
            attrMetadata.IsValidForAdvancedFind = Boolean.TryParse(row[ExcelColumsDefinition.ADVANCEDFINF], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(true);
            attrMetadata.IsSecured      = Boolean.TryParse(row[ExcelColumsDefinition.SECURED], out parseresult) ? parseresult : true;
            attrMetadata.IsAuditEnabled = Boolean.TryParse(row[ExcelColumsDefinition.AUDITENABLED], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(false);
            return(attrMetadata);
        }
Example #5
0
        /// <summary>
        /// 创建Floating Point Number字段
        /// </summary>
        public OrganizationResponse CreateFloatingPointNumberField(
            string entityName,
            string schemName,
            string displayName,
            string decription,
            double?minValue,
            double?maxValue,
            AttributeRequiredLevel requiredLevel)
        {
            var request = new CreateAttributeRequest
            {
                EntityName = entityName,
                Attribute  = new DoubleAttributeMetadata()
                {
                    SchemaName    = schemName,
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                    DisplayName   = new Label(displayName, 1033),
                    Description   = new Label(decription, 1033),
                    MinValue      = minValue,
                    MaxValue      = maxValue
                }
            };

            return(Service.Execute(request));
        }
Example #6
0
        private object GetRequiredLevelString(AttributeRequiredLevel value)
        {
            switch (value)
            {
            case AttributeRequiredLevel.None: return("Optional");

            case AttributeRequiredLevel.Recommended: return("Business required");

            case AttributeRequiredLevel.SystemRequired: return("System required");

            default: return("Application required");
            }
        }
Example #7
0
        private string GetRequiredLevel(AttributeRequiredLevel value)
        {
            switch (value)
            {
            case AttributeRequiredLevel.ApplicationRequired: return("Required");

            case AttributeRequiredLevel.SystemRequired: return("Required");

            case AttributeRequiredLevel.Recommended: return("Recommended");

            case AttributeRequiredLevel.None: return("Optional");
            }
            return(null);
        }
        private void addCreateRequest(string[] row, List <CrmOperation> crmop)
        {
            bool   parseresult;
            String reqLevelstring = row[ExcelColumsDefinition.ENTITYPRIMARYATTRIBUTEREQUIREMENTLEVEL];
            AttributeRequiredLevel attributeRequiredLevel = AttributeRequiredLevel.None;

            if (Enum.IsDefined(typeof(AttributeRequiredLevel), reqLevelstring))
            {
                attributeRequiredLevel = (AttributeRequiredLevel)Enum.Parse(typeof(AttributeRequiredLevel), reqLevelstring, true);
            }
            CreateEntityRequest createrequest = new CreateEntityRequest
            {
                Entity = new EntityMetadata
                {
                    SchemaName                  = Utils.addOrgPrefix(row[ExcelColumsDefinition.ENTITYSCHEMANAMEEXCELCOL], entitySheet.orgPrefix, true),
                    DisplayName                 = new Label(row[ExcelColumsDefinition.ENTITYDISPLAYNAMEEXCELCOL], languageCode),
                    DisplayCollectionName       = new Label(row[ExcelColumsDefinition.ENTITYPLURALNAME], languageCode),
                    Description                 = new Label(row[ExcelColumsDefinition.ENTITYDESCRIPTIONEXCELCOL], languageCode),
                    OwnershipType               = Enum.IsDefined(typeof(OwnershipTypes), row[ExcelColumsDefinition.ENTITYOWNERSHIP]) ? (OwnershipTypes)Enum.Parse(typeof(OwnershipTypes), row[ExcelColumsDefinition.ENTITYOWNERSHIP], true) : OwnershipTypes.UserOwned,
                    IsActivity                  = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYDEFINEACTIVITY], out parseresult) ? parseresult : false,
                    IsConnectionsEnabled        = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYCONNECTION], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(true),
                    IsActivityParty             = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYSENDMAIL], out parseresult) ? parseresult : false,
                    IsMailMergeEnabled          = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYMAILMERGE], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(true),
                    IsDocumentManagementEnabled = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYDOCUMENTMANAGEMENT], out parseresult) ? parseresult : false,
                    IsValidForQueue             = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYQUEUES], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(false),
                    AutoRouteToOwnerQueue       = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYMOVEOWNERDEFAULTQUEUE], out parseresult) ? parseresult : false,
                    IsDuplicateDetectionEnabled = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYDUPLICATEDETECTION], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(true),
                    IsAuditEnabled              = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYAUDITING], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(false),
                    IsVisibleInMobile           = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYMOBILEEXPRESS], out parseresult) ? new BooleanManagedProperty(parseresult) : new BooleanManagedProperty(false),
                    IsAvailableOffline          = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYOFFLINEOUTLOOK], out parseresult) ? parseresult : false,
                },
                HasNotes      = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYNOTE], out parseresult) ? parseresult : true,
                HasActivities = Boolean.TryParse(row[ExcelColumsDefinition.ENTITYACTIVITIES], out parseresult) ? parseresult : true,

                PrimaryAttribute = new StringAttributeMetadata
                {
                    SchemaName    = row[ExcelColumsDefinition.ENTITYPRIMARYATTRIBUTEDISPLAYNAME] != string.Empty ? row[ExcelColumsDefinition.ENTITYPRIMARYATTRIBUTENAME] : Utils.addOrgPrefix("name", entitySheet.orgPrefix, true),
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel),
                    MaxLength     = 100,
                    Format        = StringFormat.Text,
                    DisplayName   = row[ExcelColumsDefinition.ENTITYPRIMARYATTRIBUTEDISPLAYNAME] != string.Empty ? new Label(row[ExcelColumsDefinition.ENTITYPRIMARYATTRIBUTEDISPLAYNAME], languageCode) : new Label("Name", languageCode),
                    Description   = new Label(row[ExcelColumsDefinition.ENTITYPRIMARYATTRIBUTEDESCRIPTION], languageCode)
                }
            };
            string strPreview = string.Format("Create new Enity : {0}", createrequest.Entity.SchemaName);

            crmop.Add(new CrmOperation(CrmOperation.CrmOperationType.create, CrmOperation.CrmOperationTarget.entity, createrequest, strPreview));
        }
 public EntityAttributeMetadataBuilder StringAttribute(string schemaName, string displayName, string description,
                                                        AttributeRequiredLevel requiredLevel,
                                                        int maxLength, StringFormat format)
 {
     // Define the primary attribute for the entity
     var newAtt = new StringAttributeMetadata
     {
         SchemaName = schemaName,
         RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
         MaxLength = maxLength,
         Format = format,
         DisplayName = new Label(displayName, 1033),
         Description = new Label(description, 1033)
     };
     this.Attributes.Add(newAtt);
     return this;
 }
Example #10
0
        public EntityAttributeMetadataBuilder StringAttribute(string schemaName, string displayName, string description,
                                                              AttributeRequiredLevel requiredLevel,
                                                              int maxLength, StringFormat format)
        {
            // Define the primary attribute for the entity
            var newAtt = new StringAttributeMetadata
            {
                SchemaName    = schemaName,
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                MaxLength     = maxLength,
                Format        = format,
                DisplayName   = new Label(displayName, 1033),
                Description   = new Label(description, 1033)
            };

            this.Attributes.Add(newAtt);
            return(this);
        }
Example #11
0
        private void AddOneToMany()
        {
            OneToManyRelationshipMetadata relationship = new OneToManyRelationshipMetadata
            {
                ReferencedEntity  = ToEntity,
                ReferencingEntity = Entity,
                SchemaName        = Name
            };

            if (_context != null)
            {
                _context.SetParametersOnRelationship(relationship);
            }

            LookupAttributeMetadata lookup = new LookupAttributeMetadata
            {
                SchemaName  = AttributeName,
                DisplayName = new Label(AttributeDisplayName, CrmContext.Language),
                Description = new Label(AttributeDescription ?? string.Empty, CrmContext.Language)
            };
            AttributeRequiredLevel requiredLevel = AttributeRequiredLevel.ApplicationRequired;

            if (AttributeRequired == CrmRequiredLevel.Required)
            {
                requiredLevel = AttributeRequiredLevel.ApplicationRequired;
            }
            if (AttributeRequired == CrmRequiredLevel.Recommended)
            {
                requiredLevel = AttributeRequiredLevel.Recommended;
            }
            if (AttributeRequired == CrmRequiredLevel.Optional)
            {
                requiredLevel = AttributeRequiredLevel.None;
            }
            lookup.RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel);

            Guid result = _repository.AddRelationship(relationship, lookup);

            if (PassThru)
            {
                WriteObject(_repository.GetRelationship(result));
            }
        }
 public EntityAttributeMetadataBuilder DateTimeAttribute(string schemaName, string displayName, string description,
                                                          AttributeRequiredLevel requiredLevel,
                                                          DateTimeFormat format, ImeMode imeMode)
 {
     int languageCode = 1033;
     // Create a date time attribute
     var dtAttribute = new DateTimeAttributeMetadata
     {
         // Set base properties
         SchemaName = schemaName,
         DisplayName = new Label(displayName, languageCode),
         RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
         Description = new Label(description, languageCode),
         // Set extended properties
         Format = format,
         ImeMode = imeMode
     };
     this.Attributes.Add(dtAttribute);
     return this;
 }
Example #13
0
        public EntityAttributeMetadataBuilder DateTimeAttribute(string schemaName, string displayName, string description,
                                                                AttributeRequiredLevel requiredLevel,
                                                                DateTimeFormat format, ImeMode imeMode)
        {
            int languageCode = 1033;
            // Create a date time attribute
            var dtAttribute = new DateTimeAttributeMetadata
            {
                // Set base properties
                SchemaName    = schemaName,
                DisplayName   = new Label(displayName, languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                Description   = new Label(description, languageCode),
                // Set extended properties
                Format  = format,
                ImeMode = imeMode
            };

            this.Attributes.Add(dtAttribute);
            return(this);
        }
Example #14
0
        /// <summary>
        /// 创建Lookup字段
        /// </summary>
        public OrganizationResponse CreateLookupField(
            string entityName,
            string schemName,
            string displayName,
            string decription,
            string referencedEntityName,
            string referencedAttributeName,
            string relationshipSchemName,
            AttributeRequiredLevel requiredLevel)
        {
            CreateOneToManyRequest request = new CreateOneToManyRequest()
            {
                Lookup = new LookupAttributeMetadata()
                {
                    Description   = new Label(decription, 1033),
                    DisplayName   = new Label(displayName, 1033),
                    SchemaName    = schemName,
                    RequiredLevel =
                        new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.ApplicationRequired)
                },
                OneToManyRelationship = new OneToManyRelationshipMetadata()
                {
                    CascadeConfiguration = new CascadeConfiguration()
                    {
                        Assign   = CascadeType.Cascade,
                        Delete   = CascadeType.Cascade,
                        Merge    = CascadeType.Cascade,
                        Reparent = CascadeType.Cascade,
                        Share    = CascadeType.Cascade,
                        Unshare  = CascadeType.Cascade
                    },
                    ReferencedEntity    = referencedEntityName,
                    ReferencedAttribute = referencedAttributeName,
                    ReferencingEntity   = entityName,
                    SchemaName          = relationshipSchemName
                }
            };

            return(Service.Execute(request));
        }
 public EntityAttributeMetadataBuilder BooleanAttribute(string schemaName,
                                                          AttributeRequiredLevel requiredLevel,
                                                          int maxLength, StringFormat format,
                                                          string displayName, string description)
 {
     int languageCode = 1033;
     // Create a boolean attribute
     var boolAttribute = new BooleanAttributeMetadata
     {
         // Set base properties
         SchemaName = schemaName,
         DisplayName = new Label(displayName, languageCode),
         RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
         Description = new Label(description, languageCode),
         // Set extended properties
         OptionSet = new BooleanOptionSetMetadata(
             new OptionMetadata(new Label("True", languageCode), 1),
             new OptionMetadata(new Label("False", languageCode), 0)
             )
     };
     this.Attributes.Add(boolAttribute);
     return this;
 }
Example #16
0
        /// <summary>
        /// 创建Decimal字段
        /// </summary>
        public OrganizationResponse CreateDecimalField(
            string entityName,
            string schemName,
            string displayName,
            string decription,
            int?precision,
            AttributeRequiredLevel requiredLevel)
        {
            var request = new CreateAttributeRequest
            {
                EntityName = entityName,
                Attribute  = new DecimalAttributeMetadata()
                {
                    SchemaName    = schemName,
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                    DisplayName   = new Label(displayName, 1033),
                    Description   = new Label(decription, 1033),
                    Precision     = precision
                }
            };

            return(Service.Execute(request));
        }
Example #17
0
        /// <summary>
        /// 创建DateTime字段
        /// </summary>
        public OrganizationResponse CreateDateTimeField(
            string entityName,
            string schemName,
            string displayName,
            string decription,
            AttributeRequiredLevel requiredLevel)
        {
            var request = new CreateAttributeRequest
            {
                EntityName = entityName,
                Attribute  = new DateTimeAttributeMetadata()
                {
                    SchemaName    = schemName,
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                    DisplayName   = new Label(displayName, 1033),
                    Description   = new Label(decription, 1033),
                    // Set extended properties
                    Format  = DateTimeFormat.DateOnly,
                    ImeMode = ImeMode.Disabled
                }
            };

            return(Service.Execute(request));
        }
Example #18
0
        public EntityAttributeMetadataBuilder BooleanAttribute(string schemaName,
                                                               AttributeRequiredLevel requiredLevel,
                                                               int maxLength, StringFormat format,
                                                               string displayName, string description)
        {
            int languageCode = 1033;
            // Create a boolean attribute
            var boolAttribute = new BooleanAttributeMetadata
            {
                // Set base properties
                SchemaName    = schemaName,
                DisplayName   = new Label(displayName, languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                Description   = new Label(description, languageCode),
                // Set extended properties
                OptionSet = new BooleanOptionSetMetadata(
                    new OptionMetadata(new Label("True", languageCode), 1),
                    new OptionMetadata(new Label("False", languageCode), 0)
                    )
            };

            this.Attributes.Add(boolAttribute);
            return(this);
        }
Example #19
0
        /// <summary>
        /// 创建Multiple Lines of Text字段
        /// </summary>
        public OrganizationResponse CreateMultipleLinesOfTextField(
            string entityName,
            string schemName,
            string displayName,
            string decription,
            int maxLength,
            AttributeRequiredLevel requiredLevel)
        {
            var request = new CreateAttributeRequest
            {
                EntityName = entityName,
                Attribute  = new MemoAttributeMetadata()
                {
                    SchemaName    = schemName,
                    RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                    MaxLength     = maxLength,
                    Format        = StringFormat.Text,
                    DisplayName   = new Label(displayName, 1033),
                    Description   = new Label(decription, 1033)
                }
            };

            return(Service.Execute(request));
        }
        public void CreateCRMAttribute(DataRow record)
        {
            string result = string.Empty;

            try
            {
                #region # Read From Datatable #
                AttributeMetadata createMetadata = new AttributeMetadata();
                bool isGlobal = false;
                AttributeRequiredLevel requirementLevel = AttributeRequiredLevel.None;
                string reqLevelText      = "";
                int    precisionSource   = 0;
                int    currencyPrecision = 2;
                if (record["RequiredLevel"] != null && !string.IsNullOrEmpty(Convert.ToString(record["RequiredLevel"])))
                {
                    reqLevelText     = Convert.ToString(record["RequiredLevel"]).ToLower();
                    requirementLevel = reqLevelText == "required" ? AttributeRequiredLevel.ApplicationRequired : AttributeRequiredLevel.Recommended;
                }
                reqLevelText = record["Attribute Type"].ToString().ToLower();
                string attributeSchemaName  = record["Attribute Schema Name"].ToString().ToLower();
                string optionSetValues      = record["Option Set Values"].ToString().ToLower();
                string attributeDisplayName = record["Attribute Display Name"].ToString().ToLower();
                string attributeDiscription = record["Description"].ToString().ToLower();
                bool   boolDefaultValue     = record["Default  Value"].ToString().ToLower() == "yes"?true:false;

                Microsoft.Xrm.Sdk.Metadata.StringFormat stringFormat = GetStringFormat(record["String Format"].ToString().ToLower());
                int stringLength = record["String Length"] != null && !string.IsNullOrEmpty(Convert.ToString(record["String Length"])) && Convert.ToInt32(record["String Length"].ToString()) <= 4000? Convert.ToInt32(record["String Length"].ToString()) : 4000;

                Microsoft.Xrm.Sdk.Metadata.DateTimeFormat dateFormat   = record["Date Type Format"] != null && !string.IsNullOrEmpty(record["Date Type Format"].ToString()) ? GetDateFormat(record["Date Type Format"].ToString().ToLower()):DateTimeFormat.DateAndTime;
                Microsoft.Xrm.Sdk.Metadata.IntegerFormat  integerFormt = record["Integer Format"] != null && !string.IsNullOrEmpty(record["Integer Format"].ToString()) ? GetIntegerFormat(record["Integer Format"].ToString().ToLower()) : IntegerFormat.None;

                Double intMinValue = record["Integer Minimum Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Integer Minimum Value"])) && Convert.ToDouble(record["Integer Minimum Value"].ToString()) <= 2147483647 && Convert.ToDouble(record["Integer Minimum Value"].ToString()) >= -2147483647 ? Convert.ToDouble(record["Integer Minimum Value"].ToString()) : -2147483648;
                Double intMaxValue = record["Integer Maximum Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Integer Maximum Value"])) && Convert.ToDouble(record["Integer Maximum Value"].ToString()) <= 2147483647 && Convert.ToDouble(record["Integer Maximum Value"].ToString()) >= -2147483647 ? Convert.ToDouble(record["Integer Maximum Value"].ToString()) : 2147483647;

                int    floatingPrecision = record["Floating Number Precision"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Floating Number Precision"])) ? Convert.ToInt32(record["Floating Number Precision"].ToString()) : 2;
                Double floatMinValue     = record["Float Min Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Float Min Value"])) && Convert.ToDouble(record["Float Min Value"].ToString()) >= 0 && Convert.ToDouble(record["Float Min Value"].ToString()) <= 1000000000 ? Convert.ToDouble(record["Float Min Value"].ToString()) : 0;
                Double floatMaxValue     = record["Float Max Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Float Max Value"])) && Convert.ToDouble(record["Float Max Value"].ToString()) >= 0 && Convert.ToDouble(record["Float Max Value"].ToString()) <= 1000000000 ? Convert.ToDouble(record["Float Max Value"].ToString()) : 1000000000;

                int     decimalPrecision = record["Decimal Precision"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Decimal Precision"])) ? Convert.ToInt32(record["Decimal Precision"].ToString()) : 2;
                Decimal decimalMinValue  = record["Decimal Min Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Decimal Min Value"])) && Convert.ToDecimal(record["Decimal Min Value"].ToString()) >= -100000000000 && Convert.ToDecimal(record["Decimal Min Value"].ToString()) <= 100000000000 ? Convert.ToDecimal(record["Decimal Min Value"].ToString()) : -100000000000;
                Decimal decimalMaxValue  = record["Decimsl Max Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Decimsl Max Value"])) && Convert.ToDecimal(record["Decimsl Max Value"].ToString()) >= -100000000000 && Convert.ToDecimal(record["Decimsl Max Value"].ToString()) <= 100000000000 ? Convert.ToDecimal(record["Decimsl Max Value"].ToString()) : 100000000000;

                Double currencyMinValue = record["Currency Min Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Currency Min Value"])) && Convert.ToDouble(record["Currency Min Value"].ToString()) >= -922337203685477 && Convert.ToDouble(record["Currency Min Value"].ToString()) <= 922337203685477 ? Convert.ToDouble(record["Currency Min Value"].ToString()) : -922337203685477;
                Double currencyMaxValue = record["Currency Max Value"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Currency Max Value"])) && Convert.ToDouble(record["Currency Max Value"].ToString()) >= -922337203685477 && Convert.ToDouble(record["Currency Max Value"].ToString()) <= 922337203685477 ? Convert.ToDouble(record["Currency Max Value"].ToString()) : 922337203685477;

                Microsoft.Xrm.Sdk.Metadata.ImeMode imeMode = GetIMEMode(record["IME Mode"].ToString().ToLower());

                if (record["Currency precision"] != null && !string.IsNullOrEmpty(Convert.ToString(record["Currency precision"]).ToLower()))
                {
                    switch (Convert.ToString(record["Currency precision"]).ToLower().Trim())
                    {
                    case "pricing decimal precision":
                        precisionSource = 1;
                        break;

                    case "currency precision":
                        precisionSource = 2;
                        break;

                    default:
                        currencyPrecision = Convert.ToInt32(Convert.ToString(record["Currency precision"]));
                        break;
                    }
                }

                bool isAuditEnabled       = record["AuditEnable"] != null && record["AuditEnable"].ToString().ToLower() == "yes" ? true : false;
                bool isValidForAdvancFind = record["IsValidForAdvancedFind"] != null && record["IsValidForAdvancedFind"].ToString().ToLower() == "yes" ? true : false;
                #endregion # Read From Datatable #

                switch (reqLevelText.ToLower().Trim())
                {
                case "boolean":
                    // Create a boolean attribute
                    createMetadata = new BooleanAttributeMetadata
                    {
                        SchemaName    = attributeSchemaName,
                        DisplayName   = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description   = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        // Set extended properties
                        OptionSet = new BooleanOptionSetMetadata(
                            new OptionMetadata(new Microsoft.Xrm.Sdk.Label("Yes", _languageCode), 1),
                            new OptionMetadata(new Microsoft.Xrm.Sdk.Label("No", _languageCode), 0)
                            ),
                        DefaultValue           = boolDefaultValue,
                        IsAuditEnabled         = new BooleanManagedProperty(isAuditEnabled),
                        IsValidForAdvancedFind = new BooleanManagedProperty(isValidForAdvancFind),
                    };
                    break;

                case "date and time":
                    createMetadata = new DateTimeAttributeMetadata
                    {
                        // Set base properties
                        SchemaName    = attributeSchemaName,
                        DisplayName   = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description   = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        // Set extended properties
                        Format                 = dateFormat,
                        ImeMode                = imeMode,
                        IsAuditEnabled         = new BooleanManagedProperty(isAuditEnabled),
                        IsValidForAdvancedFind = new BooleanManagedProperty(isValidForAdvancFind),
                    };
                    break;

                case "multiple line of text":
                    createMetadata = new MemoAttributeMetadata
                    {
                        // Set base properties
                        SchemaName    = attributeSchemaName,
                        DisplayName   = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description   = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        // Set extended properties
                        ImeMode                = imeMode,
                        IsAuditEnabled         = new BooleanManagedProperty(isAuditEnabled),
                        IsValidForAdvancedFind = new BooleanManagedProperty(isValidForAdvancFind),
                        MaxLength              = stringLength
                    };
                    break;

                case "whole number":
                    createMetadata = new IntegerAttributeMetadata
                    {
                        // Set base properties
                        SchemaName    = attributeSchemaName,
                        DisplayName   = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description   = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        // Set extended properties
                        // ImeMode = imeMode,// in crm 2016 ths feature is there
                        // Set extended properties
                        Format                 = IntegerFormat.None,
                        MaxValue               = Convert.ToInt32(intMaxValue),
                        MinValue               = Convert.ToInt32(intMinValue),
                        IsAuditEnabled         = new BooleanManagedProperty(isAuditEnabled),
                        IsValidForAdvancedFind = new BooleanManagedProperty(isValidForAdvancFind)
                    };
                    break;

                case "floating point number":
                    createMetadata = new DoubleAttributeMetadata
                    {
                        SchemaName             = attributeSchemaName,
                        DisplayName            = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel          = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description            = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        MaxValue               = floatMaxValue,
                        MinValue               = floatMinValue,
                        Precision              = floatingPrecision,
                        IsAuditEnabled         = new BooleanManagedProperty(isAuditEnabled),
                        IsValidForAdvancedFind = new BooleanManagedProperty(isValidForAdvancFind),
                        ImeMode = imeMode
                    };
                    break;

                case "decimal number":
                    createMetadata = new DecimalAttributeMetadata
                    {
                        SchemaName             = attributeSchemaName,
                        DisplayName            = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel          = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description            = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        MaxValue               = decimalMaxValue,
                        MinValue               = decimalMinValue,
                        Precision              = decimalPrecision,
                        IsAuditEnabled         = new BooleanManagedProperty(isAuditEnabled),
                        IsValidForAdvancedFind = new BooleanManagedProperty(isValidForAdvancFind),
                        ImeMode = imeMode
                    };
                    break;

                case "currency":
                    createMetadata = new MoneyAttributeMetadata
                    {
                        SchemaName      = attributeSchemaName,
                        DisplayName     = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel   = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description     = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        MaxValue        = currencyMaxValue,
                        MinValue        = currencyMinValue,
                        Precision       = currencyPrecision,
                        PrecisionSource = precisionSource,
                        ImeMode         = imeMode
                    };
                    break;

                case "option set":

                    OptionMetadataCollection optionMetadataCollection = GetOptionMetadata(optionSetValues);
                    OptionSetMetadata        Optionmedata             = new OptionSetMetadata();
                    if (optionMetadataCollection != null && optionMetadataCollection.Count() > 0)
                    {
                        Optionmedata.Options.AddRange(optionMetadataCollection);
                    }
                    Optionmedata.IsGlobal      = isGlobal;
                    Optionmedata.OptionSetType = OptionSetType.Picklist;

                    createMetadata = new PicklistAttributeMetadata
                    {
                        SchemaName    = attributeSchemaName,
                        DisplayName   = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description   = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        OptionSet     = Optionmedata
                    };
                    break;

                case "single line of text":
                    createMetadata = new StringAttributeMetadata
                    {
                        SchemaName    = attributeSchemaName,
                        DisplayName   = new Microsoft.Xrm.Sdk.Label(attributeDisplayName, _languageCode),
                        RequiredLevel = new AttributeRequiredLevelManagedProperty(requirementLevel),
                        Description   = new Microsoft.Xrm.Sdk.Label(attributeDiscription, _languageCode),
                        // Set extended properties
                        ImeMode                = imeMode,
                        IsAuditEnabled         = new BooleanManagedProperty(isAuditEnabled),
                        IsValidForAdvancedFind = new BooleanManagedProperty(isValidForAdvancFind),
                        MaxLength              = stringLength
                    };
                    break;
                }
                CreateAttributeRequest request = new CreateAttributeRequest
                {
                    Attribute  = createMetadata,
                    EntityName = ApplicationSetting.SelectedEntity.LogicalName
                };
                try
                {
                    Service.Execute(request);
                    result = "Success";
                }
                catch (FaultException <Microsoft.Xrm.Sdk.OrganizationServiceFault> ex)
                {
                    result = ex.Message;
                }
                catch (Exception ex)
                {
                    result = ex.Message;
                }
            }
            catch (Exception ex)
            {
                result = ex.Message;
            }
        }
Example #21
0
        private static PicklistAttributeMetadata CreateGlobalPickListAttribute(string globalOptionSetName, string name, string displayName, AttributeRequiredLevel attributeRequiredLevel, string desription)
        {
            PicklistAttributeMetadata pickListAttribute = new PicklistAttributeMetadata
            {
                // Set base properties
                SchemaName    = publisherPrefix + name,
                LogicalName   = publisherPrefix + name,
                DisplayName   = new Label(displayName, _languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel),
                Description   = new Label(desription, _languageCode),
                // Set extended properties
                // In order to relate the picklist to the global option set, be sure
                // to specify the two attributes below appropriately.
                // Failing to do so will lead to errors.
                OptionSet = new OptionSetMetadata
                {
                    IsGlobal = true,
                    Name     = publisherPrefix + globalOptionSetName
                }
            };

            return(pickListAttribute);
        }
Example #22
0
        public EntityAttributeMetadataBuilder BooleanAttribute(string schemaName, string displayName, string description, AttributeRequiredLevel requiredLevel, string trueLabel, int trueValue, string falseLabel, int falseValue)
        {
            int languageCode = 1033;
            // Create a boolean attribute
            var boolAttribute = new BooleanAttributeMetadata
            {
                // Set base properties
                SchemaName    = schemaName,
                DisplayName   = new Label(displayName, languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                Description   = new Label(description, languageCode),
                // Set extended properties
                OptionSet = new BooleanOptionSetMetadata(
                    new OptionMetadata(new Label(trueLabel, languageCode), trueValue),
                    new OptionMetadata(new Label(falseLabel, languageCode), falseValue)
                    )
            };

            this.Attributes.Add(boolAttribute);
            return(this);
        }
Example #23
0
        public EntityAttributeMetadataBuilder PicklistAttribute(string schemaName, string displayName, string description, AttributeRequiredLevel requiredLevel, bool isGlobal, OptionSetType optionSetType, Dictionary <string, int> optionValues)
        {
            // Define the primary attribute for the entity
            // Create a integer attribute
            int languageCode = 1033;
            var att          = new PicklistAttributeMetadata()
            {
                // Set base properties
                SchemaName    = schemaName,
                DisplayName   = new Label(schemaName, languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                Description   = new Label(description, languageCode),
                // Set extended properties
                OptionSet = new OptionSetMetadata
                {
                    IsGlobal      = isGlobal,
                    OptionSetType = optionSetType
                }
            };

            foreach (var optionValue in optionValues)
            {
                att.OptionSet.Options.Add(new OptionMetadata(new Label(optionValue.Key, languageCode), optionValue.Value));
            }

            this.Attributes.Add(att);
            return(this);
        }
Example #24
0
        public EntityAttributeMetadataBuilder BigIntAttribute(string schemaName, string displayName, string description, AttributeRequiredLevel requiredLevel)
        {
            // Define the primary attribute for the entity
            var newAtt = new BigIntAttributeMetadata()
            {
                SchemaName    = schemaName,
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                DisplayName   = new Label(displayName, 1033),
                Description   = new Label(description, 1033)
            };

            this.Attributes.Add(newAtt);
            return(this);
        }
Example #25
0
        protected void WriteAttribute(AttributeMetadata attribute)
        {
            attribute.LogicalName = Name;
            attribute.DisplayName = new Label(DisplayName, CrmContext.Language);
            attribute.Description = new Label(Description ?? string.Empty, CrmContext.Language);

            AttributeRequiredLevel requiredLevel = AttributeRequiredLevel.ApplicationRequired;

            if (Required == CrmRequiredLevel.Required)
            {
                requiredLevel = AttributeRequiredLevel.ApplicationRequired;
            }
            if (Required == CrmRequiredLevel.Recommended)
            {
                requiredLevel = AttributeRequiredLevel.Recommended;
            }
            if (Required == CrmRequiredLevel.Optional)
            {
                requiredLevel = AttributeRequiredLevel.None;
            }
            attribute.RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel);

            if (CanModifyAdditionalSettings.HasValue)
            {
                attribute.CanModifyAdditionalSettings = new BooleanManagedProperty(CanModifyAdditionalSettings.Value);
            }
            if (IsAuditEnabled.HasValue)
            {
                attribute.IsAuditEnabled = new BooleanManagedProperty(IsAuditEnabled.Value);
            }
            if (IsCustomizable.HasValue)
            {
                attribute.IsCustomizable = new BooleanManagedProperty(IsCustomizable.Value);
            }
            if (IsRenameable.HasValue)
            {
                attribute.IsRenameable = new BooleanManagedProperty(IsRenameable.Value);
            }
            if (IsSecured.HasValue)
            {
                attribute.IsSecured = IsSecured.Value;
            }
            if (IsValidForAdvancedFind.HasValue)
            {
                attribute.IsValidForAdvancedFind = new BooleanManagedProperty(IsValidForAdvancedFind.Value);
            }
            if (!string.IsNullOrWhiteSpace(SchemaName))
            {
                attribute.SchemaName = SchemaName;
            }
            else
            {
                attribute.SchemaName = Name;
            }

            if (_context != null)
            {
                _context.SetParametersOnAttribute(attribute);
            }

            Guid id = _repository.AddAttribute(Entity, attribute);

            if (PassThru)
            {
                WriteObject(_repository.GetAttribute(id));
            }
        }
Example #26
0
        public EntityAttributeMetadataBuilder IntAttribute(string schemaName, string displayName, string description, AttributeRequiredLevel requiredLevel, IntegerFormat format, int min, int max)
        {
            // Define the primary attribute for the entity
            // Create a integer attribute
            int languageCode     = 1033;
            var integerAttribute = new IntegerAttributeMetadata
            {
                // Set base properties
                SchemaName    = schemaName,
                DisplayName   = new Label(schemaName, languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                Description   = new Label(description, languageCode),
                // Set extended properties
                Format   = format,
                MaxValue = max,
                MinValue = min
            };

            this.Attributes.Add(integerAttribute);
            return(this);
        }
Example #27
0
        private static IntegerAttributeMetadata CreateIntegerAttributeMetadata(string name, string displayName, AttributeRequiredLevel attributeRequiredLevel, string desription, int minValue, int maxValue)
        {
            // Create a date time attribute
            IntegerAttributeMetadata integerAttribute = new IntegerAttributeMetadata
            {
                // Set base properties
                SchemaName    = publisherPrefix + name,
                LogicalName   = publisherPrefix + name,
                DisplayName   = new Label(displayName, _languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel),
                Description   = new Label(desription, _languageCode),
                // Set extended properties
                Format   = IntegerFormat.None,
                MaxValue = maxValue,
                MinValue = minValue
            };

            return(integerAttribute);
        }
Example #28
0
        private static BooleanAttributeMetadata CreateBooleanAttribute(string name, string displayName, AttributeRequiredLevel attributeRequiredLevel, string desription)
        {
            // Create a boolean attribute
            BooleanAttributeMetadata boolAttribute = new BooleanAttributeMetadata
            {
                // Set base properties
                SchemaName    = publisherPrefix + name,
                LogicalName   = publisherPrefix + name,
                DisplayName   = new Label(displayName, _languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel),
                Description   = new Label(desription, _languageCode),
                // Set extended properties
                OptionSet = new BooleanOptionSetMetadata(
                    new OptionMetadata(new Label("True", _languageCode), 1),
                    new OptionMetadata(new Label("False", _languageCode), 0)
                    )
            };

            return(boolAttribute);
        }
Example #29
0
        private static DateTimeAttributeMetadata CreateDateTimeAttribute(string name, string displayName, AttributeRequiredLevel attributeRequiredLevel, string desription)
        {
            // Create a date time attribute
            DateTimeAttributeMetadata dtAttribute = new DateTimeAttributeMetadata
            {
                // Set base properties
                SchemaName    = publisherPrefix + name,
                LogicalName   = publisherPrefix + name,
                DisplayName   = new Label(displayName, _languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel),
                Description   = new Label(desription, _languageCode),
                // Set extended properties
                Format  = DateTimeFormat.DateOnly,
                ImeMode = ImeMode.Disabled,
            };

            return(dtAttribute);
        }
Example #30
0
        private AttributeMetadata GetAttributeMetadata(string type, string logicalname, string displayname, AttributeRequiredLevel requiredlevel)
        {
            AttributeMetadata attribute = null;

            if (type != null)
            {
                switch (type.ToLower())
                {
                case "boolean":
                    attribute = new BooleanAttributeMetadata
                    {
                        // Set extended properties
                        OptionSet = new BooleanOptionSetMetadata(
                            new OptionMetadata(new Label("True", languageCode), 1),
                            new OptionMetadata(new Label("False", languageCode), 0)
                            )
                    };
                    break;

                case "datetime":
                    // Create a date time attribute
                    attribute = new DateTimeAttributeMetadata
                    {
                        // Set extended properties
                        Format  = DateTimeFormat.DateOnly,
                        ImeMode = ImeMode.Disabled
                    };
                    break;

                case "double":
                    // Create a decimal attribute
                    attribute = new DecimalAttributeMetadata
                    {
                        // Set extended properties
                        MaxValue  = 100,
                        MinValue  = 0,
                        Precision = 1
                    };
                    break;

                case "integer":
                    // Create a integer attribute
                    attribute = new IntegerAttributeMetadata
                    {
                        // Set extended properties
                        Format   = IntegerFormat.None,
                        MaxValue = 100,
                        MinValue = 0
                    };
                    break;

                case "memo":
                    // Create a memo attribute
                    attribute = new MemoAttributeMetadata
                    {
                        // Set extended properties
                        Format    = StringFormat.TextArea,
                        ImeMode   = ImeMode.Disabled,
                        MaxLength = 500
                    };
                    break;

                case "money":
                    // Create a money attribute
                    MoneyAttributeMetadata moneyAttribute = new MoneyAttributeMetadata
                    {
                        // Set extended properties
                        MaxValue        = 1000.00,
                        MinValue        = 0.00,
                        Precision       = 1,
                        PrecisionSource = 1,
                        ImeMode         = ImeMode.Disabled
                    };
                    break;

                case "picklist":
                    // Create a picklist attribute
                    attribute = new PicklistAttributeMetadata
                    {
                        // Set extended properties
                        // Build local picklist options
                        OptionSet = new OptionSetMetadata
                        {
                            IsGlobal      = false,
                            OptionSetType = OptionSetType.Picklist
                        }
                    };
                    break;

                case "string":
                    // Create a string attribute
                    attribute = new StringAttributeMetadata
                    {
                        // Set extended properties
                        MaxLength = 100
                    };
                    break;

                default:
                    throw new ArgumentException(string.Format("Unexpected attribute type: {0}", type));
                }

                // Set base properties
                attribute.SchemaName    = logicalname;
                attribute.DisplayName   = new Label(displayname, languageCode);
                attribute.RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredlevel);
            }

            return(attribute);
        }
Example #31
0
        public EntityAttributeMetadataBuilder MoneyAttribute(string schemaName, string displayName, string description, AttributeRequiredLevel requiredLevel, double?min, double?max, int?precision, int?precisionSource, ImeMode imeMode = ImeMode.Disabled)
        {
            // Define the primary attribute for the entity
            // Create a integer attribute
            int languageCode = 1033;
            var att          = new MoneyAttributeMetadata()
            {
                // Set base properties
                SchemaName    = schemaName,
                DisplayName   = new Label(schemaName, languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(requiredLevel),
                Description   = new Label(description, languageCode),
                // Set extended properties
                Precision       = precision,
                PrecisionSource = precisionSource,
                MaxValue        = max,
                MinValue        = min,
                ImeMode         = imeMode
            };

            this.Attributes.Add(att);
            return(this);
        }
Example #32
0
        private static MoneyAttributeMetadata CreateMoneyAttribute(string name, string displayName, AttributeRequiredLevel attributeRequiredLevel, string desription, double minValue, double maxValue, int precision, int precisionSource)
        {
            // Create a date time attribute
            MoneyAttributeMetadata moneyAttribute = new MoneyAttributeMetadata
            {
                // Set base properties
                SchemaName    = publisherPrefix + name,
                LogicalName   = publisherPrefix + name,
                DisplayName   = new Label(displayName, _languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel),
                Description   = new Label(desription, _languageCode),
                // Set extended properties
                MaxValue        = maxValue,
                MinValue        = minValue,
                Precision       = precision,
                PrecisionSource = precisionSource,
                ImeMode         = ImeMode.Disabled
            };

            return(moneyAttribute);
        }
Example #33
0
        private static DecimalAttributeMetadata CreateDecimalAttributeMetadata(string name, string displayName, AttributeRequiredLevel attributeRequiredLevel, string desription, int minValue, int maxValue, int precision)
        {
            // Create a date time attribute
            DecimalAttributeMetadata decimalAttribute = new DecimalAttributeMetadata
            {
                // Set base properties
                SchemaName    = publisherPrefix + name,
                LogicalName   = publisherPrefix + name,
                DisplayName   = new Label(displayName, _languageCode),
                RequiredLevel = new AttributeRequiredLevelManagedProperty(attributeRequiredLevel),
                Description   = new Label(desription, _languageCode),
                // Set extended properties
                MaxValue  = maxValue,
                MinValue  = minValue,
                Precision = precision
            };

            return(decimalAttribute);
        }