Developer forum

Forum » Integration » Custom destination provider, inheriting from the Dynamicweb provider

Custom destination provider, inheriting from the Dynamicweb provider

Keld Lauge Gøtterup
Reply

I am trying to make some changes to the imported data when using batch integration.
 

ive been trying to make custom provider that inherits the DW provider but this doesn't seem to work.

Im having the same problem as this poster
http://developer.dynamicweb-cms.com/forum/development/how-to-use-actitivity-in-data-integration.aspx#Reply35939

 

 


Replies

 
Jonas Krarup Dam
Reply
This post has been marked as an answer

Hi Keld,

 

you can avoid the error by adding constructors as follows (Assuming your provider is called MyProvider:

        public MyProviderXmlNode xmlNode):base(xmlNode)
        {
           
        }

 

This is needed in order to allow our ConfigurableAddin functionality to instanciate the providers, based on the content of an XML configuration file.

 

Regards, Jonas

Votes for this answer: 1
 
Keld Lauge Gøtterup
Reply

that helped with the initial problem but now i get a nullreference error.


it doesn't seem to enter the RunJob method, and it doesn't give an error when its commmented out.




using System;

using System.Collections.Generic;

using System.Xml;

using Dynamicweb.Data.Integration;

using Dynamicweb.Data.Integration.Interfaces;

using Dynamicweb.Extensibility;

using Dynamicweb.Data.Providers;

using System.Data.SqlClient;

 

namespace Dynamicweb.eCommerce.LiveIntegration

{

    //AddInName attribute required in order to make the source show up in the GUI

    [AddInName("My.Custom.CustomDWDestinationProvider"), AddInLabel("My example destination provider"), AddInDescription("My example destination provider")]

    public class CustomDWDestinationProvider : DynamicwebProvider, IDestination

    {

 

 

        public CustomDWDestinationProvider()

            : base()

        {

 

        }

        public CustomDWDestinationProvider(string connectionString)

            : base(connectionString)

                         {}

        public CustomDWDestinationProvider(XmlNode xmlNode)

            : base(xmlNode)

                         {

                         }

 

        public override bool RunJob(Job job, string logFile)

        {

            try

            {

                Logger.Log("Custom Provider");

                var importSuccess = base.RunJob(job, logFile);

 

                var success = false;

 

                if (importSuccess)

                {

                    Logger.Log("Starting cleaning of imported data");

 

                    foreach (Dynamicweb.eCommerce.Products.Group gr in Dynamicweb.eCommerce.Products.Group.GetAllGroups())

                    {

                        gr.Description = Helpers.CleanContent(gr.Description);

                    }

 

                    success = true;

                    Logger.Log("Finished cleaning of imported data");

                }

            }

            catch (Exception ex)

            {

                Logger.Log("Import job failed: " + ex.Message);

                return false;

            }

       

            return true;

        }

 

 

    }

 

 

}

 

 

 

 

 

Log:

http://danishagro.net.dynamicweb-cms.com/Admin/Images/x.gif Tid

http://danishagro.net.dynamicweb-cms.com/Admin/Images/Ribbon/UI/List/column_menu.png

http://danishagro.net.dynamicweb-cms.com/Admin/Images/x.gif Besked

http://danishagro.net.dynamicweb-cms.com/Admin/Images/x.gif 

11-08-2014 16:08:57

Batch failed.

 

11-08-2014 16:08:57

Finished job - ErpDataImportV2.

 

11-08-2014 16:08:57

Error occured: Object reference not set to an instance of an object.

 

11-08-2014 16:08:33

reading configuration

 

11-08-2014 16:08:32

Starting job - ErpDataImportV2.

 

11-08-2014 16:08:31

Starting batch

 

 

 
Jonas Krarup Dam
Reply

Hi Keld,

 

In order to use the logging, you have to initialize it as the first thing in runJob - simply add this line:

SetupLogging(logFile);

 

Regards, Jonas

 

You must be logged in to post in the forum