diff --git a/Assistant/SkuAssist.cs b/Assistant/SkuAssist.cs index a9de2e1..9d90394 100644 --- a/Assistant/SkuAssist.cs +++ b/Assistant/SkuAssist.cs @@ -17,12 +17,12 @@ namespace Rehau.Sku.Assist return await httpClient.GetStringAsync(uri); } - public async static Task GetDocument(string source) + public async static Task GetDocument(Task source) { IConfiguration config = Configuration.Default; IBrowsingContext context = BrowsingContext.New(config); - return await context.OpenAsync(req => req.Content(source)); + return await context.OpenAsync(req => req.Content(source.Result)); } public static IProduct GetProductFromDocument(IDocument document) diff --git a/Functions.cs b/Functions.cs index ab6cedf..9112822 100644 --- a/Functions.cs +++ b/Functions.cs @@ -1,4 +1,4 @@ -using System; +using AngleSharp.Dom; using ExcelDna.Integration; using System.Net.Http; using System.Threading.Tasks; @@ -12,7 +12,10 @@ namespace Rehau.Sku.Assist [ExcelFunction] public static async Task RAUNAME(string request) { - throw new NotImplementedException(); + Task contentTask = Task.Run(() => SkuAssist.GetContent(request, httpClient)); + Task documentTask = await contentTask.ContinueWith(content => SkuAssist.GetDocument(content)); + IProduct product = await documentTask.ContinueWith(doc => SkuAssist.GetProductFromDocument(doc.Result)); + return product.ToString(); } } } \ No newline at end of file