Compare commits
5 Commits
4434da98be
...
2aae1805c5
Author | SHA1 | Date | |
---|---|---|---|
|
2aae1805c5 | ||
|
cf472b66a4 | ||
|
f58dec38a4 | ||
|
9c3c65a4f8 | ||
|
3e4a5e6563 |
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.8.1.0")]
|
[assembly: AssemblyVersion("1.8.2.0")]
|
||||||
[assembly: AssemblyFileVersion("1.8.1.0")]
|
[assembly: AssemblyFileVersion("1.8.2.0")]
|
||||||
|
@ -3,7 +3,6 @@ using System.Runtime.Versioning;
|
|||||||
using RhSolutions.Tools;
|
using RhSolutions.Tools;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
@ -112,7 +111,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.ToString(), positionAmount.Key.ProductLines.FirstOrDefault());
|
int? row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLines.FirstOrDefault());
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -128,7 +127,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
|
|
||||||
if (_oldSkuCell != null)
|
if (_oldSkuCell != null)
|
||||||
{
|
{
|
||||||
row = GetPositionRow(_oldSkuCell.EntireColumn, positionAmount.Key.ProductSku.ToString(), positionAmount.Key.ProductLines.FirstOrDefault());
|
row = GetPositionRow(_oldSkuCell.EntireColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLines.FirstOrDefault());
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -149,8 +148,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
string sku = positionAmount.Key.ProductSku.Article;
|
row = GetPositionRow(skuColumn, positionAmount.Key.ProductSku, positionAmount.Key.ProductLines.FirstOrDefault(), true);
|
||||||
row = GetPositionRow(skuColumn, sku, positionAmount.Key.ProductLines.FirstOrDefault());
|
|
||||||
|
|
||||||
if (row != null)
|
if (row != null)
|
||||||
{
|
{
|
||||||
@ -212,10 +210,12 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private int? GetPositionRow(Range range, string sku, string group)
|
private int? GetPositionRow(Range range, ProductSku sku, string productLine, bool justArticle = false)
|
||||||
{
|
{
|
||||||
Range found = range.Find(sku);
|
string lookupString = justArticle ? sku.Article : sku.ToString();
|
||||||
|
Range found = range.Find(lookupString);
|
||||||
string foundGroupValue;
|
string foundGroupValue;
|
||||||
|
string foundSkuValue;
|
||||||
|
|
||||||
if (found == null)
|
if (found == null)
|
||||||
{
|
{
|
||||||
@ -224,25 +224,36 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
|
|
||||||
int firstFoundRow = found.Row;
|
int firstFoundRow = found.Row;
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(group))
|
|
||||||
{
|
|
||||||
return found.Row;
|
|
||||||
}
|
|
||||||
|
|
||||||
while (true)
|
while (true)
|
||||||
{
|
{
|
||||||
|
foundSkuValue = _worksheet.Cells[found.Row, range.Column].Value2.ToString();
|
||||||
foundGroupValue = _worksheet.Cells[found.Row, _programLineCell.Column].Value2.ToString();
|
foundGroupValue = _worksheet.Cells[found.Row, _programLineCell.Column].Value2.ToString();
|
||||||
|
|
||||||
if (group.Equals(foundGroupValue))
|
if (ProductSku.TryParse(foundSkuValue, out var skus))
|
||||||
{
|
{
|
||||||
return found.Row;
|
if (skus.Any(s => s.Article == sku.Article) &&
|
||||||
|
(string.IsNullOrEmpty(productLine) || productLine.Equals(foundGroupValue)) )
|
||||||
|
{
|
||||||
|
return found.Row;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
found = range.FindNext(found);
|
||||||
|
|
||||||
|
if (found.Row == firstFoundRow)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
else
|
||||||
found = range.FindNext(found);
|
|
||||||
|
|
||||||
if (found.Row == firstFoundRow)
|
|
||||||
{
|
{
|
||||||
return null;
|
found = range.FindNext(found);
|
||||||
|
|
||||||
|
if (found.Row == firstFoundRow)
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -79,10 +79,13 @@ public class CanWriteProducts : IDisposable
|
|||||||
|
|
||||||
Assert.Equal("TestSpecificationReplaced", products.First().Item1);
|
Assert.Equal("TestSpecificationReplaced", products.First().Item1);
|
||||||
Assert.Equal("TargetSpecificationReplaced", targetProducts.First().Item1);
|
Assert.Equal("TargetSpecificationReplaced", targetProducts.First().Item1);
|
||||||
Assert.Single(targetProducts.First().Item2);
|
var result = targetProducts.First().Item2.ToArray();
|
||||||
var product = targetProducts.First().Item2.First().Key;
|
Assert.Contains("Молот Тора", result[0].Key.Name);
|
||||||
Assert.Contains("Молот Тора", product.Name);
|
Assert.Contains("15555551555", result[0].Key.Name);
|
||||||
Assert.Contains("15555551555", product.Name);
|
Assert.Equal(1, result[0].Value);
|
||||||
|
Assert.Contains("Нога Вирта", result[1].Key.Name);
|
||||||
|
Assert.Contains("17777771777", result[1].Key.Name);
|
||||||
|
Assert.Equal(1, result[1].Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationNewVariant.xlsx")]
|
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationNewVariant.xlsx")]
|
||||||
@ -98,10 +101,10 @@ public class CanWriteProducts : IDisposable
|
|||||||
|
|
||||||
Assert.Equal("TestSpecificationNewVariant", products.First().Item1);
|
Assert.Equal("TestSpecificationNewVariant", products.First().Item1);
|
||||||
Assert.Equal("TargetSpecificationNewVariant", targetProducts.First().Item1);
|
Assert.Equal("TargetSpecificationNewVariant", targetProducts.First().Item1);
|
||||||
Assert.Single(targetProducts.First().Item2);
|
var result = targetProducts.First().Item2.ToArray();
|
||||||
var product = targetProducts.First().Item2.First().Key;
|
Assert.Contains("Молот Тора", result[0].Key.Name);
|
||||||
Assert.Contains("Молот Тора", product.Name);
|
Assert.Contains("11201111555", result[0].Key.Name);
|
||||||
Assert.Contains("15555551555", product.Name);
|
Assert.Equal(1, result[0].Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Dispose()
|
public void Dispose()
|
||||||
|
Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user