Skip to content

Commit

Permalink
https://github.com/danieleteti/delphimvcframework/issues/630
Browse files Browse the repository at this point in the history
  • Loading branch information
danieleteti committed Jan 28, 2023
1 parent 89f00fd commit c033150
Show file tree
Hide file tree
Showing 1,670 changed files with 42,336 additions and 9,464 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -121,3 +121,4 @@ samples/serversideviews_lua/bin/templates/__compiled/
samples/serversideviews_lua/lua4delphi/unittests/Win32/
/unittests/general/Several/bin/EchoSingleComplexRecord_RESPONSE.json
/unittests/general/Several/bin/TestRequest_Echo_ComplexRecords_RESPONSE.json
unittests/general/Several/pgsql/testdatadir/
14 changes: 13 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,14 @@ The current beta release is named 3.2.3-radium-beta. If you want to stay on the-

- Added `MVCFramework.Commons.MVC_HTTP_STATUS_CODES` const array containing all the HTTP status codes with its `ReasonString`

- New global configuration variable `MVCSerializeNulls`.
When MVCSerializeNulls = True (default) empty nullables and nil are serialized as json null.
When MVCSerializeNulls = False empty nullables and nil are not serialized at all.

- Nullable types now have `Equal` support and a better "equality check" strategy.

- Unit tests now are always executed for Win32 and Win64 bit (both client and server).

- New built-in profiler (usable with Delphi 10.4+) - to profile a block of code, write the following

```delphi
Expand Down Expand Up @@ -1475,7 +1483,11 @@ The current beta release is named 3.2.3-radium-beta. If you want to stay on the-
[<<][ 1][MainControllerU.TMyController.ProfilerSample1][ELAPSED: 00:00:00.3277806] [profiler]
```

To get more info check the "profiling" example
To get more info check the "profiling" example.

All profiler logs are generated with a log level `info`. If measured time is greater than `WarningThreshold` the log level is `warning`.

`WarningThreshold` is expressed in milliseconds and by default is equals to 1000.

- New `Context` property named `ActionQualifiedName` which contains the currently executed action in the form `UnitName.ClassName.ActionName`. It is available where the `Context` property is available. Obviously is not available in the `OnBeforeRouting` middleware events.
- Added ObjectPool and IntfObjectPool (and related unit tests). Thanks to our sponsor [Vivaticket S.p.A.](https://corporate.vivaticket.com)
Expand Down
4 changes: 4 additions & 0 deletions ideexpert/DMVC.Expert.CodeGen.Templates.pas
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,10 @@ interface
'begin' + sLineBreak +
' ReportMemoryLeaksOnShutdown := True;' + sLineBreak +
' IsMultiThread := True;' + sLineBreak +
' // DMVCFramework Specific Configuration ' + sLineBreak +
' // When MVCSerializeNulls = True empty nullables and nil are serialized as json null.' + sLineBreak +
' // When MVCSerializeNulls = False empty nullables and nil are not serialized at all.' + sLineBreak +
' MVCSerializeNulls := True;' + sLineBreak +
' try' + sLineBreak +
' if WebRequestHandler <> nil then' + sLineBreak +
' WebRequestHandler.WebModuleClass := WebModuleClass;' + sLineBreak +
Expand Down
14 changes: 12 additions & 2 deletions samples/async_task/MainFormU.dfm
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ object MainForm: TMainForm
Top = 0
Caption = 'MVCAsync Sample'
ClientHeight = 181
ClientWidth = 503
ClientWidth = 693
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Expand All @@ -29,12 +29,22 @@ object MainForm: TMainForm
Text = 'Edit1'
end
object btnWithEx: TButton
Left = 224
Left = 448
Top = 16
Width = 161
Height = 41
Caption = 'Async Test With Exception'
TabOrder = 2
OnClick = btnWithExClick
end
object btnWithExcDefault: TButton
Left = 272
Top = 16
Width = 161
Height = 41
Caption = 'Async Test With Exception (default)'
TabOrder = 3
WordWrap = True
OnClick = btnWithExcDefaultClick
end
end
38 changes: 38 additions & 0 deletions samples/async_task/MainFormU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,10 @@ TMainForm = class(TForm)
btnAsync1: TButton;
Edit1: TEdit;
btnWithEx: TButton;
btnWithExcDefault: TButton;
procedure btnAsync1Click(Sender: TObject);
procedure btnWithExClick(Sender: TObject);
procedure btnWithExcDefaultClick(Sender: TObject);
private
{ Private declarations }
public
Expand Down Expand Up @@ -68,4 +70,40 @@ procedure TMainForm.btnWithExClick(Sender: TObject);
);
end;

