Пример #1
0
 /// <summary>
 /// Creates a new instance of the <see cref="ItemBlockModel"/>
 /// </summary>
 /// <param name="provider">The item / block data provider</param>
 public ItemBlockModel(ItemMetadataProvider provider)
 {
     Name                = provider.Name;
     Description         = provider.Description;
     AuthorId            = provider.Author;
     Type                = provider.Type.ToString();
     Path                = provider.Path;
     PlacementParameters = provider.GroundPoint?.ToString() ?? "/";
     Thumbnail           = provider.ToItemBlockImage();
 }
Пример #2
0
        public void Add_Site_With_SearchIndex()
        {
            var connection = new ConnectionSettingProvider();

            //Working across indices
            var searchConfigElastic = new ElasticClient(
                connection.Get()
                .DefaultIndex("es.info.searchconfig"));

            var metadataElastic = new ElasticClient(
                connection.Get()
                .DefaultIndex("es.info.metadata"));

            var attachmentProcessor = new AttachmentProcessor();
            var tagger               = new InformationClassifier();
            var metadataRepo         = new MetadataRepository(metadataElastic);
            var itemMetadataProvider = new ItemMetadataProvider(metadataRepo);

            var searchConfigInfo = new InformationRepository(searchConfigElastic, attachmentProcessor, itemMetadataProvider);
            var metadataInfo     = new InformationRepository(metadataElastic, attachmentProcessor, itemMetadataProvider);

            //Get metadata values defined for the group
            var groupValues = metadataInfo.GetItemWithAttachments(
                new Guid("9c60f30c-edc4-4a30-b583-9bc9b9b82eda"),
                new[] { typeof(Value) });


            //Define a site
            var site = new Site {
                ItemId = new Guid("c667e190-6177-4248-9bbf-dd27633c6ed5"),
                Title  = "informationcentral.com",
                IsNew  = true
            };

            searchConfigInfo.Save(site);

            //Get the desired metadata values for the index
            // Cluster A , English, Red
            var indexHost = groupValues.First(x =>
                                              x.ItemId == new Guid("8820432d-1b28-4f1c-bb70-9a1d0d4972fd"));
            var indexLanguage = groupValues.First(x =>
                                                  x.ItemId == new Guid("de7932b9-a0b6-4f2f-ac45-0315ea841d65"));
            var indexColor = groupValues.First(x =>
                                               x.ItemId == new Guid("c4caf9c3-3b75-46c1-b8c2-96f48fbe2f04"));

            //Define a search index for the site
            var index = new SearchIndex {
                ItemId     = new Guid("62169a15-d2a1-4741-a8c4-c9d4f7f08f7c"),
                Title      = "IA Red Cluster A",
                IndexAlias = string.Format("xxx.site.{0}.{1}.{2}",
                                           indexLanguage.Title.ToLower(),
                                           site.ItemId,
                                           indexColor.Title.ToLower())
            };

            tagger.Tag(index, (Value)indexHost);
            tagger.Tag(index, (Value)indexLanguage);
            tagger.Tag(index, (Value)indexColor);

            //Attach index to site and metadata values
            attachmentProcessor.Attach(site, index);

            //Save the site and search index
            searchConfigInfo.Save(site);
            searchConfigInfo.Save(index);
        }