aboutsummaryrefslogtreecommitdiff
path: root/Source/AddIn
diff options
context:
space:
mode:
authorSergey Chebotar <s.chebotar@gmail.com>2021-12-08 14:38:23 +0300
committerSergey Chebotar <s.chebotar@gmail.com>2021-12-08 14:38:23 +0300
commit8a869e73fb1873b1f85203b7a4a18dc8a2325a11 (patch)
tree75664c807edbd0901cfc8adb9fca44724cb1452f /Source/AddIn
parent875fc1ef72d35e66cef04697dc947f80c4bcb87c (diff)
Rename dir ExcelDNA -> AddIn
Diffstat (limited to 'Source/AddIn')
-rw-r--r--Source/AddIn/AddIn.cs53
-rw-r--r--Source/AddIn/Functions.cs19
2 files changed, 72 insertions, 0 deletions
diff --git a/Source/AddIn/AddIn.cs b/Source/AddIn/AddIn.cs
new file mode 100644
index 0000000..3c82406
--- /dev/null
+++ b/Source/AddIn/AddIn.cs
@@ -0,0 +1,53 @@
+using ExcelDna.Integration;
+using ExcelDna.Registration;
+using Microsoft.Win32;
+using System.Net.Http;
+
+namespace RehauSku.Assist
+{
+ public enum ResponseOrder
+ {
+ Default,
+ Relevance,
+ Name,
+ Price,
+ Series
+ }
+
+ public class AddIn : IExcelAddIn
+ {
+ public static readonly HttpClient httpClient = new HttpClient();
+ public static ResponseOrder responseOrder;
+ public static string priceListPath;
+
+ public void AutoOpen()
+ {
+ RegisterFunctions();
+ GetRegistryKeys();
+ }
+
+ public void AutoClose()
+ {
+
+ }
+
+ void RegisterFunctions()
+ {
+ ExcelRegistration.GetExcelFunctions()
+ .ProcessAsyncRegistrations(nativeAsyncIfAvailable: false)
+ .RegisterFunctions();
+ }
+
+ void GetRegistryKeys()
+ {
+ RegistryKey addInKeys = Registry
+ .CurrentUser
+ .OpenSubKey("SOFTWARE")
+ .OpenSubKey("REHAU")
+ .OpenSubKey("SkuAssist");
+
+ responseOrder = (ResponseOrder)addInKeys.GetValue("ResponseOrder");
+ priceListPath = (string)addInKeys.GetValue("PriceListPath");
+ }
+ }
+}
diff --git a/Source/AddIn/Functions.cs b/Source/AddIn/Functions.cs
new file mode 100644
index 0000000..6d94e24
--- /dev/null
+++ b/Source/AddIn/Functions.cs
@@ -0,0 +1,19 @@
+using ExcelDna.Integration;
+
+namespace RehauSku.Assist
+{
+ public class Functions
+ {
+ [ExcelFunction]
+ public static object RAUNAME(string request)
+ => SkuAssist.GetProduct(request, ProductField.Name);
+
+ [ExcelFunction]
+ public static object RAUSKU(string request)
+ => SkuAssist.GetProduct(request, ProductField.Id);
+
+ [ExcelFunction]
+ public static object RAUPRICE(string request)
+ => SkuAssist.GetProduct(request, ProductField.Price);
+ }
+} \ No newline at end of file