Skip to content
21 changes: 20 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Core/GXApplication.cs
Original file line number Diff line number Diff line change
Expand Up @@ -358,9 +358,11 @@ internal class GxApplication
internal static GxContext MainContext { get; set; }
}
[Serializable]
public class GxContext : IGxContext
public class GxContext : IGxContext, IDisposable
{
private static IGXLogger log = null;
[NonSerialized]
private bool _disposed;
internal static string GX_SPA_REQUEST_HEADER = "X-SPA-REQUEST";
internal static string GX_SPA_REDIRECT_URL = "X-SPA-REDIRECT-URL";
internal const string GXLanguage = "GXLanguage";
Expand Down Expand Up @@ -3441,8 +3443,25 @@ public bool ExecuteAfterConnect(String datastoreName)
}
~GxContext()
{
if (_disposed) return;
GxUserInfo.RemoveHandle(_handle);
GXFileWatcher.Instance.DeleteTemporaryFiles(_handle);
}

public void Dispose()
{
if (_disposed) return;
_disposed = true;

if (_httpAjaxContext != null)
{
try { _httpAjaxContext.Cleanup(); } catch { }
_httpAjaxContext = null;
}

GxUserInfo.RemoveHandle(_handle);
GXFileWatcher.Instance.DeleteTemporaryFiles(_handle);
GC.SuppressFinalize(this);
}
public void SetProperty(string key, string value)
{
Expand Down
18 changes: 17 additions & 1 deletion dotnet/src/dotnetframework/GxClasses/Core/Web/HttpAjaxContext.cs
Original file line number Diff line number Diff line change
Expand Up @@ -465,8 +465,24 @@ public void ajax_rsp_assign_prefixed_prop(String Control, String Property, Strin
}

public void ajax_rsp_clear()
{
{
_PropValues = new JArray();
}

public void Cleanup()
{
_AttValues = new JArray();
_HiddenValues = new JObject();
_PropValues = new JArray();
_WebComponents = new JObject();
_LoadCommands = new Hashtable();
_Messages = new JObject();
_Grids = new JArray();
DicGrids = new Dictionary<String, int>();
_ComponentObjects = new JObject();
_StylesheetsToLoad = new JArray();
commands = new GXAjaxCommandCollection();
cmpContents = new Stack();
}

public void ajax_rsp_assign_prop(String CmpContext, bool IsMasterPage, String Control, String Property, String Value, bool SendAjax = true)
Expand Down
37 changes: 18 additions & 19 deletions dotnet/src/dotnetframework/GxClasses/Data/GXDataADO.cs
Original file line number Diff line number Diff line change
Expand Up @@ -707,20 +707,20 @@ public short FullConnect()

public void Close()
{
if (connection!=null)
if (connection!=null)
{
GXLogging.Debug(log, "GxConnection.Close Id " + " connection State '" + connection.State + "'" + " handle:" + handle + " datastore:" + DataStore.Id);
}
if (connection!=null && ((connection.State & ConnectionState.Closed) == 0 ))
try
{
if (connectionCache != null) connectionCache.Clear();
}
catch (Exception e)
{
GXLogging.Warn(log, "GxConnection.Close can't close all prepared cursors", e);
}
if (connection!=null && ((connection.State & ConnectionState.Closed) == 0 ))
{
try
{
connectionCache.Clear();
}
catch(Exception e){
GXLogging.Warn(log, "GxConnection.Close can't close all prepared cursors" ,e);
}

GXLogging.Debug(log, "UncommitedChanges before Close:" + UncommitedChanges );
try
{
Expand Down Expand Up @@ -764,17 +764,16 @@ internal async Task CloseAsync()
{
GXLogging.Debug(log, "GxConnection.Close Id " + " connection State '" + connection.State + "'" + " handle:" + handle + " datastore:" + DataStore.Id);
}
try
{
if (connectionCache != null) connectionCache.Clear();
}
catch (Exception e)
{
GXLogging.Warn(log, "GxConnection.Close can't close all prepared cursors", e);
}
if (connection != null && ((connection.State & ConnectionState.Closed) == 0))
{
try
{
connectionCache.Clear();
}
catch (Exception e)
{
GXLogging.Warn(log, "GxConnection.Close can't close all prepared cursors", e);
}

GXLogging.Debug(log, "UncommitedChanges before Close:" + UncommitedChanges);
try
{
Expand Down
10 changes: 7 additions & 3 deletions dotnet/src/dotnetframework/GxClasses/Data/GXDataCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,10 @@ public virtual IDbCommand GetCommand(IGxConnection con, string stmt, GxParameter
}
else
{

foreach (object oldParam in cmd.Parameters)
{
if (oldParam is IDisposable disposable) disposable.Dispose();
}
cmd.Parameters.Clear();

AddParameters(cmd, parameters);
Expand Down Expand Up @@ -2503,16 +2506,17 @@ public DataTable GetSchemaTable()
{
throw (new GxNotImplementedException());
}
public bool IsClosed
public bool IsClosed
{
get{return !open;}
}
public int Depth
public int Depth
{
get {return 0;}
}
public void Dispose()
{
try { Close(); } catch (Exception ex) { GXLogging.Warn(log, "GxDataReader.Dispose error", ex); }
}
public string GetName(int i)
{
Expand Down
Loading
Loading