|
1 | 1 | using System; |
| 2 | +using GeneXus.Application; |
2 | 3 | using GeneXus.Configuration; |
| 4 | +using GeneXus.Data; |
3 | 5 | using GeneXus.Encryption; |
4 | 6 | using GxClasses.Helpers; |
5 | 7 | using log4net; |
@@ -110,47 +112,44 @@ public class GxDatabaseSession : ISessionService |
110 | 112 | internal static string SESSION_PASSWORD = "SESSION_PROVIDER_PASSWORD"; |
111 | 113 | internal static string SESSION_SCHEMA = "SESSION_PROVIDER_SCHEMA"; |
112 | 114 | internal static string SESSION_TABLE_NAME = "SESSION_PROVIDER_TABLE_NAME"; |
113 | | - internal static string SESSION_PROVIDER_SERVER = "SESSION_PROVIDER_SERVER"; |
114 | | - internal static string SESSION_PROVIDER_DATABASE = "SESSION_PROVIDER_DATABASE"; |
115 | | - internal static string SESSION_PROVIDER_USER = "SESSION_PROVIDER_USER"; |
| 115 | + internal static string SESSION_DATASTORE = "SESSION_PROVIDER_DATASTORE"; |
116 | 116 |
|
117 | 117 | public GxDatabaseSession(GXService serviceProvider) |
118 | 118 | { |
119 | | - string password = serviceProvider.Properties.Get(SESSION_PASSWORD); |
120 | | - if (!string.IsNullOrEmpty(password)) |
| 119 | + string datastoreName = serviceProvider.Properties.Get(SESSION_DATASTORE); |
| 120 | + if (!string.IsNullOrEmpty(datastoreName)) |
121 | 121 | { |
122 | | - password = CryptoImpl.Decrypt(password); |
| 122 | + GxContext context = GxContext.CreateDefaultInstance(); |
| 123 | + IGxDataStore datastore = context.GetDataStore(datastoreName); |
| 124 | + string schema = datastore.Connection.CurrentSchema; |
| 125 | + string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME); |
| 126 | + ConnectionString = datastore.Connection.ConnectionString; |
| 127 | + Schema = schema; |
| 128 | + TableName = tableName; |
| 129 | + context.CloseConnections(); |
123 | 130 | } |
124 | | - string serverName = serviceProvider.Properties.Get(SESSION_PROVIDER_SERVER); |
125 | | - string userName = serviceProvider.Properties.Get(SESSION_PROVIDER_USER); |
126 | | - string database = serviceProvider.Properties.Get(SESSION_PROVIDER_DATABASE); |
127 | | - string schema = serviceProvider.Properties.Get(SESSION_SCHEMA); |
128 | | - string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME); |
129 | | - |
130 | | - string sessionAddresCompatibility = serviceProvider.Properties.Get(GxDatabaseSession.SESSION_ADDRESS); |
131 | | - if (!string.IsNullOrEmpty(sessionAddresCompatibility)) |
| 131 | + else //Backward compatibility configuration |
132 | 132 | { |
133 | | - ConnectionString = sessionAddresCompatibility; |
134 | | - } |
| 133 | + string password = serviceProvider.Properties.Get(SESSION_PASSWORD); |
| 134 | + if (!string.IsNullOrEmpty(password)) |
| 135 | + { |
| 136 | + password = CryptoImpl.Decrypt(password); |
| 137 | + } |
| 138 | + string schema = serviceProvider.Properties.Get(SESSION_SCHEMA); |
| 139 | + string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME); |
| 140 | + string sessionAddresCompatibility = serviceProvider.Properties.Get(SESSION_ADDRESS); |
| 141 | + if (!string.IsNullOrEmpty(sessionAddresCompatibility)) |
| 142 | + { |
| 143 | + ConnectionString = sessionAddresCompatibility; |
| 144 | + } |
| 145 | + if (!string.IsNullOrEmpty(password)) |
| 146 | + { |
| 147 | + ConnectionString += $";password={password}"; |
| 148 | + } |
| 149 | + Schema = schema; |
| 150 | + TableName = tableName; |
135 | 151 |
|
136 | | - if (!string.IsNullOrEmpty(serverName)) |
137 | | - { |
138 | | - ConnectionString += $"Data Source={serverName};"; |
139 | | - } |
140 | | - if (!string.IsNullOrEmpty(database)) |
141 | | - { |
142 | | - ConnectionString += $"Initial Catalog={database}"; |
143 | 152 | } |
144 | | - if (!string.IsNullOrEmpty(password)) |
145 | | - { |
146 | | - ConnectionString += $";password={password}"; |
147 | | - } |
148 | | - if (!string.IsNullOrEmpty(userName)) |
149 | | - { |
150 | | - ConnectionString += $";user={userName}"; |
151 | | - } |
152 | | - Schema = schema; |
153 | | - TableName = tableName; |
154 | 153 | SessionTimeout = Preferences.SessionTimeout; |
155 | 154 | } |
156 | 155 | public GxDatabaseSession(string host, string password, string schema, string tableName) |
|
0 commit comments