protected override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_isWorkerExecuted)
            {
                return;
            }

            // set the flag the this bw_DoWork has already called
            _isWorkerExecuted = true;
            var totalProcessed = 0;
            var affectedRows   = 0;

            // parsed the vendor product data from the file
            var shippingRates = new List <ShippingRateDB>();
            var message       = CsvFileDataParser.ParseShippingRateFile(_systemJob.Parameters, shippingRates, _systemJob.HasHeader);

            // get the total items and update the system job status
            var totalItems = shippingRates.Count;

            setTotalItemsProcessed(totalItems);
            _logger.LogInfo(LogEntryType.ShippingRateFileUploadWorker, string.Format("Uploading {0} shipping rates initiated by {1}", totalItems, _systemJob.SubmittedBy));

            foreach (var item in shippingRates)
            {
                totalProcessed++;
                var percentage = (((double)totalProcessed) / totalItems) * 100.00;

                affectedRows += _repository.DoUpadateOrInsertShippingRate(item, _systemJob.IsAddNewItem);

                _bw.ReportProgress(affectedRows);
                Console.WriteLine(string.Format("{1:#0.00}% Updating/Inserting shipping rate ID: {0}", item.Id, percentage));
            }
        }
        public override bool Execute()
        {
            try
            {
                Logger.LogInfo(LogEntryType.OrderService, "Started parsing the order  inventory file.");

                TaskRepository taskRepo = new TaskRepository();
                var            currentTaskAlreadyImportedFiles = taskRepo.GetCurrentScheduleAlreadyImportFiles(_task.Id);
                var            ftpRequestor = new FtpWebRequestor(_task.FtpServer, _task.FtpUser, _task.FtpPassword, _task.FtpPort, _task.RemoteFolder);
                var            getFiles     = ftpRequestor.GetFileList(_task.FileType, _task.FileName);

                var fileNotImported = getFiles.Where(x => !currentTaskAlreadyImportedFiles.Any(y => y.FileName.ToLower() == x.ToLower())).ToList();

                OrderRepository orderRepo;
                foreach (var file in fileNotImported)
                {
                    var orders = new List <Order>();
                    orderRepo = new OrderRepository();

                    var fileOrderItems = CsvFileDataParser.GetOrderItems(ftpRequestor.GetFileStreamReader(file), _task.HasHeader, _task.FileHeaders, _task.CustomFields);
                    var fileOrders     = CsvFileDataParser.ParseOrderFile(ftpRequestor.GetFileStreamReader(file), orders, fileOrderItems, _task.HasHeader, _task.FileHeaders, _task.CustomFields);

                    List <Order> importedOrder = new List <Order>();
                    foreach (var order in orders)
                    {
                        if (importedOrder.Count == 0)
                        {
                            importedOrder.Add(order);
                            orderRepo.ManageOrders(order);
                        }
                        else if (importedOrder.Count > 0)
                        {
                            var isImported = importedOrder.Any(x => x.OrderId == order.OrderId);
                            if (!isImported)
                            {
                                importedOrder.Add(order);
                                orderRepo.ManageOrders(order);
                            }
                        }
                    }
                }

                taskRepo.ManageImportFileSchedule(fileNotImported, _task.Id);

                Logger.LogInfo(LogEntryType.OrderService, "Successfully parsed the order inventory file.");
                return(true);
            }
            catch (Exception ex)
            {
                Logger.LogError(LogEntryType.FileInventoryTaskService,
                                "Error in parsing the import inventory file! Message: " + EisHelper.GetExceptionMessage(ex), ex.StackTrace);
                return(false);
            }
        }
