Permalink
Browse files

Fixed issue #67 - Connection file gets erased

  • Loading branch information...
rmcardle
rmcardle committed Dec 6, 2011
1 parent 87b0f31 commit 46447418492c89680fe859a3973f27afa4bc7ebe
@@ -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,16 +811,54 @@ 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
tmrSqlWatcher.Start()
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
@@ -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
@@ -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>

0 comments on commit 4644741

Please sign in to comment.