// Used for testing. inRiver will use a parameterless constructor when it initializes extensions
        public DataAPI(inRiverContext _context)
        {
            Context = _context;


            initializeDictionaries();
        }
Exemple #2
0
        internal string ZipAndUploadToCloud(Configuration config, inRiverContext context, Dictionary <string, byte[]> files, CloudFileDirectory cloudDirectory, CloudFile cloudFile)
        {
            using (MemoryStream stream = new MemoryStream())
            {
                using (ZipArchive archive = new ZipArchive(stream, ZipArchiveMode.Create, true))
                {
                    foreach (KeyValuePair <string, byte[]> imageFile in files)
                    {
                        ZipArchiveEntry entry = archive.CreateEntry(imageFile.Key);
                        using (Stream entryStream = entry.Open())
                        {
                            entryStream.Write(imageFile.Value, 0, imageFile.Value.Length);
                        }
                    }
                }

                stream.Position = 0;
                cloudFile.UploadFromStream(stream);

                Uri path = cloudFile.Uri;
                config.ResourceNameInCloud = cloudFile.Name;
                context.Log(LogLevel.Debug, $"done uploading resource files to the file storage in {cloudDirectory} and this is it's uri {path}");

                return(path.ToString());
            }
        }
 public ImageAnalyzerService(inRiverContext context)
 {
     _utilityService = context.ExtensionManager.UtilityService;
     _dataService    = context.ExtensionManager.DataService;
     _cognitiveServicesTranslationService = new CognitiveServicesTranslationService(context);
     _ocrService = new CognitiveServicesImageOcrService(context);
 }
Exemple #4
0
 public DeleteUtility(Configuration deleteUtilConfig, inRiverContext context)
 {
     DeleteUtilConfig     = deleteUtilConfig;
     _context             = context;
     _epiApi              = new EpiApi(context);
     _epiElement          = new EpiElement(context);
     _channelPrefixHelper = new ChannelPrefixHelper(context);
 }
Exemple #5
0
 public RestEndpoint(string endpointAddress, string action, inRiverContext context)
 {
     this.action          = action;
     this.endpointAddress = this.ValidateEndpointAddress(endpointAddress);
     this.timeout         = 1;
     this.enableEndPoint  = true;
     _context             = context;
 }
Exemple #6
0
 public EpiDocument(inRiverContext context, Configuration configuration)
 {
     _context          = context;
     _epiElement       = new EpiElement(context);
     _channelHelper    = new ChannelHelper(context);
     _epiMappingHelper = new EpiMappingHelper(context);
     _configuration    = configuration;
     _epiApi           = new EpiApi(context);
 }
Exemple #7
0
 public CvlUtility(Configuration cvlUtilConfig, inRiverContext inRiverContext)
 {
     CvlUtilConfig     = cvlUtilConfig;
     _context          = inRiverContext;
     _epiElement       = new EpiElement(inRiverContext);
     _epiMappingHelper = new EpiMappingHelper(inRiverContext);
     _businessHelper   = new BusinessHelper(_context);
     _epiDocument      = new EpiDocument(_context, cvlUtilConfig);
     _channelHelper    = new ChannelHelper(_context);
     _epiApi           = new EpiApi(_context);
 }
Exemple #8
0
        public void TestInitialize()
        {
            Logger = new Logger(TestContext);
            Logger.Log(LogLevel.Information, $"Initialize connection to inRiver Server");

            // todo: add your inRiver username, password and environment here
            InRiverContext = new inRiverContext(
                RemoteManager.CreateInstance(_partnerRemotingUrl,
                                             "***", "***", "***"), Logger);

            Assert.IsNotNull(InRiverContext?.ExtensionManager, "Connection to inRiver failed. Please check the url and credentials within the test initialize method.");
        }
        public List <string> PeakAllMessages(string connectorId, inRiverContext Context)
        {
            List <ConnectorState> states = Context.ExtensionManager.UtilityService.GetAllConnectorStatesForConnector(connectorId);

            if (!states.Any())
            {
                return(new List <string>());
            }

            List <string> messages = states.Select(s => JsonConvert.DeserializeObject <string>(s.Data)).ToList();

            return(messages);
        }
