Skip to content

Commit 871d2aa

Browse files
Prepare for json serializer replacement. (#208)
* Prepare for json serializer replacement. * Avoid _jsonArr clear exception * Fix GetControlProps Co-authored-by: claudia <cmurialdo@gmail.com>
1 parent 186283e commit 871d2aa

File tree

20 files changed

+301
-138
lines changed

20 files changed

+301
-138
lines changed

dotnet/src/dotnetcore/GxClasses/Helpers/GXGeographyCore.cs

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,12 @@
11
using System;
2+
using System.Collections;
23
using System.Globalization;
34
using System.Runtime.Serialization;
4-
using System.Collections;
55
using Jayrock.Json;
6+
using GeographicLib;
67
using log4net;
7-
using System.Reflection;
8-
using GeneXus.Metadata;
9-
using NetTopologySuite.IO;
108
using NetTopologySuite.Geometries;
11-
using GxClasses.Helpers;
12-
using GeographicLib;
9+
using NetTopologySuite.IO;
1310

1411
namespace GeneXus.Utils
1512
{

dotnet/src/dotnetcore/GxClasses/Services/CoreWebAPI/Controller/GXBCRestService.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
using GeneXus.Utils;
2-
using Jayrock.Json;
2+
33
using Microsoft.AspNetCore.Http;
44
using System;
55
using System.IO;

dotnet/src/dotnetframework/GxClasses/Core/Web/HttpAjaxContext.cs

Lines changed: 43 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -190,11 +190,12 @@ public void ajax_rspStartCmp(String CmpId)
190190
{
191191
WebComponents.Put(CmpId, "");
192192
}
193-
catch (JsonException)
193+
catch (Exception ex)
194194
{
195+
GXLogging.Error(log, "ajax_rspStartCmp error", ex);
195196
}
196197
}
197-
context.CmpDrawLvl++;
198+
context.CmpDrawLvl++;
198199
cmpContents.Push(new GXCmpContent(CmpId));
199200
}
200201

@@ -211,12 +212,13 @@ public void ajax_rspEndCmp()
211212
((GXCmpContent)cmpContents.Peek()).Content += cmp.Content;
212213
}
213214
}
214-
catch (JsonException)
215+
catch (Exception ex)
215216
{
217+
GXLogging.Error(log, "ajax_rspEndCmp error", ex);
216218
}
217219
}
218220

219-
private JObject GetGxObject(JArray array, String CmpContext, bool IsMasterPage)
221+
private JObject GetGxObject(JArray array, String CmpContext, bool IsMasterPage)
220222
{
221223
try
222224
{
@@ -235,10 +237,12 @@ private JObject GetGxObject(JArray array, String CmpContext, bool IsMasterPage)
235237
array.Add(obj);
236238
return obj;
237239
}
238-
catch (JsonException)
239-
{
240-
}
241-
return null;
240+
catch (Exception ex)
241+
{
242+
GXLogging.Error(log, "GetGxObject error", ex);
243+
}
244+
245+
return null;
242246
}
243247

244248
public void ajax_rsp_assign_attri(String CmpContext, bool IsMasterPage, String AttName, Object AttValue)
@@ -255,8 +259,9 @@ public void ajax_rsp_assign_attri(String CmpContext, bool IsMasterPage, String A
255259
obj.Put(AttName, AttValue);
256260
}
257261
}
258-
catch (JsonException)
262+
catch (Exception ex)
259263
{
264+
GXLogging.Error(log, "ajax_rsp_assign_attri error", ex);
260265
}
261266
}
262267
}
@@ -288,8 +293,9 @@ public void ajax_rsp_assign_sdt_attri(String CmpContext, bool IsMasterPage, Stri
288293
}
289294
}
290295
}
291-
catch (JsonException)
296+
catch (Exception ex)
292297
{
298+
GXLogging.Error(log, "ajax_rsp_assign_sdt_attri error", ex);
293299
}
294300
}
295301
}
@@ -326,8 +332,9 @@ private void ajax_rsp_assign_hidden(String AttName, object AttValue)
326332
#endif
327333
HiddenValues.Put(AttName, AttValue);
328334
}
329-
catch (JsonException)
335+
catch (Exception ex)
330336
{
337+
GXLogging.Error(log, "ajax_rsp_assign_hidden error", ex);
331338
}
332339
}
333340
public void ajax_rsp_assign_hidden_sdt(String SdtName, Object SdtObj)
@@ -349,8 +356,9 @@ public void ajax_rsp_assign_hidden_sdt(String SdtName, Object SdtObj)
349356
}
350357
}
351358
}
352-
catch (JsonException)
359+
catch (Exception ex)
353360
{
361+
GXLogging.Error(log, "ajax_rsp_assign_hidden_sdt error", ex);
354362
}
355363

