public CatalogElementFactory(IConfiguration config, EpiMappingHelper mappingHelper, CatalogCodeGenerator catalogCodeGenerator, PimFieldAdapter pimFieldAdapter)
 {
     _config               = config;
     _mappingHelper        = mappingHelper;
     _catalogCodeGenerator = catalogCodeGenerator;
     _pimFieldAdapter      = pimFieldAdapter;
 }
Пример #2
0
 public EpiApi(IConfiguration config,
               CatalogCodeGenerator catalogCodeGenerator,
               PimFieldAdapter pimFieldAdapter)
 {
     _config = config;
     _catalogCodeGenerator = catalogCodeGenerator;
     _httpClient           = new HttpClientInvoker(config);
 }
        public new void Start()
        {
            ConnectorEvent startEvent = null;

            try
            {
                _config = new Configuration(Id);
                ConnectorEventHelper.CleanupOngoingEvents(_config);
                startEvent = ConnectorEventHelper.InitiateEvent(_config, ConnectorEventType.Start, "Connector is starting", 0);

                Entity channel = RemoteManager.DataService.GetEntity(_config.ChannelId, LoadLevel.Shallow);
                if (channel == null || channel.EntityType.Id != "Channel")
                {
                    _started = false;
                    ConnectorEventHelper.UpdateEvent(startEvent, "Channel id is not valid: Entity with given ID is not a channel, or doesn't exist. Unable to start", -1, true);
                    return;
                }

                _pimFieldAdapter      = new PimFieldAdapter(_config);
                _epiMappingHelper     = new EpiMappingHelper(_config, _pimFieldAdapter);
                _entityService        = new EntityService(_config, _epiMappingHelper);
                _catalogCodeGenerator = new CatalogCodeGenerator(_config, _entityService);
                _epiApi = new EpiApi(_config, _catalogCodeGenerator, _pimFieldAdapter);
                _catalogElementFactory  = new CatalogElementFactory(_config, _epiMappingHelper, _catalogCodeGenerator, _pimFieldAdapter);
                _channelHelper          = new ChannelHelper(_config, _entityService);
                _catalogDocumentFactory = new CatalogDocumentFactory(_config, _epiApi, _catalogElementFactory, _epiMappingHelper, _channelHelper, _catalogCodeGenerator, _entityService);
                _resourceElementFactory = new ResourceElementFactory(_catalogElementFactory, _epiMappingHelper, _catalogCodeGenerator, _config, _entityService);

                _documentFileHelper = new DocumentFileHelper(_config, _channelHelper);
                _cvlUpdater         = new CvlUpdater(_config, _catalogDocumentFactory, _epiApi, _documentFileHelper);

                _publisher = new ChannelPublisher(_config,
                                                  _catalogDocumentFactory,
                                                  _catalogElementFactory,
                                                  _resourceElementFactory,
                                                  _epiApi,
                                                  _epiMappingHelper,
                                                  _documentFileHelper,
                                                  _pimFieldAdapter,
                                                  _entityService,
                                                  _catalogCodeGenerator);

                AppDomain.CurrentDomain.AssemblyResolve += CurrentDomainAssemblyResolve;

                InitConnector();

                base.Start();
                _started = true;
                ConnectorEventHelper.UpdateEvent(startEvent, "Connector has started", 100);
            }
            catch (Exception ex)
            {
                IntegrationLogger.Write(LogLevel.Error, "Error while starting connector", ex);
                ConnectorEventHelper.UpdateEvent(startEvent, "Issue while starting connector, see log.", 100, true);
                throw;
            }
        }
        private void HandleSkuUpdate(int entityId,
                                     Entity channelEntity,
                                     ConnectorEvent connectorEvent,
                                     List <StructureEntity> structureEntities,
                                     out bool resourceIncluded)
        {
            resourceIncluded = false;
            Field currentField = RemoteManager.DataService.GetField(entityId, "SKUs");

            List <Field> fieldHistory = RemoteManager.DataService.GetFieldHistory(entityId, "SKUs");

            Field previousField = fieldHistory.FirstOrDefault(f => f.Revision == currentField.Revision - 1);

            string oldXml = string.Empty;

            if (previousField != null && previousField.Data != null)
            {
                oldXml = (string)previousField.Data;
            }

            string newXml = string.Empty;

            if (currentField.Data != null)
            {
                newXml = (string)currentField.Data;
            }

            List <XElement> skusToDelete, skusToAdd;

            PimFieldAdapter.CompareAndParseSkuXmls(oldXml, newXml, out skusToAdd, out skusToDelete);

            foreach (XElement skuToDelete in skusToDelete)
            {
                string skuId = skuToDelete.Attribute("id").Value;
                _epiApi.DeleteSku(skuId);
            }

            if (skusToAdd.Count > 0)
            {
                PublishEntities(channelEntity, connectorEvent, structureEntities);
                resourceIncluded = true;
            }
        }
 public ChannelPublisher(IConfiguration config,
                         CatalogDocumentFactory catalogDocumentFactory,
                         CatalogElementFactory catalogElementFactory,
                         ResourceElementFactory resourceElementFactory,
                         EpiApi epiApi,
                         EpiMappingHelper mappingHelper,
                         DocumentFileHelper documentFileHelper,
                         PimFieldAdapter pimFieldAdapter,
                         IEntityService entityService,
                         CatalogCodeGenerator catalogCodeGenerator)
 {
     _config = config;
     _catalogDocumentFactory = catalogDocumentFactory;
     _catalogElementFactory  = catalogElementFactory;
     _resourceElementFactory = resourceElementFactory;
     _epiApi               = epiApi;
     _mappingHelper        = mappingHelper;
     _documentFileHelper   = documentFileHelper;
     _pimFieldAdapter      = pimFieldAdapter;
     _entityService        = entityService;
     _catalogCodeGenerator = catalogCodeGenerator;
 }