Skip to content

Commit

Permalink
Merge branch 'master' into http-chunked
Browse files Browse the repository at this point in the history
  • Loading branch information
claudiamurialdo authored Jun 21, 2023
2 parents 7fa5359 + 9c70389 commit 6bc71f9
Show file tree
Hide file tree
Showing 16 changed files with 546 additions and 109 deletions.
2 changes: 1 addition & 1 deletion dotnet/Directory.Build.props
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<AssemblyVersion>11.0.0.0</AssemblyVersion>
<MajorFileVersion>1</MajorFileVersion>
<MajorFileVersion Condition="$(GIT_REF.EndsWith('beta'))">$([MSBuild]::Add($(MajorFileVersion), 100))</MajorFileVersion>
<MinorFileVersion>24</MinorFileVersion>
<MinorFileVersion>25</MinorFileVersion>
<PatchFileVersion Condition="'$(COMMIT_NUMBER)'!=''">$(COMMIT_NUMBER)</PatchFileVersion>
<PatchFileVersion Condition="'$(COMMIT_NUMBER)'==''">0</PatchFileVersion>
<FileVersion>$(MajorFileVersion).$(MinorFileVersion).$(PatchFileVersion)</FileVersion>
Expand Down
1 change: 0 additions & 1 deletion dotnet/src/dotnetcore/GxClasses.Web/GxClasses.Web.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
<Compile Include="..\..\dotnetframework\GxClasses\Helpers\GxDynamicCall.cs" Link="Helpers\GxDynamicCall.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Middleware\GXHttp.cs" Link="Middleware\GXHttp.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Middleware\GXHttpServices.cs" Link="Middleware\GXHttpServices.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXRuntime.cs" Link="Domain\GXRuntime.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Services\GxRestWrapper.cs" Link="Middleware\GxRestWrapper.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Services\ReflectionHelper.cs" Link="Helpers\ReflectionHelper.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\View\GXGridStateHandler.cs" Link="View\GXGridStateHandler.cs" />
Expand Down
2 changes: 2 additions & 0 deletions dotnet/src/dotnetcore/GxClasses/GxClasses.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,7 @@
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXLDAP.cs" Link="Domain\GXLDAP.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GxMessages.cs" Link="Domain\GxMessages.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GxMessaging.cs" Link="Domain\GxMessaging.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXRuntime.cs" Link="Domain\GXRuntime.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXTypeConstants.cs" Link="Domain\GXTypeConstants.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXUri.cs" Link="Domain\GXUri.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Domain\GXUserInfo.cs" Link="Domain\GXUserInfo.cs" />
Expand All @@ -57,6 +58,7 @@
<Compile Include="..\..\dotnetframework\GxClasses\Helpers\GxObjectProperties.cs" Link="Helpers\GxObjectProperties.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Helpers\GXRestAPIClient.cs" Link="Helpers\GXRestAPIClient.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Model\GXBaseObject.cs" Link="Model\GXBaseObject.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Model\GxMockProvider.cs" Link="Model\GxMockProvider.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Model\URLRouter.cs" Link="Model\URLRouter.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Model\SdtGridState.cs" Link="Model\SdtGridState.cs" />
<Compile Include="..\..\dotnetframework\GxClasses\Model\SdtGridState_InputValuesItem.cs" Link="Model\SdtGridState_InputValuesItem.cs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,8 @@
using System;
using GeneXus.Application;
using GeneXus.Configuration;
using GeneXus.Data;
using GeneXus.Data.ADO;
using GeneXus.Encryption;
using GxClasses.Helpers;
using log4net;
Expand All @@ -11,7 +14,6 @@ public class GXSessionServiceFactory
private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXSessionServiceFactory));
static string REDIS = "REDIS";
static string DATABASE = "DATABASE";

