Skip to content

Commit c502e25

Browse files
committed
fix bug #147
1 parent 5868aec commit c502e25

File tree

1 file changed

+46
-8
lines changed

1 file changed

+46
-8
lines changed

Source/FikaAmazonAPI/ReportGeneration/ProductsReport.cs

Lines changed: 46 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
1-
using System.Collections.Generic;
2-
using System.IO;
3-
using System.Linq;
1+
using FikaAmazonAPI.ReportGeneration.ReportDataTable;
2+
using System.Collections.Generic;
43

54
namespace FikaAmazonAPI.ReportGeneration
65
{
76
public class ProductsReport
87
{
9-
public List<ProductsRow> Data { get; set; }=new List<ProductsRow>();
8+
public List<ProductsRow> Data { get; set; } = new List<ProductsRow>();
109
public ProductsReport(string path, string refNumber)
1110
{
1211
if (string.IsNullOrEmpty(path))
1312
return;
14-
var values = File.ReadAllLines(path)
15-
.Skip(1)
16-
.Select(v => ProductsRow.FromCsv(v, refNumber))
17-
.ToList();
13+
14+
var table = Table.ConvertFromCSV(path);
15+
16+
List<ProductsRow> values = new List<ProductsRow>();
17+
foreach (var row in table.Rows)
18+
{
19+
values.Add(ProductsRow.FromRow(row, refNumber));
20+
}
1821
Data = values;
1922
}
2023

@@ -53,6 +56,41 @@ public class ProductsRow
5356
public string Status { get; set; }
5457
public string refNumber { get; set; }
5558

59+
public static ProductsRow FromRow(TableRow rowData, string refNumber)
60+
{
61+
var row = new ProductsRow();
62+
row.ItemName = rowData.GetString("item-name");
63+
row.ItemDescription = rowData.GetString("item-description");
64+
row.ListingId = rowData.GetString("listing-id");
65+
row.SellerSku = rowData.GetString("seller-sku");
66+
row.Price = DataConverter.GetDecimal(rowData.GetString("price"));
67+
row.Quantity = rowData.GetInt32("quantity");
68+
row.OpenDate = rowData.GetString("open-date");
69+
row.ImageUrl = rowData.GetString("image-url");
70+
row.ItemIsMarketplace = rowData.GetString("item-is-marketplace") == "y";
71+
row.ProductIdType = rowData.GetInt32("product-id-type");
72+
row.ZshopShippingFee = rowData.GetString("zshop-shipping-fee");
73+
row.ItemNote = rowData.GetString("item-note");
74+
row.ItemCondition = rowData.GetInt32("zshop-category1");
75+
row.ZshopCategory1 = rowData.GetString("zshop-category1");
76+
row.ZshopBrowsePath = rowData.GetString("zshop-browse-path");
77+
row.ZshopStorefrontFeature = rowData.GetString("zshop-storefront-feature");
78+
row.ASIN1 = rowData.GetString("asin1");
79+
row.ASIN2 = rowData.GetString("asin2");
80+
row.ASIN3 = rowData.GetString("asin3");
81+
row.WillShipInternationally = rowData.GetString("will-ship-internationally");
82+
row.ExpeditedShipping = rowData.GetString("expedited-shipping");
83+
row.ZshopBoldface = rowData.GetString("zshop-boldface");
84+
row.ProductId = rowData.GetString("product-id");
85+
row.BidForFeaturedPlacement = rowData.GetString("bid-for-featured-placement");
86+
row.AddDelete = rowData.GetString("add-delete");
87+
row.PendingQuantity = rowData.GetInt32("pending-quantity");
88+
row.FulfillmentChannel = rowData.GetString("fulfillment-channel");
89+
row.OptionalPaymentTypeExclusion = rowData.GetString("optional-payment-type-exclusion");
90+
row.Status = rowData.GetString("status");
91+
92+
return row;
93+
}
5694
public static ProductsRow FromCsv(string csvLine, string refNumber)
5795
{
5896
string[] values = csvLine.Split('\t');

0 commit comments

Comments
 (0)