source upload

This commit is contained in:
Razor12911
2022-01-17 22:16:47 +02:00
parent 12936d065b
commit 098e8c48de
1778 changed files with 1206749 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
{
Synopse mORMot framework
Sample 03 - NamedPipe Client-Server
purpose of this sample is to show Client/Server SQLite3 database usage:
- a TSampleRecord class is defined in Unit1.pas
- this sample uses down projects, Project03Client.dpr and Project03Server.dpr
- a SQLite3 server is initialized in Project03Server
- the CreateMissingTables method will create all necessary tables in the
SQLite3 database
- one or more client instances can be run in Project03Client
- the purpose of the Client form in Unit1.pas is to add a record to the
database; the Time field is filled with the current date and time
- the 'Find a previous message' button show how to perform a basic query
- since the framework use UTF-8 encoding, we use some basic functions for
fast conversion to/from the User Interface; in real applications,
you should better use our mORMoti18n unit and the corresponding
TLanguageFile.StringToUTF8() and TLanguageFile.UTF8ToString() methods
- note that you didn't need to write any SQL statement, only define a
class and call some methods; even the query was made very easy (just an
obvious WHERE clause to write)
- thanks to the true object oriented modeling of the framework, the same
exact Unit1 is used for both static in-memory database engine, or
with SQLite3 database storage: only the TForm1.Database object creation
instance was modified
- look at the tiny size of the EXE (even with SQLite3 engine embedded), less
than 400KB for the server, and 80KB for the client, with LVCL :)
Version 1.0 - January 24, 2010
}
program Project03Client;
uses
{$I SynDprUses.inc} // use FastMM4 on older Delphi, or set FPC threads
Forms,
SysUtils,
mORMot,
Unit1 in '..\01 - In Memory ORM\Unit1.pas' {Form1},
SampleData in '..\01 - In Memory ORM\SampleData.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Form1.Caption := ' Sample 03 - NamedPipe Client';
Form1.Database := TSQLRestClientURINamedPipe.Create(Form1.Model,'03');
Application.Run;
end.

View File

@@ -0,0 +1,48 @@
{
Synopse mORMot framework
Sample 03 - NamedPipe Client-Server
purpose of this sample is to show Client/Server SQLite3 database usage:
- a TSampleRecord class is defined in Unit1.pas
- this sample uses down projects, Project03Client.dpr and Project03Server.dpr
- a SQLite3 server is initialized in Project03Server
- the CreateMissingTables method will create all necessary tables in the
SQLite3 database
- one or more client instances can be run in Project03Client
- the purpose of the Client form in Unit1.pas is to add a record to the
database; the Time field is filled with the current date and time
- the 'Find a previous message' button show how to perform a basic query
- since the framework use UTF-8 encoding, we use some basic functions for
fast conversion to/from the User Interface; in real applications,
you should better use our SQLite3i18n unit and the corresponding
TLanguageFile.StringToUTF8() and TLanguageFile.UTF8ToString() methods
- note that you didn't need to write any SQL statement, only define a
class and call some methods; even the query was made very easy (just an
obvious WHERE clause to write)
- thanks to the true object oriented modeling of the framework, the same
exact Unit1 is used for both static in-memory database engine, or
with SQLite3 database storage: only the TForm1.Database object creation
instance was modified
- look at the tiny size of the EXE (even with SQLite3 engine embedded), less
than 400KB for the server, and 80KB for the client, with LVCL :)
Version 1.0 - January 24, 2010
}
program Project03Server;
uses
{$I SynDprUses.inc} // use FastMM4 on older Delphi, or set FPC threads
Forms,
Unit2 in 'Unit2.pas' {Form1},
SampleData in '..\01 - In Memory ORM\SampleData.pas';
{$R *.res}
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.

View File

@@ -0,0 +1,48 @@
object Form1: TForm1
Left = 198
Top = 124
Caption = ' 03 - NamedPipe Server'
ClientHeight = 182
ClientWidth = 418
Color = clBtnFace
Font.Charset = DEFAULT_CHARSET
Font.Color = clWindowText
Font.Height = -13
Font.Name = 'Tahoma'
Font.Style = []
OldCreateOrder = False
OnCreate = FormCreate
OnDestroy = FormDestroy
OnShow = FormShow
PixelsPerInch = 96
TextHeight = 16
object Label1: TLabel
Left = 40
Top = 16
Width = 297
Height = 33
AutoSize = False
Font.Charset = DEFAULT_CHARSET
Font.Color = clTeal
Font.Height = -16
Font.Name = 'Tahoma'
Font.Style = [fsBold]
ParentFont = False
end
object Label2: TLabel
Left = 56
Top = 72
Width = 110
Height = 16
Caption = 'Server is running...'
end
object Button1: TButton
Left = 88
Top = 120
Width = 75
Height = 25
Caption = 'Quit'
TabOrder = 0
OnClick = Button1Click
end
end

View File

@@ -0,0 +1,56 @@
unit Unit2;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs,
SynCommons, mORMot, mORMotSQLite3, SynSQLite3Static, StdCtrls, SampleData;
type
TForm1 = class(TForm)
Label1: TLabel;
Button1: TButton;
Label2: TLabel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure FormShow(Sender: TObject);
private
public
Model: TSQLModel;
Server: TSQLRestServerDB;
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
begin
Close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Model := CreateSampleModel;
Server := TSQLRestServerDB.Create(Model,ChangeFileExt(ExeVersion.ProgramFileName,'.db3'));
Server.CreateMissingTables;
Server.ExportServerNamedPipe('03');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
Server.Free;
Model.Free;
end;
procedure TForm1.FormShow(Sender: TObject);
begin
Label1.Caption := Caption;
end;
end.