public static ISessionService GetProvider()
{
ISessionService sessionService = null;
Expand All @@ -32,7 +34,6 @@ public static ISessionService GetProvider()
}
else
{

GXLogging.Debug(log, "Loading Session provider:", className);
#if !NETCORE
type = Type.GetType(className, true, true);
Expand All @@ -53,16 +54,15 @@ public static ISessionService GetProvider()
}
}
return null;

}
}
public class GxRedisSession : ISessionService
{
private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxRedisSession));
internal static string SESSION_ADDRESS = "SESSION_PROVIDER_ADDRESS";
internal static string SESSION_INSTANCE = "SESSION_PROVIDER_INSTANCE_NAME";
internal static string SESSION_PASSWORD = "SESSION_PROVIDER_PASSWORD";
static string SESSION_TIMEOUT = "SESSION_PROVIDER_SESSION_TIMEOUT";

public GxRedisSession(GXService serviceProvider)
{
string password = serviceProvider.Properties.Get(SESSION_PASSWORD);
Expand All @@ -85,6 +85,8 @@ public GxRedisSession(GXService serviceProvider)
int.TryParse(sessionTimeoutStrCompatibility, out sessionTimeoutMinutes);

SessionTimeout = sessionTimeoutMinutes;
GXLogging.Debug(log, "Redis Host:", host, ", InstanceName:", instanceName);
GXLogging.Debug(log, "Redis sessionTimeoutMinutes:", sessionTimeoutMinutes.ToString());
}
public GxRedisSession(string host, string password, string instanceName, int sessionTimeout)
{
Expand All @@ -95,63 +97,69 @@ public GxRedisSession(string host, string password, string instanceName, int ses
}
InstanceName = instanceName;
SessionTimeout = sessionTimeout;
GXLogging.Debug(log, "Redis Host:", host, ", InstanceName:", instanceName);
GXLogging.Debug(log, "Redis sessionTimeoutMinutes:", sessionTimeout.ToString());
}
public string ConnectionString { get; }
public string InstanceName { get; }
public int SessionTimeout { get; }

public string Schema => throw new NotImplementedException();

public string TableName => throw new NotImplementedException();
}
public class GxDatabaseSession : ISessionService
{
private static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxDatabaseSession));
internal static string SESSION_ADDRESS = "SESSION_PROVIDER_ADDRESS";
internal static string SESSION_PASSWORD = "SESSION_PROVIDER_PASSWORD";
internal static string SESSION_SCHEMA = "SESSION_PROVIDER_SCHEMA";
internal static string SESSION_TABLE_NAME = "SESSION_PROVIDER_TABLE_NAME";
internal static string SESSION_PROVIDER_SERVER = "SESSION_PROVIDER_SERVER";
internal static string SESSION_PROVIDER_DATABASE = "SESSION_PROVIDER_DATABASE";
internal static string SESSION_PROVIDER_USER = "SESSION_PROVIDER_USER";

internal static string SESSION_DATASTORE = "SESSION_PROVIDER_DATASTORE";
const string DEFAULT_SQLSERVER_SCHEMA = "dbo";
public GxDatabaseSession(GXService serviceProvider)
{
string password = serviceProvider.Properties.Get(SESSION_PASSWORD);
if (!string.IsNullOrEmpty(password))
{
password = CryptoImpl.Decrypt(password);
}
string serverName = serviceProvider.Properties.Get(SESSION_PROVIDER_SERVER);
string userName = serviceProvider.Properties.Get(SESSION_PROVIDER_USER);
string database = serviceProvider.Properties.Get(SESSION_PROVIDER_DATABASE);
string schema = serviceProvider.Properties.Get(SESSION_SCHEMA);
string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME);

string sessionAddresCompatibility = serviceProvider.Properties.Get(GxDatabaseSession.SESSION_ADDRESS);
if (!string.IsNullOrEmpty(sessionAddresCompatibility))
{
ConnectionString = sessionAddresCompatibility;
}

