source upload
This commit is contained in:
@@ -0,0 +1,93 @@
|
||||
unit Form1;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SmartCL.System, SmartCL.Graphics, SmartCL.Components, SmartCL.Forms,
|
||||
SmartCL.Fonts, SmartCL.Borders, SmartCL.Application, SmartCL.Controls.Panel,
|
||||
SmartCL.Controls.Label, SmartCL.Controls.EditBox, SmartCL.Controls.Button,
|
||||
SynCrossPlatformREST, mORMotClient;
|
||||
|
||||
type
|
||||
TForm1 = class(TW3Form)
|
||||
procedure BtnComputeSynchClick(Sender: TObject);
|
||||
procedure BtnComputeAsynchClick(Sender: TObject);
|
||||
procedure BtnConnectClick(Sender: TObject);
|
||||
private
|
||||
{$I 'Form1:intf'}
|
||||
protected
|
||||
Client: TSQLRestClientURI;
|
||||
procedure InitializeForm; override;
|
||||
procedure InitializeObject; override;
|
||||
procedure Resize; override;
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
{ TForm1 }
|
||||
|
||||
procedure TForm1.BtnConnectClick(Sender: TObject);
|
||||
begin
|
||||
if Client=nil then
|
||||
GetClient('127.0.0.1','User','synopse',
|
||||
lambda (aClient: TSQLRestClientURI)
|
||||
PanelCompute.Visible := true;
|
||||
W3Label1.Visible := true;
|
||||
W3Label2.Visible := true;
|
||||
LabelConnect.Caption := '';
|
||||
BtnConnect.Caption := 'Disconnect';
|
||||
LabelResult.Caption := '';
|
||||
Client := aClient;
|
||||
end,
|
||||
lambda
|
||||
ShowMessage('Impossible to connect to the server!');
|
||||
end)
|
||||
else begin
|
||||
PanelCompute.Visible := false;
|
||||
BtnConnect.Caption := 'Server Connect';
|
||||
Client.Free;
|
||||
Client := nil;
|
||||
end;
|
||||
end;
|
||||
|
||||
procedure TForm1.BtnComputeAsynchClick(Sender: TObject);
|
||||
begin
|
||||
TServiceCalculator.Create(Client).Add(
|
||||
StrToInt(EditA.Text),StrToInt(EditB.Text),
|
||||
lambda (res: integer)
|
||||
LabelResult.Caption := format('Result = %d',[res]);
|
||||
end,
|
||||
lambda
|
||||
ShowMessage('Error calling the method!');
|
||||
end);
|
||||
end;
|
||||
|
||||
procedure TForm1.BtnComputeSynchClick(Sender: TObject);
|
||||
begin
|
||||
LabelResult.Caption := format('Result = %d',
|
||||
[TServiceCalculator.Create(Client)._Add(
|
||||
StrToInt(EditA.Text),StrToInt(EditB.Text))]);
|
||||
end;
|
||||
|
||||
procedure TForm1.InitializeForm;
|
||||
begin
|
||||
inherited;
|
||||
// this is a good place to initialize components
|
||||
EditA.InputType := itNumber;
|
||||
EditB.InputType := itNumber;
|
||||
end;
|
||||
|
||||
procedure TForm1.InitializeObject;
|
||||
begin
|
||||
inherited;
|
||||
{$I 'Form1:impl'}
|
||||
end;
|
||||
|
||||
procedure TForm1.Resize;
|
||||
begin
|
||||
inherited;
|
||||
end;
|
||||
|
||||
initialization
|
||||
Forms.RegisterForm({$I %FILE%}, TForm1);
|
||||
end.
|
@@ -0,0 +1,96 @@
|
||||
<SMART>
|
||||
<Form version="2" subversion="1">
|
||||
<Created>2014-08-10T14:52:31.247</Created>
|
||||
<Modified>2014-08-10T16:08:54.867</Modified>
|
||||
<object type="TW3Form">
|
||||
<Caption>W3Form</Caption>
|
||||
<Name>Form1</Name>
|
||||
<object type="TW3Panel">
|
||||
<Width>264</Width>
|
||||
<Visible>False</Visible>
|
||||
<Top>96</Top>
|
||||
<Left>40</Left>
|
||||
<Height>264</Height>
|
||||
<Name>PanelCompute</Name>
|
||||
<object type="TW3Label">
|
||||
<Caption>A =</Caption>
|
||||
<Width>32</Width>
|
||||
<Top>32</Top>
|
||||
<Left>56</Left>
|
||||
<Height>32</Height>
|
||||
<Name>W3Label1</Name>
|
||||
</object>
|
||||
<object type="TW3EditBox">
|
||||
<Value></Value>
|
||||
<Text>1</Text>
|
||||
<Range></Range>
|
||||
<Width>128</Width>
|
||||
<Top>32</Top>
|
||||
<Left>88</Left>
|
||||
<Height>32</Height>
|
||||
<Name>EditA</Name>
|
||||
</object>
|
||||
<object type="TW3Label">
|
||||
<Caption>B =</Caption>
|
||||
<Width>32</Width>
|
||||
<Top>72</Top>
|
||||
<Left>56</Left>
|
||||
<Height>32</Height>
|
||||
<Name>W3Label2</Name>
|
||||
</object>
|
||||
<object type="TW3EditBox">
|
||||
<Value></Value>
|
||||
<Text>1</Text>
|
||||
<Range></Range>
|
||||
<Width>128</Width>
|
||||
<Top>72</Top>
|
||||
<Left>88</Left>
|
||||
<Height>32</Height>
|
||||
<Name>EditB</Name>
|
||||
</object>
|
||||
<object type="TW3Button">
|
||||
<Caption>Compute Asynch</Caption>
|
||||
<Width>168</Width>
|
||||
<Top>112</Top>
|
||||
<Left>48</Left>
|
||||
<Height>40</Height>
|
||||
<Name>BtnComputeAsynch</Name>
|
||||
<OnClick>BtnComputeAsynchClick</OnClick>
|
||||
</object>
|
||||
<object type="TW3Label">
|
||||
<Width>152</Width>
|
||||
<Top>208</Top>
|
||||
<Left>64</Left>
|
||||
<Height>32</Height>
|
||||
<Name>LabelResult</Name>
|
||||
</object>
|
||||
<object type="TW3Button">
|
||||
<Caption>Compute Synch</Caption>
|
||||
<Width>168</Width>
|
||||
<Top>160</Top>
|
||||
<Left>48</Left>
|
||||
<Height>40</Height>
|
||||
<Name>BtnComputeSynch</Name>
|
||||
<OnClick>BtnComputeSynchClick</OnClick>
|
||||
</object>
|
||||
</object>
|
||||
<object type="TW3Label">
|
||||
<Caption><small>Project14ServerHttpWrapper should be running!</Caption>
|
||||
<Width>376</Width>
|
||||
<Top>16</Top>
|
||||
<Left>24</Left>
|
||||
<Height>32</Height>
|
||||
<Name>LabelConnect</Name>
|
||||
</object>
|
||||
<object type="TW3Button">
|
||||
<Caption>Server Connect</Caption>
|
||||
<Width>176</Width>
|
||||
<Top>48</Top>
|
||||
<Left>40</Left>
|
||||
<Height>40</Height>
|
||||
<Name>BtnConnect</Name>
|
||||
<OnClick>BtnConnectClick</OnClick>
|
||||
</object>
|
||||
</object>
|
||||
</Form>
|
||||
</SMART>
|
@@ -0,0 +1,21 @@
|
||||
uses Unit1;
|
||||
|
||||
{$IFDEF SMART_INTERNAL_AUTO_REFRESH}
|
||||
uses SmartCL.AutoRefresh;
|
||||
TW3AutoRefresh.Create.Start;
|
||||
{$ENDIF}
|
||||
|
||||
var Application: TApplication;
|
||||
|
||||
{$IFDEF SMART_INTERNAL_HANDLE_EXCEPTIONS}
|
||||
uses SmartCL.System;
|
||||
try
|
||||
{$ENDIF}
|
||||
Application := TApplication.Create;
|
||||
Application.RunApp;
|
||||
{$IFDEF SMART_INTERNAL_HANDLE_EXCEPTIONS}
|
||||
except
|
||||
on e: Exception do
|
||||
ShowMessage(e.Message);
|
||||
end;
|
||||
{$ENDIF}
|
@@ -0,0 +1,120 @@
|
||||
<SMART>
|
||||
<Project version="2" subversion="2">
|
||||
<Name>Project14Client</Name>
|
||||
<Created>T00:00:00.000</Created>
|
||||
<Modified>2016-01-25T11:36:04.339</Modified>
|
||||
<Author>Arnaud Bouchez</Author>
|
||||
<Company>Synopse</Company>
|
||||
<Version>
|
||||
<Major>1</Major>
|
||||
<Minor>18</Minor>
|
||||
<Revision>0</Revision>
|
||||
</Version>
|
||||
<VendorSpecific>
|
||||
<Apple>
|
||||
<FormatDetection>0</FormatDetection>
|
||||
<StatusBarStyle>default</StatusBarStyle>
|
||||
<WebAppCapable>0</WebAppCapable>
|
||||
</Apple>
|
||||
<ChromeApp>
|
||||
<Kiosk>0</Kiosk>
|
||||
<KioskOnly>1</KioskOnly>
|
||||
<OfflineEnabled>1</OfflineEnabled>
|
||||
</ChromeApp>
|
||||
<Cordova>
|
||||
<WidgetID></WidgetID>
|
||||
<AllowIntent>http://*/* https://*/* tel:* sms:* mailto:* geo:* </AllowIntent>
|
||||
</Cordova>
|
||||
</VendorSpecific>
|
||||
<Options>
|
||||
<Compiler>
|
||||
<Assertions>1</Assertions>
|
||||
<Optimize>1</Optimize>
|
||||
<HintsLevel>1</HintsLevel>
|
||||
</Compiler>
|
||||
<Codegen>
|
||||
<Obfuscation>1</Obfuscation>
|
||||
<RangeChecking>0</RangeChecking>
|
||||
<InstanceChecking>0</InstanceChecking>
|
||||
<ConditionChecking>1</ConditionChecking>
|
||||
<LoopChecking>1</LoopChecking>
|
||||
<InlineMagics>1</InlineMagics>
|
||||
<IgnorePublishedInImplementation>0</IgnorePublishedInImplementation>
|
||||
<EmitSourceLocation>0</EmitSourceLocation>
|
||||
<EmitRTTI>0</EmitRTTI>
|
||||
<Devirtualize>1</Devirtualize>
|
||||
<MainBody>1</MainBody>
|
||||
<CodePacking>0</CodePacking>
|
||||
<SmartLinking>1</SmartLinking>
|
||||
<Verbosity>1</Verbosity>
|
||||
</Codegen>
|
||||
<ConditionalDefines>
|
||||
<HandleExceptions>1</HandleExceptions>
|
||||
<AutoRefresh>0</AutoRefresh>
|
||||
<LegacySupportForIE>0</LegacySupportForIE>
|
||||
</ConditionalDefines>
|
||||
<Linker>
|
||||
<SourceMap>0</SourceMap>
|
||||
<CompressCSS>1</CompressCSS>
|
||||
<GenerateAppCacheManifest>1</GenerateAppCacheManifest>
|
||||
<GenerateChromeAppManifest>0</GenerateChromeAppManifest>
|
||||
<GenerateFireFoxManifest>0</GenerateFireFoxManifest>
|
||||
<GenerateWebAppManifest>1</GenerateWebAppManifest>
|
||||
<GenerateWidgetPackageConfigXML>0</GenerateWidgetPackageConfigXML>
|
||||
<GenerateCordovaConfigXML>0</GenerateCordovaConfigXML>
|
||||
<ExternalCSS>0</ExternalCSS>
|
||||
<Theme>default.css</Theme>
|
||||
<CustomTheme>0</CustomTheme>
|
||||
<EmbedJavaScript>1</EmbedJavaScript>
|
||||
</Linker>
|
||||
<Output>
|
||||
<HtmlFileName>index.html</HtmlFileName>
|
||||
<OutputFilePath>www\</OutputFilePath>
|
||||
</Output>
|
||||
<Import />
|
||||
<Execute>
|
||||
<ServeManifest>0</ServeManifest>
|
||||
<Server>1</Server>
|
||||
<CustomFile></CustomFile>
|
||||
<LoadCustomFile>0</LoadCustomFile>
|
||||
<PauseAfterExecution>0</PauseAfterExecution>
|
||||
<ExecuteType>1</ExecuteType>
|
||||
<ExecuteableParams>%output%</ExecuteableParams>
|
||||
</Execute>
|
||||
</Options>
|
||||
<Files>
|
||||
<File type="main">
|
||||
<Name>Project14Client</Name>
|
||||
<Created>2014-08-10T14:52:31.247Z</Created>
|
||||
<Modified>2014-08-10T14:55:37.144</Modified>
|
||||
<Filename>Project14Client.spr</Filename>
|
||||
</File>
|
||||
<File type="unit">
|
||||
<Name>Unit1</Name>
|
||||
<Created>2014-08-10T14:52:31.247Z</Created>
|
||||
<Modified>2014-08-10T14:52:31.247</Modified>
|
||||
<Filename>Unit1.pas</Filename>
|
||||
</File>
|
||||
<File type="form">
|
||||
<Name>Form1</Name>
|
||||
<Created>2014-08-10T14:52:31.247Z</Created>
|
||||
<Modified>2014-08-10T16:07:43.657</Modified>
|
||||
<Filename>Form1.pas</Filename>
|
||||
<AutoCreate>
|
||||
<IsAutoCreate>1</IsAutoCreate>
|
||||
<IsMainForm>1</IsMainForm>
|
||||
<Order>1</Order>
|
||||
</AutoCreate>
|
||||
</File>
|
||||
</Files>
|
||||
<Target>Browser</Target>
|
||||
<Statistics>
|
||||
<BackgroundCompilations>8</BackgroundCompilations>
|
||||
<EditTime>00:00:10.144</EditTime>
|
||||
<CompileTime>00:00:06.404</CompileTime>
|
||||
<TotalTime>00:11:51.417</TotalTime>
|
||||
<DesigningTime>00:00:00.089</DesigningTime>
|
||||
<RunningTime>00:10:45.657</RunningTime>
|
||||
</Statistics>
|
||||
</Project>
|
||||
</SMART>
|
@@ -0,0 +1,16 @@
|
||||
unit Unit1;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
Pseudo.CreateForms, // auto-generated unit that creates forms during startup
|
||||
System.Types, SmartCL.System, SmartCL.Components, SmartCL.Forms,
|
||||
SmartCL.Application, Form1;
|
||||
|
||||
type
|
||||
TApplication = class(TW3CustomApplication)
|
||||
end;
|
||||
|
||||
implementation
|
||||
|
||||
end.
|
@@ -0,0 +1,130 @@
|
||||
/// remote access to a mORMot server using SmartMobileStudio
|
||||
// - retrieved from http://localhost:888/root/wrapper/SmartMobileStudio/mORMotClient.pas
|
||||
// at 2014-12-10 21:54:15 using "SmartMobileStudio.pas.mustache" template
|
||||
unit mORMotClient;
|
||||
|
||||
{
|
||||
WARNING:
|
||||
This unit has been generated by a mORMot 1.18.626 server.
|
||||
Any manual modification of this file may be lost after regeneration.
|
||||
|
||||
Synopse mORMot framework. Copyright (C) 2014 Arnaud Bouchez
|
||||
Synopse Informatique - https://synopse.info
|
||||
|
||||
This unit is released under a MPL/GPL/LGPL tri-license,
|
||||
and therefore may be freely included in any application.
|
||||
|
||||
This unit would work on Smart Mobile Studio 2.1.1 and later.
|
||||
}
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
SmartCL.System,
|
||||
System.Types,
|
||||
SynCrossPlatformSpecific,
|
||||
SynCrossPlatformREST;
|
||||
|
||||
|
||||
type
|
||||
/// service accessible via http://localhost:888/root/Calculator
|
||||
// - this service will run in sicShared mode
|
||||
// - synchronous and asynchronous methods are available, depending on use case
|
||||
// - synchronous _*() methods will block the browser execution, so won't be
|
||||
// appropriate for long process - on error, they may raise EServiceException
|
||||
TServiceCalculator = class(TServiceClientAbstract)
|
||||
public
|
||||
/// will initialize an access to the remote service
|
||||
constructor Create(aClient: TSQLRestClientURI); override;
|
||||
|
||||
procedure Add(n1: Integer; n2: Integer;
|
||||
onSuccess: procedure(Result: Integer); onError: TSQLRestEvent);
|
||||
function _Add(const n1: Integer; const n2: Integer): Integer;
|
||||
end;
|
||||
|
||||
|
||||
const
|
||||
/// the server port, corresponding to http://localhost:888
|
||||
SERVER_PORT = 888;
|
||||
|
||||
|
||||
/// return the database Model corresponding to this server
|
||||
function GetModel: TSQLModel;
|
||||
|
||||
/// create a TSQLRestClientHTTP instance and connect to the server
|
||||
// - it will use by default port 888
|
||||
// - secure connection will be established via TSQLRestServerAuthenticationDefault
|
||||
// with the supplied credentials
|
||||
// - request will be asynchronous, and trigger onSuccess or onError event
|
||||
procedure GetClient(const aServerAddress, aUserName,aPassword: string;
|
||||
onSuccess, onError: TSQLRestEvent; aServerPort: integer=SERVER_PORT);
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
|
||||
function GetModel: TSQLModel;
|
||||
begin
|
||||
result := TSQLModel.Create([TSQLAuthUser,TSQLAuthGroup],'root');
|
||||
end;
|
||||
|
||||
procedure GetClient(const aServerAddress, aUserName,aPassword: string;
|
||||
onSuccess, onError: TSQLRestEvent; aServerPort: integer);
|
||||
begin
|
||||
var client := TSQLRestClientHTTP.Create(aServerAddress,aServerPort,GetModel,true);
|
||||
client.Connect(
|
||||
lambda
|
||||
try
|
||||
if client.ServerTimeStamp=0 then begin
|
||||
if Assigned(onError) then
|
||||
onError(client);
|
||||
exit;
|
||||
end;
|
||||
if not client.SetUser(TSQLRestServerAuthenticationDefault,aUserName,aPassword) then begin
|
||||
if Assigned(onError) then
|
||||
onError(client);
|
||||
exit;
|
||||
end;
|
||||
if Assigned(onSuccess) then
|
||||
onSuccess(client);
|
||||
except
|
||||
if Assigned(onError) then
|
||||
onError(client);
|
||||
end;
|
||||
end,
|
||||
onError);
|
||||
end;
|
||||
|
||||
|
||||
{ TServiceCalculator }
|
||||
|
||||
constructor TServiceCalculator.Create(aClient: TSQLRestClientURI);
|
||||
begin
|
||||
fServiceName := 'Calculator';
|
||||
fServiceURI := 'Calculator';
|
||||
fInstanceImplementation := sicShared;
|
||||
fContractExpected := '1FC2AE72D7E2C88D';
|
||||
inherited Create(aClient);
|
||||
end;
|
||||
|
||||
|
||||
procedure TServiceCalculator.Add(n1: Integer; n2: Integer;
|
||||
onSuccess: procedure(Result: Integer); onError: TSQLRestEvent);
|
||||
begin
|
||||
fClient.CallRemoteServiceAsynch(self,'Add',1,
|
||||
[n1,n2],
|
||||
lambda (res: array of Variant)
|
||||
onSuccess(res[0]);
|
||||
end, onError);
|
||||
end;
|
||||
|
||||
function TServiceCalculator._Add(const n1: Integer; const n2: Integer): Integer;
|
||||
begin
|
||||
var res := fClient.CallRemoteServiceSynch(self,'Add',1,
|
||||
[n1,n2]);
|
||||
Result := res[0];
|
||||
end;
|
||||
|
||||
|
||||
|
||||
end.
|
@@ -0,0 +1,7 @@
|
||||
CACHE MANIFEST
|
||||
# Offline cache version 0.0.1
|
||||
# id:69550
|
||||
|
||||
CACHE:
|
||||
index.html
|
||||
res/app.css
|
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user