diff options
author | Sergey Chebotar <s.chebotar@gmail.com> | 2021-11-29 17:12:56 +0300 |
---|---|---|
committer | Sergey Chebotar <s.chebotar@gmail.com> | 2021-11-29 17:12:56 +0300 |
commit | 2afcbbf08c21aa7368361269f24240147aa79a00 (patch) | |
tree | 9f6494fb2f70d086059619c0dce6316b338b69ca /src/ExcelDNA | |
parent | d176a023f06d70cb577e64d1a917e77d677d2a2b (diff) |
Организация директорий проекта
Diffstat (limited to 'src/ExcelDNA')
-rw-r--r-- | src/ExcelDNA/AddIn.cs | 24 | ||||
-rw-r--r-- | src/ExcelDNA/Functions.cs | 21 |
2 files changed, 45 insertions, 0 deletions
diff --git a/src/ExcelDNA/AddIn.cs b/src/ExcelDNA/AddIn.cs new file mode 100644 index 0000000..dd99667 --- /dev/null +++ b/src/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/src/ExcelDNA/Functions.cs b/src/ExcelDNA/Functions.cs new file mode 100644 index 0000000..6792195 --- /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 |