mirror of
https://github.com/mRemoteNG/mRemoteNG.git
synced 2026-02-17 22:11:48 +08:00
Fixed issue #67 - Connection file gets erased
This commit is contained in:
@@ -729,6 +729,8 @@ Namespace App
|
||||
End Sub
|
||||
|
||||
Public Shared Sub LoadConnections(Optional ByVal WithDialog As Boolean = False, Optional ByVal Update As Boolean = False)
|
||||
Dim conL As New Config.Connections.Load
|
||||
|
||||
Try
|
||||
Dim tmrWasEnabled As Boolean
|
||||
If tmrSqlWatcher IsNot Nothing Then
|
||||
@@ -747,41 +749,18 @@ Namespace App
|
||||
cL = New Connection.List
|
||||
ctL = New Container.List
|
||||
|
||||
Dim conL As New Config.Connections.Load
|
||||
|
||||
If My.Settings.UseSQLServer = False Then
|
||||
If WithDialog Then
|
||||
Dim lD As OpenFileDialog = Tools.Controls.ConnectionsLoadDialog
|
||||
|
||||
If lD.ShowDialog = System.Windows.Forms.DialogResult.OK Then
|
||||
conL.ConnectionFileName = lD.FileName
|
||||
|
||||
If conL.ConnectionFileName = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile Then
|
||||
My.Settings.LoadConsFromCustomLocation = False
|
||||
Else
|
||||
My.Settings.LoadConsFromCustomLocation = True
|
||||
My.Settings.CustomConsPath = conL.ConnectionFileName
|
||||
End If
|
||||
Else
|
||||
Exit Sub
|
||||
End If
|
||||
Else
|
||||
If My.Settings.LoadConsFromCustomLocation = False Then
|
||||
Dim oldPath As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\" & My.Application.Info.ProductName & "\" & App.Info.Connections.DefaultConnectionsFile
|
||||
Dim newPath As String = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile
|
||||
#If Not PORTABLE Then
|
||||
If File.Exists(oldPath) Then
|
||||
conL.ConnectionFileName = oldPath
|
||||
Else
|
||||
conL.ConnectionFileName = newPath
|
||||
End If
|
||||
#Else
|
||||
conL.ConnectionFileName = newPath
|
||||
#End If
|
||||
Else
|
||||
conL.ConnectionFileName = My.Settings.CustomConsPath
|
||||
End If
|
||||
End If
|
||||
conL.ConnectionFileName = GetStartupConnectionFileName()
|
||||
End If
|
||||
|
||||
If File.Exists(conL.ConnectionFileName) = False Then
|
||||
If WithDialog Then
|
||||
@@ -832,6 +811,13 @@ Namespace App
|
||||
|
||||
If My.Settings.UseSQLServer = True Then
|
||||
LastSQLUpdate = Now
|
||||
Else
|
||||
If conL.ConnectionFileName = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile Then
|
||||
My.Settings.LoadConsFromCustomLocation = False
|
||||
Else
|
||||
My.Settings.LoadConsFromCustomLocation = True
|
||||
My.Settings.CustomConsPath = conL.ConnectionFileName
|
||||
End If
|
||||
End If
|
||||
|
||||
If tmrWasEnabled And tmrSqlWatcher IsNot Nothing Then
|
||||
@@ -839,9 +825,40 @@ Namespace App
|
||||
End If
|
||||
Catch ex As Exception
|
||||
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strConnectionsFileCouldNotBeLoaded & vbNewLine & ex.Message)
|
||||
If My.Settings.UseSQLServer = False Then
|
||||
If Not conL.ConnectionFileName = GetStartupConnectionFileName() Then
|
||||
LoadConnections()
|
||||
Exit Sub
|
||||
Else
|
||||
MsgBox(String.Format(My.Resources.strErrorStartupConnectionFileLoad, vbNewLine, Application.ProductName, GetStartupConnectionFileName(), ex.Message), MsgBoxStyle.OkOnly + MsgBoxStyle.Critical)
|
||||
Application.Exit()
|
||||
End If
|
||||
End If
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
Protected Shared Function GetStartupConnectionFileName() As String
|
||||
Dim fileName As New String("")
|
||||
|
||||
If My.Settings.LoadConsFromCustomLocation = False Then
|
||||
Dim oldPath As String = GetFolderPath(SpecialFolder.LocalApplicationData) & "\" & My.Application.Info.ProductName & "\" & App.Info.Connections.DefaultConnectionsFile
|
||||
Dim newPath As String = App.Info.Connections.DefaultConnectionsPath & "\" & App.Info.Connections.DefaultConnectionsFile
|
||||
#If Not PORTABLE Then
|
||||
If File.Exists(oldPath) Then
|
||||
fileName = oldPath
|
||||
Else
|
||||
fileName = newPath
|
||||
End If
|
||||
#Else
|
||||
fileName = newPath
|
||||
#End If
|
||||
Else
|
||||
fileName = My.Settings.CustomConsPath
|
||||
End If
|
||||
|
||||
Return fileName
|
||||
End Function
|
||||
|
||||
Public Shared Sub ImportConnections()
|
||||
Try
|
||||
Dim lD As OpenFileDialog = Tools.Controls.ConnectionsLoadDialog
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
1.69 (2011-07-29):
|
||||
Fixed issue #66 - Fresh Install Fails to Create Config
|
||||
Fixed issue #67 - Connection file gets erased
|
||||
Disabled automatic updates in the portable edition
|
||||
Updated PuTTY to version 0.61
|
||||
Binaries are now digitally signed
|
||||
|
||||
@@ -716,6 +716,7 @@ Namespace Config
|
||||
Catch ex As Exception
|
||||
App.Runtime.ConnectionsFileLoaded = False
|
||||
mC.AddMessage(Messages.MessageClass.ErrorMsg, My.Resources.strLoadFromXmlFailed & vbNewLine & ex.Message, True)
|
||||
Throw
|
||||
End Try
|
||||
End Sub
|
||||
|
||||
|
||||
9
mRemoteV1/My Project/Resources.Designer.vb
generated
9
mRemoteV1/My Project/Resources.Designer.vb
generated
@@ -2186,6 +2186,15 @@ Namespace My.Resources
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Looks up a localized string similar to The startup connection file could not be loaded.{0}{0}{2}{0}{3}{0}{0}In order to prevent data loss, {1} will now exit..
|
||||
'''</summary>
|
||||
Friend ReadOnly Property strErrorStartupConnectionFileLoad() As String
|
||||
Get
|
||||
Return ResourceManager.GetString("strErrorStartupConnectionFileLoad", resourceCulture)
|
||||
End Get
|
||||
End Property
|
||||
|
||||
'''<summary>
|
||||
''' Looks up a localized string similar to VerifyDatabaseVersion (Config.Connections.Save) failed. {0}.
|
||||
'''</summary>
|
||||
|
||||
@@ -2349,4 +2349,7 @@ Error Description: {1}</value>
|
||||
<data name="strUpdateCheckPortableEdition">
|
||||
<value xml:space="preserve">mRemoteNG Portable Edition does not currently support automatic updates.</value>
|
||||
</data>
|
||||
<data name="strErrorStartupConnectionFileLoad">
|
||||
<value xml:space="preserve">The startup connection file could not be loaded.{0}{0}{2}{0}{3}{0}{0}In order to prevent data loss, {1} will now exit.</value>
|
||||
</data>
|
||||
</root>
|
||||
Reference in New Issue
Block a user