Example #3
0
        //[TestMethod]
        public void ShouldParseShadowsSKU()
        {
            //Arrange
            var filePath = "D:\\logs\\Supplier Files\\Shadow_Upload_Template.csv";
            var shadows  = new List <Shadow>();


            //Act
            var result = CsvFileDataParser.ParsedShadowFile(filePath, shadows, true);


            //Assert
            //Assert.IsTrue(result.IsSucess);
            //Assert.IsTrue(!shadows.Select(o => o.FactorQuantity).Contains(0));
        }
        protected override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_isWorkerExecuted)
            {
                return;
            }

            // set the flag the this bw_DoWork has already called
            _isWorkerExecuted = true;

            // parsed and get the shadows info from the file
            var shadows      = new List <Shadow>();
            var message      = CsvFileDataParser.ParsedShadowFile(_systemJob.Parameters, shadows, _systemJob.HasHeader);
            var affectedRows = 0;

            // log the total records to be processed
            var totalRecords = shadows.Count;

            setTotalItemsProcessed(totalRecords);
            _logger.LogInfo(LogEntryType.ShadowFileUploadWorker, string.Format("Uploading {0} shadow products initiated by {1}", totalRecords, _systemJob.SubmittedBy));

            // iterate to the parsed shadow products and insert into the database
            foreach (var shadow in shadows)
            {
                // do update or insert new product
                var hasShadowProduct = doInsertOrUpdateProduct(shadow, _systemJob.IsAddNewItem);

                if (hasShadowProduct)
                {
                    // do insert or update shadow
                    doInsertOrUpdateShadow(shadow, _systemJob.IsAddNewItem);

                    // do insert or update productamazon
                    if (!string.IsNullOrEmpty(shadow.Asin))
                    {
                        doInsertOrUpdateAmazon(shadow, _systemJob.IsAddNewItem);
                    }

                    affectedRows++;
                }

                // log the progress
                _bw.ReportProgress(affectedRows);
                var percentage = (((double)affectedRows) / totalRecords) * 100.00;
                Console.WriteLine(string.Format("{1:#0.00}% Updating Shadow product for ParentSKU: {0}", shadow.ParentSKU, percentage));
            }
        }
        protected override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_isWorkerExecuted)
            {
                return;
            }

            // set the flag the this bw_DoWork has already called
            _isWorkerExecuted = true;

            // parsed and get the blacklisted skus info from the file
            var blackListedProducts = new List <BlacklistedSkuDto>();
            var message             = CsvFileDataParser.ParsedSKUFile(_systemJob.Parameters, blackListedProducts, _systemJob.HasHeader);
            var affectedRows        = 0;

            // log the total records to be processed
            var totalRecords = blackListedProducts.Count;

            setTotalItemsProcessed(totalRecords);
            _logger.LogInfo(LogEntryType.BlacklistedSKUFileUploadWorker, string.Format("Uploading {0} blacklisted sku initiated by {1}", totalRecords, _systemJob.SubmittedBy));

            // let's do the update the products first which is IsBlacklisted is TRUE
            var blacklistedProducts = blackListedProducts
                                      .Where(x => x.IsBlacklisted)
                                      .Select(x => x.EisSKU)
                                      .ToList();

            // update it first
            affectedRows += _repository.UpdateProductsBlacklistedStatus(blacklistedProducts, true, _systemJob.SubmittedBy);
            reportProgress(affectedRows, totalRecords);

            // then the unblacklisted products
            var unBlacklistedProducts = blackListedProducts
                                        .Where(x => !x.IsBlacklisted)
                                        .Select(x => x.EisSKU)
                                        .ToList();

            // update it
            affectedRows += _repository.UpdateProductsBlacklistedStatus(unBlacklistedProducts, false, _systemJob.SubmittedBy);
            reportProgress(affectedRows, totalRecords);
        }
