You are not logged in.
Pages: 1
Thank you so much. Great framework
Is it possible change value of element 0 of array v.a without deleting and adding again?
I found the problem. It seems it was my mistake:
var
NewArray2: Variant;
begin
ss := '{"a":["1"],"b":"2"}';
NewArray2 := _Arr(['2']);
V := _Json(ss);
V.a := NewArray2;
ShowMessage(TDocVariantData(V).ToJson);
or
LDocDict := DocDict(ss);
LDocDict['a'] := NewArray2;
Hi. mormot result : {"a":"[\"2\"]","b":"2"}
TJSONObject result: {"a":"["2"]","b":"2"}
when I remove line V.a := '["2"]' it is ok! After changing a property json changes.
var
V: Variant;
J: TJSONObject;
NewArray: TJSONArray;
ss: string;
begin
ss := '{"a":["1"],"b":"2"}';
V := _Json(ss);
V.a := '["2"]';
ShowMessage(TDocVariantData(V).ToJson);
j := TJSONObject.ParseJSONValue(ss) as TJSONObject;
NewArray := TJSONArray.Create;
NewArray.Add('2');
j.RemovePair('a').Free;
j.AddPair('a', NewArray);
ShowMessage(j.ToJSON);
I am using sql capabilties for generate DTO and classes. It is realy simple and flexible, maybe help some one (this is for mysql and can be implement for other dbms by changing sql):
select t.table_name,concat(group_concat(col order by ordinal_position separator ';\r\n'),';') table_create from (
select a.table_name,a.ordinal_position,concat(a.column_name,': ',
if(a.data_type in ('varchar','enum','text','char','time','varbinary','tinytext','set','mediumtext'),
if(a.is_nullable='YES','TNullableUtf8Text','RawUtf8'),
if(a.data_type in ('int','tinyint','mediumint','smallint'),
if(a.is_nullable='YES','TNullableInteger','integer'),
if(a.data_type in ('decimal'),
if(a.is_nullable='YES','TNullableCurrency','currency'),
if(a.data_type in ('bigint'),
if(a.is_nullable='YES','TNullableInteger','int64'),
if(a.data_type in ('timestamp','date','datetime'),
if(a.is_nullable='YES','TNullableDateTime','TDateTime'),
if(a.data_type in ('longblob','blob','mediumblob'),
if(a.is_nullable='YES','TNullableUtf8Text','RawUtf8'),
if(a.data_type in ('double','float'),'Double','unDefined')))))))
) col from information_schema.columns a
where table_schema='your_mysql_db_name') t
group by t.table_name;
I think AES/GCM/NOPADDING used by tms and mormot uses pkc7 pasdding. and it is different
I use encrypt method and same again ?
It is decrypted with motmot, but with another tool it gives no multi byte string error
var
key: string;
PlainText: string;
akey : RawByteString;
CryptCipher: ICryptCipher;
dest: RawByteString;
InputRawString: RawByteString;
Bytes: TBytes;
begin
PlainText := 'да, это работает. спасибо';
Key := '12345678901234567890123456789012';
akey := HexToBin(SHA256(Key));
Bytes := TEncoding.UTF8.GetBytes(PlainText);
SetString(InputRawString, PAnsiChar(PByte(Bytes)), Length(Bytes));
CryptCipher := Encrypt('aes-256-gcm', Pointer(akey));
CryptCipher.Process(InputRawString, dest, '');
dest := BinToBase64(dest);
Memo2.Text := dest;
It is correct in actual code and I forgot to add here:
Bytes := TEncoding.UTF8.GetBytes(PlainText);
before encryption
I test result in online site like devglan. for same key and IV result is different.
var
PlainText: string;
CipherText: RawByteString;
Bytes: TBytes;
begin
Key := GenerateRandomString(32);
PlainText := 'да, это работает. спасибо';
Bytes := TEncoding.UTF8.GetBytes(PlainText);
akey := HexToBin(SHA256(Key));
AES := TAesGcm.Create(pointer(akey)^, 256);
try
Bytes := AES.EncryptPkcs7(Bytes, True);
CipherText := TEncoding.ANSI.GetString(Bytes);
Result := BinToBase64(CipherText);
finally
AES.Free;
end;
Decrypt with mormot2 is ok and return original text properly.
other party tools like tms saye:
No mapping for the Unicode character in target multi-byte
Is there a future plan to implement OAEP ?
Tyvm
We can add more managers to the group. If any of the people who are here and are approved by you, I can add them
Hi,
I create group in telegram:
Many topics related to Delphi have groups in Telegram, and in this community, members who have knowledge guide the questions of newbies.
Do you think it is advisable to create such an international group for mormot?
If there is no prohibition, let's create a group
Actually, I was in the learning and testing phase. In actual programming, I created a function for encrypt and another for decrypt.
Thank you again for the valuable and great work you are doing
After making the suggested change, the same error occurred again. But by creating a new instance, the problem was solved!
Thanks. you are the best!
After 2 days I couldn't get this code to work properly:
error = Unexpected TAesGcm.Decrypt
var
AES: TAesGcm;
Key: AnsiString;
PlainText: string;
CipherText: RawUtf8;
akey : RawByteString;
s: RawByteString;
begin
//Key := GenerateRandomString(32);
Key := '12345678901234567890123456789012';
akey := HexToBin(SHA256(Key));
PlainText := '123';
s := StringToUTF8(PlainText);
AES := TAesGcm.Create(akey, 256);
CipherText := BinToBase64(AES.EncryptPkcs7(s, True));
s := StringToUTF8(CipherText);
PlainText := AES.DecryptPkcs7(Base64ToBin(s), True);
ShowMessage(UTF8ToString(PlainText));
It is requierment of taxpayer system.
Taxpayer document says:
After encryption of the bill, through the AES/GCM algorithm, the encrypted symmetric key and IV must be placed next to the encrypted bill. To encrypt the symmetric key, the asymmetric RSA-OAEP-SHA256 method must be used, which is obtained from the public key(s) of the taxpayer system with a length of 4096 bits. A valid intermediate center is used (the public key of the taxpayer system is obtained using the GET_SERVER_INFORMATION method).
C# example of this document is :
https://jsfiddle.net/8w2u3sex/
So, I can't use X509 for this?
Hi,
Can't find in documentation. I need:
OaepPadding
OaepHash = sha256
The problem is solved. thank you very much
There is a taxpayer system that requires the national code of individuals or the company's national ID in this field to produce a certificate in field 2.5.4.5.
Therefore, I have no choice and I have to fill this field so that I can send an invoice to the government taxpayer system. Is there no solution?
Thank you so much. this one worked:
aServer.ServiceRegister(TInvoiceService, [TypeInfo(IInvoiceService)], sicShared, '1');
[dcc32 Error] View.Server.pas(109): E2250 There is no overloaded version of 'ServiceRegister' that can be called with these arguments
I can't find anything wrong. Any suggestions?
unit Service.Invoice ;
TInvoiceService = class(TInjectableObjectRest, IInvoiceService)
public
constructor Create; overload;
function GetInvoiceList(const DateFr,DateTo: string): RawJson;
function TInvoiceService.GetInvoiceList(const DateFr,DateTo: string): RawJson;
begin
-- self.server is nil here
end;
constructor TInvoiceService.Create;
begin
inherited Create;
end;
Hi,
I create custom server
TMyRest = class(TRestServerFullMemory)
and register service
aServer.ServiceRegister(InvoiceService, [TypeInfo(IInvoiceService)],'1');
but in serivce methods self.server (TRestServer) is nil!
Hi mr TBO. property ConnectionPool is readonly property, how can I assgin connectionpool?
I passed it by TRestServer constructor at the moment.
thanks. but yo write "TSQL*ConnectionProperties is connection pool, not real db connection! Real db connection is TSQL*ConnectionProperties"
it is same!
TSQL*ConnectionProperties = TSQL*ConnectionProperties
But I do it with other third party component now.I want to change it to mormot.
CkCsr_SetSubjectField(csr,'2.5.4.5', pchar(Shenase) ,'UTF8String');
I was able to generate the csr file using the suggested method and with mormot.crypt.x509. But I can't fill the field 2.5.4.5 or serialnumber. There is no such field.
ok
As you can see in the code above, I pass the dbconnection to the InvoiceService constructor. I inject connection by constructor to service, and I hold connection in fConnection defined inside service. I hope it is the right approach.
I am concerned about one thing. Is a connection shared between different threads created by mormot for other services or operations? Doesn't it cause a problem in Mormot being multi-thread?
this is my code to connect to mysql database. There are 2 service, invoice and inventory.
procedure TfrmMain.btnStartClick(Sender: TObject);
begin
StartServer('zdbc:mysql://localhost:3306/mysqldb?username=user;password=mypassword');
end;procedure TfrmMain.StartServer( aDbURI : RawUTF8 );
begin
LogFamily := SQLite3Log.Family;
LogFamily.Level := LOG_VERBOSE;
LogFamily.PerThreadLog := ptIdentifiedInOnFile;MyModel := CreatePassakModel;
aDbConnection := TSQLDBZEOSConnectionProperties.Create( aDbURI, '', '', '' );
aPassakServer := TRestServerFullMemory.Create(MyModel);
InvoiceService := TInvoiceService.Create(aDbConnection);
aPassakServer.ServiceRegister(InvoiceService, [TypeInfo(IInvoiceService)],'1');InventoryService := TInventoryService.Create(aDbConnection);
aPassakServer.ServiceRegister(InventoryService, [TypeInfo(IInventoryService)],'2');aPassakServer.ServiceMethodRegister('reports', InvoiceService.testCallBack);
AddToServerWrapperMethod(aPassakServer,['templates','templates']);
aHTTPServer := TSQLHttpServer.Create( HttpPort, [aPassakServer], '+', HTTP_DEFAULT_MODE);
aHttpServer.AccessControlAllowOrigin := '*'; // allow cross-site AJAX queries
memLog.Lines.Add('Background server is running.'#10);
memLog.Lines.Add('Cross-Platform wrappers are available at ' + HttpPort + '/' + HttpRoot );
end;
openssl disabled by default. I think mormot.crypt.x509 is better.
CryptCertOpenSsl[caaRS256] does not created and raise AV.
I tried CryptCertOpenSsl[caaRS256] := TCryptCertAlgo.Create('ES256');
and
CryptCertOpenSsl[caaRS256] := TCryptCertAlgo.Create('');
with no success !
This is a big challenge in the beginning. I had the same problem. First, I tried to work on the documentation with Json and how to work with it in mormot using docvariant and doclist. Then I went back to the examples and was able to modify it to create a very basic web service. Then I tried to understand the interface base service and method base service . And finally I worked a little with swagger.
Considering that in my existing database, the primary keys are narural key and compiste. I can't use orm. Because in Orm there must be a primary key for each table. So, I leave this section aside and use the functions that take the model and store it in the database by SQL.
The next step is how to call and share the interface for the client program. The power of mormot shows itself here. And how beautifully this work is implemented.
I'm still at the beginning of the journey, but I learned a lot within a month and I try to learn more every day.
I agree that it is much more difficult to start working with mormot than other frameworks.
It is natural that piloting a plane is more difficult than driving a car. But there are many unique possibilities here. Thanks to AB
Hi, ab
first of all I thank you for very powerful framework.
I want to generate csr file from private key and public key:
var
pem: TCertPem;
CryptCertFields: TCryptCertFields; //record
LPFields: PCryptCertFields;
priv: RawUtf8;
csr: RawUtf8;
CryptCertAlgo: TCryptCertAlgo;
begin
CryptCertFields.Country := 'US';
CryptCertFields.CommonName := 'aaaaa';
CryptCertFields.EmailAddress := 'a@b.com';
LPFields := @CryptCertFields;
pem := Memo1.Lines.Text;
priv := pem;
//priv := '';CryptCertAlgo := TCryptCertAlgo.Create('aes-256-cfc');//what is algoname
csr := CryptCertAlgo.CreateSelfSignedCsr('','', priv,[], LPFields);
raise an error : TCryptCertAlgo.Create('aes-256-cfc' does not support a custom private key.
I changed algoritm to
es-256-gcm
aes-256-ofb
aes-256-cbc
aes-256-ctr
with no success.
I know, but the interesting thing is why the speed is still low when datasource is set to nil. But when beginupdate is executed, the problem is solved.
I debugged it, closing is slow.
But you are right. I changed my code and sloved I don't khow why!!!!
vwMain.BeginUpdate(); //cxgrid
//DataSource1.DataSet := nil;
Hello and thanks.
The following statements are very slow, for a json that has 300 records. It takes a few seconds:
DataSource1.DataSet := nil;
OrmTableDataSet.Close;
OrmTableDataSet.Free;
OrmTableDataSet := TOrmTableDataSet.CreateFromJson(nil , json);
DataSource1.DataSet := OrmTableDataSet;
Hi AB
many thanks to excellent mormot2 framework.
,what is the wrong with swagger :
(when I use TNullableUtf8Text)
Resolver error at paths./InvoiceService/Insert.post.parameters.0.schema.properties.AInvoice.properties.remarks.$ref
Could not resolve reference: Could not resolve pointer: /definitions/TNullableUtf8Text does not exist in document.
Thank you.
Setter solved the problem. but i have alot of tables (600 tables), with many enum fields. I want to use existing database structure as possible.
procedure TOrmInvoice.SetSize(const Value: RawUtf8);
begin
//xxlarge,xlarge,large,medium,small
if Value = 'xxlarge' then
FSize := '1'
else if Value = 'xlarge' then
FSize := '2'
else if Value = 'large' then
FSize := '3'
else if Value = 'medium' then
FSize := '4'
else if Value = 'small' then
FSize := '5';
end;
publish
Size: RawUtf8;
field data type is enum('xxlarge','xlarge','large','medium','small');
I don't know where this conversion is happen. In orm level or Zeus level.
I have truble in mormot + mysql + enum fields.
Imagine that the data type is enum('large','small') when entering information in the corresponding orm class, it should be written like this (Otherwise, the error "Data truncated for column 'column_name' will be generated):
Rec.size := '1';
That is, we must enter the enum index. While I used the enum text itself in the previous software:
query.fieldbyname('size').asstring := 'large';
The solution that comes to my mind is to find the corresponding index by a function based on the enum text and write like this:
Rec.size := Get_inum_index('large');
Hi.
For reports I have very complex sql,what is the best way for executing this kind of sql?
Is it correct using :
function TReportService.Report: RawJson;
var
MyComplexSql: RawUtf8;
begin
MyComplexSql := 'my sql with left joins and subquery ...';
Result := TRestServerDB(Self.Server).DB.ExecuteJson(MyComplexSql, True);
end;
Hi AB. Thank you for very good mORMot framework.
This code work client side.
var
OrmTable: TOrmTable;
OrmTableDataSet: TOrmTableDataSet;
begin
OrmTable := HttpClient.ExecuteList([],'select * from user limit 10');
ShowMessage(OrmTable.RowCount.ToString);
OrmTableDataSet := TOrmTableDataSet.Create(nil, OrmTable);
DataSource1.DataSet := OrmTableDataSet;
end;
but in server side not working:Result is empty. I can't find why
procedure TUserService.List(var ATable: TOrmTable); //UserService is interface base service
begin
ATable := Self.Server.ExecuteList([],'select * from user');
end;
Hello . I want to check one of the demos related to mormot1 but TCQRSResult is missing in mormot2. What is its equivalent?
Pages: 1