if (!string.IsNullOrEmpty(serverName))
string datastoreName = serviceProvider.Properties.Get(SESSION_DATASTORE);
if (!string.IsNullOrEmpty(datastoreName))
{
ConnectionString += $"Data Source={serverName};";
}
if (!string.IsNullOrEmpty(database))
{
ConnectionString += $"Initial Catalog={database}";
}
if (!string.IsNullOrEmpty(password))
{
ConnectionString += $";password={password}";
GxContext context = GxContext.CreateDefaultInstance();
IGxDataStore datastore = context.GetDataStore(datastoreName);
string schema = datastore.Connection.CurrentSchema;
if (string.IsNullOrEmpty(schema))
schema = DEFAULT_SQLSERVER_SCHEMA;
string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME);
GxConnection conn = datastore.Connection as GxConnection;
Schema = schema;
TableName = tableName;
context.CloseConnections();
GxDataRecord dr = datastore.Db as GxDataRecord;
if (dr != null && conn != null)
{
ConnectionString = dr.BuildConnectionStringImpl(conn.DataSourceName, conn.InternalUserId, conn.UserPassword, conn.DatabaseName, conn.Port, conn.CurrentSchema, conn.Data);
GXLogging.Debug(log, "Database ConnectionString:", dr.ConnectionStringForLog());
}
}
if (!string.IsNullOrEmpty(userName))
else //Backward compatibility configuration
{
ConnectionString += $";user={userName}";
string password = serviceProvider.Properties.Get(SESSION_PASSWORD);
if (!string.IsNullOrEmpty(password))
{
password = CryptoImpl.Decrypt(password);
}
string schema = serviceProvider.Properties.Get(SESSION_SCHEMA);
string tableName = serviceProvider.Properties.Get(SESSION_TABLE_NAME);
string sessionAddresCompatibility = serviceProvider.Properties.Get(SESSION_ADDRESS);
if (!string.IsNullOrEmpty(sessionAddresCompatibility))
{
ConnectionString = sessionAddresCompatibility;
}
if (!string.IsNullOrEmpty(password))
{
ConnectionString += $";password={password}";
}
Schema = schema;
TableName = tableName;
}
Schema = schema;
TableName = tableName;
SessionTimeout = Preferences.SessionTimeout;
GXLogging.Debug(log, "Database sessionTimeoutMinutes:", SessionTimeout.ToString());
}
public GxDatabaseSession(string host, string password, string schema, string tableName)
{
Expand All @@ -164,16 +172,11 @@ public GxDatabaseSession(string host, string password, string schema, string tab
TableName = tableName;
}
public string ConnectionString { get; }

public string Schema { get; }

public string TableName { get; }

public string InstanceName => throw new NotImplementedException();

public int SessionTimeout { get; }
}

