Compare commits
No commits in common. "8b125e475e4f6970d1948e77fdf832c5e77f2cec" and "e67d94f1995f3de8c4d83eeddf71816589c6bcb5" have entirely different histories.
8b125e475e
...
e67d94f199
@ -161,7 +161,7 @@ public class RhSolutionsFunction
|
|||||||
.GetResult()
|
.GetResult()
|
||||||
.FirstOrDefault();
|
.FirstOrDefault();
|
||||||
|
|
||||||
DateTime date = dateField == 0 ? DateTime.Today : DateTime.FromOADate(dateField);
|
DateTime date = dateField == 0 ? DateTime.Now : DateTime.FromOADate(dateField);
|
||||||
var exchangeRate = currencyClient.GetCurrencyCourse(date)
|
var exchangeRate = currencyClient.GetCurrencyCourse(date)
|
||||||
.GetAwaiter()
|
.GetAwaiter()
|
||||||
.GetResult();
|
.GetResult();
|
||||||
@ -193,7 +193,7 @@ public class RhSolutionsFunction
|
|||||||
|
|
||||||
if (ExcelAsyncUtil.Run("Database request", dateField, delegate
|
if (ExcelAsyncUtil.Run("Database request", dateField, delegate
|
||||||
{
|
{
|
||||||
DateTime date = dateField == 0 ? DateTime.Today : DateTime.FromOADate(dateField);
|
DateTime date = dateField == 0 ? DateTime.Now : DateTime.FromOADate(dateField);
|
||||||
var exchangeRate = currencyClient.GetCurrencyCourse(date)
|
var exchangeRate = currencyClient.GetCurrencyCourse(date)
|
||||||
.GetAwaiter()
|
.GetAwaiter()
|
||||||
.GetResult();
|
.GetResult();
|
||||||
|
@ -84,7 +84,7 @@ public class RibbonController : ExcelRibbon
|
|||||||
|
|
||||||
public bool GetConvertEnabled(IRibbonControl control) => _workbookIsValid;
|
public bool GetConvertEnabled(IRibbonControl control) => _workbookIsValid;
|
||||||
public bool GetDxfEnabled(IRibbonControl control) => _workbookIsValid;
|
public bool GetDxfEnabled(IRibbonControl control) => _workbookIsValid;
|
||||||
public bool GetGuessEnabled(IRibbonControl control) => RhSolutionsAddIn.Excel.ActiveWorkbook != null && !_workbookIsValid;
|
public bool GetGuessEnabled(IRibbonControl control) => RhSolutionsAddIn.Excel.ActiveWorkbook == null ? false : !_workbookIsValid;
|
||||||
|
|
||||||
public bool GetExportEnabled(IRibbonControl control)
|
public bool GetExportEnabled(IRibbonControl control)
|
||||||
{
|
{
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
using System.IO;
|
using Microsoft.Office.Interop.Excel;
|
||||||
|
using System.IO;
|
||||||
|
|
||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
@ -46,21 +47,19 @@ public class GuessReader : IReader
|
|||||||
}
|
}
|
||||||
if (currentIndex > productColumnIndex)
|
if (currentIndex > productColumnIndex)
|
||||||
{
|
{
|
||||||
if (IsAmountColumn(range.Columns[currentIndex]))
|
if (IsAmountColumn(range.Columns[currentIndex++]))
|
||||||
{
|
{
|
||||||
amountColumnIndex = currentIndex;
|
amountColumnIndex = currentIndex - 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else currentIndex++;
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (IsAmountColumn(range.Columns[currentIndex]))
|
if (IsAmountColumn(range.Columns[currentIndex--]))
|
||||||
{
|
{
|
||||||
amountColumnIndex = currentIndex;
|
amountColumnIndex = currentIndex + 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else currentIndex--;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -94,7 +93,7 @@ public class GuessReader : IReader
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (ProductSku.TryParse(currentCell.ToString(), out _))
|
if (ProductSku.TryParse(currentCell.ToString(), out IEnumerable<ProductSku> skus))
|
||||||
{
|
{
|
||||||
successCounter++;
|
successCounter++;
|
||||||
}
|
}
|
||||||
@ -112,43 +111,39 @@ public class GuessReader : IReader
|
|||||||
{
|
{
|
||||||
int successCounter = 0;
|
int successCounter = 0;
|
||||||
var cells = column.Value2;
|
var cells = column.Value2;
|
||||||
double maxValue = 30000;
|
|
||||||
|
|
||||||
if (cells == null)
|
if (cells == null)
|
||||||
{
|
{
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (column.Rows.Count == 1)
|
for (int row = 1; row < column.Rows.Count + 1; row++)
|
||||||
{
|
{
|
||||||
double? value = cells as double?;
|
object currentCell = column.Rows.Count == 1 ? cells : cells[row, 1];
|
||||||
|
if (currentCell == null)
|
||||||
return value != null
|
|
||||||
&& value != 0
|
|
||||||
&& value < maxValue;
|
|
||||||
}
|
|
||||||
|
|
||||||
else
|
|
||||||
{
|
|
||||||
for (int row = 1; row < column.Rows.Count + 1; row++)
|
|
||||||
{
|
{
|
||||||
object currentCell = cells[row, 1];
|
continue;
|
||||||
double? value = currentCell as double?;
|
}
|
||||||
|
|
||||||
if (value == null
|
double? value = currentCell as double?;
|
||||||
|| value == 0
|
|
||||||
|| value > maxValue)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (++successCounter > 3)
|
if (value == null || value == 0)
|
||||||
{
|
{
|
||||||
return true;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (value > 30000)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (++successCounter > 3)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return successCounter > 1;
|
|
||||||
|
return successCounter > 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn)
|
private Dictionary<Product, double> GetDictionaryFromColumns(Range productColumn, Range amountColumn)
|
||||||
|
@ -15,7 +15,7 @@ public class ReaderFactory
|
|||||||
{
|
{
|
||||||
"Guess" => (IReader)_serviceProvider.GetService(typeof(GuessReader)),
|
"Guess" => (IReader)_serviceProvider.GetService(typeof(GuessReader)),
|
||||||
"Excel" => (IReader)_serviceProvider.GetService(typeof(ExcelReader)),
|
"Excel" => (IReader)_serviceProvider.GetService(typeof(ExcelReader)),
|
||||||
_ => throw new ArgumentException($"Незвестный интерфейс {nameof(IReader)}: {readerName}")
|
_ => (IReader)_serviceProvider.GetService(typeof(ExcelReader))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -15,7 +15,7 @@ public class WriterFactory
|
|||||||
{
|
{
|
||||||
"Excel" => (IWriter)_serviceProvider.GetService(typeof(ExcelWriter)),
|
"Excel" => (IWriter)_serviceProvider.GetService(typeof(ExcelWriter)),
|
||||||
"Dxf" => (IWriter)_serviceProvider.GetService(typeof(DxfWriter)),
|
"Dxf" => (IWriter)_serviceProvider.GetService(typeof(DxfWriter)),
|
||||||
_ => throw new ArgumentException($"Незвестный интерфейс {nameof(IWriter)}: {writerName}")
|
_ => (IWriter)_serviceProvider.GetService(typeof(ExcelWriter))
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,7 +11,7 @@ internal class ToolFactory
|
|||||||
"merge" => new MergeTool(RhSolutionsAddIn.ServiceProvider),
|
"merge" => new MergeTool(RhSolutionsAddIn.ServiceProvider),
|
||||||
"dxfexport" => new DxfTool(RhSolutionsAddIn.ServiceProvider),
|
"dxfexport" => new DxfTool(RhSolutionsAddIn.ServiceProvider),
|
||||||
"Guessexport" => new GuessTool(RhSolutionsAddIn.ServiceProvider),
|
"Guessexport" => new GuessTool(RhSolutionsAddIn.ServiceProvider),
|
||||||
_ => throw new Exception($"Неизвестный инструмент {toolName}"),
|
_ => throw new Exception("Неизвестный инструмент"),
|
||||||
};
|
};
|
||||||
return tool;
|
return tool;
|
||||||
}
|
}
|
||||||
|
@ -8,15 +8,13 @@ namespace RhSolutions.Tests;
|
|||||||
public class CanDoGuess : IDisposable
|
public class CanDoGuess : IDisposable
|
||||||
{
|
{
|
||||||
private RhSolutionsAddIn _addIn;
|
private RhSolutionsAddIn _addIn;
|
||||||
private IReader _guessReader;
|
|
||||||
private IReader _reader;
|
private IReader _reader;
|
||||||
|
|
||||||
public CanDoGuess()
|
public CanDoGuess()
|
||||||
{
|
{
|
||||||
_addIn = new();
|
_addIn = new();
|
||||||
_addIn.AutoOpen();
|
_addIn.AutoOpen();
|
||||||
_guessReader = new GuessReader(Util.Application);
|
_reader = new GuessReader(Util.Application);
|
||||||
_reader = new ExcelReader(Util.Application, RhSolutionsAddIn.Configuration);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationGuess.xlsx")]
|
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationGuess.xlsx")]
|
||||||
@ -24,7 +22,7 @@ public class CanDoGuess : IDisposable
|
|||||||
{
|
{
|
||||||
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
||||||
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationGuess.xlsx"));
|
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationGuess.xlsx"));
|
||||||
var products = _guessReader.ReadProducts(new[] { sourceSheet });
|
var products = _reader.ReadProducts(new[] { sourceSheet });
|
||||||
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
||||||
_writer.WriteProducts(products);
|
_writer.WriteProducts(products);
|
||||||
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
||||||
@ -41,7 +39,7 @@ public class CanDoGuess : IDisposable
|
|||||||
{
|
{
|
||||||
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
||||||
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationGuessOneRow.xlsx"));
|
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationGuessOneRow.xlsx"));
|
||||||
var products = _guessReader.ReadProducts(new[] { sourceSheet });
|
var products = _reader.ReadProducts(new[] { sourceSheet });
|
||||||
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
||||||
_writer.WriteProducts(products);
|
_writer.WriteProducts(products);
|
||||||
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
||||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user