Add РЕХАУ, РЕХАУИМЯ, РЕХАУАРТИКУЛ, РЕХАУЦЕНА functions

This commit is contained in:
Sergey Chebotar 2023-05-12 10:18:00 +03:00
parent 9c5ba835b1
commit 6d9ff9365c
2 changed files with 88 additions and 2 deletions

View File

@ -52,4 +52,90 @@ public class RhSolutionsFunction
}
}
}
[ExcelFunction]
public static object РЕХАУ(string line) => RHSOLUTIONS(line);
[ExcelFunction]
public static object РЕХАУАРТИКУЛ(string line)
{
if (ProductSku.TryParse(line, out var skus))
{
return skus.First().Id;
}
else
{
return ExcelError.ExcelErrorNA;
}
}
[ExcelFunction]
public static object РЕХАУИМЯ(string line)
{
if (!ProductSku.TryParse(line, out var skus))
{
return ExcelError.ExcelErrorNA;
}
else
{
var article = skus.First().Id;
IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>();
if (ExcelAsyncUtil.Run("Database request", line, delegate
{
return databaseClient.GetProducts(article)
.GetAwaiter()
.GetResult();
}) is not IEnumerable<Product> requestResult)
{
return "Загрузка...";
}
else
{
if (!requestResult.Any())
{
return ExcelError.ExcelErrorNA;
}
else
{
var firstProduct = requestResult.First();
return firstProduct.Name;
}
}
}
}
[ExcelFunction]
public static object РЕХАУЦЕНА(string line)
{
if (!ProductSku.TryParse(line, out var skus))
{
return ExcelError.ExcelErrorNA;
}
else
{
var article = skus.First().Id;
IDatabaseClient databaseClient = RhSolutionsAddIn.ServiceProvider.GetService<IDatabaseClient>();
if (ExcelAsyncUtil.Run("Database request", line, delegate
{
return databaseClient.GetProducts(article)
.GetAwaiter()
.GetResult();
}) is not IEnumerable<Product> requestResult)
{
return "Загрузка...";
}
else
{
if (!requestResult.Any())
{
return ExcelError.ExcelErrorNA;
}
else
{
var firstProduct = requestResult.First();
return string.Format("{0:N2} €", firstProduct.Price * 1.2m);
}
}
}
}
}

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
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("1.6.1.5")]
[assembly: AssemblyFileVersion("1.6.1.5")]
[assembly: AssemblyVersion("1.6.2.0")]
[assembly: AssemblyFileVersion("1.6.2.0")]