356364
}
@@ -372,8 +380,9 @@ private JObject GetControlProps(JObject obj, String Control)
372380
obj.Put(Control, ctrlProps);
373381
}
374382
}
375-
catch (JsonException)
383+
catch (Exception ex)
376384
{
385+
GXLogging.Error(log, "GetControlProps error", ex);
377386
}
378387
return ctrlProps;
379388
}
@@ -420,8 +429,9 @@ public void ajax_rsp_assign_prop(String CmpContext, bool IsMasterPage, String Co
420429
ajax_rsp_assign_hidden(Control + "_" + Property.Substring(0, 1) + Property.Substring(1).ToLower(), Value);
421430
}
422431
}
423-
catch (JsonException)
432+
catch (Exception ex)
424433
{
434+
GXLogging.Error(log, "ajax_rsp_assign_prop error", ex);
425435
}
426436
}
427437
}
@@ -443,10 +453,11 @@ public void ajax_rsp_assign_grid(String GridName, Object GridObj)
443453
{
444454
Grids.Add(((IGxJSONAble)GridObj).GetJSONObject());
445455
}
446-
catch (JsonException)
447-
{
448-
}
449-
}
456+
catch (Exception ex)
457+
{
458+
GXLogging.Error(log, "ajax_rsp_assign_grid error", ex);
459+
}
460+
}
450461

451462
private bool ShouldLogAjaxControlProperty(string Property)
452463
{
@@ -474,9 +485,10 @@ public void PrintReportAtClient(string reportFile, string printerRule)
474485
obj.Put("reportFile", reportFile);
475486
obj.Put("printerRule", printerRule);
476487
}
477-
catch (JsonException)
478-
{
479-
}
488+
catch (Exception ex)
489+
{
490+
GXLogging.Error(log, "PrintReportAtClient error", ex);
491+
}
480492
commands.AppendCommand(new GXAjaxCommand("print", obj));
481493
}
482494

@@ -520,10 +532,11 @@ public string getJSONContainerResponse(IGxJSONAble Container)
520532
jsonCmdWrapper.Put("gxContainer", Container.GetJSONObject());
521533

522534
}
523-
catch (JsonException)
524-
{
525-
}
526-
return jsonCmdWrapper.ToString();
535+
catch (Exception ex)
536+
{
537+
GXLogging.Error(log, "getJSONContainerResponse error", ex);
538+
}
539+
return jsonCmdWrapper.ToString();
527540
}
528541

529542
internal string getJSONResponse(string cmpContext)
@@ -554,10 +567,11 @@ internal string getJSONResponse(string cmpContext)
554567
jsonCmdWrapper.Put("gxCommands", commands.JSONArray);
555568
}
556569
}
557-
catch (JsonException)
570+
catch (Exception ex)
558571
{
572+
GXLogging.Error(log, "getJSONResponse error", ex);
559573
}
560-
return jsonCmdWrapper.ToString();
574+
return jsonCmdWrapper.ToString();
561575
}
562576

563577
public static JArray GetParmsJArray(Object[] parms)
@@ -668,12 +682,7 @@ private JObject GetGXStateTokens(string state)
668682
{
669683
state = Encoding.UTF8.GetString(Convert.FromBase64String(state));
670684
}
671-
JsonReader reader = new JsonTextReader(new StringReader(state));
672-
JsonToken token = reader.ReadToken();
673-
if (token == JsonToken.Object)
674-
{
675-
return (JObject)reader.DeserializeNext();
676-
}
685+
return JSONHelper.ReadJSON<JObject>(state);
677686
}
678687
}
679688
catch (Exception e)
@@ -859,7 +868,7 @@ public object GetJSONObject(bool includeState)
859868
return GetJSONObject();
860869
}
861870

862-
public void FromJSONObject(IJsonFormattable obj)
871+
public void FromJSONObject(dynamic obj)
863872
{
864873
throw new Exception("The method or operation is not implemented.");
865874
}

dotnet/src/dotnetframework/GxClasses/Domain/GXGeolocation.cs

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -163,9 +163,7 @@ public static List<string> GetAddress(String location)
163163
{
164164
if (!string.IsNullOrEmpty(response))
165165
{
166-
StringReader sr = new StringReader(response);
167-
JsonTextReader tr = new JsonTextReader(sr);
168-
JObject json = (JObject)(tr.DeserializeNext());
166+
JObject json = JSONHelper.ReadJSON<JObject>(response);
169167
if (json.Contains("results"))
170168
{
171169
JArray results = (JArray)json["results"];
@@ -180,7 +178,7 @@ public static List<string> GetAddress(String location)
180178
}
181179
}
182180
}
183-
catch (JsonException ex)
181+
catch (Exception ex)
184182
{
185183
GXLogging.Error(log, "getAddress error json:" + response, ex);
186184
}
@@ -217,9 +215,7 @@ public static List<Geospatial> GetLocationGeography(String address)
217215
{
218216
if (!string.IsNullOrEmpty(response))
219217
{
220-
StringReader sr = new StringReader(response);
221-
JsonTextReader tr = new JsonTextReader(sr);
222-
JObject json = (JObject)(tr.DeserializeNext());
218+
JObject json = JSONHelper.ReadJSON<JObject>(response);
223219
if (json.Contains("results"))
224220
{
225221
JArray results = (JArray)json["results"];
@@ -243,7 +239,7 @@ public static List<Geospatial> GetLocationGeography(String address)
243239
}
244240
}
245241
}
246-
catch (JsonException ex)
242+
catch (Exception ex)
247243
{
248244
GXLogging.Error(log, "getLocation error json:" + response, ex);
249245
}

dotnet/src/dotnetframework/GxClasses/Domain/GXWindow.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public object GetJSONObject(bool includeState)
9595
return GetJSONObject();
9696
}
9797

98-
public void FromJSONObject(IJsonFormattable obj)
98+
public void FromJSONObject(dynamic obj)
9999
{
100100
}
101101

0 commit comments

Comments
 (0)