Product package update

This commit is contained in:
Sergey Chebotar 2023-05-05 08:21:26 +03:00
parent c0dd1afb18
commit 62271e75fb
7 changed files with 11 additions and 9 deletions

View File

@ -36,7 +36,7 @@
<PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" /> <PackageReference Include="Microsoft.Extensions.Http" Version="7.0.0" />
<PackageReference Include="netDxf" Version="2022.11.2" /> <PackageReference Include="netDxf" Version="2022.11.2" />
<PackageReference Include="Newtonsoft.Json" Version="13.0.3" /> <PackageReference Include="Newtonsoft.Json" Version="13.0.3" />
<PackageReference Include="RhSolutions.Sku" Version="0.1.5" /> <PackageReference Include="RhSolutions.Sku" Version="0.1.8" />
<PackageReference Include="System.Buffers" Version="4.5.1" /> <PackageReference Include="System.Buffers" Version="4.5.1" />
<PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" /> <PackageReference Include="System.Threading.Tasks.Extensions" Version="4.5.4" />
</ItemGroup> </ItemGroup>

View File

@ -47,7 +47,7 @@ public class DxfWriter : IWriter
Alignment = TextAlignment.MiddleLeft, Alignment = TextAlignment.MiddleLeft,
WidthFactor = 0.85 WidthFactor = 0.85
}, },
new Text(product.ProductSku, new Vector2(x + 24750, y), 250) new Text(product.ProductSku.ToString(), new Vector2(x + 24750, y), 250)
{ {
Alignment = TextAlignment.MiddleCenter, Alignment = TextAlignment.MiddleCenter,
WidthFactor = 0.85 WidthFactor = 0.85

View File

@ -60,7 +60,7 @@ public class ExcelReader : IReader, IDisposable
continue; continue;
} }
Product product = new() { ProductSku = currentSku }; Product product = new() { ProductSku = new(currentSku) };
if (readResult.ContainsKey(product)) if (readResult.ContainsKey(product))
{ {
@ -126,7 +126,7 @@ public class ExcelReader : IReader, IDisposable
Product p = new() Product p = new()
{ {
ProductSku = sku.ToString(), ProductSku = new (sku.ToString()),
ProductLine = productLine.ToString(), ProductLine = productLine.ToString(),
Name = name.ToString(), Name = name.ToString(),
ProductMeasure = productMeasure ProductMeasure = productMeasure

View File

@ -110,7 +110,7 @@ public class ExcelWriter : IWriter, IDisposable
Range worksheetCells = _worksheet.Cells; Range worksheetCells = _worksheet.Cells;
Range skuColumn = _skuCell.EntireColumn; Range skuColumn = _skuCell.EntireColumn;
int? row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLine); int? row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku.ToString(), positionAmount.Key.ProductLine);
if (row != null) if (row != null)
{ {
@ -126,7 +126,7 @@ public class ExcelWriter : IWriter, IDisposable
if (_oldSkuCell != null) if (_oldSkuCell != null)
{ {
row = GetPositionRow(_oldSkuCell.EntireColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLine); row = GetPositionRow(_oldSkuCell.EntireColumn, positionAmount.Key.ProductSku.ToString(), positionAmount.Key.ProductLine);
if (row != null) if (row != null)
{ {
@ -141,7 +141,7 @@ public class ExcelWriter : IWriter, IDisposable
} }
} }
string sku = positionAmount.Key.ProductSku.Substring(1, 6); string sku = positionAmount.Key.ProductSku.Article;
row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLine); row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLine);
if (row != null) if (row != null)

View File

@ -18,13 +18,15 @@ public static class WorksheetExtensions
Range skuCell; Range skuCell;
Range programLineCell; Range programLineCell;
Range nameCell; Range nameCell;
Range measureCell;
Range[] cells = new[] Range[] cells = new[]
{ {
amountCell = worksheet.Cells.Find(pricelistParameters["Amount"]), amountCell = worksheet.Cells.Find(pricelistParameters["Amount"]),
skuCell = worksheet.Cells.Find(pricelistParameters["Sku"]), skuCell = worksheet.Cells.Find(pricelistParameters["Sku"]),
programLineCell = worksheet.Cells.Find(pricelistParameters["ProductLine"]), programLineCell = worksheet.Cells.Find(pricelistParameters["ProductLine"]),
nameCell = worksheet.Cells.Find(pricelistParameters["Name"]) nameCell = worksheet.Cells.Find(pricelistParameters["Name"]),
measureCell = worksheet.Cells.Find(pricelistParameters["Measure"])
}; };
return cells.All(x => x != null); return cells.All(x => x != null);

View File

@ -39,7 +39,7 @@ public class CanReadProducts : IDisposable
Assert.NotNull(products); Assert.NotNull(products);
Assert.NotEmpty(products); Assert.NotEmpty(products);
Assert.Equal("11600011001", products.First().Key.ProductSku); Assert.Equal("11600011001", products.First().Key.ProductSku?.ToString());
Assert.Equal(20.0, products.First().Value); Assert.Equal(20.0, products.First().Value);
Assert.Equal(125.0, products.Sum(p => p.Value)); Assert.Equal(125.0, products.Sum(p => p.Value));
Assert.Equal(3, products.Count()); Assert.Equal(3, products.Count());