RhSolutions-AddIn/Source/ExcelDNA/Functions.cs

19 lines
687 B
C#
Raw Normal View History

2021-11-29 16:36:04 +03:00
using AngleSharp.Dom;
2021-11-29 15:50:24 +03:00
using ExcelDna.Integration;
using System.Net.Http;
2021-11-29 15:50:24 +03:00
using System.Threading.Tasks;
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
{
[ExcelFunction]
2021-11-29 15:50:24 +03:00
public static async Task<string> RAUNAME(string request)
2021-11-11 16:33:40 +03:00
{
2021-11-29 21:24:44 +03:00
Task<string> contentTask = Task.Run(() => SkuAssist.GetContent(request));
2021-11-29 16:36:04 +03:00
Task<IDocument> documentTask = await contentTask.ContinueWith(content => SkuAssist.GetDocument(content));
IProduct product = await documentTask.ContinueWith(doc => SkuAssist.GetProductFromDocument(doc.Result));
2021-11-29 21:24:44 +03:00
return product != null ? product.ToString() : "Не найдено";
2021-11-11 16:33:40 +03:00
}
}
}