Compare commits
5 Commits
dcbf7d6d7f
...
58a45df8cf
Author | SHA1 | Date | |
---|---|---|---|
|
58a45df8cf | ||
|
c5895f78c2 | ||
|
9f0ef90005 | ||
|
e203155474 | ||
|
8dc186c7aa |
@ -1,4 +1,5 @@
|
|||||||
using System.Net;
|
using System.Net;
|
||||||
|
using ExcelDna.IntelliSense;
|
||||||
#if !NET472
|
#if !NET472
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
#endif
|
#endif
|
||||||
@ -40,12 +41,35 @@ public sealed class RhSolutionsAddIn : IExcelAddIn
|
|||||||
Excel = ServiceProvider.GetService<Application>();
|
Excel = ServiceProvider.GetService<Application>();
|
||||||
|
|
||||||
EventsUtil.Initialize();
|
EventsUtil.Initialize();
|
||||||
|
|
||||||
|
bool isTesting = Environment.GetEnvironmentVariable("ISTESTING") switch
|
||||||
|
{
|
||||||
|
"true" => true,
|
||||||
|
"false" => false,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
if (!isTesting)
|
||||||
|
{
|
||||||
|
IntelliSenseServer.Install();
|
||||||
|
}
|
||||||
|
|
||||||
ServicePointManager.SecurityProtocol =
|
ServicePointManager.SecurityProtocol =
|
||||||
SecurityProtocolType.Tls12;
|
SecurityProtocolType.Tls12;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void AutoClose()
|
public void AutoClose()
|
||||||
{
|
{
|
||||||
EventsUtil.Uninitialize();
|
EventsUtil.Uninitialize();
|
||||||
|
|
||||||
|
bool isTesting = Environment.GetEnvironmentVariable("ISTESTING") switch
|
||||||
|
{
|
||||||
|
"true" => true,
|
||||||
|
"false" => false,
|
||||||
|
_ => false
|
||||||
|
};
|
||||||
|
if (!isTesting)
|
||||||
|
{
|
||||||
|
IntelliSenseServer.Uninstall();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,8 +9,8 @@ namespace RhSolutions.AddIn;
|
|||||||
#endif
|
#endif
|
||||||
public class RhSolutionsFunction
|
public class RhSolutionsFunction
|
||||||
{
|
{
|
||||||
[ExcelFunction(Description = "Распознать артикул и попробовать найти его в прайс-листе")]
|
[ExcelFunction(Description = "Поиск артикула в базе данных")]
|
||||||
public static object RHSOLUTIONS([ExcelArgument(Name = "\"Строка с названием материала\"")] string line)
|
public static object RHSOLUTIONS([ExcelArgument(Name = "СТРОКА", Description = "Ячейка с артикулом РЕХАУ или поисковый запрос в свободной форме")] string line)
|
||||||
{
|
{
|
||||||
IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>();
|
IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>();
|
||||||
|
|
||||||
@ -51,11 +51,12 @@ public class RhSolutionsFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFunction]
|
[ExcelFunction(Description = "Поиск артикула в базе данных")]
|
||||||
public static object РЕХАУ(string line) => RHSOLUTIONS(line);
|
public static object РЕХАУ([ExcelArgument(Name = "СТРОКА", Description = "Ячейка с артикулом РЕХАУ или поисковый запрос в свободной форме")] string line)
|
||||||
|
=> RHSOLUTIONS(line);
|
||||||
|
|
||||||
[ExcelFunction]
|
[ExcelFunction(Description = "Выделить артикул РЕХАУ из ячейки")]
|
||||||
public static object РЕХАУАРТИКУЛ(string line)
|
public static object РЕХАУАРТИКУЛ([ExcelArgument(Name = "СТРОКА", Description = "Ячейка содержащая артикул РЕХАУ")] string line)
|
||||||
{
|
{
|
||||||
if (ProductSku.TryParse(line, out var skus))
|
if (ProductSku.TryParse(line, out var skus))
|
||||||
{
|
{
|
||||||
@ -67,8 +68,8 @@ public class RhSolutionsFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFunction]
|
[ExcelFunction(Description = "Поиск названия по артикулу РЕХАУ")]
|
||||||
public static object РЕХАУИМЯ(string line)
|
public static object РЕХАУИМЯ([ExcelArgument(Name = "АРТИКУЛ", Description = "Ячейка содержащая артикул РЕХАУ")] string line)
|
||||||
{
|
{
|
||||||
if (!ProductSku.TryParse(line, out var skus))
|
if (!ProductSku.TryParse(line, out var skus))
|
||||||
{
|
{
|
||||||
@ -103,8 +104,8 @@ public class RhSolutionsFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFunction]
|
[ExcelFunction(Description = "Поиск цены артикула РЕХАУ в евро")]
|
||||||
public static object РЕХАУЦЕНА(string line)
|
public static object РЕХАУЦЕНА([ExcelArgument(Name = "АРТИКУЛ", Description = "Ячейка содержащая артикул РЕХАУ")] string line)
|
||||||
{
|
{
|
||||||
if (!ProductSku.TryParse(line, out var skus))
|
if (!ProductSku.TryParse(line, out var skus))
|
||||||
{
|
{
|
||||||
@ -139,8 +140,9 @@ public class RhSolutionsFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
[ExcelFunction]
|
[ExcelFunction(Description = "Поиск цены артикула РЕХАУ в рублях")]
|
||||||
public static object РЕХАУЦЕНАРУБ(string line, double dateField)
|
public static object РЕХАУЦЕНАРУБ([ExcelArgument(Name = "АРТИКУЛ", Description = "Ячейка содержащая артикул РЕХАУ")] string line,
|
||||||
|
[ExcelArgument(Name = "ДАТА", Description = "Дата в формате Excel (необязательно)")] double dateField)
|
||||||
{
|
{
|
||||||
if (!ProductSku.TryParse(line, out var skus))
|
if (!ProductSku.TryParse(line, out var skus))
|
||||||
{
|
{
|
||||||
@ -183,4 +185,34 @@ public class RhSolutionsFunction
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[ExcelFunction(Description = "Получить курс евро по ЦБ")]
|
||||||
|
public static object КУРСЕВРО([ExcelArgument(Name = "ДАТА", Description = "Дата в формате Excel (необязательно)")] double dateField)
|
||||||
|
{
|
||||||
|
ICurrencyClient currencyClient = RhSolutionsAddIn.ServiceProvider.GetRequiredService<ICurrencyClient>();
|
||||||
|
|
||||||
|
if (ExcelAsyncUtil.Run("Database request", dateField, delegate
|
||||||
|
{
|
||||||
|
DateTime date = dateField == 0 ? DateTime.Now : DateTime.FromOADate(dateField);
|
||||||
|
var exchangeRate = currencyClient.GetCurrencyCourse(date)
|
||||||
|
.GetAwaiter()
|
||||||
|
.GetResult();
|
||||||
|
|
||||||
|
return exchangeRate ?? -1m;
|
||||||
|
}) is not decimal requestResult)
|
||||||
|
{
|
||||||
|
return "Загрузка...";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (requestResult < 0)
|
||||||
|
{
|
||||||
|
return ExcelError.ExcelErrorNA;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return Math.Round(requestResult, 2);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
@ -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.5.0")]
|
[assembly: AssemblyVersion("1.7.0.0")]
|
||||||
[assembly: AssemblyFileVersion("1.6.5.0")]
|
[assembly: AssemblyFileVersion("1.7.0.0")]
|
||||||
|
@ -12,6 +12,7 @@
|
|||||||
<Reference Path="Microsoft.Extensions.Logging.dll" Pack="true" />
|
<Reference Path="Microsoft.Extensions.Logging.dll" Pack="true" />
|
||||||
<Reference Path="Microsoft.Extensions.Options.dll" Pack="true" />
|
<Reference Path="Microsoft.Extensions.Options.dll" Pack="true" />
|
||||||
<Reference Path="Microsoft.Extensions.Primitives.dll" Pack="true" />
|
<Reference Path="Microsoft.Extensions.Primitives.dll" Pack="true" />
|
||||||
|
<Reference Path="ExcelDna.IntelliSense.dll" Pack="true" />
|
||||||
<Reference Path="Newtonsoft.Json.dll" Pack="true" />
|
<Reference Path="Newtonsoft.Json.dll" Pack="true" />
|
||||||
<Reference Path="netDxf.dll" Pack="true" />
|
<Reference Path="netDxf.dll" Pack="true" />
|
||||||
<Reference Path="RhSolutions.ProductSku.dll" Pack="true" />
|
<Reference Path="RhSolutions.ProductSku.dll" Pack="true" />
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
<TreatAsUsed>true</TreatAsUsed>
|
<TreatAsUsed>true</TreatAsUsed>
|
||||||
</PackageReference>
|
</PackageReference>
|
||||||
<PackageReference Include="ExcelDna.Integration" Version="1.6.0" />
|
<PackageReference Include="ExcelDna.Integration" Version="1.6.0" />
|
||||||
|
<PackageReference Include="ExcelDna.IntelliSense" Version="1.6.0" />
|
||||||
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
|
<PackageReference Include="ExcelDna.Interop" Version="15.0.1" />
|
||||||
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
|
<PackageReference Include="Microsoft.Bcl.AsyncInterfaces" Version="7.0.0" />
|
||||||
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
|
<PackageReference Include="Microsoft.Bcl.HashCode" Version="1.1.1" />
|
||||||
|
8
RhSolutions.Tests/.runsettings
Normal file
8
RhSolutions.Tests/.runsettings
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
|
<RunSettings>
|
||||||
|
<RunConfiguration>
|
||||||
|
<EnvironmentVariables>
|
||||||
|
<ISTESTING>true</ISTESTING>
|
||||||
|
</EnvironmentVariables>
|
||||||
|
</RunConfiguration>
|
||||||
|
</RunSettings>
|
Loading…
x
Reference in New Issue
Block a user