Exemple #10
0
        public Configuration(inRiverContext context)
        {
            _context           = context;
            settings           = context.Settings;
            LinkTypes          = new List <LinkType>(context.ExtensionManager.ModelService.GetAllLinkTypes());
            epiFieldsIninRiver = new List <string> {
                "startdate", "enddate", "displaytemplate", "seodescription", "seokeywords", "seotitle", "seouri", "skus"
            };
            ChannelStructureEntities = new List <StructureEntity>();
            ChannelEntities          = new Dictionary <int, Entity>();

            context.Log(LogLevel.Debug, $"A new instance of {GetType().FullName} was created.");
        }
Exemple #11
0
        public void TestInitialize()
        {
            Logger = new Logger(TestContext);
            Logger.Log(LogLevel.Information, $"Initialize connection to inRiver Server");

            // Customer: https://remoting.productmarketingcloud.com
            // Sandbox:  https://partner.remoting.productmarketingcloud.com

            // todo: add your inRiver username, password and environment here
            InRiverContext = new inRiverContext(
                RemoteManager.CreateInstance("https://partner.remoting.productmarketingcloud.com",
                                             "***", "***", "***"), Logger);

            Assert.IsNotNull(InRiverContext, "Login failed ??");
        }
Exemple #12
0
        public RestEndpoint(Dictionary <string, string> settings, string action, inRiverContext context)
        {
            this._context           = context;
            this.action             = action;
            this.settingsDictionary = settings;

            if (settings.ContainsKey("EPI_APIKEY"))
            {
                this.apikey = settings["EPI_APIKEY"];
            }
            else
            {
                throw new ConfigurationErrorsException("Missing EPI_APIKEY setting on connector. It needs to be defined to else the calls will fail. Please see the documentation.");
            }

            if (settings.ContainsKey("EPI_ENDPOINT_URL") == false)
            {
                throw new ConfigurationErrorsException("Missing EPI_ENDPOINT_URL setting on connector. It should point to the import end point on the EPiServer Commerce web site. Please see the documentation.");
            }

            this.endpointAddress = this.ValidateEndpointAddress(settings["EPI_ENDPOINT_URL"]);

            if (settings.ContainsKey("EPI_RESTTIMEOUT"))
            {
                string timeoutString = settings["EPI_RESTTIMEOUT"];
                if (!int.TryParse(timeoutString, out this.timeout))
                {
                    throw new ConfigurationErrorsException("Can't parse EPI_RESTTIMEOUT : " + timeoutString);
                }
            }
            else
            {
                throw new ConfigurationErrorsException("Missing EPI_RESTTIMEOUT setting on connector. It needs to be defined to else the calls will fail. Please see the documentation.");
            }

            this.enableEndPoint = true;
            if (settings.ContainsKey("ENABLE_EPI_ENDPOINT"))
            {
                string valueEnableEPIEndpoint = settings["ENABLE_EPI_ENDPOINT"];

                if (!string.IsNullOrEmpty(valueEnableEPIEndpoint))
                {
                    this.enableEndPoint = bool.Parse(valueEnableEPIEndpoint);
                }
            }
        }
        private IInboundDataExtension CreateExtension()
        {
            string mappingConfiguration = TestFiles.FieldMapping;

            IinRiverManager inRiverManager = new FakeInRiverManager();

            inRiverContext context = new inRiverContext(inRiverManager, _extensionLog);

            context.Settings = new Dictionary <string, string>
            {
                { "MAPPING_CONFIGURATION_XML", mappingConfiguration }
            };

            IInboundDataExtension inboundDataExtension = new MappedInboundExtension();

            inboundDataExtension.Context = context;

            return(inboundDataExtension);
        }
Exemple #14
0
        private static XDocument VerifyAndCorrectDocument(XDocument doc, inRiverContext context)
        {
            List <string> unwantedEntityTypes = CreateUnwantedEntityTypeList(context);
            XDocument     result = new XDocument(doc);
            XElement      root   = result.Root;

            if (root == null)
            {
                throw new Exception("Can't verify the Catalog.cml as it's empty.");
            }

            IEnumerable <XElement> entryElements    = root.Descendants("Entry");
            List <string>          codesToBeRemoved = new List <string>();

            foreach (XElement entryElement in entryElements)
            {
                string code          = entryElement.Elements("Code").First().Value;
                string metaClassName =
                    entryElement.Elements("MetaData").Elements("MetaClass").Elements("Name").First().Value;

                if (unwantedEntityTypes.Contains(metaClassName))
                {
                    context.Log(
                        LogLevel.Debug,
                        string.Format("Code {0} will be removed as it has wrong metaclass name ({1})", code, metaClassName));
                    codesToBeRemoved.Add(code);
                }
            }

            foreach (string code in codesToBeRemoved)
            {
                string theCode = code;
                root.Descendants("Entry").Where(
                    e =>
                {
                    XElement codeElement = e.Element("Code");
                    return(codeElement != null && codeElement.Value == theCode);
                }).Remove();
            }

            return(result);
        }
