1
0
mirror of https://github.com/alex-bochkov/ssms-addin.git synced 2025-11-23 22:04:53 +02:00
Files
ssms-addin/Addin.SSMS2018/SettingManager.vb

153 lines
3.5 KiB
VB.net
Raw Normal View History

2019-12-01 12:19:10 -08:00
Imports System
Imports System.IO
Imports Microsoft.Win32
Namespace SettingManager
Module SettingManagerModule
Private Function GetRoot() As RegistryKey
Dim SettingKeyRoot As RegistryKey = Registry.CurrentUser.CreateSubKey("DBA-Helper.SSMS2018")
Dim testSettings As RegistryKey = SettingKeyRoot.CreateSubKey("Settings")
Return testSettings
End Function
2019-12-01 13:06:34 -08:00
Private Function GetRegisterValue(Parameter As String) As String
2019-12-01 12:19:10 -08:00
2019-12-01 13:06:34 -08:00
Dim RegisterValue As String = ""
Try
Dim RootKey = GetRoot()
RegisterValue = RootKey.GetValue(Parameter).ToString
2019-12-01 12:19:10 -08:00
2019-12-01 13:06:34 -08:00
Catch ex As Exception
End Try
Return RegisterValue
End Function
Private Function SaveRegisterValue(ParameterName As String, ParameterValue As String) As Boolean
2019-12-01 12:19:10 -08:00
Try
Dim RootKey = GetRoot()
2019-12-01 13:06:34 -08:00
RootKey.SetValue(ParameterName, ParameterValue)
RootKey.Close()
2019-12-01 12:19:10 -08:00
Catch ex As Exception
2019-12-01 13:06:34 -08:00
Return False
2019-12-01 12:19:10 -08:00
End Try
2019-12-01 13:06:34 -08:00
Return True
End Function
'***********************************************************************************
Function GetTemplatesFolder() As String
Dim Folder As String = GetRegisterValue("ScriptTemplatesFolder")
2019-12-01 12:19:10 -08:00
If String.IsNullOrEmpty(Folder) Then
Folder = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), "dba-helper-scripts")
End If
Return Folder
End Function
2019-12-01 13:06:34 -08:00
Function GetSQLParserVersion() As String
2019-12-01 12:19:10 -08:00
2019-12-01 13:06:34 -08:00
Dim TSQLParserVersion As String = GetRegisterValue("TSQLParserVersion")
2019-12-01 12:19:10 -08:00
2019-12-01 13:06:34 -08:00
If String.IsNullOrEmpty(TSQLParserVersion) Then
2019-12-01 12:19:10 -08:00
2019-12-01 13:06:34 -08:00
TSQLParserVersion = "SQL Server 2017" 'default value
2019-12-01 12:19:10 -08:00
2019-12-01 13:06:34 -08:00
End If
2019-12-01 12:19:10 -08:00
2019-12-01 13:06:34 -08:00
Return TSQLParserVersion
End Function
2019-12-01 14:23:48 -08:00
Function GetSQLParserType() As Boolean
2019-12-01 13:06:34 -08:00
2019-12-01 14:23:48 -08:00
Dim TSQLParserType As String = GetRegisterValue("TSQLParserType")
If String.IsNullOrEmpty(TSQLParserType) Then
Return False
End If
If TSQLParserType = "False" Then
Return False
Else
Return True
End If
End Function
2019-12-01 13:06:34 -08:00
Function SaveTemplatesFolder(Folder As String) As Boolean
Return SaveRegisterValue("ScriptTemplatesFolder", Folder)
End Function
Function SaveSQLParserVersion(TSQLParserVersion As String) As Boolean
Return SaveRegisterValue("TSQLParserVersion", TSQLParserVersion)
2019-12-01 12:19:10 -08:00
End Function
2019-12-01 14:23:48 -08:00
Function SaveSQLParserType(TSQLParserType As Boolean) As Boolean
Return SaveRegisterValue("TSQLParserType", TSQLParserType.ToString())
End Function
2019-12-01 12:19:10 -08:00
'Function GetExcelExportFolder() As String
' Dim Folder As String = ""
' Try
' Dim RootKey = GetRoot()
' Folder = RootKey.GetValue("ExcelExportFolder").ToString
' Catch ex As Exception
' End Try
' Return Folder
'End Function
'Function SaveExcelExportFolder(Folder As String) As Boolean
' Try
' Dim RootKey = GetRoot()
' RootKey.SetValue("ExcelExportFolder", Folder)
' RootKey.Close()
' Catch ex As Exception
' Return False
' End Try
' Return True
'End Function
End Module
End Namespace