Thursday 23 August 2012

Step by step import with Data Migration Framework - AX 2012


Continuation to my previous article AX 2012 Data Migration Framework

In this article, we are Importing the LedgerGeneraljournal into AX 2012. 

Demo Files are available at:
C:\Program Files\Microsoft Dynamics AX 2012 Data Migration Framework (Beta)\DemoFiles









This is the beta release and therefore there will be bugs, issues and it’s not a complete offering. With that, when we start to look at the use of this framework, we must start with the types of sources we can work from. We do this from the Data Migration Framework > Setup > Source Data Formats. 

Apart from flat file, MS is planning to add Ax and ODBC types to the framework.





We can see that there are plans then for allowing both ODBC source types, as well as enabling AX-to-AX, source-to-target usage of this framework. Since this is file based on source types for the Data Migration Framework, out-of-the-box usage for the framework is limited. It’s powerful, and has a lot of great possible value, specifically when the AX and ODBC types are fully added. DMF is work well with the file sources, as I have tested and imported some of the data. If your source data is in flat files then you can start getting a lot of use from the framework.

1. Click on Data Migration Framework > Setup > Source data formats to set up your source data format.





2. Applications:  you can select your dimensions. The Dimension code lookup is a multiselection lookup (tick the selection box on the left of the lookup and ok).




3. Click on Data Migration Framework > Common > Processing group. Create a new record and give it a name and description



4. From the Processing group form, click on Entities.

Create a new record for the LedgerGeneraljournal. If we are selecting data from demo flat files, select the path in The Sample file path field or else you want to select (modify) the fields then leave The Sample file path field will be blank.




If you use the Demo files, then skip steps 5, 6 and 7. If you want to modify the columns, then do steps 5, 6 and 7, as it will ask you if you want to modify the existing file format.

5. Generate a sample file by clicking on Generate source file button. Follow the wizard and select the fields to import.







6. Then click the Generate sample file button. This will open up the sample file in notepad.
Click Finish when done.

7. Now fill in your data on the txt file.




8. Back on the main form click the Generate source mapping button. This will analyse the file and do the mapping between the file and the stagging table.

9. Now you can open and view the mapping by clicking on the Modify source mapping button.


It should looks something like this. The Source is your txt file and the Staging is your staging table in AX. If 
your source file is messed up, you should be able to see it here.



10. Now validate the setup by clicking the Validate button on the main form.

11. View target mapping. This is a mapping between the Staging to the Target table. This should already be predefined. You can however modify the mapping.


The Function options on the left. These are predefined methods in the class to allow you to execute business logic. The example below, when you pass in a string of dimensions A-B-C, the GenerateDefaultDimension function splits the string up and generates a DefaultDimension RecId.



12. When we check the Entities from, Click the Preview source file button. This loads up the file, to give you a preview of your file.




13. In Processing group form and click the Get staging data. This opens up a dialog with the processing group, click OK. You will then get this form.

Click on the Run to run client side or Click on Run on AOS to run server side. Usually, the user account doing the import wont have access to SQL integration servers. Use the second option and it will run under the service account. This should run and complete with out errors.






14. Now you can see the staging table by going to the Execution history from the Processing group form. From there you click the View staging data button. You can modify the staging data before you process it to the target.






15. To process to the target, click on the Copy data to target button. Follow the options to execute the process.





It’s done, Now the data has been migrated to AX 2012.

That's it for now... :) 



Saturday 18 August 2012

Importing Products into AX 2012 - Part 2


Product master and a related Product variant

Continuation of the Importing Products into AX2012 - Part 1, here I am posting the Create product master, dimensions, variants and release them to the particular company.






Create a product master and a related product variant

To create a product master, use the EcoResProductService.create operation. Then use the EcoResProductMasterDimValue.create operation to associate product dimension values with the product master. Finally, use the EcoResProductService.create operation again, this time to create a product variant.
 The code to create a product master is similar to the code that creates a distinct product. The primary difference is the code that associates the product master with a product dimension group (Size-Dim is given in below code).

Release products

A product must be released to a company before it can be used in that company. The ItemService and InventDimCombinationService services serve this purpose. The former can be used to release distinct products and product masters. The latter can be used to release product variants. A product master must be released before any of its product variants can be released.

