#1 Re: mORMot 1 » Boolean and varchar Data type » 2018-08-02 04:29:19

Thanks for your answer. from Performance perspective , the length of a record is smaller is better. because more rows can be saved on a page that is 8kb.
In the systems with high transactions , data types must be very precise.

#2 Re: mORMot 1 » Boolean and varchar Data type » 2018-08-01 16:53:08

Thanks a lot.
Is it possible to create varchar or integer field type? not nvarchar or int64.

Why mORMot doesn't support boolean type?

#3 mORMot 1 » Boolean and varchar Data type » 2018-08-01 08:41:16

Hmdsadeghian
Replies: 6

Hi ab,

I want to declare boolean and varchar data types in my tables. And here is my model :

  TFinancialYears=class(TSQLRecord)
  private
    fEndDate: TDateTime;
    fClosed: Boolean;
    fClosedByUserId: Integer;
    fStartDate: TDateTime;
    fCloseDate: TDateTime;
    fCompanyId: integer;
  published
    property  CompanyId: integer read fCompanyId write fCompanyId;
    property  StartDate :TDateTime read fStartDate write fStartDate;
    property EndDate :TDateTime read fEndDate write fEndDate;
    property Closed:Boolean read fClosed write fClosed;
    property ClosedByUserId:Integer read fClosedByUserId write fClosedByUserId;
    property CloseDate :TDateTime read fCloseDate write fCloseDate;
  end;

But when the table is created in SQL Server, Integer types will map to int64, rawutf8 will map to nvarchar and boolean types will map to integer.
How can I declare exactly the same type as equal type in SQL Server in Delphi?

Thanks.

#6 Re: mORMot 1 » How to implement VirtualTableExternalMap » 2018-07-23 18:17:26

Thank you .
Do you have any example for this approach?

In your solution, can I host my service on dedicate server on the internet and connect through the internet to the service application?

If I understand correctly, I don't need change the DoStart procedure. also need to create an instance on TSQLServerServer on the TConnection Class when the Connect function called. is it true?

#7 mORMot 1 » How to implement VirtualTableExternalMap » 2018-07-23 12:38:54

Hmdsadeghian
Replies: 5

Hi,

I create a http service application and create a class for connecting to the SQL Server from client.
My connection class is :

 
type
  TConnection = class(TInterfacedObject, IConnection)
  protected
    fProps: TOleDBMSSQL2012ConnectionProperties;
  public
    destructor Destroy; override;
  public // implements IRemoteSQL methods
    procedure Connect(const aServerName, aDatabaseName,
      aUserID, aPassWord: RawUTF8);
  end;

implementation

{ TServiceRemoteSQL }

procedure TConnection.Connect(const aServerName, aDatabaseName, aUserID,
  aPassWord: RawUTF8);
begin
  if fProps<>nil then
    raise Exception.Create('Connect called more than once');
    fProps := TOleDBMSSQL2012ConnectionProperties.Create(aServerName,
              aDatabaseName,aUserID,aPassWord);
 end;

and my service code is :

procedure TFaezERPHttpService.DoStart(Sender: TService);
var
  aModel: TSQLModel;
  aServer: TSQLRestServerFullMemory;
  aHTTPServer: TSQLHttpServer;
