26 lines
995 B
C#
26 lines
995 B
C#
namespace RhSolutions.Tools;
|
|
|
|
internal class FittingsTool : Tool
|
|
{
|
|
private readonly FittingsCalculatorFactory _factory;
|
|
private string _calculatorName;
|
|
|
|
public FittingsTool(ReaderFactory readerFactory, WriterFactory writerFactory, FittingsCalculatorFactory calculatorFactory, string calculatorName) : base(readerFactory, writerFactory)
|
|
{
|
|
_factory = calculatorFactory;
|
|
_calculatorName = calculatorName;
|
|
}
|
|
|
|
public override void Execute()
|
|
{
|
|
Application app = RhSolutionsAddIn.Excel.Application;
|
|
Worksheet worksheet = app.ActiveWorkbook.ActiveSheet;
|
|
_reader = _readerFactory.GetReader("Excel");
|
|
var products = _reader.ReadProducts(new[] { worksheet });
|
|
var calculator = _factory.GetFittingsCalculator(_calculatorName);
|
|
var fittings = calculator.Calculate(products.Select(p => p.Item2).First());
|
|
_writer = _writerFactory.GetWriter("CurrentPrice");
|
|
_writer.WriteProducts(fittings);
|
|
}
|
|
}
|