Git Product home page Git Product logo

quickorm's People

Contributors

exilon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

quickorm's Issues

exceptions on sample delphi/ORMRestServerDemo

First of all thanks for your effort, making the awsome mormot more easy to be used.

Change the search path of the project from "....\common" to "..\common;" in the client and server project.

To run the sample ORMRestServerDemo without exceptions in delphi 10.3 CE I have to rewrite the line in unit ORMRestServer.dpr:

//    RestServer.Security.Groups['Operator'].Table('AGroup').AllowAll.CanDelete := False;
    RestServer.Security.Groups['Operator'].Table('AGroup').AllowAll;
    RestServer.Security.Groups['Operator'].Table('AGroup').CanDelete := False;

and add the line:
Login := TLogin.Create;
after the line:
User := TAUser.Create;

and install your other librari exilon/QuickLogger wiht delphinus, I think it should be added as a dependency in delphinus and commented in the readme.md.

In the clientmain.pas I've changed

 if assigned(User.Login) then begin
        meInfo.Lines.Add(Format('%s / %d year(s) / LastLogin: %s',[User.Name,User.Age,DateTimeToStr(User.Login.LastLogin)]));
      end
      else begin
        meInfo.Lines.Add(Format('%s / %d year(s) ',[User.Name,User.Age]));
      end;

instead of:

meInfo.Lines.Add(Format('%s / %d year(s) / LastLogin: %s',[User.Name,User.Age,DateTimeToStr(User.Login.LastLogin)]));

In the unit Quick.ORM.RestClient I got several too many arguments in function call when calling spHTTP_Socket, spHTTP_WebSocket, spWebSocketBidir_JSON, spWebSocketBidir_Binary, spWebSocketBidir_BinaryAES, just deleting "False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass," like this all compile and run.

 //          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);

the function modified is:

function TORMRestClient.Connect : Boolean;
begin
  Result := False;
  try
    if fHTTPOptions.AuthMode in [TAuthMode.amDefault,TAuthMode.amSimple] then fDataBase.IncludedClasses := fDataBase.IncludedClasses + [TORMAuthUser] + [TORMAuthGroup];
    fDataBase.Model := TSQLModel.Create(fDataBase.IncludedClasses,fDataBase.aRootURI);

    //Protocol initialization
    case fHTTPOptions.Protocol of
      spHTTP_Socket:
        begin
