diff --git a/dotnet/DotNetStandardClasses.sln b/dotnet/DotNetStandardClasses.sln index b05ba379f..2ce6c49a5 100644 --- a/dotnet/DotNetStandardClasses.sln +++ b/dotnet/DotNetStandardClasses.sln @@ -263,11 +263,14 @@ 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 Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "ws", "ws", "{B5C28D81-BCD9-4B29-9B68-EDD81D1018D5}" EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "src", "src", "{F8959289-4ED7-430C-97B7-FAAA29829708}" EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "GxSoapHandler", "src\extensions\ws\src\GxSoapHandler\GxSoapHandler.csproj", "{58C84EC7-A0B3-4C1B-BD78-989AEE87EA32}" +EndProject Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Functions", "Functions", "{E59B3248-4C26-4DB0-96CB-67437319E22B}" EndProject Global @@ -640,6 +643,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 @@ -778,6 +785,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} {B5C28D81-BCD9-4B29-9B68-EDD81D1018D5} = {C6AFB6A3-FF0B-4970-B1F1-10BCD3D932B2} {F8959289-4ED7-430C-97B7-FAAA29829708} = {B5C28D81-BCD9-4B29-9B68-EDD81D1018D5} {58C84EC7-A0B3-4C1B-BD78-989AEE87EA32} = {F8959289-4ED7-430C-97B7-FAAA29829708} diff --git a/dotnet/src/dotnetcore/GxEnterpriseLib/GXECSessionManager.cs b/dotnet/src/dotnetcore/GxEnterpriseLib/GXECSessionManager.cs new file mode 100644 index 000000000..8e0a85c6e --- /dev/null +++ b/dotnet/src/dotnetcore/GxEnterpriseLib/GXECSessionManager.cs @@ -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; + } + } + } +} diff --git a/dotnet/src/dotnetcore/GxEnterpriseLib/GxEnterpriseConnect.cs b/dotnet/src/dotnetcore/GxEnterpriseLib/GxEnterpriseConnect.cs new file mode 100644 index 000000000..e2255794b --- /dev/null +++ b/dotnet/src/dotnetcore/GxEnterpriseLib/GxEnterpriseConnect.cs @@ -0,0 +1,45 @@ +using System; +using GeneXus.Utils; +using GeneXus.Application; +using SapNwRfc; +using SapNwRfc.Pooling; + +namespace GeneXus.SAP +{ + public class GxEnterpriseConnect { + public GxEnterpriseConnect(GXECSessionManager manager) + { + if (manager != null) + { + this.SessionManager = manager; + } + } + public GxEnterpriseConnect(IGxContext context) + { + if (context!=null) + { + _sessionManager = new GXECSessionManager(context); + _sessionManager.Connect(); + _connection = _sessionManager.GetCurrentConnection(); + } + } + + /* + public ISapFunction CreateFunction(string functionName) + { + if (_connection != null) + return _connection.CreateFunction(functionName); + else + return null; + } + */ + + ISapPooledConnection _connection = null; + private GXECSessionManager _sessionManager = null; + public string ConnectionString { get => connectionString; set => connectionString = value; } + public GXECSessionManager SessionManager { get => _sessionManager; set => _sessionManager = value; } + public ISapPooledConnection Connection { get => _connection; set => _connection = value; } + + private string connectionString; + } +} diff --git a/dotnet/src/dotnetcore/GxEnterpriseLib/GxEnterpriseLib.csproj b/dotnet/src/dotnetcore/GxEnterpriseLib/GxEnterpriseLib.csproj new file mode 100644 index 000000000..9d89b6601 --- /dev/null +++ b/dotnet/src/dotnetcore/GxEnterpriseLib/GxEnterpriseLib.csproj @@ -0,0 +1,20 @@ + + + + net8.0 + Library + NETCORE;NODATIME + GeneXus.EnterpriseLib.SAP + enable + disable + + + + + + + + + + +