fix database upgrades

- fix tested db upgrading for each version
- fix version check for 3.0
This commit is contained in:
BlueBlock
2023-03-23 16:31:28 -04:00
parent e6abe3f3a1
commit b1a6ba78d4
8 changed files with 183 additions and 95 deletions

View File

@@ -61,9 +61,8 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
if (_confVersion > 1.3)
{
var protectedString = _xmlDocument.DocumentElement?.Attributes["Protected"].Value;
if (!_decryptor.ConnectionsFileIsAuthentic(protectedString,
_rootNodeInfo.PasswordString.ConvertToSecureString()))
var protectedString = _xmlDocument.DocumentElement?.Attributes["Protected"]?.Value;
if (!_decryptor.ConnectionsFileIsAuthentic(protectedString, _rootNodeInfo.PasswordString.ConvertToSecureString()))
{
return null;
}
@@ -108,9 +107,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
private void ValidateConnectionFileVersion()
{
if (_xmlDocument.DocumentElement != null && _xmlDocument.DocumentElement.HasAttribute("ConfVersion"))
_confVersion =
Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"].Value.Replace(",", "."),
CultureInfo.InvariantCulture);
_confVersion = Convert.ToDouble(_xmlDocument.DocumentElement.Attributes["ConfVersion"]?.Value.Replace(",", "."), CultureInfo.InvariantCulture);
else
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, Language.OldConffile);
@@ -142,7 +139,7 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
private void InitializeRootNode(XmlElement connectionsRootElement)
{
var rootNodeName = connectionsRootElement?.Attributes["Name"].Value.Trim();
var rootNodeName = connectionsRootElement?.Attributes["Name"]?.Value.Trim();
_rootNodeInfo.Name = rootNodeName;
}
@@ -163,7 +160,9 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
else
{
_decryptor = new XmlConnectionsDecryptor(_rootNodeInfo)
{AuthenticationRequestor = AuthenticationRequestor};
{
AuthenticationRequestor = AuthenticationRequestor
};
}
}
@@ -365,13 +364,11 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
connectionInfo.Inheritance.Port = xmlnode.GetAttributeAsBool("InheritPort");
connectionInfo.Inheritance.Protocol = xmlnode.GetAttributeAsBool("InheritProtocol");
connectionInfo.Inheritance.PuttySession = xmlnode.GetAttributeAsBool("InheritPuttySession");
connectionInfo.Inheritance.RedirectDiskDrives =
xmlnode.GetAttributeAsBool("InheritRedirectDiskDrives");
connectionInfo.Inheritance.RedirectDiskDrives = xmlnode.GetAttributeAsBool("InheritRedirectDiskDrives");
connectionInfo.Inheritance.RedirectKeys = xmlnode.GetAttributeAsBool("InheritRedirectKeys");
connectionInfo.Inheritance.RedirectPorts = xmlnode.GetAttributeAsBool("InheritRedirectPorts");
connectionInfo.Inheritance.RedirectPrinters = xmlnode.GetAttributeAsBool("InheritRedirectPrinters");
connectionInfo.Inheritance.RedirectSmartCards =
xmlnode.GetAttributeAsBool("InheritRedirectSmartCards");
connectionInfo.Inheritance.RedirectSmartCards = xmlnode.GetAttributeAsBool("InheritRedirectSmartCards");
connectionInfo.Inheritance.RedirectSound = xmlnode.GetAttributeAsBool("InheritRedirectSound");
connectionInfo.Inheritance.RedirectAudioCapture = xmlnode.GetAttributeAsBool("RedirectAudioCapture");
connectionInfo.Inheritance.Resolution = xmlnode.GetAttributeAsBool("InheritResolution");
@@ -569,27 +566,27 @@ namespace mRemoteNG.Config.Serializers.ConnectionSerializers.Xml
connectionInfo.Inheritance.RDGatewayExternalCredentialProvider = xmlnode.GetAttributeAsBool("InheritRDGatewayExternalCredentialProvider");
connectionInfo.Inheritance.RDGatewayUserViaAPI = xmlnode.GetAttributeAsBool("InheritRDGatewayUserViaAPI");
}
if (_confVersion >= 2.8)
switch (_confVersion)
{
connectionInfo.RedirectDiskDrives = xmlnode.GetAttributeAsEnum<RDPDiskDrives>("RedirectDiskDrives");
connectionInfo.RedirectDiskDrivesCustom = xmlnode.GetAttributeAsString("RedirectDiskDrivesCustom");
connectionInfo.Inheritance.RedirectDiskDrivesCustom = xmlnode.GetAttributeAsBool("InheritRedirectDiskDrivesCustom");
}
else if (_confVersion >= 0.5)
{
// used to be boolean
bool tmpRedirect = xmlnode.GetAttributeAsBool("RedirectDiskDrives");
if (tmpRedirect)
connectionInfo.RedirectDiskDrives = RDPDiskDrives.Local;
else
connectionInfo.RedirectDiskDrives = RDPDiskDrives.None;
case >= 3.0:
connectionInfo.RedirectDiskDrives = xmlnode.GetAttributeAsEnum<RDPDiskDrives>("RedirectDiskDrives");
connectionInfo.RedirectDiskDrivesCustom = xmlnode.GetAttributeAsString("RedirectDiskDrivesCustom");
connectionInfo.Inheritance.RedirectDiskDrivesCustom = xmlnode.GetAttributeAsBool("InheritRedirectDiskDrivesCustom");
break;
case >= 0.5:
{
// used to be boolean
bool tmpRedirect = xmlnode.GetAttributeAsBool("RedirectDiskDrives");
connectionInfo.RedirectDiskDrives = tmpRedirect ? RDPDiskDrives.Local : RDPDiskDrives.None;
break;
}
}
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
string.Format(Language.GetConnectionInfoFromXmlFailed,
connectionInfo.Name, ConnectionFileName, ex.Message));
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.GetConnectionInfoFromXmlFailed, connectionInfo.Name, ConnectionFileName, ex.Message));
}
return connectionInfo;

