Skip to content

Commit c6e338a

Browse files
Move common methods to GXBaseObject.
Add a virtual ExecutePrivate to move executePrivateCatch from generated code to base class.
1 parent 1804ef6 commit c6e338a

File tree

7 files changed

+72
-46
lines changed

7 files changed

+72
-46
lines changed

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: 1 addition & 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" />

dotnet/src/dotnetframework/GxClasses/Model/GXBaseObject.cs

Lines changed: 41 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
using System;
1111
using System.Collections.Generic;
1212
using System.Reflection;
13+
using System.Threading;
1314

1415
namespace GeneXus.Application
1516
{
@@ -25,11 +26,7 @@ public class GXBaseObject
2526
protected IGxContext _Context;
2627
bool _isMain;
2728
protected bool _isApi;
28-
protected virtual void ExecutePrivate()
29-
{
30-
31-
}
32-
protected virtual void ExecuteImpl()
29+
protected virtual void ExecuteEx()
3330
{
3431
if (GxMockProvider.Provider != null)
3532
{
@@ -39,6 +36,45 @@ protected virtual void ExecuteImpl()
3936
}
4037
ExecutePrivate();
4138
}
39+
protected virtual void ExecutePrivate()
40+
{
41+
42+
}
43+
protected virtual void ExecutePrivateCatch(object stateInfo)
44+
{
45+
try
46+
{
47+
((GXBaseObject)stateInfo).ExecutePrivate();
48+
}
49+
catch (Exception e)
50+
{
51+
GXUtil.SaveToEventLog("Design", e);
52+
Console.WriteLine(e.ToString());
53+
}
54+
}
55+
protected virtual void CloseCursors()
56+
{
57+
58+
}
59+
60+
protected void Submit(Action<object> executeMethod, object state)
61+
{
62+
ThreadUtil.Submit(PropagateCulture(new WaitCallback(executeMethod)), state);
63+
}
64+
protected WaitCallback PropagateCulture(WaitCallback action)
65+
{
66+
var currentCulture = Thread.CurrentThread.CurrentCulture;
67+
GXLogging.Debug(log, "Submit PropagateCulture " + currentCulture);
68+
var currentUiCulture = Thread.CurrentThread.CurrentUICulture;
69+
return (x) =>
70+
{
71+
Thread.CurrentThread.CurrentCulture = currentCulture;
72+
Thread.CurrentThread.CurrentUICulture = currentUiCulture;
73+
action(x);
74+
};
75+
}
76+
77+
4278
private List<GxObjectParameter> GetExecuteParameterMap()
4379
{
4480
ParameterInfo[] pars = GetType().GetMethod("execute").GetParameters();

dotnet/src/dotnetframework/GxClasses/Model/GXWebProcedure.cs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ namespace GeneXus.Procedure
88
using System.Threading;
99
using GeneXus.Mime;
1010
using GeneXus.Utils;
11+
using log4net;
12+
using GeneXus.Application;
1113

1214
public class GXWebProcedure : GXHttpHandler
1315
{
@@ -35,7 +37,12 @@ public override void webExecute() { }
3537
public override void initialize() { }
3638
protected override void createObjects() { }
3739
public override void skipLines(long nToSkip) { }
38-
40+
protected void SubmitImpl()
41+
{
42+
context.SetSubmitInitialConfig(context);
43+
initialize();
44+
Submit(ExecutePrivateCatch, this);
45+
}
3946
public override void cleanup()
4047
{
4148
if (!context.WillRedirect() && context.IsLocalStorageSupported())
@@ -220,14 +227,5 @@ protected void GxDrawDynamicBitMap(int printBlock, int controlId, string value,
220227
reportMetadata.GxDrawBitMap(printBlock, controlId, line, value, aspectRatio);
221228
}
222229

223-
protected static WaitCallback PropagateCulture(WaitCallback action)
224-
{
225-
return GXProcedure.PropagateCulture(action);
226-
}
227-
protected void Submit(Action<object> executeMethod, object state)
228-
{
229-
ThreadUtil.Submit(PropagateCulture(new WaitCallback(executeMethod)), state);
230-
}
231-
232230
}
233231
}

dotnet/src/dotnetframework/GxClasses/Model/gxproc.cs

Lines changed: 11 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ namespace GeneXus.Procedure
2020

2121
public abstract class GXProcedure: GXBaseObject
2222
{
23-
static readonly ILog log = log4net.LogManager.GetLogger(typeof(GeneXus.Procedure.GXProcedure));
2423
public abstract void initialize();
2524

2625
protected int handle;
@@ -59,12 +58,12 @@ public GXProcedure()
5958
#endif
6059
}
6160

62-
/*protected static int MainImpl(string[] args, GXProcedure instance)
61+
protected int MainImpl(string[] args)
6362
{
6463
try
6564
{
6665
Config.ParseArgs(ref args);
67-
return instance.ExecuteCmdLine(args);
66+
return ExecuteCmdLine(args);
6867
}
6968
catch (Exception e)
7069
{
@@ -75,47 +74,31 @@ public GXProcedure()
7574
}
7675
protected virtual int ExecuteCmdLine(string[] args)
7776
{
77+
initialize();
78+
ExecutePrivate();
7879
return GX.GXRuntime.ExitCode;
79-
}*/
80+
}
8081
protected void SubmitImpl()
8182
{
8283
context.SetSubmitInitialConfig(context);
8384
initialize();
8485
Submit(ExecutePrivateCatch, this);
8586
}
86-
protected virtual void ExecutePrivateCatch(object stateInfo)
87+
88+
public override void cleanup()
8789
{
88-
try
90+
CloseCursors();
91+
if (IsMain)
8992
{
90-
((GXProcedure)stateInfo).ExecutePrivate();
91-
}
92-
catch (Exception e)
93-
{
94-
GXUtil.SaveToEventLog("Design", e);
95-
Console.WriteLine(e.ToString());
93+
context.CloseConnections();
9694
}
95+
ExitApp();
9796
}
9897
public bool DisconnectAtCleanup
9998
{
10099
get{ return disconnectUserAtCleanup;}
101100
set{ disconnectUserAtCleanup=value;}
102101
}
103-
protected void Submit(Action<object> executeMethod, object state)
104-
{
105-
ThreadUtil.Submit(PropagateCulture(new WaitCallback(executeMethod)), state);
106-
}
107-
public static WaitCallback PropagateCulture(WaitCallback action)
108-
{
109-
var currentCulture = Thread.CurrentThread.CurrentCulture;
110-
GXLogging.Debug(log, "Submit PropagateCulture " + currentCulture);
111-
var currentUiCulture = Thread.CurrentThread.CurrentUICulture;
112-
return (x) =>
113-
{
114-
Thread.CurrentThread.CurrentCulture = currentCulture;
115-
Thread.CurrentThread.CurrentUICulture = currentUiCulture;
116-
action(x);
117-
};
118-
}
119102
protected void ExitApp()
120103
{
121104
exitApplication(BatchCursorHolder());

dotnet/src/dotnetframework/GxClasses/Reorg/GXReorg.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ public GXReorganization()
5454
GxContext.isReorganization = true;
5555
GXLogging.Debug(log, "GXReorganization.Ctr()");
5656
}
57+
protected virtual void ExecutePrivate()
58+
{
59+
60+
}
5761
public IGxContext context
5862
{
5963
get { return _Context; }
@@ -387,9 +391,14 @@ public static bool IsBadImageFormatException(Exception ex)
387391
return false;
388392
#endif
389393
}
394+
protected virtual void CloseCursors()
395+
{
396+
397+
}
398+
390399
}
391400

392-
public delegate void BlockEndCallback(string blockName, int errorCode);
401+
public delegate void BlockEndCallback(string blockName, int errorCode);
393402

394403
public class ReorgExecute
395404
{

dotnet/src/extensions/mocking/test/TestMockDBAccess/aprocmain.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ public void execute(short aP0_clientid,
6565
this.AV9Number = aP1_Number;
6666
this.AV10Message = "";
6767
initialize();
68-
ExecuteImpl();
68+
ExecuteEx();
6969
aP1_Number = this.AV9Number;
7070
aP2_Message = this.AV10Message;
7171
}

0 commit comments

Comments
 (0)