Exemple #15
0
        public Registry(inRiverContext inRiverContext)
        {
            // inRiver Context
            For <inRiverContext>().Use(inRiverContext);

            // Bynder API Client
            For <IBynderClient>().Use <BynderClient>();

            // Bynder API Client configuration
            For <BynderClientSettings>().Use(BynderClientSettings.Create(inRiverContext.Settings));

            // file name evaluator
            For <FilenameEvaluator>().Use <FilenameEvaluator>();

            // auto add the workers
            Scan(x =>
            {
                x.TheCallingAssembly();
                x.AddAllTypesOf <IWorker>().NameBy(type => type.Name);
            }
                 );
        }
Exemple #16
0
        private static List <string> CreateUnwantedEntityTypeList(inRiverContext context)
        {
            List <string> typeIds = new List <string>
            {
                "Channel",
                "Assortment",
                "Resource",
                "Task",
                "Section",
                "Publication"
            };
            List <string> result = new List <string>();

            foreach (string typeId in typeIds)
            {
                List <FieldSet> fieldSets = context.ExtensionManager.ModelService.GetFieldSetsForEntityType(typeId);
                if (!fieldSets.Any())
                {
                    if (!result.Contains(typeId))
                    {
                        result.Add(typeId);
                    }

                    continue;
                }

                foreach (FieldSet fieldSet in fieldSets)
                {
                    string value = string.Format("{0}_{1}", typeId, fieldSet.Id);
                    if (!result.Contains(value))
                    {
                        result.Add(value);
                    }
                }
            }

            return(result);
        }
 public ResourceMetapropertyUpdateWorker(inRiverContext inRiverContext, IBynderClient bynderClient)
 {
     _inRiverContext = inRiverContext;
     _bynderClient   = bynderClient;
 }
Exemple #18
0
 public AzureEnvironmentInfo(inRiverContext context)
 {
     this.AzureStorageConnection = context?.Settings?[ConnectorSettings.AzureStorageConnection];
     this.AzureEndpointUrl       = context?.Settings?[ConnectorSettings.AzureEndpointUrl];
     this.AzureContainer         = context?.Settings?[ConnectorSettings.AzureContainer];
 }
Exemple #19
0
 internal MappingHelper(inRiverContext context)
     : base(context)
 {
     this.Context = context;
 }
Exemple #20
0
 public CognitiveServicesTranslationService(inRiverContext context)
 {
     _apiKey = context.ExtensionManager.UtilityService.GetServerSetting("CognitiveServicesTranslationService_ApiKey");
 }
Exemple #21
0
 public ModelValidationWorker(inRiverContext inRiverContext)
 {
     _inRiverContext = inRiverContext;
 }
