diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2021-11-29 21:24:44 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2021-11-29 21:24:44 +0300 |
commit | 3ea18ae25e98527aa85835c9221ea01b36560b33 (patch) | |
tree | ca5ffb4f60b1c1b683e9094cec44d9431d3d1bb6 /Source/ExcelDNA | |
parent | f3b6bfcd3e13519f648c3975d19b8f1d48130059 (diff) |
Add Uri Converter
Diffstat (limited to 'Source/ExcelDNA')
-rw-r--r-- | Source/ExcelDNA/AddIn.cs | 24 | ||||
-rw-r--r-- | Source/ExcelDNA/Functions.cs | 19 |
2 files changed, 43 insertions, 0 deletions
diff --git a/Source/ExcelDNA/AddIn.cs b/Source/ExcelDNA/AddIn.cs new file mode 100644 index 0000000..dd99667 --- /dev/null +++ b/Source/ExcelDNA/AddIn.cs @@ -0,0 +1,24 @@ +using ExcelDna.Integration; +using ExcelDna.Registration; + +namespace Rehau.Sku.Assist +{ + public class AddIn : IExcelAddIn + { + public void AutoOpen() + { + RegisterFunctions(); + } + + public void AutoClose() + { + } + + void RegisterFunctions() + { + ExcelRegistration.GetExcelFunctions() + .ProcessAsyncRegistrations(nativeAsyncIfAvailable: false) + .RegisterFunctions(); + } + } +} diff --git a/Source/ExcelDNA/Functions.cs b/Source/ExcelDNA/Functions.cs new file mode 100644 index 0000000..a282e3e --- /dev/null +++ b/Source/ExcelDNA/Functions.cs @@ -0,0 +1,19 @@ +using AngleSharp.Dom; +using ExcelDna.Integration; +using System.Net.Http; +using System.Threading.Tasks; + +namespace Rehau.Sku.Assist +{ + public class Functions + { + [ExcelFunction] + public static async Task<string> RAUNAME(string request) + { + Task<string> contentTask = Task.Run(() => SkuAssist.GetContent(request)); + Task<IDocument> documentTask = await contentTask.ContinueWith(content => SkuAssist.GetDocument(content)); + IProduct product = await documentTask.ContinueWith(doc => SkuAssist.GetProductFromDocument(doc.Result)); + return product != null ? product.ToString() : "Не найдено"; + } + } +}
\ No newline at end of file |