Skip to content

Commit 21d1014

Browse files
Merge branch 'http-chunked' of https://github.com/genexuslabs/DotNetClasses into http-chunked
2 parents 5dda8b7 + 6bc71f9 commit 21d1014

File tree

16 files changed

+546
-109
lines changed

16 files changed

+546
-109
lines changed

dotnet/Directory.Build.props

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<AssemblyVersion>11.0.0.0</AssemblyVersion>
44
<MajorFileVersion>1</MajorFileVersion>
55
<MajorFileVersion Condition="$(GIT_REF.EndsWith('beta'))">$([MSBuild]::Add($(MajorFileVersion), 100))</MajorFileVersion>
6-
<MinorFileVersion>24</MinorFileVersion>
6+
<MinorFileVersion>25</MinorFileVersion>
77
<PatchFileVersion Condition="'$(COMMIT_NUMBER)'!=''">$(COMMIT_NUMBER)</PatchFileVersion>
88
<PatchFileVersion Condition="'$(COMMIT_NUMBER)'==''">0</PatchFileVersion>
99
<FileVersion>$(MajorFileVersion).$(MinorFileVersion).$(PatchFileVersion)</FileVersion>

dotnet/src/dotnetcore/GxClasses.Web/GxClasses.Web.csproj

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@
1515
<Compile Include="..\..\dotnetframework\GxClasses\Helpers\GxDynamicCall.cs" Link="Helpers\GxDynamicCall.cs" />
1616
<Compile Include="..\..\dotnetframework\GxClasses\Middleware\GXHttp.cs" Link="Middleware\GXHttp.cs" />
1717
<Compile Include="..\..\dotnetframework\GxClasses\Middleware\GXHttpServices.cs" Link="Middleware\GXHttpServices.cs" />
18-
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXRuntime.cs" Link="Domain\GXRuntime.cs" />
1918
<Compile Include="..\..\dotnetframework\GxClasses\Services\GxRestWrapper.cs" Link="Middleware\GxRestWrapper.cs" />
2019
<Compile Include="..\..\dotnetframework\GxClasses\Services\ReflectionHelper.cs" Link="Helpers\ReflectionHelper.cs" />
2120
<Compile Include="..\..\dotnetframework\GxClasses\View\GXGridStateHandler.cs" Link="View\GXGridStateHandler.cs" />

dotnet/src/dotnetcore/GxClasses/GxClasses.csproj

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@
4141
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXLDAP.cs" Link="Domain\GXLDAP.cs" />
4242
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GxMessages.cs" Link="Domain\GxMessages.cs" />
4343
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GxMessaging.cs" Link="Domain\GxMessaging.cs" />
44+
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXRuntime.cs" Link="Domain\GXRuntime.cs" />
4445
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXTypeConstants.cs" Link="Domain\GXTypeConstants.cs" />
4546
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXUri.cs" Link="Domain\GXUri.cs" />
4647
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXUserInfo.cs" Link="Domain\GXUserInfo.cs" />
@@ -57,6 +58,7 @@
5758
<Compile Include="..\..\dotnetframework\GxClasses\Helpers\GxObjectProperties.cs" Link="Helpers\GxObjectProperties.cs" />
5859
<Compile Include="..\..\dotnetframework\GxClasses\Helpers\GXRestAPIClient.cs" Link="Helpers\GXRestAPIClient.cs" />
5960
<Compile Include="..\..\dotnetframework\GxClasses\Model\GXBaseObject.cs" Link="Model\GXBaseObject.cs" />
61+
<Compile Include="..\..\dotnetframework\GxClasses\Model\GxMockProvider.cs" Link="Model\GxMockProvider.cs" />
6062
<Compile Include="..\..\dotnetframework\GxClasses\Model\URLRouter.cs" Link="Model\URLRouter.cs" />
6163
<Compile Include="..\..\dotnetframework\GxClasses\Model\SdtGridState.cs" Link="Model\SdtGridState.cs" />
6264
<Compile Include="..\..\dotnetframework\GxClasses\Model\SdtGridState_InputValuesItem.cs" Link="Model\SdtGridState_InputValuesItem.cs" />

dotnet/src/dotnetcore/GxClasses/Services/Session/GXSessionFactory.cs

