diff --git a/Src/CommonAssemblyInfo.cs b/Src/CommonAssemblyInfo.cs
index 201b3ced9..73fecf046 100644
--- a/Src/CommonAssemblyInfo.cs
+++ b/Src/CommonAssemblyInfo.cs
@@ -1,4 +1,4 @@
using System.Reflection;
-[assembly: AssemblyCompany("SolarWinds, Inc.")]
+[assembly: AssemblyCompany("SolarWinds.")]
[assembly: AssemblyCopyright("Copyright © 2015 SolarWinds Worldwide, LLC. All rights reserved.")]
diff --git a/Src/SwqlStudio/Program.cs b/Src/SwqlStudio/Program.cs
index c42e8211a..333b1606e 100644
--- a/Src/SwqlStudio/Program.cs
+++ b/Src/SwqlStudio/Program.cs
@@ -1,6 +1,9 @@
using System;
using System.Windows.Forms;
using SwqlStudio.Properties;
+using System.IO;
+using System.Configuration;
+using System.Linq;
namespace SwqlStudio
{
@@ -17,10 +20,16 @@ static void Main()
SolarWinds.Logging.Log.Configure(string.Empty);
AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException;
-
if (Settings.Default.UpdateRequired)
{
Settings.Default.Upgrade();
+
+ if (string.IsNullOrWhiteSpace(Settings.Default.PreviousServers))
+ {
+ SearchAndCopyLastUserConfig(new Version(Application.ProductVersion));
+ Settings.Default.Reload();
+ }
+
Settings.Default.UpdateRequired = false;
}
@@ -34,5 +43,63 @@ static void CurrentDomainUnhandledException(object sender, UnhandledExceptionEve
if (e.ExceptionObject is Exception)
log.Error("Unhandled exception", (Exception)e.ExceptionObject);
}
+
+ private static void SearchAndCopyLastUserConfig(Version currentVersion)
+ {
+ try
+ {
+ string userConfigFileName = "user.config";
+
+ // Expected location of the current user config
+ DirectoryInfo currentVersionConfigFileDir = new FileInfo(ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.PerUserRoamingAndLocal).FilePath).Directory;
+ if (currentVersionConfigFileDir != null)
+ {
+ if (!currentVersionConfigFileDir.Exists)
+ currentVersionConfigFileDir.Create();
+
+ //1. Look for previous version with the same .net version
+ // grab the most recent folder from the list of user's settings folders, prior to the current version
+ var previousSettingsDir = (from dir in currentVersionConfigFileDir.Parent.EnumerateDirectories()
+ let dirVer = new { Dir = dir, Ver = new Version(dir.Name) }
+ where dirVer.Ver < currentVersion
+ orderby dirVer.Ver descending
+ select dir).FirstOrDefault();
+
+ if (previousSettingsDir != null)
+ {
+ CopyUserConfigSettings(currentVersion, userConfigFileName, currentVersionConfigFileDir, previousSettingsDir);
+ }
+ //2. If not present look for older version with different .net version
+ else
+ {
+ // grab the most recent folder from the list of user's settings folders, prior to the current version
+ previousSettingsDir = (from dir in currentVersionConfigFileDir.Parent.Parent.EnumerateDirectories("????.????.????.????", SearchOption.AllDirectories)
+ let dirVer = new { Dir = dir, Ver = new Version(dir.Name) }
+ where dirVer.Ver < currentVersion && dir.Parent.Name.ToLower().Contains("swqlstudio")
+ orderby dirVer.Ver descending
+ select dir).FirstOrDefault();
+
+ CopyUserConfigSettings(currentVersion, userConfigFileName, currentVersionConfigFileDir, previousSettingsDir);
+ }
+ }
+ }
+ catch (Exception ex)
+ {
+ log.Error("An error occurred while trying to upgrade user specific settings for the new version.", ex);
+ }
+ }
+
+ private static void CopyUserConfigSettings(Version currentVersion, string userConfigFileName, DirectoryInfo currentVersionConfigFileDir, DirectoryInfo previousSettingsDir)
+ {
+ string previousVersionConfigFile = string.Concat(previousSettingsDir.FullName, @"\", userConfigFileName);
+ string currentVersionConfigFile = string.Concat(currentVersionConfigFileDir.FullName, @"\", userConfigFileName);
+
+ if (!currentVersionConfigFileDir.Exists)
+ {
+ Directory.CreateDirectory(currentVersionConfigFileDir.FullName);
+ }
+
+ File.Copy(previousVersionConfigFile, currentVersionConfigFile, true);
+ }
}
}
diff --git a/Src/SwqlStudio/SwqlStudio.csproj b/Src/SwqlStudio/SwqlStudio.csproj
index 23da72cce..2e5c90271 100644
--- a/Src/SwqlStudio/SwqlStudio.csproj
+++ b/Src/SwqlStudio/SwqlStudio.csproj
@@ -79,6 +79,7 @@
.\Security.Cryptography.dll
+
3.5