public void CreateEntity(CrmServiceClient services, DxEntity entity) { try { CreateEntityRequest createrequest = new CreateEntityRequest { Entity = new EntityMetadata { SchemaName = entity.PSchema, DisplayName = new Microsoft.Xrm.Sdk.Label(entity.PName, 3082), DisplayCollectionName = new Microsoft.Xrm.Sdk.Label(entity.PNamePlural, 3082), Description = new Microsoft.Xrm.Sdk.Label(entity.PDescription, 3082), OwnershipType = entity.POwnershipType, IsActivity = entity.IsActivity, IsConnectionsEnabled = entity.IsConnectionsEnabled, // IsActivityParty = true envio de correo }, PrimaryAttribute = new StringAttributeMetadata { SchemaName = entity.DxAttribute.PSchemaName, RequiredLevel = entity.DxAttribute.PRequiredLevel, MaxLength = 100, FormatName = entity.DxAttribute.PFormatName, DisplayName = new Microsoft.Xrm.Sdk.Label(entity.DxAttribute.PDisplayName, 3082), Description = new Microsoft.Xrm.Sdk.Label(entity.PDescription, 3082) } }; OrganizationResponse organizationResponse = services.ExecuteCrmOrganizationRequest(createrequest); new Util().CreateLog(string.Format("Entity created at {0} {1} with id {2}", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), ((CreateEntityResponse)organizationResponse).EntityId)); } catch (System.Exception exception) { var error = exception.Message; throw; } }
public List <DxEntity> GetListEntity(DataRow[] rows) { List <DxEntity> lEntities = new List <DxEntity>(); DxEntity entity; foreach (var dataRow in rows) { if (!String.IsNullOrEmpty(dataRow["PName"].ToString())) { entity = new DxEntity() { IsActivity = Boolean.Parse(dataRow["IsActivity"].ToString()), PName = dataRow["PName"].ToString(), IsConnectionsEnabled = new BooleanManagedProperty(Boolean.Parse(dataRow["IsConnectionsEnabled"].ToString())), PDescription = dataRow["PDescription"].ToString(), PNamePlural = dataRow["PNamePlural"].ToString(), POwnershipType = OwnershipTypes.UserOwned, PSchema = String.Format("{0}_{1}", dataRow["PSolutionSchema"].ToString().ToLower(), dataRow["PName"].ToString().ToLower()), PSolutionSchema = dataRow["PSolutionSchema"].ToString().ToLower(), DxAttribute = new DxAttribute() { PDisplayName = dataRow["PDisplayNameATT"].ToString(), PFormatName = StringFormatName.Text, PRequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.ApplicationRequired), PSchemaName = String.Format("{0}_{1}", dataRow["PSolutionSchema"].ToString().ToLower(), dataRow["Schema Name Att"].ToString().ToLower()) }, }; lEntities.Add(entity); } } return(lEntities); }