aboutsummaryrefslogtreecommitdiff
path: root/src/ExcelDNA/Functions.cs
diff options
context:
space:
mode:
authorSerghei Cebotari <51533848+schebotar@users.noreply.github.com>2021-11-29 17:17:16 +0300
committerGitHub <noreply@github.com>2021-11-29 17:17:16 +0300
commitf5799a28eaef3f3ea24ba56dc16970d6203b73fd (patch)
tree9532114d293af3b356630f34f0a57781a75e9939 /src/ExcelDNA/Functions.cs
parent5fc6d09f63d843ce65eb4d9fb7cc35df2ea6cc1e (diff)
parentf3b6bfcd3e13519f648c3975d19b8f1d48130059 (diff)
Merge pull request #2 from schebotar/dev
bDev
Diffstat (limited to 'src/ExcelDNA/Functions.cs')
-rw-r--r--src/ExcelDNA/Functions.cs21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/ExcelDNA/Functions.cs b/src/ExcelDNA/Functions.cs
new file mode 100644
index 0000000..ec9c607
--- /dev/null
+++ b/src/ExcelDNA/Functions.cs
@@ -0,0 +1,21 @@
+using AngleSharp.Dom;
+using ExcelDna.Integration;
+using System.Net.Http;
+using System.Threading.Tasks;
+
+namespace Rehau.Sku.Assist
+{
+ public class Functions
+ {
+ private static HttpClient _httpClient = new HttpClient();
+
+ [ExcelFunction]
+ public static async Task<string> RAUNAME(string request)
+ {
+ Task<string> contentTask = Task.Run(() => SkuAssist.GetContent(request, _httpClient));
+ Task<IDocument> documentTask = await contentTask.ContinueWith(content => SkuAssist.GetDocument(content));
+ IProduct product = await documentTask.ContinueWith(doc => SkuAssist.GetProductFromDocument(doc.Result));
+ return product == null ? ExcelError.ExcelErrorNull.ToString() : product.ToString();
+ }
+ }
+} \ No newline at end of file