Compare commits
No commits in common. "9af858cc37e5451f29b9ea235ba4d2afb4af17a6" and "a6caea17873f64beadb6f1b0ef37966393d85484" have entirely different histories.
9af858cc37
...
a6caea1787
@ -20,16 +20,16 @@ public sealed class RhSolutionsAddIn : IExcelAddIn
|
|||||||
|
|
||||||
Services.AddHttpClient()
|
Services.AddHttpClient()
|
||||||
.AddSingleton((Application)ExcelDnaUtil.Application)
|
.AddSingleton((Application)ExcelDnaUtil.Application)
|
||||||
.AddSingleton<IAddInConfiguration, AddInConfiguration>()
|
.AddSingleton<IAddInConfiguration, RhAddInConfiguration>()
|
||||||
.AddSingleton<IDatabaseClient, DatabaseClient>()
|
.AddSingleton<IDatabaseClient, RhDatabaseClient>()
|
||||||
.AddTransient<IFileDialog, FileDialog>()
|
.AddTransient<IFileDialog, ExcelFileDialog>()
|
||||||
.AddTransient<IReader, ExcelReader>();
|
.AddTransient<IExcelReader, RhExcelReader>();
|
||||||
|
|
||||||
Services.AddSingleton<WriterFactory>();
|
Services.AddSingleton<WriterFactory>();
|
||||||
Services.AddTransient<ExcelWriter>()
|
Services.AddTransient<RhExcelWriter>()
|
||||||
.AddTransient<IWriter, ExcelWriter>(s => s.GetService<ExcelWriter>());
|
.AddTransient<IExcelWriter, RhExcelWriter>(s => s.GetService<RhExcelWriter>());
|
||||||
Services.AddTransient<DxfWriter>()
|
Services.AddTransient<RhDxfWriter>()
|
||||||
.AddTransient<IWriter, DxfWriter>(s => s.GetService<DxfWriter>());
|
.AddTransient<IExcelWriter, RhDxfWriter>(s => s.GetService<RhDxfWriter>());
|
||||||
|
|
||||||
Services.AddSingleton<ToolFactory>();
|
Services.AddSingleton<ToolFactory>();
|
||||||
|
|
||||||
|
@ -31,5 +31,5 @@ using System.Runtime.InteropServices;
|
|||||||
// You can specify all the values or you can default the Build and Revision Numbers
|
// You can specify all the values or you can default the Build and Revision Numbers
|
||||||
// by using the '*' as shown below:
|
// by using the '*' as shown below:
|
||||||
// [assembly: AssemblyVersion("1.0.*")]
|
// [assembly: AssemblyVersion("1.0.*")]
|
||||||
[assembly: AssemblyVersion("1.6.0.0")]
|
[assembly: AssemblyVersion("1.5.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.6.0.0")]
|
[assembly: AssemblyFileVersion("1.5.0.0")]
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
public class FileDialog : IFileDialog
|
public class ExcelFileDialog : IFileDialog
|
||||||
{
|
{
|
||||||
private readonly Application _application;
|
private Application _application;
|
||||||
|
|
||||||
public FileDialog(Application application)
|
public ExcelFileDialog(Application application)
|
||||||
{
|
{
|
||||||
_application = application;
|
_application = application;
|
||||||
}
|
}
|
@ -1,6 +1,6 @@
|
|||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
public interface IReader : IDisposable
|
public interface IExcelReader : IDisposable
|
||||||
{
|
{
|
||||||
public Dictionary<Product, double> ReadProducts(Range range);
|
public Dictionary<Product, double> ReadProducts(Range range);
|
||||||
public List<(string, Dictionary<Product, double>)> ReadProducts(IEnumerable<Worksheet> worksheets);
|
public List<(string, Dictionary<Product, double>)> ReadProducts(IEnumerable<Worksheet> worksheets);
|
@ -1,6 +1,6 @@
|
|||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
public interface IWriter : IDisposable
|
public interface IExcelWriter : IDisposable
|
||||||
{
|
{
|
||||||
public void WriteProducts(IEnumerable<(string, Dictionary<Product, double>)> products);
|
public void WriteProducts(IEnumerable<(string, Dictionary<Product, double>)> products);
|
||||||
public void WriteProducts(Dictionary<Product, double> products);
|
public void WriteProducts(Dictionary<Product, double> products);
|
@ -3,11 +3,11 @@ using System.IO;
|
|||||||
|
|
||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
public class AddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
|
public class RhAddInConfiguration : ApplicationSettingsBase, IAddInConfiguration
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, string> _priceListHeaders;
|
private readonly Dictionary<string, string> _priceListHeaders;
|
||||||
|
|
||||||
public AddInConfiguration()
|
public RhAddInConfiguration()
|
||||||
{
|
{
|
||||||
_priceListHeaders = new Dictionary<string, string>()
|
_priceListHeaders = new Dictionary<string, string>()
|
||||||
{
|
{
|
@ -5,12 +5,12 @@ using System.Threading.Tasks;
|
|||||||
|
|
||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
public class DatabaseClient : IDatabaseClient
|
public class RhDatabaseClient : IDatabaseClient
|
||||||
{
|
{
|
||||||
private readonly IServiceProvider serviceProvider;
|
private readonly IServiceProvider serviceProvider;
|
||||||
public HttpStatusCode StatusCode { get; private set; }
|
public HttpStatusCode StatusCode { get; private set; }
|
||||||
|
|
||||||
public DatabaseClient(IServiceProvider provider)
|
public RhDatabaseClient(IServiceProvider provider)
|
||||||
{
|
{
|
||||||
this.serviceProvider = provider;
|
this.serviceProvider = provider;
|
||||||
}
|
}
|
@ -8,14 +8,14 @@ using Line = netDxf.Entities.Line;
|
|||||||
|
|
||||||
namespace RhSolutions.Services;
|
namespace RhSolutions.Services;
|
||||||
|
|
||||||
public class DxfWriter : IWriter
|
public class RhDxfWriter : IExcelWriter
|
||||||
{
|
{
|
||||||
private readonly string file;
|
private readonly string file;
|
||||||
private readonly DxfDocument doc;
|
private readonly DxfDocument doc;
|
||||||
private Dictionary<Product, double> productDict;
|
private Dictionary<Product, double> productDict;
|
||||||
private readonly Block tableBlock;
|
private readonly Block tableBlock;
|
||||||
|
|
||||||
public DxfWriter()
|
public RhDxfWriter()
|
||||||
{
|
{
|
||||||
string filepath = RhSolutionsAddIn.Excel.ActiveWorkbook.Path;
|
string filepath = RhSolutionsAddIn.Excel.ActiveWorkbook.Path;
|
||||||
string filename = Path.GetFileNameWithoutExtension(RhSolutionsAddIn.Excel.ActiveWorkbook.Name);
|
string filename = Path.GetFileNameWithoutExtension(RhSolutionsAddIn.Excel.ActiveWorkbook.Name);
|
@ -9,13 +9,13 @@ namespace RhSolutions.Services;
|
|||||||
#if !NET472
|
#if !NET472
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
#endif
|
#endif
|
||||||
public class ExcelReader : IReader, IDisposable
|
public class RhExcelReader : IExcelReader, IDisposable
|
||||||
{
|
{
|
||||||
private ProgressBar _progressBar;
|
private ProgressBar _progressBar;
|
||||||
private readonly Dictionary<string, string> headers;
|
private readonly Dictionary<string, string> headers;
|
||||||
private readonly Application _application;
|
private readonly Application _application;
|
||||||
|
|
||||||
public ExcelReader(Application application, IAddInConfiguration configuration)
|
public RhExcelReader(Application application, IAddInConfiguration configuration)
|
||||||
{
|
{
|
||||||
_application = application;
|
_application = application;
|
||||||
headers = configuration.GetPriceListHeaders();
|
headers = configuration.GetPriceListHeaders();
|
||||||
@ -110,14 +110,27 @@ public class ExcelReader : IReader, IDisposable
|
|||||||
object name = worksheet.Cells[row, NameCell.Column].Value2;
|
object name = worksheet.Cells[row, NameCell.Column].Value2;
|
||||||
object sku = worksheet.Cells[row, SkuCell.Column].Value2;
|
object sku = worksheet.Cells[row, SkuCell.Column].Value2;
|
||||||
object measure = worksheet.Cells[row, MeasureCell.Column].Value2;
|
object measure = worksheet.Cells[row, MeasureCell.Column].Value2;
|
||||||
var productMeasure = measure.ToString() switch
|
Measure productMeasure;
|
||||||
|
|
||||||
|
switch (measure.ToString())
|
||||||
{
|
{
|
||||||
"м" => Measure.M,
|
case "м":
|
||||||
"шт" => Measure.P,
|
productMeasure = Measure.M;
|
||||||
"м2" => Measure.M2,
|
break;
|
||||||
"кг" => Measure.Kg,
|
case "шт":
|
||||||
_ => Measure.P,
|
productMeasure = Measure.P;
|
||||||
};
|
break;
|
||||||
|
case "м2":
|
||||||
|
productMeasure = Measure.M2;
|
||||||
|
break;
|
||||||
|
case "кг":
|
||||||
|
productMeasure = Measure.Kg;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
productMeasure = Measure.P;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
if (productLine == null || name == null || sku == null)
|
if (productLine == null || name == null || sku == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
@ -9,7 +9,7 @@ namespace RhSolutions.Services;
|
|||||||
#if !NET472
|
#if !NET472
|
||||||
[SupportedOSPlatform("windows")]
|
[SupportedOSPlatform("windows")]
|
||||||
#endif
|
#endif
|
||||||
public class ExcelWriter : IWriter, IDisposable
|
public class RhExcelWriter : IExcelWriter, IDisposable
|
||||||
{
|
{
|
||||||
private readonly Application _application;
|
private readonly Application _application;
|
||||||
private Worksheet _worksheet;
|
private Worksheet _worksheet;
|
||||||
@ -24,7 +24,7 @@ public class ExcelWriter : IWriter, IDisposable
|
|||||||
_nameCell,
|
_nameCell,
|
||||||
_oldSkuCell;
|
_oldSkuCell;
|
||||||
|
|
||||||
public ExcelWriter(Application application, IAddInConfiguration configuration)
|
public RhExcelWriter(Application application, IAddInConfiguration configuration)
|
||||||
{
|
{
|
||||||
_application = application;
|
_application = application;
|
||||||
_pricelistPath = configuration.GetPriceListPath();
|
_pricelistPath = configuration.GetPriceListPath();
|
@ -9,16 +9,16 @@ public class WriterFactory
|
|||||||
_serviceProvider = serviceProvider;
|
_serviceProvider = serviceProvider;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IWriter GetWriter(string writerName)
|
public IExcelWriter GetWriter(string writerName)
|
||||||
{
|
{
|
||||||
if (writerName.Equals("Dxf"))
|
if (writerName.Equals("Dxf"))
|
||||||
{
|
{
|
||||||
return (IWriter)_serviceProvider.GetService(typeof(DxfWriter));
|
return (IExcelWriter)_serviceProvider.GetService(typeof(RhDxfWriter));
|
||||||
}
|
}
|
||||||
|
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return (IWriter)_serviceProvider.GetService(typeof(ExcelWriter));
|
return (IExcelWriter)_serviceProvider.GetService(typeof(RhExcelWriter));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,13 +9,13 @@ namespace RhSolutions.Tools;
|
|||||||
#endif
|
#endif
|
||||||
internal abstract class Tool : IDisposable
|
internal abstract class Tool : IDisposable
|
||||||
{
|
{
|
||||||
protected readonly IReader _reader;
|
protected readonly IExcelReader _reader;
|
||||||
protected readonly WriterFactory _writerFactory;
|
protected readonly WriterFactory _writerFactory;
|
||||||
protected IWriter _writer;
|
protected IExcelWriter _writer;
|
||||||
|
|
||||||
public Tool(IServiceProvider provider)
|
public Tool(IServiceProvider provider)
|
||||||
{
|
{
|
||||||
_reader = provider.GetRequiredService<IReader>();
|
_reader = provider.GetRequiredService<IExcelReader>();
|
||||||
_writerFactory = provider.GetRequiredService<WriterFactory>();
|
_writerFactory = provider.GetRequiredService<WriterFactory>();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -7,7 +7,7 @@ namespace RhSolutions.Tests;
|
|||||||
public class CanReadProducts : IDisposable
|
public class CanReadProducts : IDisposable
|
||||||
{
|
{
|
||||||
private RhSolutionsAddIn _addIn;
|
private RhSolutionsAddIn _addIn;
|
||||||
private IReader _reader;
|
private IExcelReader _reader;
|
||||||
private Workbook _testWorkbook;
|
private Workbook _testWorkbook;
|
||||||
|
|
||||||
public CanReadProducts()
|
public CanReadProducts()
|
||||||
@ -15,7 +15,7 @@ public class CanReadProducts : IDisposable
|
|||||||
_addIn = new();
|
_addIn = new();
|
||||||
_testWorkbook = Util.Application.Workbooks.Add();
|
_testWorkbook = Util.Application.Workbooks.Add();
|
||||||
_addIn.AutoOpen();
|
_addIn.AutoOpen();
|
||||||
_reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IReader>();
|
_reader = RhSolutionsAddIn.ServiceProvider.GetRequiredService<IExcelReader>();
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFact]
|
[ExcelFact]
|
||||||
|
Loading…
Reference in New Issue
Block a user