Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

- First implementation of SAP ERP access for netcore. Issue 100856 #1037

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions dotnet/DotNetStandardClasses.sln
Original file line number Diff line number Diff line change
Expand Up @@ -263,6 +263,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "LogTest", "test\benchmarks\
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AccessTokenController_Test", "test\NativeAccessControllerTest\AccessTokenController_Test.csproj", "{A5589382-DB6F-4450-AE2B-6C6AA1643EF1}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "GxEnterpriseLib", "src\dotnetcore\GxEnterpriseLib\GxEnterpriseLib.csproj", "{2437D532-75FA-40C5-8384-B08C8417DCB4}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand Down Expand Up @@ -633,6 +635,10 @@ Global
{956402BD-AC8C-426E-961B-B77B3F3EDAEB}.Debug|Any CPU.Build.0 = Debug|Any CPU
{956402BD-AC8C-426E-961B-B77B3F3EDAEB}.Release|Any CPU.ActiveCfg = Release|Any CPU
{956402BD-AC8C-426E-961B-B77B3F3EDAEB}.Release|Any CPU.Build.0 = Release|Any CPU
{2437D532-75FA-40C5-8384-B08C8417DCB4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2437D532-75FA-40C5-8384-B08C8417DCB4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2437D532-75FA-40C5-8384-B08C8417DCB4}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2437D532-75FA-40C5-8384-B08C8417DCB4}.Release|Any CPU.Build.0 = Release|Any CPU
{A1DBDCE0-4F09-445F-A202-9B260CDD46CF}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{A1DBDCE0-4F09-445F-A202-9B260CDD46CF}.Debug|Any CPU.Build.0 = Debug|Any CPU
{A1DBDCE0-4F09-445F-A202-9B260CDD46CF}.Release|Any CPU.ActiveCfg = Release|Any CPU
Expand Down Expand Up @@ -767,6 +773,7 @@ Global
{46DAAFD1-FAF5-4904-8EC5-406BE04E5538} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
{A1DBDCE0-4F09-445F-A202-9B260CDD46CF} = {46DAAFD1-FAF5-4904-8EC5-406BE04E5538}
{A5589382-DB6F-4450-AE2B-6C6AA1643EF1} = {1D6F1776-FF4B-46C2-9B3D-BC46CCF049DC}
{2437D532-75FA-40C5-8384-B08C8417DCB4} = {2261B65E-3757-4E5B-9DCD-EAE8D1E236A3}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {E18684C9-7D76-45CD-BF24-E3944B7F174C}
Expand Down
343 changes: 343 additions & 0 deletions dotnet/src/dotnetcore/GxEnterpriseLib/GXECSessionManager.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,343 @@
using System;
using System.ServiceModel;
using System.Xml;
using System.Runtime.Serialization;
using GeneXus.Application;
using SapNwRfc;
using SapNwRfc.Pooling;

