Developer forum

Forum » Integration » Custom Destination Provider from Order Provider as source

Custom Destination Provider from Order Provider as source

Casper Andersen
Reply

Hi DynamicWeb

I am at the moment working on my own Destination provider and have gotten it to work more or less as i want it to.

But my problem at the moment, is that my provider uses the order provider as the source to get the orders, and when i set it up i tell the order provider to only get new orders, but when i run my custom provider, it takes all the orders,

I am grabbing my orders and order lines with this code

Mapping orders = job.Mappings.SingleOrDefault(x => x.SourceTable.Name == "EcomOrders");
Mapping orderLines = job.Mappings.SingleOrDefault(x => x.SourceTable.Name == "EcomOrderLines");

Any idea on what i am doing wrong ?


Replies

 
Dmitriy Benyuk
Reply

Hi Casper,
I quess you want to export "Export not yet exported Orders"? The flow for order provider is the following: it gets all the orders which have the OrderIsExported=0 and passes them to the OrderSourceReader. Only when the job is finished(when it has been run from the DataIntegration or from the Scheduled tasks) the exported orders are marked as exported, so OrderIsExported=1 for them. Have you used this flow from the web site with running the job?If yes, maybe there were some exceptions not catched in your RunJob() method.

For getting the orders and order lines from the source provider in your destination provider in the RunJob() method you can use the code like:

foreach(Mapping mapping in job.Mappings)
                {

                    if(mapping.Active && mapping.GetColumnMappings().Count > 0)
                    {
                        //Logger.Log("Importing data to table: " + mapping.DestinationTable.Name);

                        using(var reader = job.Source.GetReader(mapping))
                        {
                            while (!reader.IsDone())
                            {
                                sourceRow = reader.GetNext();
                                // do the stuff in your Destination writer/provider to import the data
                                writer.Write(sourceRow, mapping);
                            }
                        }
                    }                    
                }
Also, here is a sample code for the custom providers

Regards, Dmitrij

 

You must be logged in to post in the forum