Add RegistryUtil
This commit is contained in:
parent
e175a634ce
commit
2511d1b444
@ -1,7 +1,6 @@
|
||||
using ExcelDna.Integration;
|
||||
using ExcelDna.IntelliSense;
|
||||
using ExcelDna.Registration;
|
||||
using Microsoft.Win32;
|
||||
using System.Net.Http;
|
||||
|
||||
namespace RehauSku
|
||||
@ -18,13 +17,12 @@ namespace RehauSku
|
||||
public class AddIn : IExcelAddIn
|
||||
{
|
||||
public static readonly HttpClient httpClient = new HttpClient();
|
||||
public static ResponseOrder StoreResponse { get; set; }
|
||||
public static string PriceListPath { get; set; }
|
||||
public static ResponseOrder StoreResponseOrder = RegistryUtil.StoreResponseOrder;
|
||||
public static string PriceListPath = RegistryUtil.PriceListPath;
|
||||
|
||||
public void AutoOpen()
|
||||
{
|
||||
RegisterFunctions();
|
||||
GetRegistryKeys();
|
||||
IntelliSenseServer.Install();
|
||||
}
|
||||
|
||||
@ -39,17 +37,5 @@ namespace RehauSku
|
||||
.ProcessAsyncRegistrations(nativeAsyncIfAvailable: false)
|
||||
.RegisterFunctions();
|
||||
}
|
||||
|
||||
void GetRegistryKeys()
|
||||
{
|
||||
RegistryKey addInKeys = Registry
|
||||
.CurrentUser
|
||||
.OpenSubKey("SOFTWARE")
|
||||
.OpenSubKey("REHAU")
|
||||
.OpenSubKey("SkuAssist");
|
||||
|
||||
StoreResponse = (ResponseOrder)addInKeys.GetValue("ResponseOrder");
|
||||
PriceListPath = (string)addInKeys.GetValue("PriceListPath");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
76
Source/AddIn/RegistryUtil.cs
Normal file
76
Source/AddIn/RegistryUtil.cs
Normal file
@ -0,0 +1,76 @@
|
||||
using Microsoft.Win32;
|
||||
|
||||
namespace RehauSku
|
||||
{
|
||||
static class RegistryUtil
|
||||
{
|
||||
public static string PriceListPath
|
||||
{
|
||||
get
|
||||
{
|
||||
_GetRootKey();
|
||||
|
||||
if (_RootKey == null)
|
||||
{
|
||||
return @"D:\Dropbox\Рабочее\Таблица заказов ИС EAE_2021.xlsm";
|
||||
}
|
||||
|
||||
else return (string)_RootKey.GetValue("PriceListPath");
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
_GetRootKey();
|
||||
|
||||
if (_RootKey == null)
|
||||
{
|
||||
RegistryKey PriceListPath = Registry.CurrentUser
|
||||
.CreateSubKey("SOFTWARE")
|
||||
.CreateSubKey("REHAU")
|
||||
.CreateSubKey("SkuAssist");
|
||||
}
|
||||
|
||||
_RootKey.SetValue("PriceListPath", value);
|
||||
}
|
||||
}
|
||||
|
||||
public static ResponseOrder StoreResponseOrder
|
||||
{
|
||||
get
|
||||
{
|
||||
_GetRootKey();
|
||||
|
||||
if (_RootKey == null)
|
||||
{
|
||||
return ResponseOrder.Default;
|
||||
}
|
||||
|
||||
return (ResponseOrder)_RootKey.GetValue("ResponseOrder");
|
||||
}
|
||||
|
||||
private set
|
||||
{
|
||||
if (_RootKey == null)
|
||||
{
|
||||
RegistryKey PriceListPath = Registry.CurrentUser
|
||||
.CreateSubKey("SOFTWARE")
|
||||
.CreateSubKey("REHAU")
|
||||
.CreateSubKey("SkuAssist");
|
||||
}
|
||||
|
||||
_RootKey.SetValue("ResponseOrder", value);
|
||||
}
|
||||
}
|
||||
|
||||
private static RegistryKey _RootKey { get; set; }
|
||||
|
||||
private static void _GetRootKey()
|
||||
{
|
||||
_RootKey = Registry
|
||||
.CurrentUser
|
||||
.OpenSubKey("SOFTWARE")
|
||||
.OpenSubKey("REHAU")
|
||||
.OpenSubKey("SkuAssist");
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user