RhSolutions-AddIn/RhSolutions.AddIn/Tools/SleevesTool.cs
2023-06-21 16:30:16 +03:00

23 lines
842 B
C#

namespace RhSolutions.Tools;
internal class SleevesTool : Tool
{
private readonly ISleevesCalculator _sleevesCaluculator;
public SleevesTool(ReaderFactory readerFactory, WriterFactory writerFactory, ISleevesCalculator sleevesCaluculator) : base(readerFactory, writerFactory)
{
_sleevesCaluculator = sleevesCaluculator;
}
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 sleeves = _sleevesCaluculator.CalculateSleeves(products.Select(p => p.Item2).First());
_writer = _writerFactory.GetWriter("CurrentPrice");
_writer.WriteProducts(sleeves);
}
}