Example #6
0
        protected override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_isWorkerExecuted)
            {
                return;
            }

            // set the flag the this bw_DoWork has already called
            _isWorkerExecuted = true;

            // get the Kit details
            var kitDetails = new List <KitDetailDto>();
            var message    = CsvFileDataParser.ParsedKitFile(_systemJob.Parameters, kitDetails, _systemJob.HasHeader);

            // log the total records to be processed
            var totalRecords = kitDetails.Count;

            setTotalItemsProcessed(totalRecords);
            _logger.LogInfo(LogEntryType.KitFileUploadWorker, string.Format("Uploading {0} kit details initiated by {1}", totalRecords, _systemJob.SubmittedBy));

            var affectedRows = 0;

            using (var connection = new MySqlConnection(_connectionString))
            {
                // get the unique parent's SKU
                var parentSKUs = kitDetails.Select(x => x.ParentKitSKU).Distinct();

                var command = new MySqlCommand("sp_updateKitComponents");
                command.CommandType = CommandType.StoredProcedure;

                // iterate to to the unique parent SKUs and update its kit details
                foreach (var parentSku in parentSKUs)
                {
                    if (string.IsNullOrEmpty(parentSku))
                    {
                        continue;
                    }

                    // open the connection if is not open yet
                    if (connection.State != ConnectionState.Open)
                    {
                        connection.Open();
                    }

                    // clear first the paramerters
                    command.Parameters.Clear();
                    command.Connection = connection;

                    var components = kitDetails.Where(x => x.ParentKitSKU == parentSku);
                    command.Parameters.Add(new MySqlParameter("@parent_kit_sku", parentSku));
                    command.Parameters.Add(new MySqlParameter("@child_kit_skus", string.Join("|", components.Select(x => x.ChildKitSKU))));

                    command.Parameters.Add(new MySqlParameter("@affected_rows", MySqlDbType.Int32));
                    command.Parameters["@affected_rows"].Direction = ParameterDirection.Output;

                    // execute the stored procedure
                    command.ExecuteNonQuery();

                    // get the affected rows
                    var retValue = (int)command.Parameters["@affected_rows"].Value;
                    affectedRows += retValue;

                    // log the progress
                    _bw.ReportProgress(affectedRows);
                    var percentage = (((double)affectedRows) / totalRecords) * 100.00;
                    Console.WriteLine(string.Format("{1:#0.00}% Updating Kit components for ParentKitSKU: {0}", parentSku, percentage));
                }
            }
        }