View File

@@ -11,26 +11,22 @@ namespace mRemoteNG.Config.Serializers.Versioning
[SupportedOSPlatform("windows")]
public class SqlDatabaseVersionVerifier
{
protected readonly Version currentSupportedVersion = new Version(2, 9);
private readonly Version _currentSupportedVersion = new Version(3, 0);
private readonly IDatabaseConnector _databaseConnector;
public SqlDatabaseVersionVerifier(IDatabaseConnector DatabaseConnector)
public SqlDatabaseVersionVerifier(IDatabaseConnector databaseConnector)
{
if (DatabaseConnector == null)
throw new ArgumentNullException(nameof(DatabaseConnector));
_databaseConnector = DatabaseConnector;
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
}
public bool VerifyDatabaseVersion(Version dbVersion)
{
var isVerified = false;
try
{
var databaseVersion = dbVersion;
Version databaseVersion = dbVersion;
if (databaseVersion.Equals(new Version()))
if (databaseVersion.Equals(_currentSupportedVersion))
{
return true;
}
@@ -47,7 +43,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
new SqlVersion29To30Upgrader(_databaseConnector),
};
foreach (var upgrader in dbUpgraders)
foreach (IVersionUpgrader upgrader in dbUpgraders)
{
if (upgrader.CanUpgrade(databaseVersion))
{
@@ -56,23 +52,19 @@ namespace mRemoteNG.Config.Serializers.Versioning
}
// DB is at the highest current supported version
if (databaseVersion.CompareTo(currentSupportedVersion) == 0)
isVerified = true;
if (databaseVersion.CompareTo(_currentSupportedVersion) == 0)
{
return true;
}
if (isVerified == false)
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg,
string.Format(Language.ErrorBadDatabaseVersion,
databaseVersion,
GeneralAppInfo.ProductName));
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.ErrorBadDatabaseVersion, databaseVersion, GeneralAppInfo.ProductName));
}
catch (Exception ex)
{
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg,
string.Format(Language.ErrorVerifyDatabaseVersionFailed,
ex.Message));
Runtime.MessageCollector.AddMessage(MessageClass.ErrorMsg, string.Format(Language.ErrorVerifyDatabaseVersionFailed, ex.Message));
}
return isVerified;
return false;
}
}
}

View File

