Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
73660bb
Refactor procs and http procs to allow having a common base object an…
claudiamurialdo Feb 16, 2023
1c8a3b3
Remove unused Render method at GXHttpHandler.
claudiamurialdo Feb 22, 2023
e55bf71
Add a mock provider prototype for procedures.
claudiamurialdo Feb 23, 2023
4cae79c
Print parameter values on mocking test.
claudiamurialdo Feb 24, 2023
0b3ae01
Simplify IGxMock interface: remove CanHandle Method.
claudiamurialdo Mar 2, 2023
1804ef6
Make GXHttpHandler a GXBaseObject in order to move common code to bas…
claudiamurialdo Mar 7, 2023
c6e338a
Move common methods to GXBaseObject.
claudiamurialdo Mar 8, 2023
0f9e7a4
Move SubmitImpl and initialize methods to base clase GXBaseObject.
claudiamurialdo Mar 9, 2023
42b3deb
Move initialize method to base clase GXBaseObject.
claudiamurialdo Mar 9, 2023
3ae5c21
Fix NullReferenceException at log message when provider is null.
claudiamurialdo Mar 13, 2023
111aa0b
Submit was not working for objects calling the submit method itself.
claudiamurialdo Mar 29, 2023
ca95526
Force build.
claudiamurialdo Mar 30, 2023
691aa23
Add method for RE_RUN_AS_X86 setting at config.gx.
claudiamurialdo Apr 1, 2023
2b9ab70
Fix name passed to GXUtil.HandleException: it must pass the executabl…
claudiamurialdo Apr 3, 2023
1e6e678
Submit method must be done in the same instance to support passing pa…
claudiamurialdo Apr 5, 2023
47a7e02
Compatibility fix for HttpHandler for each object: Restore WebControl…
claudiamurialdo Apr 19, 2023
b1c77f1
Compatibility fix for HttpHandler for each object: Restore WebControl…
claudiamurialdo Apr 19, 2023
d97fa5d
Compatibility fix for HttpHandler for each object: Restore WebControl…
claudiamurialdo Apr 19, 2023
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
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
87 changes: 67 additions & 20 deletions dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,12 @@ namespace GeneXus.Http
using GeneXus.Notifications;
using Web.Security;
using System.Web.SessionState;
using GeneXus.Mock;
using GeneXus.Data.NTier;
#endif



#if NETCORE
public abstract class GXHttpHandler : GXBaseObject, IHttpHandler
#else
Expand Down Expand Up @@ -271,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 @@ -1545,8 +1603,6 @@ protected void SendResponseStatus(HttpStatusCode statusCode)
{
SendResponseStatus((int)statusCode, string.Empty);
}


#if !NETCORE
protected void SendResponseStatus(int statusCode, string statusDescription)
{
Expand Down Expand Up @@ -2221,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 @@ -2832,21 +2882,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
93 changes: 92 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
using GeneXus.Data.NTier;
using GeneXus.Encryption;
using GeneXus.Http;
using GeneXus.Mock;
using GeneXus.Utils;
using Jayrock.Json;
using log4net;
Expand All @@ -8,17 +10,106 @@
#endif
using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;

namespace GeneXus.Application
{

public class GxObjectParameter
{
public ParameterInfo ParmInfo { get; set; }
public string ParmName { get; set; }
}
public class GXBaseObject
{
static readonly ILog log = log4net.LogManager.GetLogger(typeof(GXBaseObject));
private Dictionary<string, string> callTargetsByObject = new Dictionary<string, string>();
protected IGxContext _Context;
bool _isMain;
protected bool _isApi;
protected virtual void ExecuteEx()
{
if (GxMockProvider.Provider != null)
{
List<GxObjectParameter> parmInfo = GetExecuteParameterMap();
if (GxMockProvider.Provider.Handle(_Context, this, parmInfo))
return;
}
ExecutePrivate();
}
protected virtual void ExecutePrivate()
{

}
protected virtual void ExecutePrivateCatch(object stateInfo)
{
try
{
((GXBaseObject)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()
{

}
public virtual void initialize() { throw new Exception("The method or operation is not implemented."); }
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);
};
}


private List<GxObjectParameter> GetExecuteParameterMap()
{
ParameterInfo[] pars = GetType().GetMethod("execute").GetParameters();
string[] parms = GetParameters();
int idx = 0;
List<GxObjectParameter> parmInfo = new List<GxObjectParameter>();
if (pars != null && parms!=null && pars.Length == parms.Length)
{
foreach (ParameterInfo par in pars)
{
parmInfo.Add(new GxObjectParameter()
{
ParmInfo = par,
ParmName = parms[idx]
});
idx++;
}
}
return parmInfo;
}
protected virtual string[] GetParameters()
{
return null;
}

public virtual IGxContext context
{
Expand Down
1 change: 0 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Model/GXSilentTrn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ public GxSilentTrn()
{
}

public virtual void initialize() { }
public void flushBuffer(){ }

public virtual object getParm(object[] parms, int index)
Expand Down
13 changes: 3 additions & 10 deletions dotnet/src/dotnetframework/GxClasses/Model/GXWebProcedure.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ namespace GeneXus.Procedure
using System.Threading;
using GeneXus.Mime;
using GeneXus.Utils;
using log4net;
using GeneXus.Application;
using GeneXus.Data.NTier;

public class GXWebProcedure : GXHttpHandler
{
Expand Down Expand Up @@ -219,15 +222,5 @@ protected void GxDrawDynamicBitMap(int printBlock, int controlId, string value,
{
reportMetadata.GxDrawBitMap(printBlock, controlId, line, value, aspectRatio);
}

protected static WaitCallback PropagateCulture(WaitCallback action)
{
return GXProcedure.PropagateCulture(action);
}
protected void Submit(Action<object> executeMethod, object state)
{
ThreadUtil.Submit(PropagateCulture(new WaitCallback(executeMethod)), state);
}

}
}
31 changes: 31 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/Model/GxMockProvider.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System.Collections.Generic;
using GeneXus.Application;
using log4net;
namespace GeneXus.Mock
{
public interface IGxMock
{
bool Handle<T>(IGxContext context, T objectInstance, List<GxObjectParameter> parameters) where T : GXBaseObject;
}
public class GxMockProvider
{
static readonly ILog log = log4net.LogManager.GetLogger(typeof(GxMockProvider));

private static volatile IGxMock provider;

public static IGxMock Provider{
get
{
return provider;
}
set{
provider = value;
if (provider != null)
GXLogging.Debug(log, "Mock provider: " + provider.GetType().FullName);
else
GXLogging.Debug(log, "Mock provider set to null ");
}
}
}

}
Loading