From d5e78242683d5143a9d5f435245aef96da7130ec Mon Sep 17 00:00:00 2001 From: Claudia Beatriz Murialdo Garrone Date: Thu, 19 Sep 2024 18:23:32 -0300 Subject: [PATCH 1/4] Add async interfaces. --- .../Middleware/HandlerFactory.cs | 2 +- .../GxClasses/Middleware/GXHttp.cs | 31 +++++++++-- .../GxClasses/View/GXGridStateHandler.cs | 51 ++++++++++++++++--- 3 files changed, 70 insertions(+), 14 deletions(-) diff --git a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs index d072c5d27..197a97b44 100644 --- a/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs +++ b/dotnet/src/dotnetcore/GxClasses.Web/Middleware/HandlerFactory.cs @@ -75,7 +75,7 @@ public async Task Invoke(HttpContext context) handler.sendAdditionalHeaders(); return Task.CompletedTask; }); - GXWebProcedure gxWebProc = handler as GXWebProcedure; + GXHttpHandler gxWebProc = handler as GXHttpHandler; if (gxWebProc != null && gxWebProc.GetAsyncEnabledInternal()) { await gxWebProc.ProcessRequestAsync(context); diff --git a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs index cfe9ed0d5..e6da5c381 100644 --- a/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs +++ b/dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs @@ -296,7 +296,7 @@ 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."); } - protected virtual Task WebExecuteAsync() + public virtual Task WebExecuteAsync() { GXLogging.Warn(log, this.GetType().FullName + " not generated as async service"); webExecute(); @@ -2945,10 +2945,10 @@ protected void initialize(int objClass, int objId, int dbgLines, long hash) public abstract class GXWebComponent : GXHttpHandler { - public abstract void componentstart(); - public abstract void componentdraw(); - public abstract void componentprepare(Object[] parms); - public abstract void componentbind(Object[] values); + public virtual void componentstart() { } + public virtual void componentdraw() { } + public virtual void componentprepare(Object[] parms) { } + public virtual void componentbind(Object[] values) { } public abstract String getstring(String s); public bool IsUrlCreated() @@ -3096,6 +3096,27 @@ public virtual void componentjscripts() public virtual void componentthemes() { } + public virtual async Task ComponentRestoreStateAsync(string sPPrefix, string sPSFPrefix) + { + await Task.CompletedTask; + } + public virtual async Task ComponentProcessAsync(string sPPrefix, string sPSFPrefix, string sEvt) + { + await Task.CompletedTask; + } + public virtual async Task ComponentPrepareAsync(Object[] parms) + { + await Task.CompletedTask; + } + public virtual async Task ComponentStartAsync() + { + await Task.CompletedTask; + } + public virtual async Task ComponentDrawAsync() + { + await Task.CompletedTask; + } + } public class GXErrorWebComponent : GXWebComponent diff --git a/dotnet/src/dotnetframework/GxClasses/View/GXGridStateHandler.cs b/dotnet/src/dotnetframework/GxClasses/View/GXGridStateHandler.cs index fa2c8206c..864b9f3e4 100644 --- a/dotnet/src/dotnetframework/GxClasses/View/GXGridStateHandler.cs +++ b/dotnet/src/dotnetframework/GxClasses/View/GXGridStateHandler.cs @@ -1,20 +1,43 @@ using System; +using System.Threading.Tasks; using GeneXus.Application; using GeneXus.Core.genexus.common; namespace GeneXus.WebControls { + public class GXGridStateHandlerAsync: GXGridStateHandler + { + readonly Func varsFromState; + readonly Func varsToState; + public GXGridStateHandlerAsync(IGxContext context, string gridName, string programName, Func varsFromState, Func varsToState) + { + this.gridName = $"{programName}_{gridName}_{GRID_STATE}"; + this.varsFromState = varsFromState; + this.varsToState = varsToState; + this.context = context; + state = new SdtGridState(context); + dirty = true; + } + protected override void ToState() + { + varsToState().GetAwaiter().GetResult(); + } + protected override void FromState() + { + varsFromState().GetAwaiter().GetResult(); + } + } + public class GXGridStateHandler { - string gridName; + protected string gridName; readonly Action varsFromState; readonly Action varsToState; - IGxContext context; - SdtGridState state; - bool dirty; - const string GRID_STATE = "GridState"; - + protected IGxContext context; + protected SdtGridState state; + protected bool dirty; + protected const string GRID_STATE = "GridState"; public GXGridStateHandler(IGxContext context, string gridName, string programName, Action varsFromState, Action varsToState) { this.gridName = $"{programName}_{gridName}_{GRID_STATE}"; @@ -24,10 +47,13 @@ public GXGridStateHandler(IGxContext context, string gridName, string programNam state = new SdtGridState(context); dirty = true; } + internal GXGridStateHandler() + { + } public void SaveGridState() { state.FromJSonString(context.GetSession().Get(gridName)); - varsToState(); + ToState(); context.GetSession().Set(gridName, state.ToJSonString()); dirty = true; } @@ -37,10 +63,19 @@ public void LoadGridState() { state = new SdtGridState(context); state.FromJSonString(context.GetSession().Get(gridName)); - varsFromState(); + FromState(); dirty = true; } } + + protected virtual void FromState() + { + varsFromState(); + } + protected virtual void ToState() + { + varsToState(); + } public string FilterValues(int idx) { return state.gxTpr_Inputvalues[idx-1].gxTpr_Value; From a061e5e194874b0a200b592bca38cf6a560062c8 Mon Sep 17 00:00:00 2001 From: Claudia Murialdo Date: Fri, 27 Sep 2024 13:50:37 -0300 Subject: [PATCH 2/4] Fix build error. --- dotnet/test/DotNetCoreWebUnitTest/apps/aprochttpgetstatic.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/dotnet/test/DotNetCoreWebUnitTest/apps/aprochttpgetstatic.cs b/dotnet/test/DotNetCoreWebUnitTest/apps/aprochttpgetstatic.cs index 8fef42f0f..5fff18077 100644 --- a/dotnet/test/DotNetCoreWebUnitTest/apps/aprochttpgetstatic.cs +++ b/dotnet/test/DotNetCoreWebUnitTest/apps/aprochttpgetstatic.cs @@ -9,7 +9,7 @@ namespace GeneXus.Programs { public class aprochttpgetstatic : GXWebProcedure { - protected override async Task WebExecuteAsync( ) + public override async Task WebExecuteAsync( ) { context.SetDefaultTheme("HttpClientTest", true); initialize(); From 00cc4322ea6ec5b3f4c1ee2417192053485175fa Mon Sep 17 00:00:00 2001 From: Claudia Murialdo Date: Fri, 27 Sep 2024 17:04:42 -0300 Subject: [PATCH 3/4] Add Async methods for reorg. --- .../GxClasses/Reorg/GXReorg.cs | 27 ++++++++++++++----- 1 file changed, 21 insertions(+), 6 deletions(-) diff --git a/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs b/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs index 1fa54132c..6459b9e49 100644 --- a/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs +++ b/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs @@ -7,6 +7,7 @@ namespace GeneXus.Reorg using System.Reflection; using System.Runtime.CompilerServices; using System.Threading; + using System.Threading.Tasks; using GeneXus.Application; using GeneXus.Configuration; using GeneXus.Data; @@ -47,12 +48,26 @@ public virtual void cleanup() { } public GXReorganization() - { - DataStoreUtil.LoadDataStores(new GxContext()); //force to load dbms library (p.e. libmysql.dll 32x) - _isMain = true; - GxContext.isReorganization = true; - GXLogging.Debug(log, "GXReorganization.Ctr()"); - } + { + DataStoreUtil.LoadDataStores(new GxContext()); //force to load dbms library (p.e. libmysql.dll 32x) + _isMain = true; + GxContext.isReorganization = true; + GXLogging.Debug(log, "GXReorganization.Ctr()"); + } +#if NETCORE + protected virtual Task ExecutePrivateAsync() + { + return Task.CompletedTask; + } + protected virtual Task CleanupAsync() { + return Task.CompletedTask; + } + protected virtual async Task ExecuteImplAsync() + { + await ExecutePrivateAsync(); + } +#endif + protected virtual void ExecutePrivate() { From 4db39696aff131f08dc903bff5f4a622d50432ff Mon Sep 17 00:00:00 2001 From: Claudia Murialdo Date: Fri, 27 Sep 2024 17:37:59 -0300 Subject: [PATCH 4/4] Add ExecFormAsync --- dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs b/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs index 6459b9e49..84a444055 100644 --- a/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs +++ b/dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs @@ -66,6 +66,11 @@ protected virtual async Task ExecuteImplAsync() { await ExecutePrivateAsync(); } + public virtual Task ExecFormAsync() + { + return Task.CompletedTask; + } + #endif protected virtual void ExecutePrivate()