Fix exception on guessing single row
This commit is contained in:
parent
9d2f386a74
commit
7f8455d868
@ -14,7 +14,7 @@ public class GuessReader : IReader
|
||||
|
||||
public Dictionary<Product, double> ReadProducts(Range range)
|
||||
{
|
||||
_progressBar = new("Ищу колонки со значениями", range.Columns.Count);
|
||||
_progressBar = new("Поиск возможных пар артикул-количество...", range.Columns.Count);
|
||||
int? productColumnIndex = null;
|
||||
List<int> amountColumnIndeces = new();
|
||||
|
||||
@ -74,7 +74,7 @@ public class GuessReader : IReader
|
||||
private bool IsProductColumn(Range column)
|
||||
{
|
||||
int successCounter = 0;
|
||||
object[,] cells = column.Value2;
|
||||
var cells = column.Value2;
|
||||
|
||||
if (cells == null)
|
||||
{
|
||||
@ -83,7 +83,7 @@ public class GuessReader : IReader
|
||||
|
||||
for (int row = 1; row < column.Rows.Count + 1; row++)
|
||||
{
|
||||
object currentCell = cells[row, 1];
|
||||
object currentCell = column.Rows.Count == 1 ? cells : cells[row, 1];
|
||||
if (currentCell == null)
|
||||
{
|
||||
continue;
|
||||
@ -106,7 +106,7 @@ public class GuessReader : IReader
|
||||
private bool IsAmountColumn(Range column)
|
||||
{
|
||||
int successCounter = 0;
|
||||
object[,] cells = column.Value2;
|
||||
var cells = column.Value2;
|
||||
|
||||
if (cells == null)
|
||||
{
|
||||
@ -115,7 +115,7 @@ public class GuessReader : IReader
|
||||
|
||||
for (int row = 1; row < column.Rows.Count + 1; row++)
|
||||
{
|
||||
object currentCell = cells[row, 1];
|
||||
object currentCell = column.Rows.Count == 1 ? cells : cells[row, 1];
|
||||
if (currentCell == null)
|
||||
{
|
||||
continue;
|
||||
@ -144,22 +144,29 @@ public class GuessReader : IReader
|
||||
}
|
||||
|
||||
successCounter++;
|
||||
|
||||
if (successCounter > 5)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return successCounter > 1;
|
||||
return successCounter > 0;
|
||||
}
|
||||
|
||||
private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn)
|
||||
{
|
||||
Dictionary<Product, double> result = new();
|
||||
_progressBar = new("Заполняю словарь значений...", productColumn.Rows.Count);
|
||||
|
||||
for (int row = 1; row < productColumn.Rows.Count + 1; row++)
|
||||
{
|
||||
object[,] amountCells = amountColumn.Value2;
|
||||
object currentAmountCell = amountCells[row, 1];
|
||||
_progressBar.Update();
|
||||
var amountCells = amountColumn.Value2;
|
||||
object currentAmountCell = productColumn.Rows.Count == 1 ? amountCells : amountCells[row, 1];
|
||||
|
||||
object[,] productCells = productColumn.Value2;
|
||||
object currentProductCell = productCells[row, 1];
|
||||
var productCells = productColumn.Value2;
|
||||
object currentProductCell = productColumn.Rows.Count == 1 ? productCells : productCells[row, 1];
|
||||
|
||||
double amountValue = 0.0;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user