Release product master

The only information required to release a product to a company is the ID of the product and the ID by which it will be represented in the company (ItemId). It is possible to add information to the ItemService service. In the following example, information about the units used for storage, purchasing, and selling is provided.

Release a product variant

A product variant can be released after a related product master has been released. When you release a product variant to a company, the product variant can be identified in two different ways:
•             Use the product number of the product variant.
•             Use the ID of the associated product master in the company (ItemId) and the InventDim structure, with the relevant fields set to the dimension values for the variant (the ItemId/InventDim approach).


Code:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ProcutMasterImport.ProductDataImportService;
using System.IO;
using System.Text.RegularExpressions;


namespace ProcutMasterImport
{
    public partial class Product : Form
    {
        internal static int ProdNumber = 0;
        internal static int Searchname = 1;
        internal static int ProdName = 2;
        internal static int StorageDimGroup = 3;
        internal static int SerialNumGroup = 4;
        internal static int InventUnitID = 5;
        internal static int PurchUnitID = 6;
        internal static int SalesUnitID = 7;
        internal static int ProdCompanyID = 8;
        internal static int ItemGroup = 9;
        internal static int ItemType = 10;
        internal static int InventoryModelGroup = 11;
        internal static int Baseprice = 12;
        //internal static int InventWareHouse   = 13;
        //internal static int PurchWareHouse    = 14;
        //internal static int SalesWareHouse    = 15;
        internal static int Itemsalestaxgroup_PO = 13;
        internal static int Itemsalestaxgroup_sales = 14;
        internal static int Priceunit_purch = 15;
        internal static int Dateofprice_purch = 16;
        internal static int Totaldiscount_purch = 17;
        internal static int Priceunit_inv = 18;
        internal static int Dateofprice_inv = 19;
        internal static int Priceunit_sales = 20;
        internal static int Dateofprice_sales = 21;
        internal static int Totaldiscount_sales = 22;



        //Master Data
        internal static int MasterProdNumber = 0;
        internal static int MasterSearchname = 2;
        internal static int MasterProdName = 3;
        internal static int DefaultColor = 5;
        internal static int DefaultConfig = 6;
        internal static int DefaultSiz = 7;
        internal static int BOMUnitID = 9;
        internal static int InputWeight = 24;
        internal static int ProductInstanceRelationType = 38; 
        internal static int Tareweight = 47;//Column Number in Excel = AV       
        internal static int TrackingDimGroupName = 49;
        internal static int MasterStorageDimGroup = 50;
        internal static int MasterProdDimGroup = 51;
        internal static int MasterLanguage = 52;
        internal static int MasterItemGroup = 53;
        internal static int MasterInventoryModelGroup = 54;
        internal static int MasterPriceunit_purch = 57;
        internal static int MasterPriceunit_sales = 58;
        internal static int MasterPriceunit_inv = 59;
        internal static int MasterItemsalestaxgroup_PO = 60;
        internal static int MasterItemsalestaxgroup_sales = 61;
        internal static int MasterProdCompanyID = 62;

        //Dim Import - Size
        internal static int MasterProdIDSize = 0;
        internal static int MasterProdSize = 1;
        internal static int MasterProdSizeName = 2;

        //Dim Import - Color
        internal static int MasterProdIDColor = 0;
        internal static int MasterProdColor = 1;
        internal static int MasterProdColorName = 2;

        //Dim Import - Config
        internal static int MasterProdIDConfig = 0;
        internal static int MasterProdConfig = 1;
        internal static int MasterProdConfigName = 2;

        //VariantaCreation
        internal static int MasterVariantID = 0;
        internal static int MasterVariantSearchname = 1;
        internal static int MasterVariantProdMaster = 2;
        internal static int MasterVariantName = 3;
        internal static int MasterVariantConfig = 4;
        internal static int MasterVariantSize = 5;
        internal static int MasterVariantColor = 6;
        internal static int MasterVariantCompanyID = 8;
        //internal static int MasterVariantConfigName = 9;
        //internal static int MasterVariantSizeName = 10;
        //internal static int MasterVariantColorName = 11;

