Compare commits

..

No commits in common. "d6a78c42c7eddcff64c3e97b9877dc5969f80968" and "8902d51c14f2679aa3bf168dc3a02056a1352f57" have entirely different histories.

4 changed files with 4 additions and 31 deletions

View File

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

View File

@ -4,8 +4,6 @@ using RhSolutions.Tools;
#endif #endif
using System.Text.RegularExpressions;
namespace RhSolutions.Services; namespace RhSolutions.Services;
#if !NET472 #if !NET472
@ -132,12 +130,6 @@ public class ExcelWriter : IWriter, IDisposable
if (row != null) 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) foreach (int column in columns)
{ {
Range cell = worksheetCells[row, column]; Range cell = worksheetCells[row, column];
@ -154,12 +146,6 @@ public class ExcelWriter : IWriter, IDisposable
if (row != null) 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) foreach (int column in columns)
{ {
Range cell = worksheetCells[row, column]; Range cell = worksheetCells[row, column];
@ -198,7 +184,8 @@ public class ExcelWriter : IWriter, IDisposable
current.ClearContents(); current.ClearContents();
worksheetCells[row, groupColumn].Value2 = product.ProductLines.FirstOrDefault() ?? string.Empty; 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 = "???"; worksheetCells[row, skuColumn].Value2 = "???";
if (_oldSkuCell != null) if (_oldSkuCell != null)
{ {

View File

@ -44,18 +44,5 @@ public static class WorksheetExtensions
range.Value2 += value; 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()); Assert.Equal(3, products.Count());
} }
[ExcelFact(Workbook = @"TestWorkbooks\TestSpecification.xlsx")] [ExcelFact(Workbook = @"TestWorkbooks\TestSpecificaion.xlsx")]
public void CanReadWorkbook() public void CanReadWorkbook()
{ {
Worksheet worksheet = Util.Workbook.Worksheets[1]; Worksheet worksheet = Util.Workbook.Worksheets[1];
var result = _reader.ReadProducts(new[] { worksheet }); var result = _reader.ReadProducts(new[] { worksheet });
Assert.NotNull(result); Assert.NotNull(result);
Assert.NotEmpty(result); Assert.NotEmpty(result);
Assert.Equal("TestSpecification", result.First().Item1); Assert.Equal("TestSpecificaion", result.First().Item1);
var products = result.First().Item2; var products = result.First().Item2;
Assert.Equal(46, products.Count()); Assert.Equal(46, products.Count());
Assert.Equal(29266, products.Sum(p => p.Value)); Assert.Equal(29266, products.Sum(p => p.Value));