Loading...
Area: Episerver B2B Commerce

DataSet table and column names

Recommended reading 

Many times integration jobs will use a DataSet to store data in memory. These data sets are used for a variety of purposes, including to load data from Epi B2B Commerce before a job begins and report data back to Epi B2B Commerce from an external system, like an ERP. The processors that operate on this data rely on specific names for the tables and columns within the data sets. Epi B2B Commerce provides a class that holds all of these table and column names so that processors don't need to repeat the same names and reference the correct tables and columns. Below is an excerpt from that class along with a few of the many properties that hold the table and column names.

Code Sample: Class Example Excerpt

public class Data
{
    public static string CustomerSubmitTable = "CustomerSubmit";
 
    public static string OrderSubmitTable = "OrderSubmit";
 
    public static string ErpCustomerNumberColumn = "ErpCustomerNumber";
 
    public static string ErpCustomerSequenceColumn = "ErpCustomerSequence";
 
    // ...
}

All of the tables and column names shown above are used by the JobPostprocessorProcessSubmitResponse postprocessor when processing the response from an order submission. Below is an excerpt from that postprocessor that updates the Customer table within Epi B2B Commerce using the customer sequence and number from the ERP response.

Code Sample: JobPostprocessorProcessSubmitResponse Excerpt

protected virtual void ProcessCustomerSubmit(DataSet dataSet)
{
    if (dataSet.Tables.Contains("CustomerSubmit"))
    {
        var customerNumber = dataSet.Tables["CustomerSubmit"].Rows[0]["CustomerNumber"].ToString();
        var customerSequence = dataSet.Tables["CustomerSubmit"].Rows[0]["CustomerSequence"].ToString();
        var erpCustomerNumber = dataSet.Tables["CustomerSubmit"].Rows[0]["ErpCustomerNumber"].ToString();
        var erpCustomerSequence = dataSet.Tables["CustomerSubmit"].Rows[0]["ErpCustomerSequence"].ToString();
 
        // if nothing on the customer table changed, no need to update
        if (customerNumber.Equals(erpCustomerNumber, StringComparison.OrdinalIgnoreCase)
            && customerSequence.Equals(erpCustomerSequence, StringComparison.OrdinalIgnoreCase))
        {
            this.JobLogger.Info(LoggingMessages.CustomerInfoUnchanged.FormatWith(new { customerNumber, customerSequence }));
        }
        else
        {
            // find the customer on our tables via the CustomerNumber and CustomerSequence and Update its
            // ErpNumber and CustomerSequence to what is returned from the Customer Submit.
            var customer = this.UnitOfWork.GetRepository<Customer>().GetTable()
                .FirstOrDefault(c => c.CustomerNumber.Equals(customerNumber, StringComparison.OrdinalIgnoreCase)
                                        && c.CustomerSequence.Equals(customerSequence, StringComparison.OrdinalIgnoreCase));
            if (customer == null)
            {
                this.JobLogger.Info(LoggingMessages.InvalidCustomer.FormatWith(new { customerNumber, customerSequence }));
            }
            else
            {
                customer.ErpNumber = erpCustomerNumber;
                customer.ErpSequence = erpCustomerSequence;
 
                this.JobLogger.Info(LoggingMessages.UpdatingCustomer.FormatWith(new { customerNumber, customerSequence, erpCustomerNumber, erpCustomerSequence }));
            }
        }
    }
}

Do you find this information helpful? Please log in to provide feedback.

Last updated: Dec 11, 2020

Recommended reading