public FormatTextTableHandler AddLineIfNotEqual(string fieldName, BooleanManagedProperty value1, BooleanManagedProperty value2) { var valueString1 = value1 != null?value1.Value.ToString() : "null"; var valueString2 = value2 != null?value2.Value.ToString() : "null"; if (valueString1 != valueString2) { this.AddLine(fieldName, valueString1, valueString2); } return(this); }
private bool IsEqualBooleanManagedProperty(BooleanManagedProperty x, BooleanManagedProperty y) { if (x == null && y != null) { return(false); } else if (x != null && y == null) { return(false); } else if (x != null && y != null) { return(x.Value == y.Value && x.CanBeChanged == y.CanBeChanged); } return(true); }
public BooleanManagedPropertyAttributeMetadataControl(ManagedPropertyAttributeMetadata attributeMetadata, BooleanManagedProperty initialValue, bool allwaysAddToEntity, bool showRestoreButton) { InitializeComponent(); AttributeMetadataControlFactory.SetGroupBoxNameByAttributeMetadata(gbAttribute, attributeMetadata); this._initialValue = initialValue; this._allwaysAddToEntity = allwaysAddToEntity; this.AttributeMetadata = attributeMetadata; FillComboBox(); Views.WindowBase.SetElementsEnabledAndVisible(allwaysAddToEntity, btnRemoveControl); Views.WindowBase.SetElementsEnabledAndVisible(showRestoreButton, btnRestore); Views.WindowBase.SetElementsVisible(showRestoreButton, chBChanged); }
public BooleanManagedPropertyAttributeMetadataControl(bool fillAllways, ManagedPropertyAttributeMetadata attributeMetadata, BooleanManagedProperty initialValue) { InitializeComponent(); AttributeMetadataControlFactory.SetGroupBoxNameByAttributeMetadata(gbAttribute, attributeMetadata); this._initialValue = initialValue; this._fillAllways = fillAllways; this.AttributeMetadata = attributeMetadata; FillComboBox(); btnRemoveControl.IsEnabled = _fillAllways; btnRemoveControl.Visibility = btnRemoveControl.IsEnabled ? Visibility.Visible : Visibility.Collapsed; chBChanged.Visibility = _fillAllways ? Visibility.Collapsed : Visibility.Visible; btnRestore.IsEnabled = !_fillAllways; btnRestore.Visibility = btnRestore.IsEnabled ? Visibility.Visible : Visibility.Collapsed; }
public BooleanManagedPropertyInfo(BooleanManagedProperty property) { this.property = property; }
public UserControl CreateControlForAttribute( IWriteToOutput iWriteToOutput , IOrganizationServiceExtented service , EntityMetadata entityMetadata , AttributeMetadata attributeMetadata , Entity entity , object value , bool allwaysAddToEntity , bool showRestoreButton ) { if (attributeMetadata is MemoAttributeMetadata memoAttrib) { string initialValue = null; if (value != null && value is string) { initialValue = (string)value; } return(new MemoAttributeMetadataControl(memoAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is StringAttributeMetadata stringAttrib) { string initialValue = null; if (value != null && value is string) { initialValue = (string)value; } return(new StringAttributeMetadataControl(stringAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is IntegerAttributeMetadata intAttrib) { int?initialValue = null; if (value != null && value is int) { initialValue = (int)value; } return(new IntegerAttributeMetadataControl(intAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is BigIntAttributeMetadata bigIntAttrib) { long?initialValue = null; if (value != null && value is long) { initialValue = (long)value; } return(new BigIntAttributeMetadataControl(bigIntAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is DecimalAttributeMetadata decimalAttrib) { decimal?initialValue = null; if (value != null && value is decimal) { initialValue = (decimal)value; } return(new DecimalAttributeMetadataControl(decimalAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is DoubleAttributeMetadata doubleAttrib) { double?initialValue = null; if (value != null && value is double) { initialValue = (double)value; } return(new DoubleAttributeMetadataControl(doubleAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is MoneyAttributeMetadata moneyAttrib) { Money initialValue = null; if (value != null && value is Money) { initialValue = (Money)value; } return(new MoneyAttributeMetadataControl(moneyAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is DateTimeAttributeMetadata dateTimeAttrib) { DateTime?initialValue = null; if (value != null && value is DateTime) { initialValue = (DateTime)value; } return(new DateTimeAttributeMetadataControl(dateTimeAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is BooleanAttributeMetadata boolAttrib) { bool?initialValue = null; if (value != null && value is bool boolValue) { initialValue = boolValue; } return(new BooleanAttributeMetadataControl(boolAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is ManagedPropertyAttributeMetadata managedPropertyAttributeMetadata) { if (managedPropertyAttributeMetadata.ValueAttributeTypeCode == AttributeTypeCode.Boolean) { BooleanManagedProperty initialValue = null; if (value != null && value is BooleanManagedProperty booleanManagedProperty) { initialValue = booleanManagedProperty; } return(new BooleanManagedPropertyAttributeMetadataControl(managedPropertyAttributeMetadata, initialValue, allwaysAddToEntity, showRestoreButton)); } } if (attributeMetadata is PicklistAttributeMetadata picklistAttrib) { int?initialValue = null; if (value != null && value is OptionSetValue optionSetValue) { initialValue = optionSetValue.Value; } string initialFormatedValue = string.Empty; if (entity != null && entity.FormattedValues != null && entity.FormattedValues.ContainsKey(picklistAttrib.LogicalName) && !string.IsNullOrEmpty(entity.FormattedValues[picklistAttrib.LogicalName]) ) { initialFormatedValue = entity.FormattedValues[picklistAttrib.LogicalName]; } return(new PicklistAttributeMetadataControl(picklistAttrib, initialValue, initialFormatedValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is MultiSelectPicklistAttributeMetadata multiSelectPicklistAttributeMetadata) { OptionSetValueCollection initialValue = null; if (value != null && value is OptionSetValueCollection optionSetValueCollection) { initialValue = optionSetValueCollection; } return(new MultiSelectPicklistAttributeMetadataControl(multiSelectPicklistAttributeMetadata, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is StatusAttributeMetadata statusAttrib) { var stateAttrib = entityMetadata.Attributes.OfType <StateAttributeMetadata>().FirstOrDefault(); if (stateAttrib != null) { int?initialValueStatus = null; int?initialValueState = null; if (value != null && value is OptionSetValue optionSetValueStatus) { initialValueStatus = optionSetValueStatus.Value; } string statusFormatedValue = string.Empty; if (entity != null) { if (entity.Attributes.ContainsKey(stateAttrib.LogicalName) && entity.Attributes[stateAttrib.LogicalName] != null && entity.Attributes[stateAttrib.LogicalName] is OptionSetValue optionSetValueState ) { initialValueState = optionSetValueState.Value; } if (entity.FormattedValues != null && entity.FormattedValues.ContainsKey(statusAttrib.LogicalName) && !string.IsNullOrEmpty(entity.FormattedValues[statusAttrib.LogicalName]) ) { statusFormatedValue = entity.FormattedValues[statusAttrib.LogicalName]; } } return(new StatusAttributeMetadataControl(statusAttrib, stateAttrib, initialValueStatus, initialValueState, statusFormatedValue, allwaysAddToEntity, showRestoreButton)); } } if (attributeMetadata is LookupAttributeMetadata lookupAttrib) { EntityReference initialValue = null; if (value != null && value is EntityReference) { initialValue = (EntityReference)value; } return(new LookupAttributeMetadataControl(iWriteToOutput, service, lookupAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is EntityNameAttributeMetadata entityNameAttrib) { string initialValue = null; if (value != null && value is string entityName) { initialValue = entityName; } return(new EntityNameAttributeMetadataControl(service.ConnectionData, entityNameAttrib, initialValue, allwaysAddToEntity, showRestoreButton)); } if (attributeMetadata is UniqueIdentifierAttributeMetadata uniqueAttrib || attributeMetadata.AttributeType == AttributeTypeCode.Uniqueidentifier ) { Guid?initialValue = null; if (value != null && value is Guid valueGuid) { initialValue = valueGuid; } return(new UniqueIdentifierAttributeMetadataControl(attributeMetadata, initialValue, allwaysAddToEntity, showRestoreButton)); } return(null); }
public BooleanManagedPropertyInfo(BooleanManagedProperty property) { this.property = property; }
private static bool CheckMetadata(CheckState checkstate, BooleanManagedProperty metafield) { return(CheckMetadata(checkstate, metafield?.Value)); }
public void RegisterDataSource() { var languageCode = GetLanguageCode(); var propertyFalse = new BooleanManagedProperty(false); var propertyTrue = new BooleanManagedProperty(true); var request = new CreateEntityRequest { HasActivities = false, PrimaryAttribute = new StringAttributeMetadata { SchemaName = $"{DataSourceName}Name", RequiredLevel = new AttributeRequiredLevelManagedProperty(AttributeRequiredLevel.None), MaxLength = 100, DisplayName = new Label(json.displayname, languageCode), ExternalName = json.displayname }, Entity = new EntityMetadata { DataProviderId = new Guid?(new Guid("B2112A7E-B26C-42F7-9B63-9A809A9D716F")), IsActivity = new bool?(false), SchemaName = DataSourceName, DisplayName = new Label(json.displayname, languageCode), DisplayCollectionName = new Label(json.pluralname, languageCode), ExternalCollectionName = json.pluralname.Replace(" ", string.Empty), ExternalName = json.displayname.Replace(" ", string.Empty), OwnershipType = new OwnershipTypes?(OwnershipTypes.OrganizationOwned), IsAvailableOffline = new bool?(false), Description = new Label(string.Empty, languageCode), IsBusinessProcessEnabled = new bool?(false), IsVisibleInMobile = propertyFalse, IsVisibleInMobileClient = propertyFalse, IsReadOnlyInMobileClient = propertyFalse, IsOfflineInMobileClient = propertyFalse, IsAuditEnabled = propertyFalse, IsSLAEnabled = new bool?(false), IsBPFEntity = new bool?(false), IsDuplicateDetectionEnabled = propertyFalse, IsConnectionsEnabled = propertyFalse, IsActivityParty = new bool?(false), IsReadingPaneEnabled = new bool?(false), IsQuickCreateEnabled = new bool?(false), AutoCreateAccessTeams = new bool?(false), CanCreateCharts = propertyFalse, IsMailMergeEnabled = propertyFalse, ChangeTrackingEnabled = new bool?(false), CanChangeTrackingBeEnabled = propertyFalse, IsEnabledForExternalChannels = new bool?(false), EntityHelpUrlEnabled = new bool?(false), IsCustomizable = propertyTrue, IsRenameable = propertyTrue, IsMappable = propertyFalse, SyncToExternalSearchIndex = new bool?(false), CanEnableSyncToExternalSearchIndex = propertyFalse, CanModifyAdditionalSettings = propertyFalse, CanChangeHierarchicalRelationship = propertyFalse } }; if (request.Parameters == null) { request.Parameters = new ParameterCollection(); } if (request.Parameters.ContainsKey("SolutionUniqueName")) { request.Parameters["SolutionUniqueName"] = json.solution; } else { request.Parameters.Add("SolutionUniqueName", json.solution); } var response = (CreateEntityResponse)crmServiceClient.Execute(request); var entityId = response.EntityId; var retrieveEntityRequest = new RetrieveEntityRequest() { EntityFilters = EntityFilters.All, MetadataId = entityId }; EntityMetadata entityMetadata = ((RetrieveEntityResponse)crmServiceClient.Execute(retrieveEntityRequest)).EntityMetadata; //Update field Id var requestId = new RetrieveAttributeRequest() { EntityLogicalName = entityMetadata.LogicalName, LogicalName = string.Format("{0}id", entityMetadata.LogicalName) }; var attributeMetadataId = ((RetrieveAttributeResponse)crmServiceClient.Execute(requestId)).AttributeMetadata; attributeMetadataId.ExternalName = $"{DataSourceName}Id"; var updateRequestId = new UpdateAttributeRequest() { Attribute = attributeMetadataId, EntityName = entityMetadata.LogicalName, MergeLabels = false }; crmServiceClient.Execute(updateRequestId); //Update field name var requestName = new RetrieveAttributeRequest() { EntityLogicalName = entityMetadata.LogicalName, LogicalName = string.Format("{0}name", DataSourceName.ToLower()) }; var attributeMetadataName = ((RetrieveAttributeResponse)crmServiceClient.Execute(requestName)).AttributeMetadata; attributeMetadataName.ExternalName = $"{DataSourceName}Name"; var updateRequestName = new UpdateAttributeRequest() { Attribute = attributeMetadataName, EntityName = entityMetadata.LogicalName, MergeLabels = false }; crmServiceClient.Execute(updateRequestName); try { PublishAllXmlRequest publishAllXmlRequest = new PublishAllXmlRequest(); PublishAllXmlResponse publishAllXmlResponse = (PublishAllXmlResponse)crmServiceClient.Execute(publishAllXmlRequest); } catch { } }
public FormatTextTableHandler AddEntityMetadataString(string fieldName, BooleanManagedProperty value) { var valueString = value != null?value.Value.ToString() : "null"; return(this.AddLineNotNull(fieldName, valueString)); }
public static bool GetValueOrDefault(this BooleanManagedProperty oBoolManProp, bool defaultValue = false) { if (oBoolManProp == null) return defaultValue; return oBoolManProp.Value; }