begin
  // define the log level
  with TSQLLog.Family do begin
    Level := LOG_VERBOSE;
    EchoToConsole := LOG_VERBOSE; // log all events to the console
    PerThreadLog := ptIdentifiedInOnFile;
  end;
  AllocConsole;
  TextColor(ccLightGray); // needed to notify previous AllocConsole
  TModel.CreateModel(aModel);
  try
    aServer := TSQLRestServerFullMemory.Create(aModel,'users.json',false,true);
    try
      TregisterService.RegisterAllServices(AServer);
      aHTTPServer := TSQLHttpServer.Create(PORT_NAME,[aServer],'+',HTTP_DEFAULT_MODE);
      try
        aHTTPServer.AccessControlAllowOrigin := '*'; // for AJAX requests to work
        Sleep(200); // allow all HTTP threads to be launched and logged
        writeln(#10'Background server is running.'#10);
        writeln('Press [Enter] to close the server.'#10);
        ConsoleWaitForEnterKey;
      finally
        aHTTPServer.Free;
      end;
    finally
      aServer.Free;
    end;
  finally
    aModel.Free;
  end;
end;

Also I create a class for registering services and create models and mapping virtual tables that code is :

Type
  TRegisterService=class

  public
   class  procedure RegisterAllServices(var server:TSQLRestServerFullMemory);
   class  procedure RegisterClientServices(var server:TSQLRestClientURI);
  end;

  TModel= Class
  public
   class  Procedure CreateModel(Var Model:TSQLModel);
  End;

  TDatabaseConfiguration=class
  public
   class  procedure RegisterVirtualTable(var model:TSQLModel;
          var Props:TOleDBMSSQL2012ConnectionProperties);
  end;

const
  ROOT_NAME = 'root';
  PORT_NAME = '8888';
  APPLICATION_NAME = 'RestService';

implementation

uses UntConnection,UntIConnection,UntUsers;

{ TRegisterService }

class procedure TRegisterService.RegisterAllServices(
  var server: TSQLRestServerFullMemory);
begin
    Server.ServiceDefine(TConnection,[IConnection],sicClientDriven);
end;

class procedure TRegisterService.RegisterClientServices(
  var server: TSQLRestClientURI);
begin
   Server.ServiceDefine([IConnection],sicClientDriven);
end;

{ TModel }

class procedure TModel.CreateModel(var Model: TSQLModel);
begin
   Model := TSQLModel.Create([TSQLSampleRecord],Root_Name);

end;

{ TDatabaseConfiguration }

class procedure TDatabaseConfiguration.RegisterVirtualTable(
  var model: TSQLModel; var Props: TOleDBMSSQL2012ConnectionProperties);
begin
  VirtualTableExternalMap(Model,TSQLSampleRecord,Props,'TestTable');
end;

My problem is that in Mormot documentation said for using virtualTableExternalMap must use before server.create . But in my code , I want to create server and client send username,password and server name to connect to SQL Server. I don't know with this approach, how to using this function and create external tables on SQL Server.

Thanks a lot

#10 Re: mORMot 1 » Type of Service Application » 2018-07-11 03:56:23

I'm focus on example 16 . "Execute SQL via services". Is this sample is appropriate for me for creating REST server application from this example or not?

#13 Re: mORMot 1 » Type of Service Application » 2018-07-09 15:52:13

Thanks a lot
I want to create a Http server with interface-based services  with MVVM pattern. also in client application I have only UI without any business code.

with this architecture , Can I have a asp.net that connect to this server and working with that?
Would you tell me that this architecture is good or not?

I want to write my core engine with delphi and publish on the web( with buying a dedicated server) and connect to the core from the browser. Also want to create client application (web app) with Angular and asp.net core.
Also in intranet , I want to create client desktop application with Delphi to connect to the Server that is hosted on that intranet.

would you tell me that which architecture is the best for me.?


Thanks .

#14 Re: mORMot 1 » Type of Service Application » 2018-07-09 14:48:34

Thanks a lot.
after creating server application, can I deploy on the web? I don't have a dedicate server.

#15 mORMot 1 » Type of Service Application » 2018-07-09 09:11:17

Hmdsadeghian
Replies: 9

Hi all,
Which type of application must be created for server side services?

I have an old application that want to separate into two physical layers (server and client) , and write business in server side that expose services to the client. Also need to create client side for web and mobile. But I don't know which type of application is appropriate for server side that can publish on the web easily.

Thanks in advance.

#16 mORMot 1 » SQL Server HierarchyID Data Type » 2018-07-09 07:07:00

Hmdsadeghian
Replies: 3

Hi everyone
How can I define HierarchyID with mORMot?

#18 mORMot 1 » Database First problem » 2017-12-13 04:46:57

Hmdsadeghian
Replies: 2

Hi all,

I want to create my db with database project. I create model in Delphi application  and I have two apps that one of them is server and the other is client.
I create schema for tables. but I don't know how to mapping table name with schema in my source code and in my model.
I don't know which I need to use VirtualTableExternalRegister and createmissingtable?

Can you post a sample which how can I do that?

thanks.

#20 mORMot 1 » DDD Samples » 2017-12-04 09:10:38

Hmdsadeghian
Replies: 2

Hi ab,
Do you have any documentation about your DDD samples which explain more such as other samples in your documentation?

Thanks

#23 mORMot 1 » Difference between TSyndaemon and TService » 2017-11-29 19:51:41

Hmdsadeghian
Replies: 2

Hi all,

What is difference between TSyndaemon and Tservice.
In your DDD practical demo , you using TSyndaemon but in other SOA demos, using TService.


Thanks

#24 Re: mORMot 1 » EKON 21 Conference » 2017-11-29 19:08:11

Do you have your presentation powerpoint or pdf files ?
or do you have any videos about DDD?

#25 mORMot 1 » EKON 21 Conference » 2017-11-29 18:51:15

Hmdsadeghian
Replies: 4

Hi ab,

I would like to watch or buying your presentation. how can I buy or downloading those courses?

thank you

#27 Re: mORMot 1 » Difference between DTO and entity » 2017-11-28 09:52:38

Thank you very much AB

Do you have any sample about using DTO and entities with together that how can I mapping between DTO and domain entities?
Your sample about DTO only using DTO .

Thanks again

#28 mORMot 1 » Difference between DTO and entity » 2017-11-27 15:26:00

Hmdsadeghian
Replies: 5

Hi all,

What is difference between DTO vs entities that inherited from TSQLRecord? and when be used?

Thanks in advance

#30 Re: mORMot 1 » Problem with define property in interface » 2017-11-25 10:16:51

Thanks.
But I want to pass value to this property from client. Also I don't know how to using constructor with parameters in client side.
at client side I use this code for using my service

  fClient.ServiceRegisterClientDriven(typeInfo(IConnection),fService);
  fClient.ServiceRegisterClientDriven(typeInfo(IConnectionProperties),fConnectionProperties);
 

But how to using constructor or pass parameters to interface property from client side that property defined const?

Another Question is when the constructor of Class service is called?
for example at below code

 
Type
  TConnection =class(TInterfacedObject,IConnection)
  protected
     fDbProps :TSQLDbConnectionProperties;
     fConnectionProp :IConnectionProperties;
  public
     Constructor create;
     function GetConnectionProp:TConnectionData;
     procedure SetConnectionProp(var aValue :TconnectionData);
     procedure Connect (Var ConnectionData :TConnectionData);
  end;

when the constructor is called? and I don't know that I really need the constructor or not?

#31 mORMot 1 » Problem with define property in interface » 2017-11-25 07:32:15

Hmdsadeghian
Replies: 4

Hi all,

This is my Interface

 
unit UntIConnectionProperties;

interface
uses
  syncommons;

Type
  TConnectionData=packed record
    fServerName :RawUTF8;
    fUserName :RawUTF8;
    fPassword :RawUTF8;
  end;

  IConnectionProperties =Interface(IInvokable)
    ['{391FC485-33AF-42C8-B4C7-1C87EF850D0D}']
    function GetConnectionData: TConnectionData;
    procedure SetConnectionData(aValue :TConnectionData);
    property ConnectionData :TConnectionData read GetConnectionData write SetConnectionData;
  End;

and this is my class

 
unit UntTConnectionProperties;

interface
uses
  UntIConnectionProperties,
  inifiles,
  System.SysUtils,SynCommons;

Type
  TConnectionProperties =Class(TInterfacedObject,IConnectionProperties)
  private
    fConnectionINI: TIniFile;
  public
    constructor create;
    destructor Destroy; override;
    property ConnectionINI :TIniFile read fConnectionINI write fConnectionINI;
    function GetConnectionData:TConnectionData;
    procedure SetConnectionData(aValue :TConnectionData);
  published
    property ConnectionData :TConnectionData read GetConnectionData write SetConnectionData;
  End;

and I register this service with this code

 
    aServer.ServiceRegister(TConnectionProperties,[Typeinfo(IConnectionProperties)],sicClientDriven).
            SetOptions([],[optExecInMainThread,optFreeInMainThread]);

at the compile time I don't have any error but when running service and service want to be register, I get error message that parameter in SetConnectionData must be const,var or out.

how can I solve this problem?

thanks

Board footer

Powered by FluxBB