@@ -13,10 +13,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
public SqlVersion22To23Upgrader(IDatabaseConnector databaseConnector)
{
if (databaseConnector == null)
throw new ArgumentNullException(nameof(databaseConnector));
_databaseConnector = databaseConnector;
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
}
public bool CanUpgrade(Version currentVersion)
@@ -27,13 +24,16 @@ namespace mRemoteNG.Config.Serializers.Versioning
public Version Upgrade()
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.2 to version 2.3.");
const string sqlText = @"
ALTER TABLE tblCons
ADD EnableFontSmoothing bit NOT NULL DEFAULT 0,
EnableDesktopComposition bit NOT NULL DEFAULT 0,
InheritEnableFontSmoothing bit NOT NULL DEFAULT 0,
InheritEnableDesktopComposition bit NOT NULL DEFAULT 0;";
var dbCommand = _databaseConnector.DbCommand(sqlText);
dbCommand.ExecuteNonQuery();
return new Version(2, 3);

View File

@@ -13,10 +13,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
public SqlVersion23To24Upgrader(IDatabaseConnector databaseConnector)
{
if (databaseConnector == null)
throw new ArgumentNullException(nameof(databaseConnector));
_databaseConnector = databaseConnector;
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
}
public bool CanUpgrade(Version currentVersion)
@@ -26,13 +23,15 @@ namespace mRemoteNG.Config.Serializers.Versioning
public Version Upgrade()
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
"Upgrading database from version 2.3 to version 2.4.");
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg, "Upgrading database from version 2.3 to version 2.4.");
const string sqlText = @"
ALTER TABLE tblCons
ADD UseCredSsp bit NOT NULL DEFAULT 1,
InheritUseCredSsp bit NOT NULL DEFAULT 0;";
var dbCommand = _databaseConnector.DbCommand(sqlText);
dbCommand.ExecuteNonQuery();
return new Version(2, 4);

View File

@@ -13,10 +13,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
public SqlVersion24To25Upgrader(IDatabaseConnector databaseConnector)
{
if (databaseConnector == null)
throw new ArgumentNullException(nameof(databaseConnector));
_databaseConnector = databaseConnector;
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
}
public bool CanUpgrade(Version currentVersion)

View File

@@ -13,10 +13,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
public SqlVersion25To26Upgrader(IDatabaseConnector databaseConnector)
{
if (databaseConnector == null)
throw new ArgumentNullException(nameof(databaseConnector));
_databaseConnector = databaseConnector;
_databaseConnector = databaseConnector ?? throw new ArgumentNullException(nameof(databaseConnector));
}
public bool CanUpgrade(Version currentVersion)

View File