Lines changed: 49 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
using System;
2+
using GeneXus.Application;
23
using GeneXus.Configuration;
4+
using GeneXus.Data;
5+
using GeneXus.Data.ADO;
36
using GeneXus.Encryption;
47
using GxClasses.Helpers;
58
using log4net;
@@ -11,7 +14,6 @@ public class GXSessionServiceFactory
1114
private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXSessionServiceFactory));
1215
static string REDIS = "REDIS";
1316
static string DATABASE = "DATABASE";
14-
1517
public static ISessionService GetProvider()
1618
{
1719
ISessionService sessionService = null;
@@ -32,7 +34,6 @@ public static ISessionService GetProvider()
3234
}
3335
else
3436
{
35-
3637
GXLogging.Debug(log, "Loading Session provider:", className);
3738
#if !NETCORE
3839
type = Type.GetType(className, true, true);
@@ -53,16 +54,15 @@ public static ISessionService GetProvider()
5354
}
5455
}
5556
return null;
56-
5757
}
5858
}
5959
public class GxRedisSession : ISessionService
6060
{
61+
private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxRedisSession));
6162
internal static string SESSION_ADDRESS = "SESSION_PROVIDER_ADDRESS";
6263
internal static string SESSION_INSTANCE = "SESSION_PROVIDER_INSTANCE_NAME";
6364
internal static string SESSION_PASSWORD = "SESSION_PROVIDER_PASSWORD";
6465
static string SESSION_TIMEOUT = "SESSION_PROVIDER_SESSION_TIMEOUT";
65-
6666
public GxRedisSession(GXService serviceProvider)
6767
{
6868
string password = serviceProvider.Properties.Get(SESSION_PASSWORD);
@@ -85,6 +85,8 @@ public GxRedisSession(GXService serviceProvider)
8585
int.TryParse(sessionTimeoutStrCompatibility, out sessionTimeoutMinutes);
8686

8787
SessionTimeout = sessionTimeoutMinutes;
88+
GXLogging.Debug(log, "Redis Host:", host, ", InstanceName:", instanceName);
89+
GXLogging.Debug(log, "Redis sessionTimeoutMinutes:", sessionTimeoutMinutes.ToString());
8890
}
8991
public GxRedisSession(string host, string password, string instanceName, int sessionTimeout)
9092
{
@@ -95,63 +97,69 @@ public GxRedisSession(string host, string password, string instanceName, int ses
9597
}
9698
InstanceName = instanceName;
9799
SessionTimeout = sessionTimeout;
100+
GXLogging.Debug(log, "Redis Host:", host, ", InstanceName:", instanceName);
101+
GXLogging.Debug(log, "Redis sessionTimeoutMinutes:", sessionTimeout.ToString());
98102
}
99103
public string ConnectionString { get; }
100104
public string InstanceName { get; }
101105
public int SessionTimeout { get; }
102-
103106
public string Schema => throw new NotImplementedException();
104-
105107
public string TableName => throw new NotImplementedException();
106108
}
107109
public class GxDatabaseSession : ISessionService
108110
{
111+
private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxDatabaseSession));
109112
internal static string SESSION_ADDRESS = "SESSION_PROVIDER_ADDRESS";
110113
internal static string SESSION_PASSWORD = "SESSION_PROVIDER_PASSWORD";
111114
internal static string SESSION_SCHEMA = "SESSION_PROVIDER_SCHEMA";
112115
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";
116-
116+
internal static string SESSION_DATASTORE = "SESSION_PROVIDER_DATASTORE";
117+
const string DEFAULT_SQLSERVER_SCHEMA = "dbo";
117118
public GxDatabaseSession(GXService serviceProvider)
118119
{
119-
string password = serviceProvider.Properties.Get(SESSION_PASSWORD);
120-
if (!string.IsNullOrEmpty(password))
121-
{
122-
password = CryptoImpl.Decrypt(password);
123-
}
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))
132-
{
133-
ConnectionString = sessionAddresCompatibility;
134-
}
135-
136-
if (!string.IsNullOrEmpty(serverName))
120+
string datastoreName = serviceProvider.Properties.Get(SESSION_DATASTORE);
121+
if (!string.IsNullOrEmpty(datastoreName))
137122
{
138-
ConnectionString += $"Data Source={serverName};";
139-
}
140-
if (!string.IsNullOrEmpty(database))
141-
{
142-
ConnectionString += $"Initial Catalog={database}";
143-
}
144-
if (!string.IsNullOrEmpty(password))
145-
{
146-
ConnectionString += $";password={password}";
123+
GxContext context = GxContext.CreateDefaultInstance();
124+
IGxDataStore datastore = context.GetDataStore(datastoreName);
125+
string schema = datastore.Connection.CurrentSchema;
126+
if (string.IsNullOrEmpty(schema))
127+
schema = DEFAULT_SQLSERVER_SCHEMA;
128+
string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME);
129+
GxConnection conn = datastore.Connection as GxConnection;
130+
Schema = schema;
131+
TableName = tableName;
132+
context.CloseConnections();
133+
GxDataRecord dr = datastore.Db as GxDataRecord;
134+
if (dr != null && conn != null)
135+
{
136+
ConnectionString = dr.BuildConnectionStringImpl(conn.DataSourceName, conn.InternalUserId, conn.UserPassword, conn.DatabaseName, conn.Port, conn.CurrentSchema, conn.Data);
137+
GXLogging.Debug(log, "Database ConnectionString:", dr.ConnectionStringForLog());
138+
}
147139
}
148-
if (!string.IsNullOrEmpty(userName))
140+
else //Backward compatibility configuration
149141
{
150-
ConnectionString += $";user={userName}";
142+
string password = serviceProvider.Properties.Get(SESSION_PASSWORD);
143+
if (!string.IsNullOrEmpty(password))
144+
{
145+
password = CryptoImpl.Decrypt(password);
146+
}
147+
string schema = serviceProvider.Properties.Get(SESSION_SCHEMA);
148+
string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME);
149+
string sessionAddresCompatibility = serviceProvider.Properties.Get(SESSION_ADDRESS);
150+
if (!string.IsNullOrEmpty(sessionAddresCompatibility))
151+
{
152+
ConnectionString = sessionAddresCompatibility;
153+
}
154+
if (!string.IsNullOrEmpty(password))
155+
{
156+
ConnectionString += $";password={password}";
157+
}
158+
Schema = schema;
159+
TableName = tableName;
151160
}
152-
Schema = schema;
153-
TableName = tableName;
154161
SessionTimeout = Preferences.SessionTimeout;
162+
GXLogging.Debug(log, "Database sessionTimeoutMinutes:", SessionTimeout.ToString());
155163
}
156164
public GxDatabaseSession(string host, string password, string schema, string tableName)
157165
{
@@ -164,16 +172,11 @@ public GxDatabaseSession(string host, string password, string schema, string tab
164172
TableName = tableName;
165173
}
166174
public string ConnectionString { get; }
167-
168175
public string Schema { get; }
169-
170176
public string TableName { get; }
171-
172177
public string InstanceName => throw new NotImplementedException();
173-
174178
public int SessionTimeout { get; }
175179
}
176-
177180
public interface ISessionService
178181
{
179182
string ConnectionString { get; }

dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -511,8 +511,8 @@ public class StringUtil
511511
const char QMARK = '_';
512512
static char[] numbersAndSep = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '-' };
513513
static char[] numbers = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
514-
internal static Dictionary<char, char> LogUserEntryWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789+-_=/[]{}\":, ".ToDictionary(item => item, item => item);
515-
internal static Dictionary<char, char> HttpHeaderWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789.;+-_=/[]{}\"':, @()?<>\\".ToDictionary(item => item, item => item);
514+
internal static Dictionary<char, char> LogUserEntryWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890+-_=/[]{}\":, ".ToDictionary(item => item, item => item);
515+
internal static Dictionary<char, char> HttpHeaderWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890.;+-_=/[]{}\"':, @()?<>\\".ToDictionary(item => item, item => item);
516516

