2021-12-03 12:57:22 +03:00
|
|
|
|
using ExcelDna.Integration;
|
2021-11-29 15:50:24 +03:00
|
|
|
|
using System.Threading.Tasks;
|
2021-12-03 12:57:22 +03:00
|
|
|
|
using System.Runtime.Caching;
|
2021-11-11 16:33:40 +03:00
|
|
|
|
|
|
|
|
|
namespace Rehau.Sku.Assist
|
|
|
|
|
{
|
2021-11-29 15:50:24 +03:00
|
|
|
|
public class Functions
|
2021-11-11 16:33:40 +03:00
|
|
|
|
{
|
2021-11-29 11:26:25 +03:00
|
|
|
|
[ExcelFunction]
|
2021-12-03 12:57:22 +03:00
|
|
|
|
public static object RAUNAME(string request)
|
2021-11-11 16:33:40 +03:00
|
|
|
|
{
|
2021-12-03 12:57:22 +03:00
|
|
|
|
if (MemoryCache.Default.Contains(request))
|
|
|
|
|
return MemoryCache.Default[request].ToString();
|
|
|
|
|
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
object result = ExcelAsyncUtil.Run("Rauname", new[] { request },
|
|
|
|
|
delegate
|
|
|
|
|
{
|
|
|
|
|
Task<IProduct> product = Task.Run(() => SkuAssist.GetProduct(request));
|
|
|
|
|
return product.Result;
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
if (Equals(result, ExcelError.ExcelErrorNA))
|
|
|
|
|
{
|
|
|
|
|
return "Загрузка...";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
MemoryCache.Default.Add(request, result, System.DateTime.Now.AddMinutes(10));
|
|
|
|
|
return result == null ? "Не найдено" : result.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
2021-11-11 16:33:40 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|