@@ -10,7 +10,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
[SupportedOSPlatform("windows")]
public class SqlVersion28To29Upgrader : IVersionUpgrader
{
private readonly Version version = new Version(2, 9);
private readonly Version _version = new Version(2, 9);
private readonly IDatabaseConnector _databaseConnector;
public SqlVersion28To29Upgrader(IDatabaseConnector databaseConnector)
@@ -23,44 +23,44 @@ namespace mRemoteNG.Config.Serializers.Versioning
return currentVersion == new Version(2, 8) ||
// Support upgrading during dev revisions, 2.9.1, 2.9.2, etc...
(currentVersion <= new Version(2, 9) &&
currentVersion < version);
currentVersion < _version);
}
public Version Upgrade()
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
$"Upgrading database to version {version}.");
$"Upgrading database to version {_version}.");
// MYSQL
const string mySqlAlter = @"
ALTER TABLE tblCons ADD COLUMN `InheritUseRestrictedAdmin` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `UseRCG` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `UseRestrictedAdmin` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritUseRCG` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritRDGatewayExternalCredentialProvider` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritRDGatewayUserViaAPI` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritExternalCredentialProvider` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritUserViaAPI` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritUseRestrictedAdmin` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `UseRCG` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `UseRestrictedAdmin` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritUseRCG` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritRDGatewayExternalCredentialProvider` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritRDGatewayUserViaAPI` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritExternalCredentialProvider` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritUserViaAPI` tinyint NOT NULL;
ALTER TABLE tblCons ADD COLUMN `EC2Region` varchar(32) DEFAULT NULL;
ALTER TABLE tblCons ADD COLUMN `EC2InstanceId` varchar(32) DEFAULT NULL;
ALTER TABLE tblCons ADD COLUMN `ExternalCredentialProvider` varchar(256) DEFAULT NULL;
ALTER TABLE tblCons ADD COLUMN `ExternalAddressProvider` varchar(256) DEFAULT NULL;
SET SQL_SAFE_UPDATES=0;
UPDATE tblCons SET InheritUseEnhancedMode = 0 WHERE InheritUseEnhancedMode IS NULL;
ALTER TABLE tblCons MODIFY COLUMN InheritUseEnhancedMode tinyint(1) NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN InheritUseEnhancedMode tinyint NOT NULL;
UPDATE tblCons SET UseEnhancedMode = 0 WHERE UseEnhancedMode IS NULL;
ALTER TABLE tblCons MODIFY COLUMN UseEnhancedMode tinyint(1) NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN UseEnhancedMode tinyint NOT NULL;
UPDATE tblCons SET InheritVmId = 0 WHERE InheritVmId IS NULL;
ALTER TABLE tblCons MODIFY COLUMN InheritVmId tinyint(1) NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN InheritVmId tinyint NOT NULL;
UPDATE tblCons SET InheritUseVmId = 0 WHERE InheritUseVmId IS NULL;
ALTER TABLE tblCons MODIFY COLUMN InheritUseVmId tinyint(1) NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN InheritUseVmId tinyint NOT NULL;
UPDATE tblCons SET UseVmId = 0 WHERE UseVmId IS NULL;
ALTER TABLE tblCons MODIFY COLUMN UseVmId tinyint(1) NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN UseVmId tinyint NOT NULL;
SET SQL_SAFE_UPDATES=1;
ALTER TABLE tblRoot ALTER COLUMN ConfVersion VARCHAR(15) NOT NULL;
ALTER TABLE tblRoot MODIFY COLUMN ConfVersion VARCHAR(15) NOT NULL;
";
const string mySqlUpdate = @"UPDATE tblRoot SET ConfVersion=?;";
const string mySqlUpdate = @"SET SQL_SAFE_UPDATES=0; UPDATE tblRoot SET ConfVersion=?; SET SQL_SAFE_UPDATES=1;";
// MS-SQL
const string msSqlAlter = @"
@@ -116,7 +116,7 @@ ALTER TABLE tblRoot ALTER COLUMN [ConfVersion] VARCHAR(15) NOT NULL;
}
var pConfVersion = dbCommand.CreateParameter();
pConfVersion.ParameterName = "confVersion";
pConfVersion.Value = version.ToString();
pConfVersion.Value = _version.ToString();
pConfVersion.DbType = System.Data.DbType.String;
pConfVersion.Direction = System.Data.ParameterDirection.Input;
dbCommand.Parameters.Add(pConfVersion);
@@ -124,7 +124,7 @@ ALTER TABLE tblRoot ALTER COLUMN [ConfVersion] VARCHAR(15) NOT NULL;
dbCommand.ExecuteNonQuery();
sqlTran.Commit();
}
return version;
return _version;
}
}
}

View File

@@ -10,7 +10,7 @@ namespace mRemoteNG.Config.Serializers.Versioning
[SupportedOSPlatform("windows")]
public class SqlVersion29To30Upgrader : IVersionUpgrader
{
private readonly Version version = new Version(3, 0);
private readonly Version _version = new Version(3, 0);
private readonly IDatabaseConnector _databaseConnector;
public SqlVersion29To30Upgrader(IDatabaseConnector databaseConnector)
@@ -23,25 +23,131 @@ namespace mRemoteNG.Config.Serializers.Versioning
return currentVersion == new Version(2, 9) ||
// Support upgrading during dev revisions, 2.9.1, 2.9.2, etc...
(currentVersion <= new Version(3, 0) &&
currentVersion < version);
currentVersion < _version);
}
public Version Upgrade()
{
Runtime.MessageCollector.AddMessage(MessageClass.InformationMsg,
$"Upgrading database to version {version}.");
$"Upgrading database to version {_version}.");
// MYSQL
const string mySqlAlter = @"
ALTER TABLE tblCons ALTER COLUMN `RedirectDiskDrives` varchar(32) DEFAULT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RenderingEngine` varchar(32) DEFAULT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RedirectDiskDrives` varchar(32) DEFAULT NULL;
ALTER TABLE tblCons ADD COLUMN `RedirectDiskDrivesCustom` varchar(32) DEFAULT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritRedirectDiskDrivesCustom` tinyint(1) NOT NULL;
ALTER TABLE tblCons ADD COLUMN `InheritRedirectDiskDrivesCustom` tinyint NOT NULL;
-- mysql tinyint(1) is deprecated - modify all tinyint(1) columns to tinyint
ALTER TABLE tblCons MODIFY COLUMN `Expanded` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `AutomaticResize` tinyint NOT NULL DEFAULT '1';
ALTER TABLE tblCons MODIFY COLUMN `CacheBitmaps` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `ConnectToConsole` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `Connected` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `DisableCursorBlinking` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `DisableCursorShadow` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `DisableFullWindowDrag` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `DisableMenuAnimations` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `DisplayThemes` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `DisplayWallpaper` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `EnableDesktopComposition` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `EnableFontSmoothing` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `Favorite` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RDPAlertIdleTimeout` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RedirectAudioCapture` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RedirectClipboard` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RedirectKeys` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RedirectPorts` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RedirectPrinters` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `RedirectSmartCards` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `UseCredSsp` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `UseEnhancedMode` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `UseVmId` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `VNCViewOnly` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritAutomaticResize` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritCacheBitmaps` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritColors` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDescription` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDisableCursorBlinking` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDisableCursorShadow` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDisableFullWindowDrag` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDisableMenuAnimations` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDisplayThemes` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDisplayWallpaper` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritDomain` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritEnableDesktopComposition` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritEnableFontSmoothing` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritExtApp` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritFavorite` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritICAEncryptionStrength` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritIcon` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritLoadBalanceInfo` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritMacAddress` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritOpeningCommand` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritPanel` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritPassword` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritPort` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritPostExtApp` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritPreExtApp` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritProtocol` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritPuttySession` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayDomain` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayHostname` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayPassword` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayUsageMethod` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayUseConnectionCredentials` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayExternalCredentialProvider` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayUsername` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDGatewayUserViaAPI` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDPAlertIdleTimeout` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDPAuthenticationLevel` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRDPMinutesToIdleTimeout` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRdpVersion` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectAudioCapture` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectClipboard` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectDiskDrives` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectDiskDrivesCustom` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectKeys` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectPorts` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectPrinters` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectSmartCards` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRedirectSound` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritRenderingEngine` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritResolution` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritSSHOptions` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritSSHTunnelConnectionName` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritSoundQuality` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUseConsoleSession` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUseCredSsp` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUseRestrictedAdmin` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUseRCG` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritExternalCredentialProvider` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUserViaAPI` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `UseRestrictedAdmin` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `UseRCG` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUseEnhancedMode` tinyint DEFAULT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUseVmId` tinyint DEFAULT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUserField` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritUsername` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCAuthMode` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCColors` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCCompression` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCEncoding` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCProxyIP` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCProxyPassword` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCProxyPort` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCProxyType` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCProxyUsername` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCSmartSizeMode` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVNCViewOnly` tinyint NOT NULL;
ALTER TABLE tblCons MODIFY COLUMN `InheritVmId` tinyint NOT NULL;
";
const string mySqlUpdate = @"UPDATE tblRoot SET ConfVersion=?;";
const string mySqlUpdate = @"SET SQL_SAFE_UPDATES=0; UPDATE tblRoot SET ConfVersion=?; SET SQL_SAFE_UPDATES=1;";
// MS-SQL
const string msSqlAlter = @"
ALTER TABLE tblCons ALTER COLUMN RenderingEngine varchar(32) DEFAULT NULL;
ALTER TABLE tblCons ALTER COLUMN RedirectDiskDrives varchar(32) DEFAULT NULL;
ALTER TABLE tblCons ADD RedirectDiskDrivesCustom varchar(32) DEFAULT NULL;
ALTER TABLE tblCons ADD InheritRedirectDiskDrivesCustom bit NOT NULL;
@@ -74,7 +180,7 @@ ALTER TABLE tblCons ADD InheritRedirectDiskDrivesCustom bit NOT NULL;
}
var pConfVersion = dbCommand.CreateParameter();
pConfVersion.ParameterName = "confVersion";
pConfVersion.Value = version.ToString();
pConfVersion.Value = _version.ToString();
pConfVersion.DbType = System.Data.DbType.String;
pConfVersion.Direction = System.Data.ParameterDirection.Input;
dbCommand.Parameters.Add(pConfVersion);
@@ -82,7 +188,7 @@ ALTER TABLE tblCons ADD InheritRedirectDiskDrivesCustom bit NOT NULL;
dbCommand.ExecuteNonQuery();
sqlTran.Commit();
}
return version;
return _version;
}
}
}