Compare commits

..

No commits in common. "58a45df8cf1790f01d4f9f7b75cda0e2cb1699b2" and "dcbf7d6d7f76ad7714d6ad2c0aefe73c14d94ef3" have entirely different histories.

6 changed files with 15 additions and 81 deletions

View File

@ -1,5 +1,4 @@
using System.Net; using System.Net;
using ExcelDna.IntelliSense;
#if !NET472 #if !NET472
using System.Runtime.Versioning; using System.Runtime.Versioning;
#endif #endif
@ -41,35 +40,12 @@ 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();
}
} }
} }

View File

@ -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 = "СТРОКА", Description = "Ячейка с артикулом РЕХАУ или поисковый запрос в свободной форме")] string line) public static object RHSOLUTIONS([ExcelArgument(Name = "\"Строка с названием материала\"")] string line)
{ {
IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>(); IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>();
@ -51,12 +51,11 @@ public class RhSolutionsFunction
} }
} }
[ExcelFunction(Description = "Поиск артикула в базе данных")] [ExcelFunction]
public static object РЕХАУ([ExcelArgument(Name = "СТРОКА", Description = "Ячейка с артикулом РЕХАУ или поисковый запрос в свободной форме")] string line) public static object РЕХАУ(string line) => RHSOLUTIONS(line);
=> RHSOLUTIONS(line);
[ExcelFunction(Description = "Выделить артикул РЕХАУ из ячейки")] [ExcelFunction]
public static object РЕХАУАРТИКУЛ([ExcelArgument(Name = "СТРОКА", Description = "Ячейка содержащая артикул РЕХАУ")] string line) public static object РЕХАУАРТИКУЛ(string line)
{ {
if (ProductSku.TryParse(line, out var skus)) if (ProductSku.TryParse(line, out var skus))
{ {
@ -68,8 +67,8 @@ public class RhSolutionsFunction
} }
} }
[ExcelFunction(Description = "Поиск названия по артикулу РЕХАУ")] [ExcelFunction]
public static object РЕХАУИМЯ([ExcelArgument(Name = "АРТИКУЛ", Description = "Ячейка содержащая артикул РЕХАУ")] string line) public static object РЕХАУИМЯ(string line)
{ {
if (!ProductSku.TryParse(line, out var skus)) if (!ProductSku.TryParse(line, out var skus))
{ {
@ -104,8 +103,8 @@ public class RhSolutionsFunction
} }
} }
[ExcelFunction(Description = "Поиск цены артикула РЕХАУ в евро")] [ExcelFunction]
public static object РЕХАУЦЕНА([ExcelArgument(Name = "АРТИКУЛ", Description = "Ячейка содержащая артикул РЕХАУ")] string line) public static object РЕХАУЦЕНА(string line)
{ {
if (!ProductSku.TryParse(line, out var skus)) if (!ProductSku.TryParse(line, out var skus))
{ {
@ -140,9 +139,8 @@ public class RhSolutionsFunction
} }
} }
[ExcelFunction(Description = "Поиск цены артикула РЕХАУ в рублях")] [ExcelFunction]
public static object РЕХАУЦЕНАРУБ([ExcelArgument(Name = "АРТИКУЛ", Description = "Ячейка содержащая артикул РЕХАУ")] string line, public static object РЕХАУЦЕНАРУБ(string line, double dateField)
[ExcelArgument(Name = "ДАТА", Description = "Дата в формате Excel (необязательно)")] double dateField)
{ {
if (!ProductSku.TryParse(line, out var skus)) if (!ProductSku.TryParse(line, out var skus))
{ {
@ -185,34 +183,4 @@ 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);
}
}
}
} }

View File

@ -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.7.0.0")] [assembly: AssemblyVersion("1.6.5.0")]
[assembly: AssemblyFileVersion("1.7.0.0")] [assembly: AssemblyFileVersion("1.6.5.0")]

View File

@ -12,7 +12,6 @@
<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" />

View File

@ -29,7 +29,6 @@
<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" />

View File

@ -1,8 +0,0 @@
<?xml version="1.0" encoding="utf-8" ?>
<RunSettings>
<RunConfiguration>
<EnvironmentVariables>
<ISTESTING>true</ISTESTING>
</EnvironmentVariables>
</RunConfiguration>
</RunSettings>