//        ORM := TSQLHttpClientWinSock.Create(fHost, IntToStr(fPort), fDataBase.Model, False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          ORM := TSQLHttpClientWinSock.Create(fHost, IntToStr(fPort), fDataBase.Model, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWinSock(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
        end;
      spHTTPsys:
        begin
          ORM := TSQLHttpClientWinHTTP.Create(fHost,IntToStr(fPort), fDataBase.Model, False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout,fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWinHTTP(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
          TSQLHttpClientWinHTTP(ORM).Compression := [hcSynShaAes];
        end;
     {$ifdef MSWINDOWS}
      spHTTPsys_SSL:
        begin
          ORM := TSQLHttpClientWinHTTP.Create(fHost,IntToStr(fPort), fDataBase.Model, True, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWinHTTP(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
          TSQLHttpClientWinHTTP(ORM).Compression := [hcSynShaAes];
        end;
     {$endif}
      spHTTPsys_AES:
        begin
          ORM := TSQLHttpClientWinHTTP.Create(fHost,IntToStr(fPort), fDataBase.Model, True, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWinHTTP(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
          TSQLHttpClientWinHTTP(ORM).Compression := [hcSynShaAes];
        end;
      spHTTP_WebSocket:
        begin
//        ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWebsockets(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
        end;
      spWebSocketBidir_JSON:
        begin
//          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWebsockets(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
          (ORM as TSQLHttpClientWebsockets).WebSocketsUpgrade('', True);
        end;
      spWebSocketBidir_Binary:
        begin
//          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWebsockets(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
          (ORM as TSQLHttpClientWebsockets).WebSocketsUpgrade('', False);
        end;
      spWebSocketBidir_BinaryAES:
        begin
//          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, False, fHTTPOptions.ProxyName, fHTTPOptions.ProxyPass, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          ORM := TSQLHttpClientWebsockets.Create(fHost,IntToStr(fPort), fDataBase.Model, fHTTPOptions.SendTimeout, fHTTPOptions.ReceiveTimeout, fHTTPOptions.ConnectTimeout);
          TSQLHttpClientWebsockets(ORM).KeepAliveMS := fHTTPOptions.ConnectionTimeout;
          (ORM as TSQLHttpClientWebsockets).WebSocketsUpgrade(fHTTPOptions.WSEncryptionKey, False);
        end;
      spNamedPipe:
        begin
          ORM := TSQLRestClientURINamedPipe.Create(fDataBase.Model,'\\.\pipe\' + fHTTPOptions.NamedPipe);
        end
    else
      begin
        raise Exception.Create('Protocol not available!');
      end;
    end;

    //Authmode initialization
    case fHTTPOptions.AuthMode of
      amNoAuthentication: //No user Authentication
        begin
          //nothing to do here
          Result := True; //shows as connected ever ???
        end;
      amSimple:
        begin //TSQLRestServerAuthenticationNone (uses user/pass but not signature on client side)
          Result := TSQLRestServerAuthenticationNone.ClientSetUser(ORM,fLogin.UserName,fLogin.HashedPassword,passHashed);
        end;
      amDefault: //TSQLRestServerAuthenticationDefault (uses user/pass with signature on client side)
        begin
          Result := ORM.SetUser(fLogin.UserName,fLogin.HashedPassword,True);
        end;
      amHttpBasic: //TSQLRestServerAuthenticationHttpBasic
        begin
          Result := TSQLRestServerAuthenticationHttpBasic.ClientSetUser(ORM,fLogin.UserName,fLogin.HashedPassword,passHashed);
        end;
      {$IFDEF MSWINDOWS}
      amSSPI: //TSQLRestServerAuthenticationSSPI
        begin
          Result := TSQLRestServerAuthenticationSSPI.ClientSetUser(ORM,fLogin.UserName,fLogin.HashedPassword,passHashed);
        end;
      {$ENDIF}
    else
      begin
        raise Exception.Create('Authentication mode not available');
      end;
    end;

    if Result then
    begin
      //Check TimeSync with Server
      if not ORM.ServerTimeStampSynchronize() then
      begin
        Result := False;
        raise Exception.Create(ORM.LastErrorMessage);
      end;

      //Service initialization
      if fService.Enabled then
      begin
        fService.SetORM(ORM);
        ORM.ServiceDefine([fService.fMethodInterface],fService.fInstanceImplementation);
      end;

      //get Auth Group
      fMyAuthGroup := TORMAuthGroup.CreateAndFillPrepare(ORM,'ID=?',[ORM.SessionUser.GroupRights.ID]);
      if not fMyAuthGroup.FillOne then
      begin
        //raise Exception.Create('No group assigned or error on get group info!');
      end;
    end;
  finally
    if Result then
    begin
      if Assigned(fOnConnect) then fOnConnect;
    end
    else
    begin
      if Assigned(fOnConnectError) then fOnConnectError;
    end
  end;
end;

I hope my comments will be usefull.

ORMRestServer->Exception ECrtsocket (SockRecvLn [10060 WSAETimedout... When accesing from web browser to services and methods

First,. thanks again for your effort and awsome work.

Don't khnow if its mormot problem, quickorm or configuration but when I open services or methods whith chrome like http://127.0.0.1:8099/root/ServiceMethods.Sum?[2,2] i get then following exception:

First chance exception at $741218E2. Exception class ECrtSocket with message 'SockRecvLn [10060 WSAETIMEDOUT "Se produjo un error durante el intento de conexión ya que la parte conectada no respondió adecuadamente tras un periodo de tiempo, o bien se produjo un error en la conexión establecida ya que el host conectado no ha podido responder"]'. Process ORMRestServer.exe (7944)

When I access from ORMRestClient.exe everithing is OK.

I'cant debug it, but found a similar isue at https://synopse.info/forum/viewtopic.php?id=4439

I'm runnint it from delphi 10.3, and I've tried it in Windows 10 in two different computers.

find a bug

find a bug in Quick.ORM.UTF8Helper.pas unit,unit header do not edit ,yet it is Quick.UTF8Helper

Access violation when AuthMode=amNoAuthentication in TORMRestClient.Connect

if I disable authentification in server and client in TORMRestClient.Connect I get an accces violation in the next line:

      //get Auth Group
      fMyAuthGroup := TORMAuthGroup.CreateAndFillPrepare(ORM,'ID=?',[ORM.SessionUser.GroupRights.ID]);

Correct me if Im wrong but, I think this should be enclosed in an if (fHTTPOptions.AuthMode<>amNoAuthentication) then

Sample Errors

2 Issues
Sample in \samples\ORMRestServerDemo\source\delphi
1、 ORMRestServer AV Error
2、ORMRestClient Compile Error: Missing Quick.AppSecurity.pas

Change in TORMDataBase.SetDBFileName

Consider this change in code :
procedure TORMDataBase.SetDBFileName(const dbfname : RawUTF8);
begin
//if dbfile not found, sets as current app dir
// Modificado Juan
if (dbfname = SQLITE_MEMORY_DATABASE_NAME) or TFile.Exists(dbfname) then fDBFileName := dbfname
else fDBFileName := Format('%s%s',[path.EXEPATH,TPath.GetFileName(dbfname)]);
end;
`

And this to compatibility with custom external databases:
function TORMRestServer.Connect(DoCustomDb: TProc): Boolean; .. if not Assigned(DoCustomDb) then case DataBase.DBType of dtSQLite: begin .. end; dtMSSQL: begin .. end else DoCustomDb(); end; .. end;

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.