Exemple #22
0
 public SchemaBasedChannelListener(inRiverContext context)
 {
     this.Context = context;
     initializeListener();
 }
 public AssetUploadWorker(inRiverContext inRiverContext, IBynderClient bynderClient = null)
 {
     _inRiverContext = inRiverContext;
     _bynderClient   = bynderClient;
 }
        static void Initialize()
        {
            _remoteManager = RemoteManager.CreateInstance("https://partner.remoting.productmarketingcloud.com", "*****@*****.**", "b6r1lLGMIClbiAKTlszG!");
            _logger        = new ConsoleLogger();
            _context       = new inRiverContext(_remoteManager, _logger);


            // Where can I find settings options? Are these just custom? https://servicecenter.inriver.com/hc/en-us/articles/360012462053-inRiver-Context

            /*Dictionary<string, string> settings = new Dictionary<string, string> {
             * { "clientID", "RY3WL3AR-RY3W" },
             * { "integrationUsername", "jratiniIntegration" },
             * { "userToken", "270bd80a61274300bd5f0ed19d2d5f69" },
             * { "aprimoTenant", "productstrategy1" },
             * { "entityTypeDAMFieldID", "e101ff8be98d404ca43daa3f01538c97" }, //inRiverEntityType
             * { "entityIDDAMFieldID", "6989a1abea754a3e887eaa8b0102c77b" }, // inRiverEntityID
             * { "resourceIDDAMFieldID", "c871793508d34d1a97b9aa86010ca90a" },
             * { "ResourceTitle", "Record Title" },
             * { "aprimoRecordIdFieldTypeID", "AprimoRecordId" },
             * { "aprimoResourceFromAprimoFieldTypeID", "ResourceFromAprimo" },
             * { "aprimoInRiverStatusFieldID", "6e6ff917-37ef-42d7-949e-aa8c013cb2fe" },
             * { "entityUniqueFieldsForIdentifying", "Product:ProductId;Item:ItemNumber;Channel:ChannelName" },
             * { "inRiverProductMetadataMapping", "SKU:4661dee1-b4c8-4575-afbf-aa8c00edcd84;Materials:ce349f4e-0995-46dd-8934-aa880121abd9;Price:b47a5ce7-a364-4b6f-9eb5-aa8c00ee3fe8" }
             * };*/

            Dictionary <string, string> InboundDataExtensionSettings = new Dictionary <string, string>
            {
                { "clientID", "RY3WL3AR-RY3W" },
                { "integrationUsername", "jratiniIntegration" },
                { "userToken", "270bd80a61274300bd5f0ed19d2d5f69" },
                { "aprimoTenant", "productstrategy1" },
                { "entityTypeDAMFieldID", "e101ff8be98d404ca43daa3f01538c97" }, //inRiverEntityType
                { "entityIDDAMFieldID", "7ac090e504944877ab4faa3f0153d467" },   // inRiverEntityID
                { "resourceIDDAMFieldID", "c871793508d34d1a97b9aa86010ca90a" },
                { "statusDAMFieldID", "6e6ff917-37ef-42d7-949e-aa8c013cb2fe" },
                { "ResourceTitle", "Record Title" },
                { "aprimoRecordIdFieldTypeID", "AprimoRecordId" },
                { "aprimoResourceFromAprimoFieldTypeID", "ResourceFromAprimo" },
                { "entityUniqueFieldsForIdentifying", "Product:ProductId;Item:ItemNumber;Channel:ChannelName" }
            };
            Dictionary <string, string> ListenerExtensionSettings = new Dictionary <string, string>
            {
                { "clientID", "RY3WL3AR-RY3W" },
                { "integrationUsername", "jratiniIntegration" },
                { "userToken", "270bd80a61274300bd5f0ed19d2d5f69" },
                { "aprimoTenant", "productstrategy1" },
                { "aprimoResourceFromAprimoFieldTypeID", "ResourceFromAprimo" },
                { "aprimoRecordIdFieldTypeID", "AprimoRecordId" },
                { "inRiverProductMetadataMapping", "SKU:4661dee1-b4c8-4575-afbf-aa8c00edcd84;Materials:ce349f4e-0995-46dd-8934-aa880121abd9;Price:b47a5ce7-a364-4b6f-9eb5-aa8c00ee3fe8" },
                { "inRiverItemMetadataMapping", "inRiverField1:aprimoField1" }
            };



            dataAPI = new DataAPI();
            //listener = new InRiverAprimoListener();

            dataAPI.Context = _context;
            //listener.Context = _context;

            dataAPI.Context.Settings = InboundDataExtensionSettings;
            //listener.Context.Settings = ListenerExtensionSettings;
        }
Exemple #25
0
 public ConnectorEventHelper(inRiverContext inRiverContext)
 {
     _context = inRiverContext;
 }
Exemple #26
0
 public AssetDeletedWorker(inRiverContext inRiverContext)
 {
     _inRiverContext = inRiverContext;
 }
Exemple #27
0
 public NonResourceMetapropertyWorker(inRiverContext inRiverContext, ResourceMetapropertyUpdateWorker resourceMetapropertyUpdateWorker)
 {
     _inRiverContext = inRiverContext;
     _resourceMetapropertyUpdateWorker = resourceMetapropertyUpdateWorker;
 }
 public AssetUsageUpdateWorker(inRiverContext inRiverContext, IBynderClient bynderBynderClient)
 {
     _inRiverContext     = inRiverContext;
     _bynderBynderClient = bynderBynderClient;
 }
Exemple #29
0
 public ChannelHelper(inRiverContext inRiverContext)
 {
     _context    = inRiverContext;
     _epiElement = new EpiElement(inRiverContext);
 }
Exemple #30
0
 public AssetUpdatedWorker(inRiverContext inRiverContext, IBynderClient bynderClient, FilenameEvaluator fileNameEvaluator)
 {
     _inRiverContext    = inRiverContext;
     _bynderClient      = bynderClient;
     _fileNameEvaluator = fileNameEvaluator;
 }