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);
        }
        private bool HandleResourceUpdate(Entity updatedEntity, string folderDateTime)
        {
            var       resourceIncluded  = false;
            XDocument resourceDocument  = _resourceElementFactory.HandleResourceUpdate(updatedEntity, folderDateTime);
            string    resourcesBasePath = Path.Combine(_config.ResourcesRootPath, folderDateTime);

            _documentFileHelper.SaveDocument(resourceDocument, resourcesBasePath);

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

            string baseFilePath    = Path.Combine(_config.ResourcesRootPath, folderDateTime);
            string resourceXmlPath = Path.Combine(baseFilePath, "Resources.xml");

            _epiApi.ImportResources(resourceXmlPath, baseFilePath);

            _epiApi.NotifyEpiserverPostImport(resourceXmlPath);
            resourceIncluded = true;

            return(resourceIncluded);
        }