Skip to content
Merged
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
31 changes: 31 additions & 0 deletions dotnet/src/dotnetcore/GxClasses.Web/Middleware/GXRestServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,38 @@ internal void Initialize()
context.HttpContext.NewSessionCheck();
ServiceHeaders();
}
//Renamed to LoadSdt
protected T ToInternalModel<T>(GxGenericCollectionItem<T> restSDT) where T : GxUserType, new()
{
return LoadSdt<T>(restSDT);
}
protected T LoadSdt<T>(GxGenericCollectionItem<T> restSDT) where T : GxUserType, new()
{
if (restSDT != null)
{
restSDT.Sdt.context = context;
return restSDT.InternalSdt;
}
else
{
T internalSDT = new T();
internalSDT.context = context;
return internalSDT;
}
}

protected void LoadCollection<X, T>(GxGenericCollection<X> restModel, GXBaseCollection<T> internalModel) where T : GxUserType, new()
where X : new()
{
if (restModel != null)
{
restModel.LoadCollection(internalModel);
foreach (GxUserType item in internalModel)
{
item.context = context;
}
}
}
protected void Cleanup()
{
if (runAsMain)
Expand Down
19 changes: 19 additions & 0 deletions dotnet/src/dotnetcore/GxNetCoreStartup/Startup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
using Microsoft.AspNetCore.Http.Features;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Routing;
using Microsoft.AspNetCore.Rewrite;
using Microsoft.AspNetCore.Routing;
Expand Down Expand Up @@ -124,11 +125,29 @@ public static IApplicationBuilder MapWebSocketManager(this IApplicationBuilder a
}
public class CustomBadRequestObjectResult : ObjectResult
{
static readonly IGXLogger log = GXLoggerFactory.GetLogger(typeof(CustomBadRequestObjectResult).FullName);
public CustomBadRequestObjectResult(ActionContext context)
: base(HttpHelper.GetJsonError(StatusCodes.Status400BadRequest.ToString(), HttpHelper.StatusCodeToTitle(HttpStatusCode.BadRequest)))
{
LogErrorResponse(context);
StatusCode = StatusCodes.Status400BadRequest;
}
static void LogErrorResponse(ActionContext context)
{
if (log.IsErrorEnabled)
{
foreach (KeyValuePair<string, ModelStateEntry> entry in context.ModelState)
{
if (entry.Value.Errors.Count > 0)
{
foreach (ModelError error in entry.Value.Errors)
{
GXLogging.Error(log, "Field ", entry.Key, "Errors:", error.ErrorMessage);
}
}
}
}
}
}

public class Startup
Expand Down
20 changes: 20 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/Core/GXUtilsCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2850,6 +2850,15 @@ internal static DateTime CToDT2(string jsonDate, IGxContext context) {
return CToD2(jsonDate);
}
}
public static GxSimpleCollection<DateTime> CToT2(GxSimpleCollection<string> stCollection, IGxContext context)
{
GxSimpleCollection<DateTime> dtCollection = new GxSimpleCollection<DateTime>();
foreach (string st in stCollection)
{
dtCollection.Add(CToT2(st, context));
}
return dtCollection;
}
public static DateTime CToH2(string value)
{
if (isNullJsonDate(value))
Expand Down Expand Up @@ -2916,10 +2925,21 @@ public static string TToC2(DateTime dt, IGxContext context)
{
return TToC2(dt, true, context);
}
public static GxSimpleCollection<string> TToC2(GxSimpleCollection<DateTime> dtCollection, IGxContext context)
{
GxSimpleCollection<string> stCollection = new GxSimpleCollection<string>();
foreach(DateTime dt in dtCollection)
{
stCollection.Add(TToC2(dt, true, context));
}
return stCollection;
}

public static string HToC2(DateTime dt)
{
return TToC2(dt, false);
}

//[Obsolete("TToC2 is deprecated, use TToC2(DateTime, bool, IGxContext) instead", false)]
public static string TToC2(DateTime dt, bool toUTC)
{
Expand Down
41 changes: 36 additions & 5 deletions dotnet/src/dotnetframework/GxClasses/Domain/GxCollections.cs
Original file line number Diff line number Diff line change
Expand Up @@ -787,20 +787,51 @@ public virtual void FromJSONObject(dynamic obj)
public GxSimpleCollection<string> ToStringCollection(int digits, int decimals)
{
GxSimpleCollection<string> result = new GxSimpleCollection<string>();
foreach (T item in this)
if (typeof(T) == typeof(string))
{
decimal value = (decimal)Convert.ChangeType(item, typeof(decimal));
result.Add(StringUtil.LTrim(StringUtil.Str(value, digits, decimals)));
foreach (T item in this)
{
result.Add(item as string);
}
}
else
{
foreach (T item in this)
{
decimal value = (decimal)Convert.ChangeType(item, typeof(decimal));
result.Add(StringUtil.LTrim(StringUtil.Str(value, digits, decimals)));
}
}
return result;
}
public void FromStringCollection(GxSimpleCollection<string> value)
{
foreach (string item in value)
if (typeof(T) == typeof(DateTime))
{
foreach (string item in value)
{
Add(DateTimeUtil.CToT2(item));
}
}
else if(typeof(T) == typeof(string))
{
Add(Convert.ChangeType(NumberUtil.Val(item.ToString()), typeof(T)));
foreach (string item in value)
{
Add(item);
}
}else {
foreach (string item in value)
{
Add(Convert.ChangeType(NumberUtil.Val(item.ToString()), typeof(T)));
}
}
}
//To delete
public void FromStringCollection(GxSimpleCollection<string> value, IGxContext context)
{
FromStringCollection(value);
}


}
#if !NETCORE
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,6 @@ public GXBaseCollection(GXBaseCollection<T> value)
Add(item);
}
}

protected CollectionBase jsonArr
{
get
Expand Down
9 changes: 9 additions & 0 deletions dotnet/src/dotnetframework/GxClasses/Model/GXSilentTrn.cs
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,15 @@ public GxUserType Sdt
get { return sdt1; }
set { sdt1 = (T)value; }
}
#if NETCORE
[JsonIgnore]
public T InternalSdt
{
get { return sdt1; }
set { sdt1 = value; }
}
#endif

#if NETCORE
[JsonIgnore]
#endif
Expand Down
Loading