Merge pull request #2396 from BlueBlock/fix_load_misssing_localconnectionproperties_xml_file

Fix load misssing localconnectionproperties xml file
This commit is contained in:
Dimitrij
2023-03-21 20:44:59 +00:00
committed by GitHub
4 changed files with 9 additions and 8 deletions

View File

@@ -17,6 +17,7 @@ namespace mRemoteNG.App.Info
public static string LayoutFileName { get; } = "pnlLayout.xml";
public static string ExtAppsFilesName { get; } = "extApps.xml";
public static string ThemesFileName { get; } = "Themes.xml";
public static string LocalConnectionProperties { get; } = "LocalConnectionProperties.xml";
public static string ThemeFolder { get; } =
SettingsPath != null ? Path.Combine(SettingsPath, "Themes") : String.Empty;

View File

@@ -21,6 +21,11 @@ namespace mRemoteNG.Config.DataProviders
var fileContents = "";
try
{
if (!File.Exists(FilePath))
{
CreateMissingDirectories();
File.WriteAllLines(FilePath, new []{ $@"<?xml version=""1.0"" encoding=""UTF-8""?>", $@"<LocalConnections/>" });
}
fileContents = File.ReadAllText(FilePath);
}
catch (FileNotFoundException ex)

View File

@@ -113,7 +113,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.MsSql
// ANSI SQL way. Works in PostgreSQL, MSSQL, MySQL.
var cmd = databaseConnector.DbCommand("select case when exists((select * from information_schema.tables where table_name = '" + tableName + "')) then 1 else 0 end");
cmd.ExecuteNonQuery();
exists = (int)cmd.ExecuteScalar()! == 1;
exists = (int)(long)cmd.ExecuteScalar()! == 1;
}
catch
{

View File

@@ -44,13 +44,8 @@ namespace mRemoteNG.Connection
public ConnectionsService(PuttySessionsManager puttySessionsManager)
{
if (puttySessionsManager == null)
throw new ArgumentNullException(nameof(puttySessionsManager));
_puttySessionsManager = puttySessionsManager;
var path = SettingsFileInfo.SettingsPath;
_localConnectionPropertiesDataProvider =
new FileDataProvider(Path.Combine(path, "LocalConnectionProperties.xml"));
_puttySessionsManager = puttySessionsManager ?? throw new ArgumentNullException(nameof(puttySessionsManager));
_localConnectionPropertiesDataProvider = new FileDataProvider(Path.Combine(SettingsFileInfo.SettingsPath, SettingsFileInfo.LocalConnectionProperties));
_localConnectionPropertiesSerializer = new LocalConnectionPropertiesXmlSerializer();
}