Example #7
0
        public override bool Execute()
        {
            var product = new List <Product>();

            string fileUrl = string.Format("{0}\\{1}\\{2}\\{3}",
                                           _exportedFileFolder,
                                           _subFolderName,
                                           _task.CustomerId,
                                           _task.ImportFileName);

            var streamFileRead = new StreamReader(fileUrl);

            CsvFileDataParser.ParseCustomerWholeSalePriceSkuFile(streamFileRead, product, _task.HasHeader, _task.FileHeaders, _task.CustomFields);

            if (product.Count == 0)
            {
                return(true);
            }

            var skuList = product.Select(x => x.EisSKU).ToList();

            var customer = GetCustomer(_task.CustomerId);

            var productList = GetProductFromEisSkuList(skuList);

            Console.WriteLine("Creating {0} file -> {1}", TaskType, _generatedFile);

            using (var streamWriter = new StreamWriter(_generatedFile))
            {
                var      csvWriter   = new CsvWriter(streamWriter);
                string[] fileHeaders = { "EisSku", "Price" };

                foreach (var header in fileHeaders)
                {
                    csvWriter.WriteField(header);
                }

                csvWriter.NextRecord();

                foreach (var item in productList)
                {
                    string  eisSku = item.EisSKU;
                    decimal?price  = 0;

                    if (customer.AccountType == (int)CustomerAccountTypeEnum.Retail)
                    {
                        price = item.SellerPrice;
                    }
                    else
                    {
                        if (customer.CostPlusBasedWholeSalePriceType == (int)CostPlusBasedWholeSalePriceTypeEnum.SellingPrice)
                        {
                            price = CalculatePrice(item.SellerPrice, (int)customer.AmountType, (decimal)customer.CostPlusBasedWholeSalePrice);
                        }
                        else if (customer.CostPlusBasedWholeSalePriceType == (int)CostPlusBasedWholeSalePriceTypeEnum.SupplierPrice)
                        {
                            price = CalculatePrice(item.SupplierPrice, (int)customer.AmountType, (decimal)customer.CostPlusBasedWholeSalePrice);
                        }
                    }

                    csvWriter.WriteField(eisSku);
                    csvWriter.WriteField(price);

                    csvWriter.NextRecord();

                    SaveValuesInCustomerWholeSalePriceHistoryTable(item.EisSKU, customer.CustomerId, _task.Id, price.Value);
                }
            }
            Console.WriteLine("Done creating {0} file -> {1}", TaskType, _generatedFile);
            return(true);
        }
        protected override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_isWorkerExecuted)
            {
                return;
            }

            // set the flag the this bw_DoWork has already called
            _isWorkerExecuted = true;
            var totalProcessed = 0;
            var affectedRows   = 0;

            // parsed the vendor product data from the file
            var vendorProducts = new List <VendorProduct>();
            var message        = CsvFileDataParser.ParseVendorInventoryFile(_systemJob.Parameters, vendorProducts, _systemJob.HasHeader);

            try
            {
                if (vendorProducts.Count == 0)
                {
                    Console.WriteLine("0 records to update vendor inventory products");
                    _jobRepository.UpdateSystemJobStatus(_systemJob.Id, JobStatus.Completed);
                    return;
                }
                int selectedVendorId = Convert.ToInt32(supportiveParameters["selectedVendor"]);
                if (Convert.ToBoolean(supportiveParameters["inventoryZero"]))
                {
                    var vendorProductsList = _service.GetProductsByVendorId(selectedVendorId).Take(5).ToList();

                    var totalItems = vendorProductsList.Count;
                    setTotalItemsProcessed(totalItems);
                    _logger.LogInfo(LogEntryType.VendorProductFileUploadWorker, string.Format("Uploading {0} vendor inventory products initiated by {1}", totalItems, _systemJob.SubmittedBy));


                    var vendorProductsNotInList = vendorProductsList.Where(x => !vendorProducts.Any(y => y.VendorId == selectedVendorId && y.EisSupplierSKU == x.EisSupplierSKU)).
                                                  Select(x => new VendorProduct
                    {
                        Category       = x.Category,
                        Description    = x.Description,
                        EisSupplierSKU = x.EisSupplierSKU,
                        Quantity       = 0,
                        VendorId       = x.VendorId
                    }).ToList();


                    foreach (var vendorProduct in vendorProducts)
                    {
                        totalProcessed++;
                        var percentage = (((double)totalProcessed) / totalItems) * 100.00;

                        affectedRows += _service.DoUpdateVendorInventoryProduct(vendorProduct, selectedVendorId, _systemJob.SubmittedBy);

                        _bw.ReportProgress(affectedRows);
                        Console.WriteLine(string.Format("{1:#0.00}% Updating vendor products EisSupplierSKU: {0}", vendorProduct.EisSupplierSKU, percentage));
                    }

                    foreach (var vendorProduct in vendorProductsNotInList)
                    {
                        totalProcessed++;
                        var percentage = (((double)totalProcessed) / totalItems) * 100.00;

                        affectedRows += _service.DoUpdateVendorInventoryProduct(vendorProduct, selectedVendorId, _systemJob.SubmittedBy);

                        _bw.ReportProgress(affectedRows);
                        Console.WriteLine(string.Format("{1:#0.00}% Updating vendor products EisSupplierSKU: {0}", vendorProduct.EisSupplierSKU, percentage));
                    }
                }
                else
                {
                    var totalItems = vendorProducts.Count;
                    setTotalItemsProcessed(totalItems);
                    _logger.LogInfo(LogEntryType.VendorProductFileUploadWorker, string.Format("Uploading {0} vendor inventory products initiated by {1}", totalItems, _systemJob.SubmittedBy));

                    foreach (var vendorProduct in vendorProducts)
                    {
                        totalProcessed++;
                        var percentage = (((double)totalProcessed) / totalItems) * 100.00;

                        affectedRows += _service.DoUpdateVendorInventoryProduct(vendorProduct, selectedVendorId, _systemJob.SubmittedBy);

                        _bw.ReportProgress(affectedRows);
                        Console.WriteLine(string.Format("{1:#0.00}% Updating vendor inventory products EisSupplierSKU: {0}", vendorProduct.EisSupplierSKU, percentage));
                    }
                }
            }
            catch (DbEntityValidationException ex)
            {
                _hasError = true;
                _logger.LogError(LogEntryType.VendorProductFileUploadWorker, EisHelper.ParseDbEntityValidationException(ex), ex.StackTrace);
                _jobRepository.UpdateSystemJobStatus(_systemJob.Id, JobStatus.Failed);
            }
            catch (Exception ex)
            {
                _hasError = true;
                _logger.LogError(LogEntryType.VendorProductFileUploadWorker,
                                 string.Format("Error in uploading vendor inventory products. <br/> Error message: {0}", EisHelper.GetExceptionMessage(ex)),
                                 ex.StackTrace);
                _jobRepository.UpdateSystemJobStatus(_systemJob.Id, JobStatus.Failed);
            }

            _logger.LogInfo(LogEntryType.VendorProductFileUploadWorker, string.Format("{0} vendor inventory products have been successfully uploaded by {1}", totalProcessed, _systemJob.SubmittedBy));
        }
        protected override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_isWorkerExecuted)
            {
                return;
            }

            // set the flag the this bw_DoWork has already called
            _isWorkerExecuted = true;

            var eisProducts        = new List <Product>();
            var amazonProducts     = new List <ProductAmazon>();
            var eBayProducts       = new List <ProducteBayDto>();
            var bigCommerceProucts = new List <ProductBigCommerceDto>();
            var repository         = new ProductRepository(_logger);
            var affectedProducts   = 0;
            var isCreateNew        = _systemJob.IsAddNewItem;

            // get the Product and/or Amazon details from the file path
            var message = CsvFileDataParser.ParseProductFile(_systemJob.Parameters,
                                                             eisProducts,
                                                             amazonProducts,
                                                             eBayProducts,
                                                             bigCommerceProucts,
                                                             _systemJob.HasHeader);
            var defaultCompany = repository.GetDefaultCompany();
            var totalProducts  = eisProducts.Count;

            setTotalItemsProcessed(totalProducts);
            _logger.LogInfo(LogEntryType.ProductFileUploadWorker, string.Format("Uploading {0} products initiated by {1}", totalProducts, _systemJob.SubmittedBy));

            try
            {
                var retValue = 0;
                foreach (var eisProduct in eisProducts)
                {
                    // get the product EIS SKU
                    var eisSKU = eisProduct.EisSKU;
                    if (!isCreateNew && string.IsNullOrEmpty(eisSKU))
                    {
                        continue;
                    }

                    // update the EIS Product details if there's any
                    if (eisProduct.HasAnyChanges)
                    {
                        var isUpdate = true;
                        if (string.IsNullOrEmpty(eisSKU) && isCreateNew)
                        {
                            eisSKU   = repository.GetNextEisSKUForCompany(eisProduct.CompanyId);
                            isUpdate = false;
                        }

                        eisProduct.EisSKU = eisSKU;
                        retValue          = repository.DoUpadateOrInsertProduct(eisProduct, isUpdate, _systemJob.SubmittedBy);
                    }

                    // then update the Amazon product details, if there's any
                    var amazonModel = amazonProducts.FirstOrDefault(x => x.EisSKU == eisProduct.EisSKU);
                    if (amazonModel != null && amazonModel.HasAnyChanges)
                    {
                        // set the EIS SKU for the product Amzon
                        amazonModel.EisSKU = eisSKU;
                        retValue           = repository.DoUpdateOrInsertAmazon(amazonModel, _systemJob.SubmittedBy);
                    }

                    // update eBay product details, if there's any
                    var eBayModel = eBayProducts.FirstOrDefault(x => x.EisSKU == eisProduct.EisSKU);
                    if (eBayModel != null && eBayModel.HasAnyChanged)
                    {
                        // set the EIS SKU for the product eBay
                        eBayModel.EisSKU = eisSKU;
                        retValue         = repository.DoUpadateOrInserteBay(eBayModel, _systemJob.SubmittedBy);
                    }

                    // lastly, update the bigCommerce details, if there's any changed
                    var bigCommerce = bigCommerceProucts.FirstOrDefault(x => x.EisSKU == eisProduct.EisSKU);
                    if (bigCommerce != null && bigCommerce.HasAnyChanged)
                    {
                        // set the EIS SKU for this model
                        bigCommerce.EisSKU = eisSKU;
                        retValue           = repository.DoUpdateOrInsertBigCommerce(bigCommerce, _systemJob.SubmittedBy);
                    }

                    affectedProducts += retValue;
                    _bw.ReportProgress(affectedProducts);
                    var percentage = (((double)affectedProducts) / totalProducts) * 100.00;
                    Console.WriteLine(string.Format("{1:#0.00}% Updating EIS/Amazon Product EisSKU: {0}", eisProduct.EisSKU, percentage));
                }

                // close the repo db connection
                repository.CloseDbConnection();
            }
            catch (DbEntityValidationException ex)
            {
                _hasError = true;
                _logger.LogError(LogEntryType.ProductFileUploadWorker, EisHelper.ParseDbEntityValidationException(ex), ex.StackTrace);
                _jobRepository.UpdateSystemJobStatus(_systemJob.Id, JobStatus.Failed);
            }
            catch (Exception ex)
            {
                _hasError = true;
                _logger.LogError(LogEntryType.ProductFileUploadWorker,
                                 string.Format("Error in uploading products. <br/> Error message: {0}", EisHelper.GetExceptionMessage(ex)),
                                 ex.StackTrace);
                _jobRepository.UpdateSystemJobStatus(_systemJob.Id, JobStatus.Failed);
            }

            _logger.LogInfo(LogEntryType.ProductFileUploadWorker, string.Format("{0} products have been successfully uploaded by {1}", affectedProducts, _systemJob.SubmittedBy));
        }
