Skip to content

Commit

Permalink
Message server support (#40)
Browse files Browse the repository at this point in the history
* Added connection parameters MSHOST, R3NAME and GROUP to use load balanced message server

* Reverted adding whitespace to cast
  • Loading branch information
oliver-hermann authored Feb 9, 2020
1 parent 77f9432 commit f230afe
Show file tree
Hide file tree
Showing 2 changed files with 59 additions and 14 deletions.
38 changes: 37 additions & 1 deletion src/NwRfcNet/RfcConnection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
using NwRfcNet.TypeMapper;
using System;

namespace NwRfcNet
namespace NwRfcNet
{
/// <summary>
/// Represents a connection to a RFC server.
Expand Down Expand Up @@ -35,9 +35,12 @@ public RfcConnection() { }
public RfcConnection(string userName = null,
string password = null,
string hostname = null,
string messageServerHostname = null,
string client = null,
string language = null,
string systemNumber = null,
string systemId = null,
string group = null,
string sapRouter = null,
string sncQop = null,
string sncMyname = null,
Expand All @@ -48,9 +51,12 @@ public RfcConnection(string userName = null,
UserName = userName;
Password = password;
Hostname = hostname;
MessageServerHostname = messageServerHostname;
Client = client;
Language = language;
SystemNumber = systemNumber;
SystemId = systemId;
Group = group;
SapRouter = sapRouter;
SncQop = sncQop;
SncMyname = sncMyname;
Expand Down Expand Up @@ -97,6 +103,16 @@ public string Hostname
}
}

public string MessageServerHostname
{
get => _parms.MessageServerHostname;
set
{
CheckConnectionIsClosed();
_parms.MessageServerHostname = value;
}
}

public string Client
{
get => _parms.Client;
Expand Down Expand Up @@ -127,6 +143,26 @@ public string Language
}
}

public string SystemId
{
get => _parms.SystemId;
set
{
CheckConnectionIsClosed();
_parms.SystemId = value;
}
}

public string Group
{
get => _parms.Group;
set
{
CheckConnectionIsClosed();
_parms.Group = value;
}
}

public string SapRouter
{
get => _parms.SapRouter;
Expand Down
35 changes: 22 additions & 13 deletions src/NwRfcNet/RfcConnectionBuilder.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,39 +13,48 @@ internal class RfcConnectionBuilder
private static readonly IReadOnlyDictionary<string, string> PropertyToRfcParam = typeof(RfcConnectionBuilder)
.GetProperties()
.Where(p => p.IsDefined(typeof(RfcConnectionPropertyAttribute), false))
.ToDictionary(
.ToDictionary(
key => key.Name,
prop => ((RfcConnectionPropertyAttribute[])prop .GetCustomAttributes(typeof(RfcConnectionPropertyAttribute), false))
prop => ((RfcConnectionPropertyAttribute[])prop.GetCustomAttributes(typeof(RfcConnectionPropertyAttribute), false))
.First().RfcParamName);

#region Properties

[RfcConnectionPropertyAttribute("user")]
public string UserName { get ; set; }
public string UserName { get; set; }

[RfcConnectionPropertyAttribute("passwd")]
public string Password { get ; set; }
public string Password { get; set; }

[RfcConnectionPropertyAttribute("ASHOST")]
public string Hostname { get ; set; }

public string Hostname { get; set; }

[RfcConnectionPropertyAttribute("MSHOST")]
public string MessageServerHostname { get; set; }

[RfcConnectionPropertyAttribute("client")]
public string Client { get ; set; }
public string Client { get; set; }

[RfcConnectionPropertyAttribute("sysnr")]
public string SystemNumber { get ; set; }
public string SystemNumber { get; set; }

[RfcConnectionPropertyAttribute("R3NAME")]
public string SystemId { get; set; }

[RfcConnectionPropertyAttribute("GROUP")]
public string Group { get; set; }

[RfcConnectionPropertyAttribute("lang")]
public string Language { get ; set; }
public string Language { get; set; }

[RfcConnectionPropertyAttribute("saprouter")]
public string SapRouter { get ; set; }
public string SapRouter { get; set; }

[RfcConnectionPropertyAttribute("trace")]
public string Trace { get ; set; }
public string Trace { get; set; }

[RfcConnectionPropertyAttribute("snc_qop")]
public string SncQop { get ; set; }
public string SncQop { get; set; }

[RfcConnectionPropertyAttribute("snc_myname")]
public string SncMyname { get; set; }
Expand Down Expand Up @@ -74,7 +83,7 @@ internal RFC_CONNECTION_PARAMETER[] GetParms()
.GetValue(this);

if (rfcValue != null)
{
{
rfcParams.Add(new RFC_CONNECTION_PARAMETER()
{
Name = prop.Value,
Expand Down

0 comments on commit f230afe

Please sign in to comment.