        public static List<string[]> ParseCSVFile(string path, Boolean hasHeaders)
        {
            List<string[]> CSVRows = new List<string[]>();
            int rowNumber = 0;
            using (StreamReader inputFile = new StreamReader(path))
            {
                string line;
                string[] line1;

                while ((line = inputFile.ReadLine()) != null)
                {
                    String pattern = ",(?=(?:[^\"]*\"[^\"]*\")*(?![^\"]*\"))";
                    Regex r = new Regex(pattern);
                    line1 = r.Split(line);
                    if (hasHeaders != true || rowNumber != 0)
                    {
                        CSVRows.Add(line1);
                    }
                    rowNumber++;
                }
            }
            return CSVRows;
        }


        public Product()
        {
            InitializeComponent();
        }

     

                //                          //
        //Create a product master and a related product variant //
        //                          //
        static void createMaster(string[] _product)
        {
            //Boolean ismastercreated;

            //master definition
            AxdEntity_Product_EcoResProductMaster productMaster = new AxdEntity_Product_EcoResProductMaster()
            {
                DisplayProductNumber = _product[MasterProdNumber],
                ProductType = AxdEnum_EcoResProductType.Item,
                SearchName = _product[MasterSearchname]
            };
            productMaster.Translation = new AxdEntity_Translation[1];

            productMaster.Translation[0] = new AxdEntity_Translation()
            {
                LanguageId = "en-us",
                Name = _product[MasterProdName]
            };

            productMaster.Identifier = new AxdEntity_Identifier[1];
            productMaster.Identifier[0] = new AxdEntity_Identifier()
            {
                ProductNumber = _product[MasterProdNumber]
            };

            productMaster.ProductDimGroup = new AxdEntity_ProductDimGroup[1];
            productMaster.ProductDimGroup[0] = new AxdEntity_ProductDimGroup()
            {
                Product = _product[MasterProdNumber],
                ProductDimensionGroup = _product[MasterProdDimGroup]
            };

            productMaster.StorageDimGroup = new AxdEntity_StorageDimGroup[1];
            productMaster.StorageDimGroup[0] = new AxdEntity_StorageDimGroup()
            {
                Product = _product[MasterProdNumber], //"Bulb60W",
                StorageDimensionGroup = _product[MasterStorageDimGroup] //"Std-Dim"

            };


            productMaster.VariantConfigurationTechnology = AxdEnum_EcoResVariantConfigurationTechnologyType.PredefinedVariants;
            AxdEcoResProduct axdProduct = new AxdEcoResProduct()
            {
                Product = new AxdEntity_Product_EcoResProduct[1]
                {
                    productMaster
                }
            };

            CallContext ctx = new CallContext();
            EcoResProductServiceClient productService = new EcoResProductServiceClient();
            try
            {
                productService.create(ctx, axdProduct);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message);
                System.Console.ReadKey();
            }

        }



