#1 Re: mORMot 1 » TSQLSettings.CreateAndFillPrepare issue question » 2018-04-13 08:51:02

I have nothing done with Users. I swear smile. I am using User account with standard password for test purpose only.

maybe it was incident, but I was confused and it took me a long time to deal with this problem.

#2 Re: mORMot 1 » TSQLSettings.CreateAndFillPrepare issue question » 2018-04-12 22:04:50

Maybe yes maybe no smile I dont remember, but...

I have deleted sqlite db, and created again with TSQLModel and the same tables configuration (3 tables in the same order).
In SQLite DB have been created 5 tables:  Users and Groups i 3 of my tables.
Problem were still existed...

Solution was a change range in AuthGroups for User by hand..., but is normal way? I dont think so smile

#3 Re: mORMot 1 » TSQLSettings.CreateAndFillPrepare issue question » 2018-04-12 21:37:25

Hmmm I have searched a lot of time and I suposse guilty is AuthGroup:
User:   14,1-3,6-256,0,1-3,6-256,0,1-3,6-256,0,1-3,6-256,0

The order of the columns is a magical unknown to me, even after reading the documentation....
I created sql tables in proper order...

#4 mORMot 1 » TSQLSettings.CreateAndFillPrepare issue question » 2018-04-12 08:01:46

danny
Replies: 6

Hello,
I have created 3 tables and next, for example:
   

Settings := TSQLSettings.CreateAndFillPrepare(Client, 'LogonName LIKE ?', [ALogonName]);
    FileSettings := TSQLFileSettings.CreateAndFillPrepare(Client, 'LogonName LIKE ? AND FileVersion LIKE ?', [ALogonName, AVersion]);
    TerminationSettings := TSQLTerminationSettings.CreateAndFillPrepare(Client, 'LogonName LIKE ?', [ALogonName]);

and later iterate:

if Settings.FillOne then
      begin
        ....
      end;

while FileSettings.FillOne do
      begin
        ........
      end;

 while TerminationSettings.FillOne do
      begin    
       .......
        end;
      end;

Issue is that - only Settings and FileSettings are iterated....
TerminationSettings is not iterate - 'TSQLTerminationSettings.CreateAndFillPrepare' return NIL (table nil).
In SQLite database file TerminationSettings table have created....
What is wrong?

Best regards.

#5 mORMot 1 » Proper way to connect MSSQL 2016 in Lazarus (1.8.2) » 2018-03-23 21:24:12

danny
Replies: 1

Hello,
I would like to ask for example of connection to MSSQL 2016 via MORMOT in Lazarus 1.8.2 (windows).
I am so confused, so I prefer ask.

What code for connection and what drivers (dll) are need?

I use a code below for mssql 2012 and is OK, but not work for 2016...

FConnection := TOleDBMSSQL2012ConnectionProperties.Create('server','db','sa', ''); 

THX for some example code ...

Cheers.

#6 Re: mORMot 1 » Problem with TInterfacedCollection for Lazarus 1.8.2 » 2018-03-15 17:56:37

ok, i replace Connection on

 
FConnection := TOleDBMSSQL2012ConnectionProperties.Create('Server','DB','sa', '');   

And i think is ok now, thx for all.

#7 Re: mORMot 1 » Problem with TInterfacedCollection for Lazarus 1.8.2 » 2018-03-15 15:17:42

Thx, hnb, that was it!

Its ok, but unfortunately there is one more such situation when I get ???? instead chars...
when I assign values by FSQLDBRows.ColumnUTF8, Am I doing this well?

while FSQLDBRows.Step do
  begin
    with Cities.Add do
    begin
      Name := FSQLDBRows.ColumnUTF8('NazwyMiast');  // <------------------------------------------------ return RawUTF8  - Name field is RawUTf8 too......
    end;
  end;  

when I assign by const then is all ok..:

    with Cities.Add do
    begin
      Name := 'Rzeszów';
    end;

#8 Re: mORMot 1 » Problem with TInterfacedCollection for Lazarus 1.8.2 » 2018-03-15 12:01:26

Ehh this is some insane....problm still exists

I have checked on fpc 3.1.1, lazarus 1.9.0 and the same story....

My example codes:
INTERFACES

TDTOCity = class(TCollectionItem)  // deklaracja obiektu DTO dla Miasta
  private
    FName: RawUTF8;
  published
    property Name: RawUTF8 read FName write FName;
  end;

  TDTOCities = class(TInterfacedCollection)  // deklaracja kolekcji obiektow TDTOCity
  private
    function GetCollItem(aIndex: Integer): TDTOCity;
  protected
    class function GetClass: TCollectionItemClass; override;
  public
    function Add: TDTOCity;
    property Item[aIndex: Integer]: TDTOCity read GetCollItem; default;
  end;

  ICitiesService = interface(IInvokable)   // deklaracja interfejsu
    ['{49ACE92E-F9E8-4AE9-BA04-AC9A3198F034}']
    procedure GetCities(const Name: RawUTF8; out Cities: TDTOCities);
  end;

const
  ROOT_NAME = 'Demo';
  PORT_NAME = '888';

implementation

{ TDTOCities }

function TDTOCities.Add: TDTOCity;
begin
  result := TDTOCity(inherited Add);
end;

class function TDTOCities.GetClass: TCollectionItemClass;
begin
  result := TDTOCity;
end;

function TDTOCities.GetCollItem(aIndex: Integer): TDTOCity;
begin
  result := TDTOCity(GetItem(aIndex));
end;                  