Example #10
0
        protected override void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            if (_isWorkerExecuted)
            {
                return;
            }

            // set the flag the this bw_DoWork has already called
            _isWorkerExecuted = true;
            var totalProcessed = 0;
            var affectedRows   = 0;

            // parsed the vendor product data from the file
            var vendorProducts = new List <VendorProduct>();
            var message        = CsvFileDataParser.ParseVendorProductFile(_systemJob.Parameters, vendorProducts, _systemJob.HasHeader);

            // get the total items and update the system job status
            var totalItems = vendorProducts.Count;

            setTotalItemsProcessed(totalItems);
            _logger.LogInfo(LogEntryType.VendorProductFileUploadWorker, string.Format("Uploading {0} products initiated by {1}", totalItems, _systemJob.SubmittedBy));

            try
            {
                // iterate and do insert or update vendor product data
                foreach (var vendorProduct in vendorProducts)
                {
                    totalProcessed++;
                    var percentage = (((double)totalProcessed) / totalItems) * 100.00;

                    // get first the vendor product SKU
                    var eisSupplierSKU = _service.GetVendorProductSKU(vendorProduct);
                    vendorProduct.EisSupplierSKU = eisSupplierSKU;

                    // continue if it is not to create new item and its eisSupplierSKU is NULL
                    if (!_systemJob.IsAddNewItem && string.IsNullOrEmpty(eisSupplierSKU))
                    {
                        Console.WriteLine(string.Format("{1:#0.00}% No vendor product updated!", vendorProduct.EisSupplierSKU, percentage));
                        continue;
                    }

                    var isToUpdate = true;
                    if (string.IsNullOrEmpty(eisSupplierSKU))
                    {
                        // get the start SKU code for this vendor
                        var startSkuCode = _service.GetVendorStartSku(vendorProduct.VendorId);
                        vendorProduct.EisSupplierSKU = string.Format("{0}{1}", startSkuCode, vendorProduct.SupplierSKU.Trim());
                        isToUpdate = false;
                    }

                    // do insert or update vendor product
                    affectedRows += _service.DoUpadateOrInsertVendorProduct(vendorProduct, isToUpdate, _systemJob.SubmittedBy);
                    var uploadResultType = UploadResultType.NoChanges;
                    var newEisSKU        = string.Empty;

                    // the IsAutoLinkToEisSKU field from the vendor product is the highest precedendens over on the HasPostAction_2 and HasPostAction_1
                    if (vendorProduct.IsAutoLinkToEisSKUSet)
                    {
                        if (vendorProduct.IsAutoLinkToEisSKU)
                        {
                            // update the current link of this vendor product
                            uploadResultType = _service.UpdateEisProductLinks(vendorProduct.EisSupplierSKU, vendorProduct.UPC, vendorProduct.MinPack);
                        }
                        else
                        {
                            // delete the existing product links if there's any
                            _service.DeleteOldVendorProductLinks(vendorProduct.EisSupplierSKU, new List <string>());
                            uploadResultType = UploadResultType.DeletedLink;
                        }
                    }
                    else
                    {
                        // check first if we want to auto-link and create new EIS product if it doesn't exist
                        if (_systemJob.HasPostAction_2 && !string.IsNullOrEmpty(vendorProduct.UPC))
                        {
                            newEisSKU        = _service.AddLinkAndCreateEisProductIfNoMatchWithUPC(vendorProduct);
                            uploadResultType = string.IsNullOrEmpty(newEisSKU) ? UploadResultType.UpdatedItem : UploadResultType.NewItemCreated;
                        }

                        // check if there's a need to auto-link this vendor product with EIS product
                        if (_systemJob.HasPostAction_1 && !_systemJob.HasPostAction_2 && !string.IsNullOrEmpty(vendorProduct.UPC))
                        {
                            uploadResultType = _service.UpdateEisProductLinks(vendorProduct.EisSupplierSKU, vendorProduct.UPC, vendorProduct.MinPack);
                        }
                    }

                    // add the EisSupplierSKU for the upload result tracking
                    addUploadFileResult(vendorProduct.EisSupplierSKU, newEisSKU, uploadResultType);

                    _bw.ReportProgress(affectedRows);
                    Console.WriteLine(string.Format("{1:#0.00}% Updating vendor products EisSupplierSKU: {0}", vendorProduct.EisSupplierSKU, percentage));
                }
            }
            catch (DbEntityValidationException ex)
            {
                _hasError = true;
                _logger.LogError(LogEntryType.VendorProductFileUploadWorker, EisHelper.ParseDbEntityValidationException(ex), ex.StackTrace);
                _jobRepository.UpdateSystemJobStatus(_systemJob.Id, JobStatus.Failed);
            }
            catch (Exception ex)
            {
                _hasError = true;
                _logger.LogError(LogEntryType.VendorProductFileUploadWorker,
                                 string.Format("Error in uploading vendor products. <br/> Error message: {0}", EisHelper.GetExceptionMessage(ex)),
                                 ex.StackTrace);
                _jobRepository.UpdateSystemJobStatus(_systemJob.Id, JobStatus.Failed);
            }

            _logger.LogInfo(LogEntryType.VendorProductFileUploadWorker, string.Format("{0} vendor products have been successfully uploaded by {1}", totalProcessed, _systemJob.SubmittedBy));
        }