Beispiel #1
0
        private void HandleDictionary(Item item, EnterspeedSitecoreConfiguration configuration, bool itemIsDeleted, bool itemIsPublished)
        {
            if (item == null)
            {
                return;
            }

            // Skip, if the item published is not a dictionary item
            if (!item.IsDictionaryItem())
            {
                return;
            }

            if (!IsItemReferencedFromEnabledContent(item, configuration))
            {
                return;
            }

            SitecoreDictionaryEntity sitecoreDictionaryEntity = _sitecoreDictionaryEntityModelMapper.Map(item);

            if (sitecoreDictionaryEntity == null)
            {
                return;
            }

            if (itemIsDeleted)
            {
                string id = _identityService.GetId(item);
                _loggingService.Info($"Beginning to delete dictionary entity ({id}).");
                Response deleteResponse = _enterspeedIngestService.Delete(id);

                if (!deleteResponse.Success)
                {
                    _loggingService.Warn($"Failed deleting dictionary entity ({id}). Message: {deleteResponse.Message}", deleteResponse.Exception);
                }
                else
                {
                    _loggingService.Debug($"Successfully deleting dictionary entity ({id})");
                }

                return;
            }

            if (itemIsPublished)
            {
                string id = _identityService.GetId(item);
                _loggingService.Info($"Beginning to ingest dictionary entity ({id}).");
                Response saveResponse = _enterspeedIngestService.Save(sitecoreDictionaryEntity);

                if (!saveResponse.Success)
                {
                    _loggingService.Warn($"Failed ingesting dictionary entity ({id}). Message: {saveResponse.Message}", saveResponse.Exception);
                }
                else
                {
                    _loggingService.Debug($"Successfully ingested dictionary entity ({id})");
                }
            }
        }
Beispiel #2
0
        private void SaveEntity(RenderingItem renderingItem)
        {
            SitecoreRenderingEntity sitecoreRenderingEntity = _sitecoreRenderingEntityModelMapper.Map(renderingItem);

            string id = _identityService.GetId(renderingItem);

            _loggingService.Info($"Beginning to ingest rendering entity ({id}).");
            Response saveResponse = _enterspeedIngestService.Save(sitecoreRenderingEntity);

            if (!saveResponse.Success)
            {
                _loggingService.Warn($"Failed ingesting rendering entity ({id}). Message: {saveResponse.Message}", saveResponse.Exception);
            }
            else
            {
                _loggingService.Debug($"Successfully ingested rendering entity ({id})");
            }
        }
Beispiel #3
0
        private IEnterspeedEntity Map(Item item)
        {
            IEnterspeedEntity entity;

            if (item.IsRenderingItem())
            {
                entity = _renderingMapper.Map(item);
            }
            else if (item.IsDictionaryItem())
            {
                entity = _dictionaryMapper.Map(item);
            }
            else
            {
                entity = _itemMapper.Map(item);
            }

            return(entity);
        }
Beispiel #4
0
        private void HandleContentItem(Item item, EnterspeedSitecoreConfiguration configuration, bool itemIsDeleted, bool itemIsPublished)
        {
            try
            {
                if (item == null)
                {
                    return;
                }

                // Skip, if the item published is not a content item
                if (!item.IsContentItem())
                {
                    return;
                }

                EnterspeedSiteInfo siteOfItem = configuration.GetSite(item);
                if (siteOfItem == null)
                {
                    // If no enabled site was found for this item, skip it
                    return;
                }

                SitecoreContentEntity sitecoreContentEntity = _sitecoreContentEntityModelMapper.Map(item);
                if (sitecoreContentEntity == null)
                {
                    return;
                }

                if (itemIsDeleted)
                {
                    string id = _identityService.GetId(item);
                    _loggingService.Info($"Beginning to delete content entity ({id}).");
                    Response deleteResponse = _enterspeedIngestService.Delete(id);

                    if (!deleteResponse.Success)
                    {
                        _loggingService.Warn($"Failed deleting content entity ({id}). Message: {deleteResponse.Message}", deleteResponse.Exception);
                    }
                    else
                    {
                        _loggingService.Debug($"Successfully deleting content entity ({id})");
                    }

                    return;
                }

                if (itemIsPublished)
                {
                    string id = _identityService.GetId(item);
                    _loggingService.Info($"Beginning to ingest content entity ({id}).");
                    Response saveResponse = _enterspeedIngestService.Save(sitecoreContentEntity);

                    if (!saveResponse.Success)
                    {
                        _loggingService.Warn($"Failed ingesting content entity ({id}). Message: {saveResponse.Message}", saveResponse.Exception);
                    }
                    else
                    {
                        _loggingService.Debug($"Successfully ingested content entity ({id})");
                    }
                }
            }
            catch (Exception exception)
            {
                Debug.WriteLine(exception.ToString());
            }
        }