#1 Re: mORMot Framework » Stop the war! » 2022-02-27 15:47:15

I'm so sorry Pavlov. I'm from Argentina and our government is a shame, they are pro russian because they are corrupts like any populist government and need money from China and Russia and they only make a weak opposition to Putin's genocidal attack. Many people from my country are with your. I just wait that the world rest can help to Ukraine.

#2 Re: mORMot Framework » Firebird transactions » 2021-04-19 11:27:34

Check if you is doing commit retaining instead of hard commit.

#3 Re: mORMot Framework » _Jsonfast » 2020-12-17 13:42:22

Double escape "\", example:

{"ToAddress":"someaddress.gmail.com", "Attachment":"c:\\photos\\photo1.bmp"}

#4 Re: mORMot Framework » Renaming TSQLRecord to TORM » 2020-10-30 12:10:13

I agree with prefixing the framework with TSyn*, historically Delphi third party frameworks have used this. Even more, functions and procedure they should have a prefix, but thats is more complex for compatibility. It's just another opinion.

#5 Re: mORMot Framework » Renaming TSQLRecord to TORM » 2020-10-26 18:52:27

The new name is perfect for me. Have much make sense.

#6 Re: mORMot Framework » Duplicate entry error compiling with Laz/FPC » 2020-07-01 15:40:59

ok, @ab patched the @mpv pull request, the @ab speed is as warp 9 in Star Trek (and @mpv too).

#8 Re: mORMot Framework » Duplicate entry error compiling with Laz/FPC » 2020-07-01 12:47:54

Thanks @mpv, unfortunately our target development is Windows and I want migrate from Delphi 4 to FPC/Lazarus but with this limitation cannot will be possible.

#9 mORMot Framework » Duplicate entry error compiling with Laz/FPC » 2020-06-29 14:59:37

EMartin
Replies: 5

Hi @ab, I tried compile LogView.lpi with Laz 2.0.8/FPC 3.2.0 and have error in SynMemoEx.pas:

const
  RAEditorCompletionChars: set of AnsiChar =
    [#8, '_', '0'..'9', 'A'..'Z', 'a'..'z'];
  Separators: set of AnsiChar =
    [#0, ' ', '-', #13, #10, '.', ',', '/', '\', ':', '+', '%', '*', '(', ')',
    ';', '=', '{', '}', '[', ']', '{', '}', '|', '!', '@', '"']; 

the '{', '}' is duplicated.

UPDATE

  • SynMemoEx.pas(567,40) Error: Identifier not found "TCreateParams" in TCustomMemoEx in Laz 2.0.8 / FPC 3.2.0

  • With Delphi 10.3 no error is raised by the compiler (either duplicated entry and TCreateParams.

I thought that LogView was FPC/Windows compatible, my mistake.

Best regards.

#10 Re: mORMot Framework » Call stack - how to get? » 2020-06-09 13:39:15

I use TSynLog.Add.Log(all StackTrace, ...) and was very helpful.

#11 Re: mORMot Framework » 2tier to 3tier migration. AdoDataset -> RestDataset solution » 2020-05-19 13:27:14

Sure, I mean that the mORMot framework allow custom solutions, although I prefer to use mORMot features, RemObjects (my old version) also uses Indy and OpenSSL but the TWinHTTP is very superior.

#12 Re: mORMot Framework » 2tier to 3tier migration. AdoDataset -> RestDataset solution » 2020-05-19 13:10:37

I had similar needs but migrating from 3tier (with RemObjects) to 3tier (with mORMot). I implemented TSynRestDataset but using full mORMot features -not Indy, not OpenSSL, mORMot validators- (see https://synopse.info/forum/viewtopic.php?id=2712), we make small adaptations in out client applications (5, 10, 15 years) and all works fine. The mORMot framework greatness is infinite.

#14 Re: mORMot Framework » Contribution: TSynRestDataset » 2020-05-17 21:53:46

Yes, is what i am currently using with Delphi 7.

#17 Re: mORMot Framework » The mORMot on Android » 2020-05-03 15:21:53

Thank you @AOG !!! I'll investigate. One question: is needed asphyre for non graphical apps ?

#18 Re: mORMot Framework » The mORMot on Android » 2020-04-28 11:14:54

all tests passed !!! Congratulations AOG !!!

Can you suggest me tutorials for Android development with Lazarus/FPC ? I know that there is someones in the net, but I don't know the more reliable.

Thanks.

#19 mORMot Framework » Possible bug or limited feature in SynMustache » 2020-04-24 12:47:24

EMartin
Replies: 0

Hi @ab, I have a problem rendering mustache template:

Template

{{^context.video.main.parts}}-v error -y -i {{context.video.main.sourcefilename}} {{context.video.main.tempfilename}}.avi{{/context.video.main.parts}}
{{#context.video.main.parts}}
  {{#-first}}-v error -y -i {{context.video.main.sourcefilename}}{{/-first}}
  {{^-last}} -ss {{startoffsetinsecs}} -t {{durationinsecs}} {{tempfilename}}.avi {{/-last}}
  {{#-last}} -ss {{startoffsetinsecs}} {{tempfilename}}.avi{{/-last}}
{{/context.video.main.parts}}

Context (the context is a reduced version but same structure)

{
    "context": {
        "callrefid": "441299259001",
        "audio": {
            "main": {
                "sourcefilename": "\\TECNOVOZ\\ACD\\Vox\\20191217\\11285401.139",
                "parts": [],
                "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\A~44129925900100",
                "destfilename": "\\TecnoVoz\\Streaming\\441299259001"
            },
            "holds": []
        },
        "video": {
            "main": {
                "sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000.avi",
                "parts": [{
                        "startoffsetinsecs": 0,
                        "durationinsecs": 275.333,
                        "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900101"
                    }, {
                        "startoffsetinsecs": 275.666,
                        "durationinsecs": 60.3339999999999,
                        "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900103"
                    }, {
                        "startoffsetinsecs": 1152,
                        "durationinsecs": 0,
                        "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900115"
                    }
                ],
                "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900100",
                "destfilename": "\\TecnoVoz\\Streaming\\441299259001"
            },
            "holds": [{
                    "sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000_01.avi",
                    "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900102"
                }, {
                    "sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000_02.avi",
                    "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900104"
                }, {
                    "sourcefilename": "\\TECNOVOZ\\ACD\\Video\\20191217\\01_0139_20191217_112854_0000000000_06.avi",
                    "tempfilename": "C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900112"
                }
            ]
        }
    }
}

Result

[context] property not found in {"startoffsetinsecs":0,"durationinsecs":275.333,"tempfilename":"C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900101"}

When debugging I see try access to "startoffsetinsecs" starting from path "context.video.main.parts" and "context" not exists in array element {"startoffsetinsecs":0,"durationinsecs":275.333,"tempfilename":"C:\\Users\\EMartin\\AppData\\Local\\Temp\\V~44129925900101"}.

Is this a bug or limited feature ?

Thanks.

#20 Re: mORMot Framework » Revision 2.x of the framework » 2020-03-09 12:09:06

I agree with @macfly, version 2 should be breaking change this way the migration will require the source code update.

on the other hand, ORM data response could be a class that could be replaced by other, for example for return in OData format ?

Thanks.

#21 Re: mORMot Framework » Compatibility problem between AESCBC 256 mORMot and C# » 2020-03-07 17:24:12

You mean that the text key always should be of 32 characteres ?

#22 Re: mORMot Framework » Compatibility problem between AESCBC 256 mORMot and C# » 2020-03-06 20:45:19

Hi @ab, I found the problem the compatibility (or not perhaps is by design):

in:

constructor TAESAbstract.Create(const aKey; aKeySize: cardinal);
begin
   if (aKeySize<>128) and (aKeySize<>192) and (aKeySize<>256) then
    raise ESynCrypto.CreateUTF8('%.Create(aKeySize=%): 128/192/256 required',[self,aKeySize]);
  fKeySize := aKeySize;
  fKeySizeBytes := fKeySize shr 3;
  MoveFast(aKey,fKey,fKeySizeBytes); <<<--- (1)
end;

(1) if the key is, for example, "12345678" the byte array TAESKey should be:

[49, 50, 51, 52, 53, 54, 55, 56, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]

in other words, the rest of array should be completed with zeroes but is filled with other values that are valids. For workaround I added Key as property in TAESAbstract with read/write and after create I refilling with correct data and it works.

Can you tell me if this behavior is by design or bug ?

UPDATE:
I removed Key property from TAESAbstract and implemented TAESAbstrackHack for accessing fKey protected member.
I don't know how patch MoveFast for non-filling with invalid values the rest of byte array. I think that Create constructor should have extra parameter with length of key text.

Thanks.

#23 Re: mORMot Framework » Revision 2.x of the framework » 2020-03-04 16:24:10

Thanks @ab, my intention is move to FPC but out base code is huge and much UI with DevEx and other visual third party components, all these tasks take time and we are very small team. We have not Delphi 2007 license.

#24 Re: mORMot Framework » Revision 2.x of the framework » 2020-03-04 13:28:36

I agree at all, except excluding Delphi 7 because all our projects are developed with it and, unfortunately, with third party components. I initiated conversations with my boss for migrating UI to web and use FPC as tool for backend development, but that's something that takes time. Maybe support for Delphi 7 for a few years (you decide how long) will be fantastic.

Excellent idea of use the semantic versioning.

Units splitting should be for functionality in my opinion, for example SynJSON with all related support for JSON handling.

Maybe this thread shoud be post as "sticky".

#25 Re: mORMot Framework » Compatibility problem between AESCBC 256 mORMot and C# » 2020-01-28 14:45:26

Thanks @ab, I'll try that the provider modify the algorithm, but in case that's not posible, how use TAESCBC to make the encryption as in C# ?.

Thanks again.

#26 Re: mORMot Framework » Compatibility problem between AESCBC 256 mORMot and C# » 2020-01-28 13:29:35

The text <b>pepego</b> with key <b>Aesdns06</b> works ok in https://dotnetfiddle.net/tlO25C and was generated with a C# application.

Any idea why mORMot encryption not working ?

Thanks.

#27 mORMot Framework » Compatibility problem between AESCBC 256 mORMot and C# » 2020-01-27 15:05:12

EMartin
Replies: 7

I need to generate a key using AES CBC 256 PKCS7 encryption for a .Net C# application that use this key for password when connection to database. The key have the form IV.KEY and is stored in a config file. I have the following code to generate the key in that way.

var
  lKey: TBytes;
  lIV: TAESBlock;
  lText, lTextEncrypted, lIVText: RawByteString;
  lAESCBC: TAESCBC;
begin
  ...
      // edtKey.Text is KEY
      // edtSource.Text is TEXT TO ENCRYPT
      SetLength(lKey, Length(edtKey.Text));
      SynCommons.HexToBin(Pointer(edtKey.Text), @lKey, Min(Length(edtKey.Text),SizeOf(lKey)));
      RawByteStringToBytes(RawByteString(edtKey.Text), lKey);
      lAESCBC := TAESCBC.Create(lKey, CRYPT_KEY_SIZES[2]{=256});
      try
        lText := StringToUTF8(edtSource.Text);
        TAESPRNG.Main.FillRandom(lIV);
        lAESCBC.IV := lIV;
        lTextEncrypted := SynCommons.BinToBase64(lAESCBC.EncryptPKCS7(lText));
        lIVText := SynCommons.BinToBase64(@lAESCBC.IV, SizeOf(lAESCBC.IV));
        edtDest.Text := UTF8ToString(lTextEncrypted)+'.'+lIVText;
      finally
        lAESCBC.Free;
      end;
  ...
end;

and the key generated with the above code

KEY=key
TEXT TO ENCRYPT=text to encrypt

oTfXA3+lm6aiOaGYjCsk+Q==.OX0qIq1iSEMhTdw/fl0ehg== (the dot is a separator)

raise an exception <b>Padding is invalid and cannot be removed.</b>

For testing I'm using dotfiddle.net in https://dotnetfiddle.net/tlO25C

What's wrong ?

Thanks.

#28 Re: mORMot Framework » Interfaced method syncronisation » 2019-12-20 14:37:16

sicShared works this way but then another mothods are also blocked.

Using lock/unlock inside the endpoint of interface service does not block other endpoints of the interface service.

#29 Re: mORMot Framework » Interfaced method syncronisation » 2019-12-18 18:31:37

We are using sicShared and when we need serialized access to somene services we use TSynLocker.Lock and TSynLocker.Unlock in a try .. finally.

#31 Re: mORMot Framework » Kingdom Driven Design principles » 2019-10-01 13:28:18

Very interesting !!! @ab is the new Martin Fowler ? big_smile

#33 Re: mORMot Framework » Error compiling in Lazarus/FPC » 2019-07-29 01:04:48

With FPC Fixes3.2 and Lazarus trunk it works.

#34 Re: mORMot Framework » Error compiling in Lazarus/FPC » 2019-07-28 02:36:38

It works with FPC Fixes3.2 and Lazarus Fixes2.0, not works with FPC 3.3.1 and Lazarus 2.1.

"It works" mean that when added the SynCommons unit and run the project no error is raised.

Thanks @hnb.

PD: Is usefull try with FPC Fixes3.2 and Lazarus 2.1.0 ?

#35 Re: mORMot Framework » Error compiling in Lazarus/FPC » 2019-07-26 11:35:12

Ok, I'll use "fixes3.2" option from fpcupdeluxe.

A pity, whenever I try to initiate a migration to FPC some problem of this kind happens. My boss considers that these open source software are unstable, I try to convince him otherwise.

Thanks.

#36 Re: mORMot Framework » Error compiling in Lazarus/FPC » 2019-07-26 11:09:35

Thanks @hnb, that solve this error compilation, but now I have another:

"External: SIGSEGV" in this line:

..
if fElemType<>nil then begin
    {$ifndef HASDIRECTTYPEINFO}
    // FPC compatibility: if you have a GPF here at startup, your 3.1 trunk
    // revision seems older than June 2016
    // -> enable HASDIRECTTYPEINFO conditional below $ifdef VER3_1 in Synopse.inc
    // or in your project's options
    fElemType := PPointer(fElemType)^; // inlined DeRef() <-- THIS LINE
    {$endif HASDIRECTTYPEINFO}
    {$ifdef FPC}
    if not (PTypeKind(fElemType)^ in tkManagedTypes) then
      fElemType := nil; // as with Delphi
    {$endif FPC}
  end;
end;
..

I understand the warning comment but I downloaded, with FPCUpDeluxe, the trunk version (Lazarus 2.1.0 and FPC 3.3.1) ergo the revision is not that old.

What happend now ?

Thanks

#37 mORMot Framework » Error compiling in Lazarus/FPC » 2019-07-25 21:19:28

EMartin
Replies: 10

Hi @ab, I'm starting try to use Lazarus/FPC. I have installed mORMot with FPCUpDeluxe, and I when added the unit SynCommons to default Lazarus project (after Lazarus is started) and when I compile I have the following error:

Compile Project, Target: D:\fpcupdeluxe\projects\project1.exe: Exit code 1, Errors: 1, Warnings: 5, Hints: 9
SynLZ.pas(652,18) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(660,21) Warning: Local variable "cache" does not seem to be initialized
SynLZ.pas(723,7) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(723,19) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(724,10) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(726,13) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(728,9) Hint: Conversion between ordinals and pointers is not portable
SynLZ.pas(1196,51) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(1286,69) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(1325,18) Hint: Local variable "offset" does not seem to be initialized
SynLZ.pas(1333,21) Warning: Local variable "cache" does not seem to be initialized
SynCommons.pas(6661,23) Warning: Some fields coming after "" were not initialized
SynCommons.pas(13390,42) Warning: Some fields coming after "VType" were not initialized
SynCommons.pas(15038,56) Warning: Some fields coming after "VOptions" were not initialized
SynFPCTypInfo.pas(99,3) Fatal: Syntax error, "BEGIN" expected but "[" found

and the line in the unit is:

...
implementation

procedure FPCDynArrayClear(var a: Pointer; typeInfo: Pointer);
  [external name 'FPC_DYNARRAY_CLEAR'];
procedure FPCFinalizeArray(p: Pointer; typeInfo: Pointer; elemCount: PtrUInt);
  [external name 'FPC_FINALIZE_ARRAY'];
procedure FPCFinalize(Data: Pointer; TypeInfo: Pointer);
  [external name 'FPC_FINALIZE'];
procedure FPCRecordCopy(const Source; var Dest; TypeInfo: pointer);
  [external name 'FPC_COPY'];
procedure FPCRecordAddRef(var Data; TypeInfo : pointer);
  [external name 'FPC_ADDREF'];
...

I installed trunk version of Lazarus/FPC with FPCUpDeluxe 1.6.2x, using {$mode delphi}.

What am I doing wrong ?

Thanks.

#38 Re: mORMot Framework » Raising http 400 in Interface-Based Service » 2019-06-18 01:24:43

Try:

CurrentServiceContextServer.Error(400,'error message');

I don't remember the exact sintax.

#39 mORMot Framework » Small bug in SynDB.pas » 2019-06-11 17:02:33

EMartin
Replies: 1

Hi @ab, there is a small bug in SynDB.pas:

function TSQLDBConnectionPropertiesThreadSafe.CurrentThreadConnectionIndex: Integer;
var id: TThreadID;
    tix: Int64;
    conn: TSQLDBConnectionThreadSafe;
begin // caller made EnterCriticalSection(fConnectionCS)
  if self<>nil then begin
    ...
    result := 0;
--    while result<fConnectionPool.Count-1 do begin
++    while result<fConnectionPool.Count do begin
      conn := TSQLDBConnectionThreadSafe(fConnectionPool.List[result]);
      if conn.IsOutdated(tix) then // to guarantee reconnection
        fConnectionPool.Delete(result) else begin
        if conn.fThreadID=id then begin
          fLatestConnectionRetrievedInPool := result;
          exit;
        end;
        inc(result);
      end;
    end;
  end;
  result := -1;
end;

Just remove the -1 (minus one).

Thanks.

#41 mORMot Framework » Expired database connections not destroyed quickly » 2019-05-27 16:25:33

EMartin
Replies: 2

Hi @ab, I created a pull request https://github.com/synopse/mORMot/pull/ … -282564854. I found a problem when creating connections and the cause is that the expired connections are not destroyed quicly. I need create many connections because I need drop tables and this way avoid the error "object is in use".

If you are agree can you apply the PR ?.

Thanks.

#42 Re: mORMot Framework » multipart/form-data not implemented yet » 2019-05-14 16:20:07

No es un framework fácil y la documentación es buena pero hay que leer un poco el código, así lo aprendí. Igual te recomiendo que hagas en inglés las consultas, usá el Google Translator o DeepL Translator.

This is my code uploading files using interface based services using TSQLRestClientURI:

function UpLoadFiles(const aSourceFiles, aDestFolder: RawUTF8; out aNotUploadedFiles: RawUTF8): Boolean;
var
  I: Integer;
  lMultiPart: TMultiPartDynArray;
  lMultiPartFormData: RawUTF8;
  lMultiPartContentType: RawUTF8;
  lSourceFiles: TRawUTF8DynArray;
  lResp: RawUTF8;
begin
  Result := False;
  CSVToRawUTF8DynArray(aSourceFiles, ',', '', lSourceFiles);
  if Length(lSourceFiles)=0 then
    Exit;
  for I := 0 to Length(lSourceFiles)-1 do begin
    MultiPartFormDataAddFile(lSourceFiles[I], lMultiPart);
    if MultiPartFormDataEncode(lMultiPart, lMultiPartContentType, lMultiPartFormData) then
      // fClient = instance of TSQLRestClientURI and logged
     // change 'root' for your root
      fClient.URI(FormatUTF8('%/UpFile?path=%', ['root', aDestFolder]),
                             'POST', @lResp, @lMultiPartContentType, @lMultiPartFormData)
    else
      AddToCSV(lSourceFiles[I],aNotUploadedFiles);
  end;
  Result := True;
end;

Use as reference for using TWinHTTP.

Saludos.

#44 Re: mORMot Framework » Lazarus package » 2019-05-07 14:31:24

I trying migrate from Delphi 7 to FPC 3.3.1 and Lazarus 2.1.0 (I don't know anything of Lazarus/FPC), the OPM is very interesting and I have two questions:

1) Is posible that every time @ab update mORMot it is uploaded to http://packages.lazarus-ide.org/ automatically as with github ?
2) Is posible put in the OPM package version the content the synopsecommit.inc ? This way the last update is knowed.

Thanks.

#45 Re: mORMot Framework » Template for generating Swagger-UI-JSON » 2019-02-28 16:45:11

Thanks @sevo.

I can assure that enumDescription is not filled in mORMotWrapper.pas and it's very likely the other types aren't either.

#46 Re: mORMot Framework » Template for generating Swagger-UI-JSON » 2019-02-26 14:11:53

Hi @ab, can you add this line in swagger template ? this modification allow view the method description in swagger.io.

    ...
    "paths": {
      {{#soa}} {{#services}}
      {{#methods}}
        "/{{uri}}/{{methodName}}": {
            "post": {
		"description": {{jsonQuote methodDescription}}, //--> ADD THIS LINE
		"tags": ["{{uri}}"],
                "parameters": [{
                    "in": "body",
                    "name": "body",
                    "schema": {
                        "type": "object",
                        "properties": {
                          {{#args}}{{#dirInput}} 
                            "{{argName}}": {{>schema-fuer-typ}}{{commaInSingle}}
                          {{/dirInput}}{{/args}}
                        }
                    }
                }],
                "responses": {
    ...

Thanks.

#47 Re: mORMot Framework » Template for generating Swagger-UI-JSON » 2019-02-21 13:21:01

Thanks @ab, it's working, I added description to swagger template, later I'll do a pull request.

#48 Re: mORMot Framework » Template for generating Swagger-UI-JSON » 2019-02-20 17:42:13

@ab, what about this ?

And, is possible to use descriptions from endpoint services  (/// and // - and // !) to put in Swagger ?

Ok, I found how generate descriptions, I made two mistakes:

1. I put wrong path
2. There is a bug in mORMotWrappers.pas:

constructor TWrapperContext.CreateFromModel(aServer: TSQLRestServer;
  const aSourcePath, aDescriptions: TFileName);
var t,f,s,n: integer;
  ...
begin
  Create(aDescriptions);
  if aSourcePath<>'' then begin
    src := pointer(aSourcePath);
    n := 0;
    repeat
      source := GetNextItemString(src,';');
      if (source<>'') and DirectoryExists(source) then begin
        SetLength(fSourcePath,n+1);
        fSourcePath[n] := IncludeTrailingPathDelimiter(source); //--> CHANGE aSourcePath by source
        inc(n);
      end;
    until src=nil;
  end;
  fServer := aServer;
  TDocVariant.NewFast([@fields,@services]);
  // compute ORM information
  for t := 0 to fServer.Model.TablesMax do begin
  ...

Thanks.

#49 Re: mORMot Framework » Using mORMot to create a client connecting to an existing webservice » 2019-02-03 23:14:14

I use TWinHttp that is in unit SynCrtSock.pas. I did make a consumer webservice for SOAP and JSON with SSL support.

Board footer

Powered by FluxBB