コード例 #1
0
        private void FilterEntitiesMetaList()
        {
            if (!EntitiesMetaListView.CanFilter)
            {
                return;
            }
            ListCollectionView collectionView = new ListCollectionView(EntitiesMetaList);

            collectionView.Filter = (e) =>
            {
                EntityMetaObject em                 = e as EntityMetaObject;
                bool             filterCustom       = true;
                bool             filterAdvancedFind = true;
                if (this.IsCustom)
                {
                    filterCustom = (em.IsCustomEntity == true);
                }
                if (this.IsValidForAdvancedFind)
                {
                    filterAdvancedFind = (em.IsValidForAdvancedFind == true);
                }
                return(filterCustom || filterAdvancedFind);
            };
            this.Count           = collectionView.Count;
            EntitiesMetaListView = collectionView;
            EntitiesMetaListView.Refresh();
        }
コード例 #2
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();
        }