Пример #1
0
        private void FillEntitiesMetaList()
        {
            if (crmService == null || !crmService.IsConnected)
            {
                MessageBox.Show("Not connected to CRM.", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                return;
            }

            var entities = crmService.GetAllEntitiesMeta();

            EntitiesMetaList = new ObservableCollection <EntityMetaObject>();

            foreach (EntityMetadata entity in entities)
            {
                EntityMetaObject entityMeta = new EntityMetaObject();
                entityMeta.MetaId                 = entity.MetadataId.HasValue ? entity.MetadataId.Value : Guid.Empty;
                entityMeta.SchemaName             = entity.SchemaName;
                entityMeta.LogicalName            = entity.LogicalName;
                entityMeta.DisplayName            = (entity.DisplayName.UserLocalizedLabel != null) ? entity.DisplayName.UserLocalizedLabel.Label : entity.SchemaName;
                entityMeta.ObjectTypeCode         = entity.ObjectTypeCode.HasValue ? entity.ObjectTypeCode.Value : 0;
                entityMeta.Description            = (entity.Description.UserLocalizedLabel != null) ? entity.Description.UserLocalizedLabel.Label : "";
                entityMeta.IsCustomEntity         = entity.IsCustomEntity.Value;
                entityMeta.IsManaged              = entity.IsManaged.Value;
                entityMeta.IsValidForAdvancedFind = entity.IsValidForAdvancedFind.Value;
                entityMeta.IsValidForQueue        = entity.IsValidForQueue.Value;
                entityMeta.IsVisibleInMobile      = entity.IsVisibleInMobile.Value;
                EntitiesMetaList.Add(entityMeta);
            }
            this.Count           = EntitiesMetaList.Count;
            EntitiesMetaListView = CollectionViewSource.GetDefaultView(EntitiesMetaList);
            EntitiesMetaListView.Refresh();
        }