|
1 |
| -using System.Collections.Generic; |
2 |
| -using System.IO; |
3 |
| -using System.Linq; |
| 1 | +using FikaAmazonAPI.ReportGeneration.ReportDataTable; |
| 2 | +using System.Collections.Generic; |
4 | 3 |
|
5 | 4 | namespace FikaAmazonAPI.ReportGeneration
|
6 | 5 | {
|
7 | 6 | public class ProductsReport
|
8 | 7 | {
|
9 |
| - public List<ProductsRow> Data { get; set; }=new List<ProductsRow>(); |
| 8 | + public List<ProductsRow> Data { get; set; } = new List<ProductsRow>(); |
10 | 9 | public ProductsReport(string path, string refNumber)
|
11 | 10 | {
|
12 | 11 | if (string.IsNullOrEmpty(path))
|
13 | 12 | 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 | + } |
18 | 21 | Data = values;
|
19 | 22 | }
|
20 | 23 |
|
@@ -53,6 +56,41 @@ public class ProductsRow
|
53 | 56 | public string Status { get; set; }
|
54 | 57 | public string refNumber { get; set; }
|
55 | 58 |
|
| 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 | + } |
56 | 94 | public static ProductsRow FromCsv(string csvLine, string refNumber)
|
57 | 95 | {
|
58 | 96 | string[] values = csvLine.Split('\t');
|
|
0 commit comments