RhSolutions-AddIn/RhSolutions.AddIn/Tools/SleevesTool.cs

23 lines
837 B
C#
Raw Normal View History

2023-06-20 09:51:44 +03:00
namespace RhSolutions.Tools;
internal class SleevesTool : Tool
{
2023-11-02 23:07:06 +03:00
private readonly IFittingsCalculator _sleevesCaluculator;
2023-06-20 11:52:42 +03:00
2023-11-02 23:07:06 +03:00
public SleevesTool(ReaderFactory readerFactory, WriterFactory writerFactory, IFittingsCalculator sleevesCaluculator) : base(readerFactory, writerFactory)
2023-06-20 09:51:44 +03:00
{
2023-06-20 11:52:42 +03:00
_sleevesCaluculator = sleevesCaluculator;
2023-06-20 09:51:44 +03:00
}
public override void Execute()
{
Application app = RhSolutionsAddIn.Excel.Application;
2023-06-20 11:52:42 +03:00
Worksheet worksheet = app.ActiveWorkbook.ActiveSheet;
2023-06-20 09:51:44 +03:00
_reader = _readerFactory.GetReader("Excel");
2023-06-20 11:52:42 +03:00
var products = _reader.ReadProducts(new[] { worksheet });
2023-11-02 23:07:06 +03:00
var sleeves = _sleevesCaluculator.Calculate(products.Select(p => p.Item2).First());
2023-06-21 16:30:16 +03:00
_writer = _writerFactory.GetWriter("CurrentPrice");
2023-06-20 11:52:42 +03:00
_writer.WriteProducts(sleeves);
2023-06-20 09:51:44 +03:00
}
}