Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add async interfaces. #1067

Draft
wants to merge 4 commits into
base: master
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
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
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
31 changes: 26 additions & 5 deletions dotnet/src/dotnetframework/GxClasses/Middleware/GXHttp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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
Expand Down
32 changes: 26 additions & 6 deletions dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -47,12 +48,31 @@ 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();
}
public virtual Task ExecFormAsync()
{
return Task.CompletedTask;
}

#endif

protected virtual void ExecutePrivate()
{

Expand Down
51 changes: 43 additions & 8 deletions dotnet/src/dotnetframework/GxClasses/View/GXGridStateHandler.cs
Original file line number Diff line number Diff line change
@@ -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<Task> varsFromState;
readonly Func<Task> varsToState;
public GXGridStateHandlerAsync(IGxContext context, string gridName, string programName, Func<Task> varsFromState, Func<Task> 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}";
Expand All @@ -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;
}
Expand All @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading