fix:console commands for Secrets Management Modified

This commit is contained in:
Trevor Payne
2022-07-15 17:40:48 -05:00
parent c3818b8bf2
commit 5a4cc2fd39
3 changed files with 79 additions and 75 deletions

View File

@@ -39,7 +39,10 @@ namespace PepperDash.Essentials.Core.Config
Name = dc.Name; Name = dc.Name;
Group = dc.Group; Group = dc.Group;
Type = dc.Type; Type = dc.Type;
Properties = JToken.FromObject(dc.Properties);
Properties = JToken.Parse(dc.Properties.ToString());
//Properties = JToken.FromObject(dc.Properties);
} }
public DeviceConfig() {} public DeviceConfig() {}

View File

@@ -59,7 +59,7 @@ namespace PepperDash.Essentials.Core.Devices
/// <summary> /// <summary>
/// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc) /// Used by the extending class to allow for any custom actions to be taken (tell the ConfigWriter to write config, etc)
/// </summary> /// </summary>
/// <param name="Config"></param> /// <param name="config"></param>
protected virtual void CustomSetConfig(DeviceConfig config) protected virtual void CustomSetConfig(DeviceConfig config)
{ {
ConfigWriter.UpdateDeviceConfig(config); ConfigWriter.UpdateDeviceConfig(config);

View File

@@ -36,21 +36,22 @@ namespace PepperDash.Essentials.Core
public bool SetSecret(string key, object value) public bool SetSecret(string key, object value)
{ {
var secret = value as string; var secret = value as string;
CrestronDataStore.CDS_ERROR returnCode;
if (String.IsNullOrEmpty(secret)) if (String.IsNullOrEmpty(secret))
{ {
Debug.Console(2, this, "Unable to set secret for {0}:{1} - value is empty.", Key, key); returnCode = CrestronDataStoreStatic.clearLocal(key);
return false; if (returnCode == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) return true;
} }
var setErrorCode = CrestronDataStoreStatic.SetLocalStringValue(key, secret);
switch (setErrorCode) else
{ {
case CrestronDataStore.CDS_ERROR.CDS_SUCCESS: returnCode = CrestronDataStoreStatic.SetLocalStringValue(key, secret);
Debug.Console(1, this,"Secret Successfully Set for {0}:{1}", Key, key); if (returnCode == CrestronDataStore.CDS_ERROR.CDS_SUCCESS) return true;
return true;
default:
Debug.Console(2, this, Debug.ErrorLogLevel.Notice, "Unable to set secret for {0}:{1} - {2}", Key, key, setErrorCode.ToString());
return false;
} }
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Unable to set secret for {0}:{1} - {2}", Key, key, returnCode.ToString());
return false;
} }
/// <summary> /// <summary>