namespace GeneXus.SAP
{

public class GXECSessionManager
{

ISapPooledConnection pooledConnection = null;
//GxEnterpriseConnect GxConnect = null;
IGxContext _context;
string _connectionString = null;
static SapConnectionPool _pool;

public GXECSessionManager(IGxContext context)
{
_context = context;
this.SessionName = _context.GetContextProperty("SAP-Session") as string;
_connectionString = _context.GetContextProperty("SAP-ConnStr") as string;

}

String userName;
public String UserName
{
get { return userName; }
set { userName = value; }
}
String password;

public String Password
{
get { return password; }
set { password = value; }
}
String appServer;

public String AppServer
{
get { return appServer; }
set { appServer = value; }
}
String instanceNumber;

public String InstanceNumber
{
get { return instanceNumber; }
set { instanceNumber = value; }
}
String clientNumber;

public String ClientNumber
{
get { return clientNumber; }
set { clientNumber = value; }
}
String routerString;

public String RouterString
{
get { return routerString; }
set { routerString = value; }
}
String systemId;

public String SystemId
{
get { return systemId; }
set { systemId = value; }
}
String sessionName;

public String SessionName
{
get { return sessionName; }
set {
sessionName = value;
}
}
String sAPGUI;

public String SAPGUI
{
get { return sAPGUI; }
set { sAPGUI = value; }
}

String lang;
public String Language
{
get { return lang; }
set { lang = value; }
}

String msHost;
public string MessageHost
{
get { return msHost; }
set { msHost = value; }
}

String msServ;
public string MessageSrv
{
get { return msServ; }
set { msServ = value; }
}

String group;
public String Group
{
get { return group; }
set { group = value; }
}
String sPort;
public String Port
{
get { return sPort; }
set { sPort = value;}
}

String sapRouter;
public String SAPRouter
{
get { return sapRouter; }
set { sapRouter = value; }
}

String sGatewayHost;
public String GatewayHost
{
get { return sGatewayHost; }
set { sGatewayHost = value; }
}

String sGatewaySrv;
public String GatewaySrv
{
get { return sGatewaySrv; }
set { sGatewaySrv = value; }
}

String sProgramID;
public String ProgramID
{
get { return sProgramID; }
set { sProgramID = value; }
}

String sRegistrationCount;
public String RegistrationCount
{
get { return sRegistrationCount; }
set { sRegistrationCount = value; }
}

String sServerName;
public String ServerName
{
get { return sServerName; }
set { sServerName = value; }
}

int errorCode;

public string ConnectionString
{
get {
if (String.IsNullOrEmpty(_connectionString))
{
return "AppServerHost=" + this.RouterString + this.AppServer + ";"
+ "SystemNumber=" + this.instanceNumber + ";"
+ "User=" + this.UserName + ";"
+ "Password=" + this.Password + ";"
+ "Client=" + this.ClientNumber + ";"
+ "PoolSize=" + "5" + ";"
+ "Language=" + this.Language;
}
else
{
return _connectionString;
}
}
}
public int ErrorCode
{
get
{
return errorCode;
}
set
{
errorCode = value;
}
}
String errorMessage;

public string ErrorMessage
{
get
{
return errorMessage;
}
set
{
errorMessage = value;
}
}

public void Save()
{
}

public void Load()
{

}

public void DocumentReceiverStart()
{
//connection.StartReceiverServer();
}

public void DocumentSenderStart()
{
//connection.StartSenderServer();
}

public void DocumentSenderStop()
{
//connection.StopSender();
}

public void DocumentReceiverStop()
{
// connection.StopReceiver();
}

public void TransactionBegin()
{

// connection.TransactionBegin();
}

public void TransactionCommit()
{
// connection.TransactionCommit();
}

private ISapConnection FindConnection()
{
/*
if (connection != null)
{
return connection;
}
else
{
string _session = "";
if (!String.IsNullOrEmpty(this.sessionName))
{
_session = this.sessionName;
}
else
{
Object objectSession = _context.GetContextProperty("SessionName");
if (objectSession != null && !String.IsNullOrEmpty((String)objectSession))
{
this.sessionName = (String)objectSession;
_session = this.sessionName;
}
}
this.sessionName = _session;
connection = new GxEnterpriseConnect(this);
return connection;
}
*/
return null;

}
public void Disconnect()
{
//connection = FindConnection();
//if (connection != null)
//{
// connection.Disconnect();
//}
}

public bool IsConnected()
{
//connection = FindConnection();

if (pooledConnection != null)
// return connection.IsValid;
return true;
else
return false;

}

public void ConnectSession(string SessionName, string Scope)
{
Connect();
}

public ISapPooledConnection GetCurrentConnection()
{
if (errorCode == 0)
return pooledConnection;
else
return null;
}

public void Connect()
{
try
{
if (pooledConnection == null)
{
if (_pool == null)
_pool = new SapConnectionPool(ConnectionString);
_context.SetContextProperty("SAP-Session", this.SessionName);
_context.SetContextProperty("SAP-ConnStr", ConnectionString);
//connection = _pool.GetConnection();
//bool result = connection.Ping();
pooledConnection = new SapPooledConnection(_pool);
}
}
catch (Exception e)
{
errorCode = 2;
errorMessage = e.Message;
}
}
}
}
Loading
Loading