2021-11-29 16:36:04 +03:00
|
|
|
|
using AngleSharp.Dom;
|
2021-11-29 15:50:24 +03:00
|
|
|
|
using ExcelDna.Integration;
|
2021-11-14 12:27:49 +03:00
|
|
|
|
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
|
|
|
|
{
|
2021-11-29 17:13:36 +03:00
|
|
|
|
private static HttpClient _httpClient = new HttpClient();
|
2021-11-11 16:33:40 +03:00
|
|
|
|
|
2021-11-29 11:26:25 +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 17:13:36 +03:00
|
|
|
|
Task<string> contentTask = Task.Run(() => SkuAssist.GetContent(request, _httpClient));
|
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 17:10:43 +03:00
|
|
|
|
return product == null ? ExcelError.ExcelErrorNull.ToString() : product.ToString();
|
2021-11-11 16:33:40 +03:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|