aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2023-06-20 11:52:42 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2023-06-20 11:52:42 +0300
commit5153e951e4313739dd4fd106ce985c3f6c991837 (patch)
treeee9e3d000512f39c2d7ab343fe8e25e2b5297dd2
parentb9cdad649a91944c6d387c79709fb3027cac01bf (diff)
Edit sleeves tool
-rw-r--r--RhSolutions.AddIn/Tools/SleevesTool.cs19
-rw-r--r--RhSolutions.AddIn/Tools/ToolFactory.cs3
2 files changed, 10 insertions, 12 deletions
diff --git a/RhSolutions.AddIn/Tools/SleevesTool.cs b/RhSolutions.AddIn/Tools/SleevesTool.cs
index 727baed..3981371 100644
--- a/RhSolutions.AddIn/Tools/SleevesTool.cs
+++ b/RhSolutions.AddIn/Tools/SleevesTool.cs
@@ -2,24 +2,21 @@
internal class SleevesTool : Tool
{
- public SleevesTool(IServiceProvider provider) : base(provider)
+ private readonly ISleevesCaluculator _sleevesCaluculator;
+
+ public SleevesTool(ReaderFactory readerFactory, WriterFactory writerFactory, ISleevesCaluculator sleevesCaluculator) : base(readerFactory, writerFactory)
{
+ _sleevesCaluculator = sleevesCaluculator;
}
public override void Execute()
{
Application app = RhSolutionsAddIn.Excel.Application;
+ Worksheet worksheet = app.ActiveWorkbook.ActiveSheet;
_reader = _readerFactory.GetReader("Excel");
_writer = _writerFactory.GetWriter("CurrentPrice");
- var products = new List<(string, Dictionary<Product, double>)>()
- {
- (string.Empty, new Dictionary<Product, double>()
- {
- [new Product("11600011001")] = 10,
- [new Product("11600021001")] = 10,
- [new Product("11600031001")] = 10
- })
- };
- _writer.WriteProducts(products);
+ var products = _reader.ReadProducts(new[] { worksheet });
+ var sleeves = _sleevesCaluculator.CalculateSleeves(products.Select(p => p.Item2).First());
+ _writer.WriteProducts(sleeves);
}
}
diff --git a/RhSolutions.AddIn/Tools/ToolFactory.cs b/RhSolutions.AddIn/Tools/ToolFactory.cs
index 09a6413..a330197 100644
--- a/RhSolutions.AddIn/Tools/ToolFactory.cs
+++ b/RhSolutions.AddIn/Tools/ToolFactory.cs
@@ -4,6 +4,7 @@ internal class ToolFactory
{
static ReaderFactory readerFactory = RhSolutionsAddIn.ServiceProvider.GetService<ReaderFactory>();
static WriterFactory writerFactory = RhSolutionsAddIn.ServiceProvider.GetService<WriterFactory>();
+ static ISleevesCaluculator sleevesCaluculator = RhSolutionsAddIn.ServiceProvider.GetService<ISleevesCaluculator>();
public Tool GetTool(string toolName)
{
@@ -14,7 +15,7 @@ internal class ToolFactory
"merge" => new MergeTool(readerFactory, writerFactory),
"dxfexport" => new DxfTool(readerFactory, writerFactory),
"guess" => new GuessTool(readerFactory, writerFactory),
- "fillsleeves" => new SleevesTool(RhSolutionsAddIn.ServiceProvider),
+ "fillsleeves" => new SleevesTool(readerFactory, writerFactory, sleevesCaluculator),
_ => throw new Exception($"Неизвестный инструмент {toolName}"),
};
return tool;