        //                          //
        ///master dimensions Size //
        //                          //
        static void createMasterDimension_Size(string[] _productDimsSize)
        {
            //master dimensions definition (two sizes, L and M)
            AxdEntity_MasterDim_EcoResProductMasterSize sizeDimensionL = new AxdEntity_MasterDim_EcoResProductMasterSize()
            {
                SizeProductMaster = _productDimsSize[MasterProdIDSize],
                Size = _productDimsSize[MasterProdSize], //"L",
                EcoResSize = new AxdEntity_EcoResSize[1]
                {
                    new AxdEntity_EcoResSize()
                    {
                        Name =  _productDimsSize[MasterProdSize] //"L"
                    }
                },
                Description = _productDimsSize[MasterProdSizeName],
                SizeProductDimensionAttribute = 3173
            };


            AxdEcoResProductMasterDimValue axdDimValue = new AxdEcoResProductMasterDimValue()
            {

                MasterDim = new AxdEntity_MasterDim_EcoResProductMasterDimensionValue[1]
                {
                    sizeDimensionL
                }
            };

            CallContext ctx = new CallContext();
            EcoResProductMasterDimValueServiceClient masterDimensionService = new EcoResProductMasterDimValueServiceClient();
            try
            {
                masterDimensionService.create(ctx, axdDimValue);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }



        //                          //
        ///master dimensions CONFIG definition (two sizes, L and M) //
        //                          //

        static void createMasterDimension_Config(string[] _productDimsConfig)
        {
            //master dimensions definition (two sizes, L and M)
            AxdEntity_MasterDim_EcoResProductMasterConfiguration ConfigDimensionL = new AxdEntity_MasterDim_EcoResProductMasterConfiguration()
            {
                EcoResConf = new AxdEntity_EcoResConf[1]
                {
                    new AxdEntity_EcoResConf()
                    {                        
                        Name = _productDimsConfig[MasterProdConfig]//_productDimsConfig[MasterProdConfigName]// "L"
                    }
                },
                ConfigProductMaster = _productDimsConfig[MasterProdIDConfig],
                Configuration = _productDimsConfig[MasterProdConfig],  //"L",               
                Description = _productDimsConfig[MasterProdConfigName],
                //AdditionalDescription = _productDimsConfig[MasterProdConfigName],
                ConfigProductDimensionAttribute = 3170
            };


            AxdEcoResProductMasterDimValue axdDimValue = new AxdEcoResProductMasterDimValue()
            {
                //SenderId = "3274",
                MasterDim = new AxdEntity_MasterDim_EcoResProductMasterDimensionValue[1]
                {                   
                    ConfigDimensionL//, ConfigDimensionM
                }

            };

            CallContext ctx = new CallContext();
            EcoResProductMasterDimValueServiceClient masterDimensionService = new EcoResProductMasterDimValueServiceClient();
            try
            {
                masterDimensionService.create(ctx, axdDimValue);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }


        //                          //
        ///master dimensions Size //
        //                          //
        static void createMasterDimension_Color(string[] _productDimsColor)
        {
            //master dimensions definition (two sizes, L and M)
            AxdEntity_MasterDim_EcoResProductMasterColor colorDimensionL = new AxdEntity_MasterDim_EcoResProductMasterColor()
            {
                ColorProductMaster = _productDimsColor[MasterProdIDColor],
                Color = _productDimsColor[MasterProdColor], //"L",
                EcoResColor = new AxdEntity_EcoResColor[1]
                {
                    new AxdEntity_EcoResColor()
                    {
                        Name =  _productDimsColor[MasterProdColor] //"L"
                    }
                },
                Description = _productDimsColor[MasterProdSizeName],
                ColorProductDimensionAttribute = 3169
            };


            AxdEcoResProductMasterDimValue axdDimValue = new AxdEcoResProductMasterDimValue()
            {

                MasterDim = new AxdEntity_MasterDim_EcoResProductMasterDimensionValue[1]
                {
                    colorDimensionL
                }
            };

            CallContext ctx = new CallContext();
            EcoResProductMasterDimValueServiceClient masterDimensionService = new EcoResProductMasterDimValueServiceClient();
            try
            {
                masterDimensionService.create(ctx, axdDimValue);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }


        //                          //
        ////product variant definition//
        //                          //
        static void createVariant(string[] _productVariant)
        {
            //product variant definition
            AxdEntity_Product_EcoResDistinctProductVariant productVariant = new AxdEntity_Product_EcoResDistinctProductVariant()
            {
                DisplayProductNumber = _productVariant[MasterVariantID], //"RunningShoeL",
                ProductType = AxdEnum_EcoResProductType.Item,
                SearchName = _productVariant[MasterVariantSearchname], //"RunningShoeL",
                ProductMaster = _productVariant[MasterVariantProdMaster] //"RunningShoe"
            };

            productVariant.Translation = new AxdEntity_Translation[1];
            productVariant.Translation[0] = new AxdEntity_Translation()
            {
                LanguageId = "en-us",
                Name = _productVariant[MasterVariantName] //"Comfortable running shoe L size"
            };

            productVariant.VariantDimValue = new AxdEntity_VariantDimValue_EcoResProductVariantDimensionValue[3];

            if (_productVariant[MasterVariantSize].ToString() != "")
            {
                productVariant.VariantDimValue[0] = new AxdEntity_VariantDimValue_EcoResProductVariantSize()
                {
                    DistinctProductVariant = _productVariant[MasterVariantID], //"RunningShoeL",
                    ProductDimensionAttribute = 3173,//The ID of the EcoResSize table
                    Size = _productVariant[MasterVariantSize], //"L",
                    EcoResSize = new AxdEntity_EcoResSize1[1]
                    {
                        new AxdEntity_EcoResSize1()
                        {
                            Name = _productVariant[MasterVariantSize] //"L"
                        }
                    }
                };
            }

            //added by imthiyaz - Color
            if (_productVariant[MasterVariantColor] != "")
            {
                productVariant.VariantDimValue[1] = new AxdEntity_VariantDimValue_EcoResProductVariantColor()
                {
                    DistinctProductVariant = _productVariant[MasterVariantID],
                    ProductDimensionAttribute = 3169,
                    Color = _productVariant[MasterVariantColor], //"L",
                    EcoResColor = new AxdEntity_EcoResColor1[1]
                {
                    new AxdEntity_EcoResColor1()
                    {
                        Name = _productVariant[MasterVariantColor]
                    }
                }
                };
            }

            //added by imthiyaz - Config
            if (_productVariant[MasterVariantConfig] != "")
            {
                productVariant.VariantDimValue[2] = new AxdEntity_VariantDimValue_EcoResProductVariantConfiguration()
                {
                    DistinctProductVariant = _productVariant[MasterVariantID],
                    ProductDimensionAttribute = 3170,
                    Configuration = _productVariant[MasterVariantConfig], //"L",
                    EcoResConf = new AxdEntity_EcoResConf1[1]
                {
                    new AxdEntity_EcoResConf1()
                    {
                        Name = _productVariant[MasterVariantConfig]
                    }
                }
                };
            }

            AxdEcoResProduct axdProduct = new AxdEcoResProduct()
            {
                Product = new AxdEntity_Product_EcoResProduct[1]
                {
                    productVariant
                }
            };

            CallContext ctx = new CallContext();
            EcoResProductServiceClient productService = new EcoResProductServiceClient();
            try
            {
                productService.create(ctx, axdProduct);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }


      

        //                          //
        ////Release a product master//
        //                          //

        private static void releaseMasterProduct(string[] _productRelease)
        {
            AxdEntity_InventTable inventTable = new AxdEntity_InventTable()
            {

                ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                Product = _productRelease[MasterProdNumber], //"Bulb60W",


                SalesPriceModelBasic = AxdEnum_SalesPriceModelBasic.PurchPrice, //(AxdEnum_SalesPriceModelBasic)Enum.Parse(typeof(AxdEnum_SalesPriceModelBasic), _productRelease[Baseprice]),//_product[Baseprice],
                //SerialNumGroupId = _productRelease[SerialNumGroup],

                Invent = new AxdEntity_Invent[1]
                {
                    new AxdEntity_Invent()
                    {
                        ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                        UnitId = _productRelease[MasterPriceunit_inv] //"Box"
                    }
                },
                Purch = new AxdEntity_Purch[1]
                {
                    new AxdEntity_Purch()
                    {
                        ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                        UnitId = _productRelease[MasterPriceunit_purch] //"Box"
                    }
                },
                Sales = new AxdEntity_Sales[1]
                {
                    new AxdEntity_Sales()
                    {
                        ItemId = _productRelease[MasterProdNumber], //"Bulb60W",
                        UnitId = _productRelease[MasterPriceunit_sales] //"Pcs"
                    }
                },

                InventModelGroupItem = new AxdEntity_InventModelGroupItem[1]
                {
                    new AxdEntity_InventModelGroupItem()
                    {                       
                        ModelGroupId = _productRelease[MasterInventoryModelGroup]
                    }
                },
                InventItemGroupItem = new AxdEntity_InventItemGroupItem[1]
                {
                    new AxdEntity_InventItemGroupItem()
                    {
                        ItemGroupId = _productRelease[MasterItemGroup]
                    }
                }

            };

           
            /*inventTable.StandardInventColorId = _productRelease[DefaultColor];
            inventTable.StandardConfigId = _productRelease[DefaultConfig];
            inventTable.StandardInventSizeId = _productRelease[DefaultSiz];*/
            //default size, color, config cvon't be aasuigned here

            inventTable.BOMUnitId = _productRelease[BOMUnitID];
            inventTable.NetWeight = Decimal.Parse(_productRelease[InputWeight]);
            inventTable.TaraWeightSpecified = true;
            inventTable.MetalTypeSpecified = true;
            inventTable.TaraWeight = Decimal.Parse(_productRelease[Tareweight]);
         
            AxdItem item = new AxdItem()
            {
                InventTable = new AxdEntity_InventTable[1]
                {
                    inventTable
                }
            };

            CallContext ctx = new CallContext()
            {
                Company = _productRelease[MasterProdCompanyID] //"DMO"
            };

            ItemServiceClient itemService = new ItemServiceClient();
            try
            {
                itemService.create(ctx, item);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }



        //                          //
        ///Use the ItemId/InventDim approach//
        //                          //      

        private static void releaseProductVariants2(string[] _productVariantRelease)
        {
            AxdEntity_InventDimCombination releasedVariant = new AxdEntity_InventDimCombination()
            {
                DistinctProductVariant = "",
                ItemId = _productVariantRelease[MasterVariantProdMaster],// "RunningShoe",
                InventDimId = "",
                InventDim = new AxdEntity_InventDim[1]
                {
                    new AxdEntity_InventDim()
                    {
                        InventSizeId = _productVariantRelease[MasterVariantSize], //"M",
                        InventColorId = _productVariantRelease[MasterVariantColor],
                        ConfigId = _productVariantRelease[MasterVariantConfig]
                    }
                }
            };

            AxdInventDimCombination inventDimCombination = new AxdInventDimCombination()
            {
                InventDimCombination = new AxdEntity_InventDimCombination[1]
                {
                    releasedVariant
                }
            };

            CallContext ctx = new CallContext()
            {
                Company = _productVariantRelease[MasterVariantCompanyID] //"DMO"
            };

            InventDimCombinationServiceClient inventDimCombinationService = new InventDimCombinationServiceClient();
            try
            {
                inventDimCombinationService.create(ctx, inventDimCombination);
            }
            catch (Exception e)
            {
                System.Console.WriteLine(e.Message); System.Console.ReadKey();
            }
        }


        private void ProductMaster_Click(object sender, EventArgs e)
        {
            List<string[]> ProdData = ParseCSVFile("D:\\ProductMasters.csv", true);
            foreach (string[] ProdMasterData in ProdData)
            {
                createMaster(ProdMasterData);
            }
        }

      
         private void CreateDims_Click(object sender, EventArgs e)
        {
            List<string[]> ProdDims_Size = ParseCSVFile("D:\\MasterDimSize.csv", true);

            foreach (string[] MasterDimensions_Size in ProdDims_Size)
            {
                createMasterDimension_Size(MasterDimensions_Size);
            }

            List<string[]> ProdDims_Color = ParseCSVFile("D:\\MasterDimsColor.csv", true);

            foreach (string[] MasterDimensions_Color in ProdDims_Color)
            {
                createMasterDimension_Color(MasterDimensions_Color);
            }

            List<string[]> ProdData_Config = ParseCSVFile("D:\\MasterDimConfig.csv", true);

            foreach (string[] MasterDimensions_Config in ProdData_Config)
            {
                createMasterDimension_Config(MasterDimensions_Config);
            }
        }

        private void CreateVariants_Click(object sender, EventArgs e)
        {
            List<string[]> ProdData_Variants = ParseCSVFile("D:\\ProductMasterVariants.csv", true);

            foreach (string[] ProdMasterData_Variants in ProdData_Variants)
            {
                createVariant(ProdMasterData_Variants);

            }
        }

        private void ReleaseAll_Click(object sender, EventArgs e)
        {
            List<string[]> ProdMasterData_Rel = ParseCSVFile("D:\\ProductMasters.csv", true);

            foreach (string[] ProdMasterDataRelease in ProdMasterData_Rel)
            {
                releaseMasterProduct(ProdMasterDataRelease);//master products              
            }

        }

        private void ReleaseVariants_Click_1(object sender, EventArgs e)
        {
            List<string[]> ProdData_VariantsRel = ParseCSVFile("D:\\ProductMasterVariants.csv", true);

            foreach (string[] ProdMasterData_VariantsRel in ProdData_VariantsRel)
            {
                releaseProductVariants2(ProdMasterData_VariantsRel);
            }
        }
    }
}




Sample CSV: