extracted rdp error codes to new class

This commit is contained in:
David Sparer
2018-11-12 18:54:54 -06:00
parent f6877631d9
commit 65e21190b9
4 changed files with 45 additions and 41 deletions

View File

@@ -304,7 +304,7 @@ namespace mRemoteNG.Connection
if (prot.InterfaceControl.Info.Protocol != ProtocolType.RDP) return;
if (Convert.ToInt32(errorMessage) > -1)
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strConnectionRdpErrorDetail, errorMessage, RdpProtocol.FatalErrors.GetError(errorMessage)));
Runtime.MessageCollector.AddMessage(MessageClass.WarningMsg, string.Format(Language.strConnectionRdpErrorDetail, errorMessage, RdpErrorCodes.GetError(errorMessage)));
}
catch (Exception ex)
{

View File

@@ -0,0 +1,43 @@
using System;
using System.Collections;
using mRemoteNG.App;
namespace mRemoteNG.Connection.Protocol.RDP
{
public static class RdpErrorCodes
{
private static Hashtable _description;
private static void InitDescription()
{
_description = new Hashtable
{
{"0", "Language.strRdpErrorUnknown"},
{"1", "Language.strRdpErrorCode1"},
{"2", "Language.strRdpErrorOutOfMemory"},
{"3", "Language.strRdpErrorWindowCreation"},
{"4", "Language.strRdpErrorCode2"},
{"5", "Language.strRdpErrorCode3"},
{"6", "Language.strRdpErrorCode4"},
{"7", "Language.strRdpErrorConnection"},
{"100", "Language.strRdpErrorWinsock"}
};
}
public static string GetError(string id)
{
try
{
if (_description == null)
InitDescription();
return (string)_description?[id];
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpErrorGetFailure, ex);
return string.Format(Language.strRdpErrorUnknown, id);
}
}
}
}

View File

@@ -1,5 +1,4 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.ComponentModel;
using System.Diagnostics;
@@ -920,45 +919,6 @@ namespace mRemoteNG.Connection.Protocol.RDP
public static readonly Version RDC81 = new Version(6, 3, 9600);
}
#region Fatal Errors
public static class FatalErrors
{
private static Hashtable _description;
private static void InitDescription()
{
_description = new Hashtable
{
{"0", "Language.strRdpErrorUnknown"},
{"1", "Language.strRdpErrorCode1"},
{"2", "Language.strRdpErrorOutOfMemory"},
{"3", "Language.strRdpErrorWindowCreation"},
{"4", "Language.strRdpErrorCode2"},
{"5", "Language.strRdpErrorCode3"},
{"6", "Language.strRdpErrorCode4"},
{"7", "Language.strRdpErrorConnection"},
{"100", "Language.strRdpErrorWinsock"}
};
}
public static string GetError(string id)
{
try
{
if (_description == null)
InitDescription();
return (string)_description?[id];
}
catch (Exception ex)
{
Runtime.MessageCollector.AddExceptionStackTrace(Language.strRdpErrorGetFailure, ex);
return string.Format(Language.strRdpErrorUnknown, id);
}
}
}
#endregion
#region Reconnect Stuff
public void tmrReconnect_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
{

View File

@@ -243,6 +243,7 @@
<Compile Include="Connection\Protocol\Http\Connection.Protocol.HTTPS.CertEvent.cs" />
<Compile Include="Connection\Protocol\ProtocolFactory.cs" />
<Compile Include="Connection\Protocol\RDP\AzureLoadBalanceInfoEncoder.cs" />
<Compile Include="Connection\Protocol\RDP\RdpErrorCodes.cs" />
<Compile Include="Connection\Protocol\VNC\VNCEnum.cs" />
<Compile Include="Connection\WebHelper.cs" />
<Compile Include="Credential\PlaceholderCredentialRecord.cs" />