/// <summary> /// Write the values of this instance to the registry. /// </summary> public void WriteRegistry() { RegistryKey regKey = null; try { regKey = Base.GetOtcRegKey(); regKey.SetValue("EnableAm", Convert.ToInt32(EnableAM).ToString()); regKey.SetValue("ManagedAttachmentAsk", Convert.ToInt32(ManagedAttachmentAsk).ToString()); regKey.SetValue("ManagedAttachmentThreshold", ManagedAttachmentThreshold.ToString()); regKey.SetValue("ManagedAttachmentExpiryGen", ExpiryGenSetting.ToString()); regKey.SetValue("ManagedAttachmentExpiryCustomValue", ExpiryCustomValue.ToString()); regKey.SetValue("ManagedAttachmentExpiryCustomUnit", ExpiryCustomUnit.ToString()); } catch (Exception ex) { Base.HandleException(ex, true); } finally { if (regKey != null) { regKey.Close(); } } }
/// <summary> /// Writes the settings to the registry, including the attachment management /// specific settings. /// </summary> public void WriteRegistry() { Logging.Log("Writing OTC settings from the registry."); RegistryKey regKey = null; try { regKey = Base.GetOtcRegKey(); regKey.SetValue("EnableOTC", Convert.ToInt32(OtcEnabledFlag).ToString()); regKey.SetValue("EnableSkurl", Convert.ToInt32(SkurlEnabledFlag).ToString()); regKey.SetValue("EnableOtcDebugging", Convert.ToInt32(LogToFileFlag).ToString()); regKey.SetValue("HideAmWelcomeFlag", Convert.ToInt32(HideAmWelcomeFlag).ToString()); AmSettings.WriteRegistry(); } catch (Exception ex) { Base.HandleException(ex, true); } finally { if (regKey != null) { regKey.Close(); } } }
/// <summary> /// Reads the registry and update the object's variables. Includes updating the /// attachment management specific settings. /// </summary> public void ReadRegistry() { RegistryKey regKey = null; try { regKey = Base.GetOtcRegKey(); int val; if (Int32.TryParse(regKey.GetValue("EnableOtc", "1") as String, out val)) { OtcEnabledFlag = Convert.ToBoolean(val); } else { OtcEnabledFlag = true; } // First, look up the legacy key name. Use its value if present. String skurl = regKey.GetValue("Public_Workspace", "DEFAULT") as String; if (skurl != null && skurl != "DEFAULT" && Int32.TryParse(skurl, out val)) { // Convert to new key name. SkurlEnabledFlag = Convert.ToBoolean(val); regKey.DeleteValue("Public_Workspace", false); regKey.SetValue("EnableSkurl", val.ToString()); } else { if (Int32.TryParse(regKey.GetValue("EnableSkurl", "1") as String, out val)) { SkurlEnabledFlag = Convert.ToBoolean(val); } else { SkurlEnabledFlag = true; } } if (Int32.TryParse(regKey.GetValue("EnableOtcDebugging", "0") as String, out val)) { if (val > 0) { LogToFileFlag = true; Logging.Log("Enabling OTC logging."); } else { Logging.Log("Disabling OTC logging."); LogToFileFlag = false; } } else { LogToFileFlag = true; } if (Int32.TryParse(regKey.GetValue("HideAmWelcomeFlag", "0") as String, out val)) { HideAmWelcomeFlag = Convert.ToBoolean(val); } else { HideAmWelcomeFlag = false; } // Update the attachment management settings. AmSettings.ReadRegistry(); } finally { if (regKey != null) { regKey.Close(); } } }
/// <summary> /// Read the values of this instance from the registry. /// </summary> public void ReadRegistry() { RegistryKey regKey = null; try { regKey = Base.GetOtcRegKey(); int val; UInt64 uval; if (Int32.TryParse(regKey.GetValue("EnableAM", "1") as String, out val)) { EnableAM = Convert.ToBoolean(val); } else { EnableAM = true; } if (Int32.TryParse(regKey.GetValue("ManagedAttachmentAsk", "1") as String, out val)) { ManagedAttachmentAsk = Convert.ToBoolean(val); } else { ManagedAttachmentAsk = true; } if (UInt64.TryParse(regKey.GetValue("ManagedAttachmentThreshold", DefaultThreshold.ToString()) as String, out uval)) { ManagedAttachmentThreshold = uval; } else { ManagedAttachmentThreshold = DefaultThreshold; } if (Int32.TryParse(regKey.GetValue("ManagedAttachmentExpiryGen", "0") as String, out val) && IsValidGenValue(val)) { ExpiryGenSetting = val; } else { ExpiryGenSetting = 1; } if (Int32.TryParse(regKey.GetValue("ManagedAttachmentExpiryCustomValue", "1") as String, out val)) { ExpiryCustomValue = val; } else { ExpiryCustomValue = 1; } if (Int32.TryParse(regKey.GetValue("ManagedAttachmentExpiryCustomUnit", "0") as String, out val) && IsValidCustomUnit(val)) { ExpiryCustomUnit = val; } else { ExpiryCustomUnit = 0; } } catch (Exception ex) { Base.HandleException(ex, true); } finally { if (regKey != null) { regKey.Close(); } } }