Fixed issue #67 - Connection file gets erased

This commit is contained in:
rmcardle
2011-12-06 03:21:28 -06:00
parent 87b0f317d1
commit 4644741849
5 changed files with 56 additions and 25 deletions

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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>

View File

@@ -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>