Rename Magic to Guess
This commit is contained in:
parent
733440392e
commit
16b5ddedb1
@ -36,8 +36,8 @@ public sealed class RhSolutionsAddIn : IExcelAddIn
|
|||||||
Services.AddSingleton<ReaderFactory>();
|
Services.AddSingleton<ReaderFactory>();
|
||||||
Services.AddTransient<ExcelReader>()
|
Services.AddTransient<ExcelReader>()
|
||||||
.AddTransient<IReader, ExcelReader>(s => s.GetService<ExcelReader>());
|
.AddTransient<IReader, ExcelReader>(s => s.GetService<ExcelReader>());
|
||||||
Services.AddTransient<MagicReader>()
|
Services.AddTransient<GuessReader>()
|
||||||
.AddTransient<IReader, MagicReader>(s => s.GetService<MagicReader>());
|
.AddTransient<IReader, GuessReader>(s => s.GetService<GuessReader>());
|
||||||
|
|
||||||
Services.AddSingleton<ToolFactory>();
|
Services.AddSingleton<ToolFactory>();
|
||||||
|
|
||||||
|
@ -27,7 +27,7 @@ public class RibbonController : ExcelRibbon
|
|||||||
<button id='export' getEnabled='GetExportEnabled' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnToolPressed'/>
|
<button id='export' getEnabled='GetExportEnabled' label='Экспорт в новый файл' size='normal' imageMso='PivotExportToExcel' onAction='OnToolPressed'/>
|
||||||
<button id='convert' getEnabled='GetConvertEnabled' label='Актуализировать' size='normal' imageMso='FileUpdate' onAction='OnToolPressed'/>
|
<button id='convert' getEnabled='GetConvertEnabled' label='Актуализировать' size='normal' imageMso='FileUpdate' onAction='OnToolPressed'/>
|
||||||
<button id='merge' label='Объединить' size='normal' imageMso='Copy' onAction='OnToolPressed'/>
|
<button id='merge' label='Объединить' size='normal' imageMso='Copy' onAction='OnToolPressed'/>
|
||||||
<button id='magicexport' label='Распознать и экспортировать' size='normal' imageMso='ExportExcel' onAction='OnToolPressed'/>
|
<button id='Guessexport' label='Распознать и экспортировать' size='normal' imageMso='ExportExcel' onAction='OnToolPressed'/>
|
||||||
<button id='dxfexport' getEnabled='GetDxfEnabled' label='Экспортировать в DXF' size='normal' imageMso='ExportExcel' onAction='OnToolPressed'/>
|
<button id='dxfexport' getEnabled='GetDxfEnabled' label='Экспортировать в DXF' size='normal' imageMso='ExportExcel' onAction='OnToolPressed'/>
|
||||||
</group>
|
</group>
|
||||||
<group id='rausettings' getLabel='GetVersionLabel'>
|
<group id='rausettings' getLabel='GetVersionLabel'>
|
||||||
|
@ -2,12 +2,12 @@
|
|||||||
|
|
||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
public class MagicReader : IReader
|
public class GuessReader : IReader
|
||||||
{
|
{
|
||||||
private readonly Application _application;
|
private readonly Application _application;
|
||||||
private ProgressBar _progressBar;
|
private ProgressBar _progressBar;
|
||||||
|
|
||||||
public MagicReader(Application application)
|
public GuessReader(Application application)
|
||||||
{
|
{
|
||||||
_application = application;
|
_application = application;
|
||||||
}
|
}
|
@ -13,7 +13,7 @@ public class ReaderFactory
|
|||||||
{
|
{
|
||||||
return readerName switch
|
return readerName switch
|
||||||
{
|
{
|
||||||
"Magic" => (IReader)_serviceProvider.GetService(typeof(MagicReader)),
|
"Guess" => (IReader)_serviceProvider.GetService(typeof(GuessReader)),
|
||||||
"Excel" => (IReader)_serviceProvider.GetService(typeof(ExcelReader)),
|
"Excel" => (IReader)_serviceProvider.GetService(typeof(ExcelReader)),
|
||||||
_ => (IReader)_serviceProvider.GetService(typeof(ExcelReader))
|
_ => (IReader)_serviceProvider.GetService(typeof(ExcelReader))
|
||||||
};
|
};
|
||||||
|
@ -4,9 +4,9 @@ using System.Runtime.Versioning;
|
|||||||
|
|
||||||
namespace RhSolutions.Tools;
|
namespace RhSolutions.Tools;
|
||||||
|
|
||||||
internal class MagicTool : Tool
|
internal class GuessTool : Tool
|
||||||
{
|
{
|
||||||
public MagicTool(IServiceProvider provider) : base(provider)
|
public GuessTool(IServiceProvider provider) : base(provider)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -14,7 +14,7 @@ internal class MagicTool : Tool
|
|||||||
{
|
{
|
||||||
Application app = RhSolutionsAddIn.Excel.Application;
|
Application app = RhSolutionsAddIn.Excel.Application;
|
||||||
Worksheet worksheet = app.ActiveWorkbook.ActiveSheet;
|
Worksheet worksheet = app.ActiveWorkbook.ActiveSheet;
|
||||||
_reader = _readerFactory.GetReader("Magic");
|
_reader = _readerFactory.GetReader("Guess");
|
||||||
var products = _reader.ReadProducts(new[] { worksheet });
|
var products = _reader.ReadProducts(new[] { worksheet });
|
||||||
_writer = _writerFactory.GetWriter("Excel");
|
_writer = _writerFactory.GetWriter("Excel");
|
||||||
_writer.WriteProducts(products);
|
_writer.WriteProducts(products);
|
@ -10,7 +10,7 @@ internal class ToolFactory
|
|||||||
"convert" => new ConvertTool(RhSolutionsAddIn.ServiceProvider),
|
"convert" => new ConvertTool(RhSolutionsAddIn.ServiceProvider),
|
||||||
"merge" => new MergeTool(RhSolutionsAddIn.ServiceProvider),
|
"merge" => new MergeTool(RhSolutionsAddIn.ServiceProvider),
|
||||||
"dxfexport" => new DxfTool(RhSolutionsAddIn.ServiceProvider),
|
"dxfexport" => new DxfTool(RhSolutionsAddIn.ServiceProvider),
|
||||||
"magicexport" => new MagicTool(RhSolutionsAddIn.ServiceProvider),
|
"Guessexport" => new GuessTool(RhSolutionsAddIn.ServiceProvider),
|
||||||
_ => throw new Exception("Неизвестный инструмент"),
|
_ => throw new Exception("Неизвестный инструмент"),
|
||||||
};
|
};
|
||||||
return tool;
|
return tool;
|
||||||
|
@ -5,33 +5,31 @@ using System.IO;
|
|||||||
namespace RhSolutions.Tests;
|
namespace RhSolutions.Tests;
|
||||||
|
|
||||||
[ExcelTestSettings(OutOfProcess = true)]
|
[ExcelTestSettings(OutOfProcess = true)]
|
||||||
public class CanDoMagic : IDisposable
|
public class CanDoGuess : IDisposable
|
||||||
{
|
{
|
||||||
private RhSolutionsAddIn _addIn;
|
private RhSolutionsAddIn _addIn;
|
||||||
//private ReaderFactory _readerFactory;
|
|
||||||
private IReader _reader;
|
private IReader _reader;
|
||||||
|
|
||||||
public CanDoMagic()
|
public CanDoGuess()
|
||||||
{
|
{
|
||||||
_addIn = new();
|
_addIn = new();
|
||||||
_addIn.AutoOpen();
|
_addIn.AutoOpen();
|
||||||
//_readerFactory = RhSolutionsAddIn.ServiceProvider.GetRequiredService<ReaderFactory>();
|
_reader = new GuessReader(Util.Application);
|
||||||
_reader = new MagicReader(Util.Application);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationMagic.xlsx")]
|
[ExcelFact(Workbook = @"..\..\..\TestWorkbooks\TestSpecificationGuess.xlsx")]
|
||||||
public void CanWrite()
|
public void CanWrite()
|
||||||
{
|
{
|
||||||
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
Worksheet sourceSheet = Util.Workbook.Worksheets[1];
|
||||||
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationMagic.xlsx"));
|
RhSolutionsAddIn.Configuration.SetPriceListPath(Path.GetFullPath(@"..\..\..\TestWorkbooks\TargetSpecificationGuess.xlsx"));
|
||||||
var products = _reader.ReadProducts(new[] { sourceSheet });
|
var products = _reader.ReadProducts(new[] { sourceSheet });
|
||||||
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
var _writer = new ExcelWriter(Util.Application, RhSolutionsAddIn.Configuration);
|
||||||
_writer.WriteProducts(products);
|
_writer.WriteProducts(products);
|
||||||
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
Worksheet targetSheet = Util.Application.ActiveWindow.ActiveSheet;
|
||||||
var targetProducts = _reader.ReadProducts(new[] { targetSheet });
|
var targetProducts = _reader.ReadProducts(new[] { targetSheet });
|
||||||
|
|
||||||
Assert.Equal("TestSpecificationMagic", products.First().Item1);
|
Assert.Equal("TestSpecificationGuess", products.First().Item1);
|
||||||
Assert.Equal("TargetSpecificationMagic", targetProducts.First().Item1);
|
Assert.Equal("TargetSpecificationGuess", targetProducts.First().Item1);
|
||||||
Assert.Equal(products.First().Item2.Count(), targetProducts.First().Item2.Count());
|
Assert.Equal(products.First().Item2.Count(), targetProducts.First().Item2.Count());
|
||||||
Assert.Equal(products.First().Item2.Values.Sum(), targetProducts.First().Item2.Values.Sum());
|
Assert.Equal(products.First().Item2.Values.Sum(), targetProducts.First().Item2.Values.Sum());
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user