Compare commits

..

5 Commits

Author SHA1 Message Date
Sergey Chebotar
d6a78c42c7 Merge branch 'testing' 2023-05-19 08:17:40 +03:00
Sergey Chebotar
08fcc33f9d Fix replace and missing descriptions duplicates 2023-05-19 08:16:40 +03:00
Sergey Chebotar
f9ff1e55b9 Set ExcelDnaPackCompressResources to false 2023-05-19 07:43:29 +03:00
Sergey Chebotar
ea69a77a0e Add description to replaced products 2023-05-18 15:26:38 +03:00
Sergey Chebotar
28d6c3b6b9 Fix file naming 2023-05-18 14:53:52 +03:00
4 changed files with 31 additions and 4 deletions

View File

@ -8,6 +8,7 @@
<GenerateAssemblyInfo>false</GenerateAssemblyInfo>
<UseWindowsForms>true</UseWindowsForms>
<ImportWindowsDesktopTargets>true</ImportWindowsDesktopTargets>
<ExcelDnaPackCompressResources>false</ExcelDnaPackCompressResources>
</PropertyGroup>
<PropertyGroup>
<StartupObject />

View File

@ -4,6 +4,8 @@ using RhSolutions.Tools;
#endif
using System.Text.RegularExpressions;
namespace RhSolutions.Services;
#if !NET472
@ -130,6 +132,12 @@ public class ExcelWriter : IWriter, IDisposable
if (row != null)
{
Range nameCell = worksheetCells[row, _nameCell.Column];
if (!Regex.IsMatch(nameCell.Value2, @"(арт. \d{11})"))
{
nameCell.AddValue($"-> замена (арт. {positionAmount.Key.ProductSku})");
}
foreach (int column in columns)
{
Range cell = worksheetCells[row, column];
@ -146,6 +154,12 @@ public class ExcelWriter : IWriter, IDisposable
if (row != null)
{
Range nameCell = worksheetCells[row, _nameCell.Column];
if (!Regex.IsMatch(nameCell.Value2, @"(арт. \d{11})"))
{
nameCell.AddValue($" -> замена (арт. {positionAmount.Key.ProductSku})");
}
foreach (int column in columns)
{
Range cell = worksheetCells[row, column];
@ -184,8 +198,7 @@ public class ExcelWriter : IWriter, IDisposable
current.ClearContents();
worksheetCells[row, groupColumn].Value2 = product.ProductLines.FirstOrDefault() ?? string.Empty;
worksheetCells[row, nameColumn].Value2 = $"{product.Name} не найден ({product.ProductSku})";
worksheetCells[row, nameColumn].Value2 = $"{product.Name} -> не найден (арт. {product.ProductSku})";
worksheetCells[row, skuColumn].Value2 = "???";
if (_oldSkuCell != null)
{

View File

@ -44,5 +44,18 @@ public static class WorksheetExtensions
range.Value2 += value;
}
}
public static void AddValue(this Range range, string value)
{
if (range.Value2 == null)
{
range.Value2 = value;
}
else
{
range.Value2 = $"{range.Value2} {value}";
}
}
}

View File

@ -45,14 +45,14 @@ public class CanReadProducts : IDisposable
Assert.Equal(3, products.Count());
}
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecificaion.xlsx")]
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecification.xlsx")]
public void CanReadWorkbook()
{
Worksheet worksheet = Util.Workbook.Worksheets[1];
var result = _reader.ReadProducts(new[] { worksheet });
Assert.NotNull(result);
Assert.NotEmpty(result);
Assert.Equal("TestSpecificaion", result.First().Item1);
Assert.Equal("TestSpecification", result.First().Item1);
var products = result.First().Item2;
Assert.Equal(46, products.Count());
Assert.Equal(29266, products.Sum(p => p.Value));