Esempio n. 1
0
        public VendorProduct GetNextProduct()
        {
            var product = new VendorProduct();
            var hasData = false;

            while (!hasData)
            {
                try
                {
                    if (!_excelReader.Read() || _excelReader.GetString(_config.SKU) == null)
                    {
                        return(null);
                    }

                    product.VendorId         = _config.VendorId;
                    product.SKU              = _excelReader.GetString(_config.SKU);
                    product.Name             = _config.Name == null ? null : _excelReader.GetString(_config.Name ?? 0);
                    product.Description      = _config.Name == null ? null : _excelReader.GetString(_config.Description ?? 0);
                    product.ShortDescription = _config.Name == null ? null : _excelReader.GetString(_config.ShortDescription ?? 0);
                    product.Category         = _config.Name == null ? null : _excelReader.GetString(_config.Category ?? 0);
                    product.UPCCode          = _config.Name == null ? null : _excelReader.GetString(_config.UPCCode ?? 0);
                    product.Cost             = _config.Name == null ? -1 : _excelReader.GetDecimal(_config.Cost ?? 0);
                    product.Quantity         = _config.Name == null ? -1 : _excelReader.GetInt16(_config.Quantity ?? 0);
                    product.ResultDate       = _config.ResultDate;

                    // set the flag to true
                    hasData = true;
                }
                catch (Exception ex)
                {
                    hasData = false;
                    Console.Error.WriteLine("Error in parsing file {0} at row number: {1}", _fileInfo.FullName, _records);
                    Logger.LogError(this.GetType().Name, string.Format("Error in parsing file {0} at row number: {1}", _fileInfo.FullName, _records), ex.StackTrace);
                    throw new Exception(ex.Message);
                }
                finally
                {
                    // increment the record counter
                    _records++;
                }
            }

            return(product);
        }
Esempio n. 2
0
        public VendorProduct GetNextVendorProduct()
        {
            var product = new VendorProduct();

            try
            {
                if (!_excelReader.Read() || _excelReader.GetString((int)_task.SKU) == null)
                {
                    return(null);
                }

                product.VendorId      = _task.VendorId;
                product.SupplierSKU   = _excelReader.GetString((int)_task.SKU);
                product.SupplierPrice = _task.SupplierPrice == null ? -1 : _excelReader.GetDecimal(_task.SupplierPrice ?? 0);
                product.Quantity      = _task.Quantity == null ? -1 : _excelReader.GetInt16(_task.Quantity ?? 0);
                product.Name          = _task.ProductName == null ? null : _excelReader.GetString(_task.ProductName ?? 0);
                product.Description   = _task.Description == null ? null : _excelReader.GetString(_task.Description ?? 0);
                product.Category      = _task.Category == null ? null : _excelReader.GetString(_task.Category ?? 0);
                product.UPC           = _task.UPC == null ? null : _excelReader.GetString(_task.UPC ?? 0);
                product.MinPack       = _task.MinPack == null ? -1 : _excelReader.GetInt32(_task.MinPack ?? 0);

                // set the flag to true
                product.HasInvalidData = false;
            }
            catch (Exception ex)
            {
                product.HasInvalidData = true;
                Logger.LogError(LogEntryType.FileInventoryTaskService, string.Format("Error in parsing vendor product file {0} at row number: {1}", _fileInfo.FullName, _records), ex.StackTrace);
            }
            finally
            {
                // increment the record counter
                _records++;
            }

            return(product);
        }
Esempio n. 3
0
 public short GetInt16(int i) => _reader.GetInt16(i);