IMPLEMENTATION:

 { TCitiesService }

  TCitiesService = class(TInterfacedObject, ICitiesService) // implementacja interfejsu
  private
    FConnection: TSQLDBZEOSConnectionProperties;
    FSQLDBRows: ISQLDBRows;
  public
    constructor Create;
    destructor Destroy; override;

    procedure GetCities(const Name: RawUTF8; out Cities: TDTOCities);
  end;

implementation

{ TCitiesService }

constructor TCitiesService.Create;
begin
  inherited;
end;

destructor TCitiesService.Destroy;
begin
  FConnection.Free;
  inherited Destroy;
end;

procedure TCitiesService.GetCities(const Name: RawUTF8; out Cities: TDTOCities);
begin
  //proste polaczenie do bazy
  FConnection := TSQLDBZEOSConnectionProperties.Create(TSQLDBZEOSConnectionProperties.URI(dMSSQL,'SERVER'),'DATABSE','sa', '');
  FSQLDBRows := FConnection.Execute('SELECT NazwyMiast FROM Miasta WHERE NazwyMiast LIKE ? ', [Name]);

    with Cities.Add do
    begin
      Name := 'Rzeszów;
    end;
        with Cities.Add do
    begin
      Name := 'Miasto2';
    end;
            with Cities.Add do
    begin
      Name := 'Miasto3';
    end;

  //while FSQLDBRows.Step do
  //begin
  //  with Cities.Add do
  //  begin
  //    Name := FSQLDBRows.ColumnUTF8('NazwyMiast');
  //  end;
  //end;
end;      

FPC HELP INTERFACES

{$ifndef HASINTERFACERTTI} // circumvent old FPC bug of missing RTTI

{ TInterfaceFactoryDefinition }

type
  /// define and manage missing interface RTTI for the following interfaces:
  // - ICalculator
  TInterfaceFactoryDefinition = class(TInterfaceFactoryGenerated)
  protected
    procedure AddMethodsFromTypeInfo(aInterface: PTypeInfo); override;
  end;

procedure TInterfaceFactoryDefinition.AddMethodsFromTypeInfo(aInterface: PTypeInfo);
begin
  if aInterface=TypeInfo(ICitiesService) then   //dodajemy metode pomocnicza, bo Lazarus ma problem z interfejsami
  begin
    AddMethod('GetCities',[
      ord(smdconst),'Name',TypeInfo(RawUTF8),
      ord(smdOut),'Cities',TypeInfo(TDTOCities)
      ]);
    exit;
  end;
end;

initialization
  TInterfaceFactoryDefinition.RegisterInterface(TypeInfo(ICitiesService)); //rejestrujemy interfejs

{$endif HASINTERFACERTTI}  

Maybe someone can send me some example demo with DTO (with interfaced colection)?

#9 Re: mORMot 1 » Problem with TInterfacedCollection for Lazarus 1.8.2 » 2018-03-14 16:47:43

Unfortunately not work...

Now, cutting string after meet polish special character:

[{
		"Name": "Rzesz

The same at retrieving name from object (not as json)

#11 mORMot 1 » Problem with TInterfacedCollection for Lazarus 1.8.2 » 2018-03-14 12:55:45

danny
Replies: 11

Hello,
I am writing from Poland, where I use polish characters on a daily basis, for example: ó, ł, ą, ę, etc.

I create simple app with DTO objects and I have problem with special polish characters. Problem not exists on Delphi, but only for Lazarus (I have checked both).

I suppose the problem is related to TCollectionItem and TInterfacedCollection.

The same problem occurs in demo "20 - DTO interface based service".

for example in Delphi, result shows as:

{
	"Airport": 
	[{
			"Location": "Rzeszów",            <--------------------------------------------------------------------------------------
			"Terminal": ["terminalA","terminalB","terminalC"],
			"Gate": ["gate1","gate2","gate3","gate4","gate5"],
			"BHS": "Siemens",
			"DCS": "Altiea"
		}
	],
	"Airline": 
	[{
			"CX": ["B777","B737","A380","A320"],
			"QR": ["A319","A380","B787"],
			"ET": "380",
			"SQ": "A320"
		}
	],
	"GroundHandler": ["Swissport","SATS","Wings","TollData"]
}

but for lazarus:

{
	"Airport": 
	[{
			"Location": "Rzesz??w",            <--------------------------------------------------------------------------------------
			"Terminal": ["terminalA","terminalB","terminalC"],
			"Gate": ["gate1","gate2","gate3","gate4","gate5"],
			"BHS": "Siemens",
			"DCS": "Altiea"
		}
	],
	"Airline": 
	[{
			"CX": ["B777","B737","A380","A320"],
			"QR": ["A319","A380","B787"],
			"ET": "380",
			"SQ": "A320"
		}
	],
	"GroundHandler": ["Swissport","SATS","Wings","TollData"]
}

I have tried different combinations with UTF8ToString etc - nothing helped.

I am asking for some tips.....
Regards

#13 mORMot 1 » Start with mORMot Framework for specific project » 2016-08-02 10:46:14

danny
Replies: 2

Hello everyone,

I am writing some small project client-server and I want use mORMot...
I would be grateful for any tips as I can started my work...

assumptions project:
Client (windows):
1. Send text by the Timer to the server on the another place (VPS windows probably) every 5 minutes.
2. Receive callback from the server.

Server (windows VPS?)
1. Receive messages from Client every 5 minutes and save it to the database for example SQLite.
2. Send callback to the Client (some message).

important information:
I want to have one server and up to 100 clients...

Questions.
1. I started discovering mormot from demo sample - 14 - Interface based services - there is good sample for my project?
2. How is the best way to save messages from Server to database - use firedac or mormot to save to sqlite - which sample show my this possibility?

thanks!

Board footer

Powered by FluxBB