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

23 lines
842 B
C#
Raw Normal View History

2023-06-20 09:51:44 +03:00
namespace RhSolutions.Tools;
internal class SleevesTool : Tool
{
2023-06-21 07:11:31 +03:00
private readonly ISleevesCalculator _sleevesCaluculator;
2023-06-20 11:52:42 +03:00
2023-06-21 07:11:31 +03:00
public SleevesTool(ReaderFactory readerFactory, WriterFactory writerFactory, ISleevesCalculator 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 });
var sleeves = _sleevesCaluculator.CalculateSleeves(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
}
}