コード例 #1
0
        private void PubilshToEpiserver(ConnectorEvent connectorEvent,
                                        XDocument catalogDocument,
                                        List <StructureEntity> structureEntitiesToGetResourcesFor,
                                        Entity channelEntity)
        {
            ConnectorEventHelper.UpdateEvent(connectorEvent, "Done generating catalog.xml. Generating Resource.xml and saving files to disk...", 26);

            var folderNameTimestampComponent = DateTime.Now.ToString(Constants.PublicationFolderNameTimeComponent);

            var resourcesBasePath    = Path.Combine(_config.ResourcesRootPath, folderNameTimestampComponent);
            var resourceDocument     = _resourceElementFactory.GetResourcesNodeForChannelEntities(structureEntitiesToGetResourcesFor, resourcesBasePath);
            var resourceDocumentPath = _documentFileHelper.SaveDocument(resourceDocument, resourcesBasePath);

            var savedCatalogDocument = _documentFileHelper.SaveCatalogDocument(channelEntity, catalogDocument, folderNameTimestampComponent);

            ConnectorEventHelper.UpdateEvent(connectorEvent, "Done generating/saving Resource.xml, sending Catalog.xml to EPiServer...", 50);

            _epiApi.ImportCatalog(savedCatalogDocument);

            ConnectorEventHelper.UpdateEvent(connectorEvent, "Done sending Catalog.xml to EPiServer", 75);

            _epiApi.NotifyEpiserverPostImport(savedCatalogDocument);

            ConnectorEventHelper.UpdateEvent(connectorEvent, "Sending Resources to EPiServer...", 76);

            _epiApi.ImportResources(resourceDocumentPath, resourcesBasePath);

            ConnectorEventHelper.UpdateEvent(connectorEvent, "Done sending Resources to EPiServer...", 99);

            _epiApi.NotifyEpiserverPostImport(resourceDocumentPath);
            var channelName = _mappingHelper.GetNameForEntity(channelEntity, 100);

            _epiApi.ImportUpdateCompleted(channelName, ImportUpdateCompletedEventType.Publish, true);
        }
コード例 #2
0
        public ConnectorEvent ChannelEntityUpdated(Entity channel, int entityId, string data)
        {
            ConnectorEvent connectorEvent = ConnectorEventHelper.InitiateEvent(_config, ConnectorEventType.ChannelEntityUpdated,
                                                                               $"Received entity update for entity {entityId} in channel {channel.DisplayName}", 0);


            Entity updatedEntity = _entityService.GetEntity(entityId, LoadLevel.DataAndLinks);

            if (updatedEntity.EntityType.IsLinkEntityType)
            {
                return(connectorEvent);
            }

            string folderDateTime   = DateTime.Now.ToString(Constants.PublicationFolderNameTimeComponent);
            var    resourceIncluded = false;
            List <StructureEntity> structureEntities = _entityService.GetStructureEntitiesForEntityInChannel(_config.ChannelId, entityId);

            if (updatedEntity.EntityType.Id.Equals("Resource"))
            {
                resourceIncluded = HandleResourceUpdate(updatedEntity, folderDateTime);
            }
            else
            {
                IntegrationLogger.Write(LogLevel.Debug, $"Updated entity found. Type: {updatedEntity.EntityType.Id}, id: {updatedEntity.Id}");

                if (updatedEntity.EntityType.Id.Equals("Item") && data != null && data.Split(',').Contains("SKUs"))
                {
                    HandleSkuUpdate(entityId, channel, connectorEvent, structureEntities, out resourceIncluded);
                }
                else if (updatedEntity.EntityType.Id.Equals("ChannelNode"))
                {
                    HandleChannelNodeUpdate(channel, structureEntities, connectorEvent);
                    return(connectorEvent);
                }

                XDocument doc = _catalogDocumentFactory.CreateUpdateDocument(channel, updatedEntity);

                string catalogDocumentName = _documentFileHelper.SaveCatalogDocument(channel, doc, folderDateTime);

                IntegrationLogger.Write(LogLevel.Debug, "Starting automatic import!");

                _epiApi.ImportCatalog(catalogDocumentName);
                _epiApi.NotifyEpiserverPostImport(catalogDocumentName);
            }

            string channelName = _mappingHelper.GetNameForEntity(channel, 100);

            _epiApi.ImportUpdateCompleted(channelName, ImportUpdateCompletedEventType.EntityUpdated, resourceIncluded);
            return(connectorEvent);
        }
コード例 #3
0
        public ConnectorEvent CVLValueUpdated(Entity channel, string cvlId, string cvlValueKey)
        {
            var connectorEvent = ConnectorEventHelper.InitiateEvent(_config,
                                                                    ConnectorEventType.CVLValueUpdated,
                                                                    $"CVL value updated, updating values in channel: {channel.DisplayName.Data}", 0);

            var cvlFieldTypes = RemoteManager.ModelService.GetAllFieldTypes().Where(x => x.CVLId == cvlId);

            var criterias = cvlFieldTypes.Select(cvlFieldType => new Criteria
            {
                FieldTypeId = cvlFieldType.Id,
                Value       = cvlValueKey,
                Operator    = Operator.Equal
            }).ToList();

            var query = new Query {
                Criteria = criterias, Join = Join.Or
            };
            var entities = RemoteManager.DataService.Search(query, LoadLevel.DataOnly);

            IntegrationLogger.Write(LogLevel.Debug, $"Found {entities.Count} entities with the CVL {cvlId} to update. Value-key to update: {cvlValueKey}.");

            var updateDocument = _catalogDocumentFactory.CreateUpdateDocument(channel, entities);
            var folderDateTime = DateTime.Now.ToString(Constants.PublicationFolderNameTimeComponent);

            var savedCatalogDocument = _documentFileHelper.SaveCatalogDocument(channel, updateDocument, folderDateTime);

            _epiApi.ImportCatalog(savedCatalogDocument);

            ConnectorEventHelper.UpdateEvent(connectorEvent, "Done sending Catalog.xml to EPiServer", 75);

            _epiApi.NotifyEpiserverPostImport(Path.Combine(_config.PublicationsRootPath, folderDateTime, savedCatalogDocument));

            return(connectorEvent);
        }