procedure TMainForm.btnWithExcDefaultClick(Sender: TObject);
begin
var lSavedCaption := btnWithExcDefault.Caption;
btnWithExcDefault.Caption := 'processing...';
btnWithExcDefault.Enabled := False;
MVCAsync.Run<String>(
function: String
begin
Sleep(1000);
raise Exception.Create('BOOOM!');
end,
procedure(const Value: String)
begin
//never called
end
);


//just to re-enable the button
MVCAsync.Run<Boolean>(
function: Boolean
begin
Sleep(3000);
Result := True;
end,
procedure(const Value: Boolean)
begin
btnWithExcDefault.Caption := lSavedCaption;
btnWithExcDefault.Enabled := True;
btnWithExcDefault.Update;
end
);


end;

end.
23 changes: 12 additions & 11 deletions samples/commons/BusinessObjectsU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -698,17 +698,18 @@ function TNullablesTest.Equals(Obj: TObject): boolean;
begin
lOtherObj := Obj as TNullablesTest;
Result := true;
Result := Result and Self.ff_int2.Equals(lOtherObj.ff_int2);
Result := Result and Self.ff_int4.Equals(lOtherObj.ff_int4);
Result := Result and Self.ff_int8.Equals(lOtherObj.ff_int8);
Result := Result and Self.ff_bool.Equals(lOtherObj.ff_bool);
Result := Result and (DateToISODate(Self.ff_date) = DateToISODate(lOtherObj.ff_date));
Result := Result and (TimeToISOTime(Self.ff_time) = TimeToISOTime(lOtherObj.ff_time));
Result := Result and (DateTimeToISOTimeStamp(Self.ff_datetime) = DateTimeToISOTimeStamp(lOtherObj.ff_datetime));
Result := Result and Self.ff_float4.Equals(lOtherObj.ff_float4);
Result := Result and Self.ff_float8.Equals(lOtherObj.ff_float8);
Result := Result and Self.ff_string.Equals(lOtherObj.ff_string);
Result := Result and Self.ff_currency.Equals(lOtherObj.ff_currency);
Result := Result and (Self.ff_int2 = lOtherObj.ff_int2);
Result := Result and (Self.ff_int4 = lOtherObj.ff_int4);
Result := Result and (Self.ff_int8 = lOtherObj.ff_int8);
Result := Result and (Self.ff_bool = lOtherObj.ff_bool);
Result := Result and (Self.ff_date = lOtherObj.ff_date);
Result := Result and (Self.ff_time = lOtherObj.ff_time);
Result := Result and (Self.ff_datetime = lOtherObj.ff_datetime);
Result := Result and (Self.ff_float4 = lOtherObj.ff_float4);
Result := Result and (Self.ff_float8 = lOtherObj.ff_float8);
Result := Result and (Self.ff_string = lOtherObj.ff_string);
Result := Result and (Self.ff_currency = lOtherObj.ff_currency);

{ TODO -oDanieleT -cGeneral : Deserialize a stream over a nil pointer... should we create the TMemoryStream? }
// Result := Result and ((Self.ff_blob as TStringStream).DataString = (lOtherObj.ff_blob as TStringStream).DataString);
end;
Expand Down
3 changes: 2 additions & 1 deletion samples/renders/renders.dpr
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
//
// Delphi MVC Framework
//
// Copyright (c) 2010-2022 Daniele Teti and the DMVCFramework Team
// Copyright (c) 2010-2023 Daniele Teti and the DMVCFramework Team
//
// https://github.com/danieleteti/delphimvcframework
//
Expand Down Expand Up @@ -73,6 +73,7 @@ end;

begin
ReportMemoryLeaksOnShutdown := True;
MVCSerializeNulls := True;
try
if WebRequestHandler <> nil then
WebRequestHandler.WebModuleClass := WebModuleClass;
Expand Down
2 changes: 1 addition & 1 deletion samples/winecellarclient_mobile/MainFormU.pas
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ THeaderFooterForm = class(TForm)
URL = 'http://localhost:3000/api';
{$ENDIF}
{$IF Defined(ANDROID)}
URL = 'http://192.168.1.46:3000/api';
URL = 'http://192.168.1.153:3000/api';
{$ENDIF}

var
Expand Down
Loading

0 comments on commit c033150

Please sign in to comment.