public interface ISessionService
{
string ConnectionString { get; }
Expand Down
4 changes: 2 additions & 2 deletions dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -511,8 +511,8 @@ public class StringUtil
const char QMARK = '_';
static char[] numbersAndSep = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9', '-' };
static char[] numbers = new char[] { '1', '2', '3', '4', '5', '6', '7', '8', '9' };
internal static Dictionary<char, char> LogUserEntryWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789+-_=/[]{}\":, ".ToDictionary(item => item, item => item);
internal static Dictionary<char, char> HttpHeaderWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz123456789.;+-_=/[]{}\"':, @()?<>\\".ToDictionary(item => item, item => item);
internal static Dictionary<char, char> LogUserEntryWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890+-_=/[]{}\":, ".ToDictionary(item => item, item => item);
internal static Dictionary<char, char> HttpHeaderWhiteList = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890.;+-_=/[]{}\"':, @()?<>\\".ToDictionary(item => item, item => item);

internal static string Sanitize(string input, Dictionary<char, char> WhiteList)
{
Expand Down
82 changes: 64 additions & 18 deletions dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,8 @@ namespace GeneXus.Http
using GeneXus.Notifications;
using Web.Security;
using System.Web.SessionState;
using GeneXus.Mock;
using GeneXus.Data.NTier;
#endif


Expand Down Expand Up @@ -274,15 +276,68 @@ private bool IsFullAjaxRequest(HttpContext httpContext)
public virtual void InitializeDynEvents() { throw new Exception("The method or operation is not implemented."); }
public virtual void initialize_properties() { throw new Exception("The method or operation is not implemented."); }
public virtual void webExecute() { throw new Exception("The method or operation is not implemented."); }
public virtual void initialize() { throw new Exception("The method or operation is not implemented."); }
#if !NETCORE
public virtual void initialize() { throw new Exception("The method or operation is not implemented."); }
public virtual void cleanup() { }
virtual public bool UploadEnabled() { return false; }

protected virtual void ExecuteEx()
{
ExecutePrivate();
}
protected virtual void ExecutePrivate()
{

}
protected virtual void ExecutePrivateCatch(object stateInfo)
{
try
{
((GXHttpHandler)stateInfo).ExecutePrivate();
}
catch (Exception e)
{
GXUtil.SaveToEventLog("Design", e);
Console.WriteLine(e.ToString());
}
}
protected void SubmitImpl()
{
GxContext submitContext = new GxContext();
DataStoreUtil.LoadDataStores(submitContext);
IsMain = true;
submitContext.SetSubmitInitialConfig(context);
this.context = submitContext;
initialize();
Submit(ExecutePrivateCatch, this);
}
protected virtual void CloseCursors()
{

}
protected void Submit(Action<object> executeMethod, object state)
{
ThreadUtil.Submit(PropagateCulture(new WaitCallback(executeMethod)), state);
}
public static WaitCallback PropagateCulture(WaitCallback action)
{
var currentCulture = Thread.CurrentThread.CurrentCulture;
GXLogging.Debug(log, "Submit PropagateCulture " + currentCulture);
var currentUiCulture = Thread.CurrentThread.CurrentUICulture;
return (x) =>
{
Thread.CurrentThread.CurrentCulture = currentCulture;
Thread.CurrentThread.CurrentUICulture = currentUiCulture;
action(x);
};
}
protected virtual string[] GetParameters()
{
return null;
}
#endif
public virtual bool SupportAjaxEvent() { return false; }
public virtual String AjaxOnSessionTimeout() { return "Ignore"; }
#if !NETCORE
virtual public bool UploadEnabled() { return false; }
#endif
#if NETCORE
public void DoAjaxLoad(int SId, GXWebRow row)
{
Expand Down Expand Up @@ -2222,22 +2277,16 @@ public virtual bool CompressHtmlResponse()
{
return GXUtil.CompressResponse();
}

#if NETCORE
protected virtual void Render(HtmlTextWriter output)
#else
#if !NETCORE
protected override void Render(HtmlTextWriter output)
#endif
{
#if !NETCORE
localHttpContext = Context;
#endif
localHttpContext = Context;
ControlOutputWriter = output;
LoadParameters(Parms);
InitPrivates();
webExecuteEx(localHttpContext);
}

#endif
public void InitPrivates()
{
context.GX_msglist = new msglist();
Expand Down Expand Up @@ -2857,21 +2906,18 @@ public void ComponentInit()
createObjects();
initialize();
}

#if !NETCORE
protected override void Render(HtmlTextWriter output)
{
ControlOutputWriter = output;
#if NETCORE
localHttpContext = localHttpContext;
#else
localHttpContext = Context;
#endif
LoadParameters(Parms);
InitPrivates();
SetPrefix(_prefixId + "_"); // Load Prefix from Name property
initpars(); // Initialize Iterator Parameters
webExecuteEx(localHttpContext);
}
#endif
public virtual void componentdrawstyles()
{
}
Expand Down
Loading

0 comments on commit 6bc71f9

Please sign in to comment.