public IReportItemDTO Parse(string[] fields, string[] headers) { //string[] fields = line.Split(' '); if (fields.Length < Length) { return(null); } var item = new ListingFBAInvDTO(); for (var i = 0; i < fields.Length; i++) { try { var val = fields[i]; switch (i) { case SellerSKU: item.SellerSKU = val; break; case ASIN: item.ASIN = val; break; case FulfillmentChannelSKU: item.FulfillmentChannelSKU = val; break; case WarehouseConditionCode: item.WarehouseConditionCode = val; break; case QuantityAvailable: item.QuantityAvailable = LineParserHelper.GetAmount(val); break; } } catch (Exception ex) { _log.Error(string.Format("Unable to parse field: {0}", fields[i]), ex); } } return(item); }
public IReportItemDTO Parse(string[] fields, string[] headers) { //string[] fields = line.Split(' '); //if (fields.Length < Length) //{ // return null; //} var item = new ItemDTO(); for (var i = 0; i < fields.Length; i++) { try { var val = fields[i]; var header = headers[i]; switch (header) { case "item-name": item.Name = val; break; case "item-description": item.Description = val; break; case "listing-id": item.ListingId = val; break; case "seller-sku": item.SKU = val; if (item.SKU.Contains("-FBA")) { item.IsFBA = true; } if (item.SKU.Contains("-FPB")) { item.IsPrime = true; } break; case "price": item.CurrentPrice = LineParserHelper.GetPrice(val) ?? 0; break; case "quantity": item.RealQuantity = 0; if (!string.IsNullOrEmpty(val)) { item.RealQuantity = LineParserHelper.GetAmount(val) ?? 0; } else { item.IsFBA = true; } break; case "open-date": item.OpenDate = LineParserHelper.GetDateVal(_log, val, OpenDate, ""); break; case "image-url": break; case "item-is-marketplace": break; case "product-id-type": item.ProductIdType = LineParserHelper.GetAmount(val) ?? 0; item.PublishedStatus = (int)PublishedStatuses.Published; //switch (item.ProductIdType) //{ // case 3: // item.PublishedStatus = (int) PublishedStatuses.Published; // break; // case 1: // item.PublishedStatus = (int) PublishedStatuses.PublishedInactive; // break; // default: // item.PublishedStatus = (int) PublishedStatuses.None; // break; //} break; case "item-note": item.Note = val; break; case "asin1": item.ASIN = val; item.SourceMarketId = val; break; case "will-ship-internationally": item.IsInternational = LineParserHelper.GetBoolVal(val); break; case "Business Price": item.BusinessPrice = LineParserHelper.TryGetPrice(val); break; case "merchant-shipping-group": item.OnMarketTemplateName = val; if (item.OnMarketTemplateName == AmazonTemplateHelper.PrimeTemplate) { item.IsPrime = true; } break; } } catch (Exception ex) { _log.Error(string.Format("Unable to parse field: {0}", fields[i]), ex); } } return(item); }