517517
internal static string Sanitize(string input, Dictionary<char, char> WhiteList)
518518
{

dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs

Lines changed: 64 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,8 @@ namespace GeneXus.Http
4444
using GeneXus.Notifications;
4545
using Web.Security;
4646
using System.Web.SessionState;
47+
using GeneXus.Mock;
48+
using GeneXus.Data.NTier;
4749
#endif
4850

4951

@@ -274,15 +276,68 @@ private bool IsFullAjaxRequest(HttpContext httpContext)
274276
public virtual void InitializeDynEvents() { throw new Exception("The method or operation is not implemented."); }
275277
public virtual void initialize_properties() { throw new Exception("The method or operation is not implemented."); }
276278
public virtual void webExecute() { throw new Exception("The method or operation is not implemented."); }
277-
public virtual void initialize() { throw new Exception("The method or operation is not implemented."); }
278279
#if !NETCORE
280+
public virtual void initialize() { throw new Exception("The method or operation is not implemented."); }
279281
public virtual void cleanup() { }
282+
virtual public bool UploadEnabled() { return false; }
283+
284+
protected virtual void ExecuteEx()
285+
{
286+
ExecutePrivate();
287+
}
288+
protected virtual void ExecutePrivate()
289+
{
290+
291+
}
292+
protected virtual void ExecutePrivateCatch(object stateInfo)
293+
{
294+
try
295+
{
296+
((GXHttpHandler)stateInfo).ExecutePrivate();
297+
}
298+
catch (Exception e)
299+
{
300+
GXUtil.SaveToEventLog("Design", e);
301+
Console.WriteLine(e.ToString());
302+
}
303+
}
304+
protected void SubmitImpl()
305+
{
306+
GxContext submitContext = new GxContext();
307+
DataStoreUtil.LoadDataStores(submitContext);
308+
IsMain = true;
309+
submitContext.SetSubmitInitialConfig(context);
310+
this.context = submitContext;
311+
initialize();
312+
Submit(ExecutePrivateCatch, this);
313+
}
314+
protected virtual void CloseCursors()
315+
{
316+
317+
}
318+
protected void Submit(Action<object> executeMethod, object state)
319+
{
320+
ThreadUtil.Submit(PropagateCulture(new WaitCallback(executeMethod)), state);
321+
}
322+
public static WaitCallback PropagateCulture(WaitCallback action)
323+
{
324+
var currentCulture = Thread.CurrentThread.CurrentCulture;
325+
GXLogging.Debug(log, "Submit PropagateCulture " + currentCulture);
326+
var currentUiCulture = Thread.CurrentThread.CurrentUICulture;
327+
return (x) =>
328+
{
329+
Thread.CurrentThread.CurrentCulture = currentCulture;
330+
Thread.CurrentThread.CurrentUICulture = currentUiCulture;
331+
action(x);
332+
};
333+
}
334+
protected virtual string[] GetParameters()
335+
{
336+
return null;
337+
}
280338
#endif
281339
public virtual bool SupportAjaxEvent() { return false; }
282340
public virtual String AjaxOnSessionTimeout() { return "Ignore"; }
283-
#if !NETCORE
284-
virtual public bool UploadEnabled() { return false; }
285-
#endif
286341
#if NETCORE
287342
public void DoAjaxLoad(int SId, GXWebRow row)
288343
{
@@ -2222,22 +2277,16 @@ public virtual bool CompressHtmlResponse()
22222277
{
22232278
return GXUtil.CompressResponse();
22242279
}
2225-
2226-
#if NETCORE
2227-
protected virtual void Render(HtmlTextWriter output)
2228-
#else
2280+
#if !NETCORE
22292281
protected override void Render(HtmlTextWriter output)
2230-
#endif
22312282
{
2232-
#if !NETCORE
2233-
localHttpContext = Context;
2234-
#endif
2283+
localHttpContext = Context;
22352284
ControlOutputWriter = output;
22362285
LoadParameters(Parms);
22372286
InitPrivates();
22382287
webExecuteEx(localHttpContext);
22392288
}
2240-
2289+
#endif
22412290
public void InitPrivates()
22422291
{
22432292
context.GX_msglist = new msglist();
@@ -2857,21 +2906,18 @@ public void ComponentInit()
28572906
createObjects();
28582907
initialize();
28592908
}
2860-
2909+
#if !NETCORE
28612910
protected override void Render(HtmlTextWriter output)
28622911
{
28632912
ControlOutputWriter = output;
2864-
#if NETCORE
2865-
localHttpContext = localHttpContext;
2866-
#else
28672913
localHttpContext = Context;
2868-
#endif
28692914
LoadParameters(Parms);
28702915
InitPrivates();
28712916
SetPrefix(_prefixId + "_"); // Load Prefix from Name property
28722917
initpars(); // Initialize Iterator Parameters
28732918
webExecuteEx(localHttpContext);
28742919
}
2920+
#endif
28752921
public virtual void componentdrawstyles()
28762922
{
28772923
}

0 commit comments

Comments
 (0)