Jump to content

toufik

Members
  • Content Count

    75
  • Joined

  • Last visited

Posts posted by toufik


  1. @Remy Lebeau thanks alot for taking a time to reply  ,,,now its work with small change

    in line 
     

    TDialogService.MessageDialog('you are gonna edit something ', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes], TMsgDlgBtn.mbYes,0,

    to 

     

     TDialogService.MessageDialog('you are gonna edit something ', TMsgDlgType.mtConfirmation, [TMsgDlgBtn.mbYes, TMsgDlgBtn.mbNo], TMsgDlgBtn.mbYes, 0,


  2. good morning every one ..
    its work just fine in windows ,, and in android its doesn't execute the procedure called StartLogin10 after the user choses yes ,, nothing happen ....can someone help please thanks ...
    i have this code below :
    procedure TFrmLogin.SpeedButton5Click(Sender: TObject);
    var Reply : Integer;
    begin
    if (lst2.Items.Count <> 0) and (lst2.ItemIndex <> -1)then
    begin
    Reply := 0;
    TDialogService.MessageDialog('you are gonna edit something ', TMsgDlgType.mtInformation, [TMsgDlgBtn.mbYes], TMsgDlgBtn.mbYes,0,
    procedure(const AResult: TModalResult)
    begin
    Reply := AResult;
    end
    );
    if Reply =mrYes then
    StartLogin10 ;********************************************
    end else ShowMessage( 'you have cancel the operation');
    end else
    ShowMessage('chose something from the list');

  3. 43 minutes ago, Serge_G said:

    Hi,

    Well, logic, yes.  

    Depending on the REST API server function. 

    On another side a TListview (livebinded) for only 10 records a VerticalScrollbox filled by code should be a good alternative,

    IMO getting previous page and next page (30 records) during thread process should be better

    thank you for taking time to reply .


  4. good morning every one ^^...
    TListView Paging****
    is this look logic to you ?
    a mobile app + rest .
    I want to be able to get 10 record every time .
    so how about putting the last record i get every time and send it back to the server side to get 10 more record starting with it ,,,,and so on ...
    is this look ok to you thank you

  5. hello every one can some one help convert Thorse procedure unit to Tdwserverevent thank you in advance the code on Thorse are:
    unit uServico;
     
    interface
    uses Horse, System.SysUtils, DataSet.Serialize;
    procedure Servico(App: THorse);
    procedure Get(Req: THorseRequest; Res: THorseResponse; Next: TProc);
    implementation
    uses dmPrincipal;
     
    procedure Get(Req: THorseRequest; Res: THorseResponse; Next: TProc);
    begin
    try
    try
    DataModule1 := TDataModule1.Create(nil);
    DataModule1.FDQuery1.Close;
    if req.Params.Count > 0 then
    begin
    DataModule1.FDQuery1.FetchOptions.RecsSkip:= strtointdef(req.Params.Items['pagina'],1) * strtointdef(req.Params.Items['max'],1);
    DataModule1.FDQuery1.FetchOptions.RecsMax:= strtointdef(req.Params.Items['max'],1);
    end;
    DataModule1.FDQuery1.Open();
    Res.Send(DataModule1.FDQuery1.ToJSONArray.ToJSON);
    finally
    Res.Status(200);
    FreeAndNil(DataModule1);
     
    end;
    except
    on e: exception do
    begin
    Res.Send(e.Message);
    Res.Status(400);
     
    end;
    end;
    end;
    procedure Servico(App: THorse);
    begin
    App.Get('/saler/:pagina/:max', Get);
     
    end;
     

  6. hi every one
    can some one help me with problem
    I'm using Delphi REST with server and client but when i tried to show data on the client side its show only one row for some reason,
    what did i do wrong ?
    PS : I'm using Delphi roi and restdataware 
    the video down show what I'm deal with ; any help will be very appreciated ^^ thank you 
    on the client side i'm using this code 
     

    procedure listv;
    var

        jsonObj : TJsonObject;
        json, sucesso, erro,id_store ,nom_store, phone_saler: string;
    begin
      //  FrmLogin.FloatAnimation2.Stop;
       // FrmLogin.FloatAnimation3.Stop;
      if FrmLogin.listvreq.Response.JSONValue = nil then
        begin
          //  FrmLogin.ExibirCampos;
            ShowMessage('خطأ في إنشاء الحساب (JSON غير صالح)');
            exit;
        end;

        try
            json := FrmLogin.listvreq.Response.JSONValue.ToString;
            jsonObj := TJSONObject.ParseJSONValue(TEncoding.UTF8.GetBytes(json), 0) as TJSONObject;

            sucesso := jsonObj.GetValue('sucesso').Value;
            erro := jsonObj.GetValue('erro').Value;
          id_store := jsonObj.GetValue('id_store').Value;
             nom_store := jsonObj.GetValue('nom_store').Value;
              if sucesso <> 'S' then
            begin
             //   FrmLogin.ExibirCampos;
                ShowMessage(erro);
                exit;
            end
            else

              // showmessage('تم احضار بيانات: ' + id_store+nom_store);

              //  FrmLogin.ExibirCampos;///

             //   FrmLogin.ListView1.Items.Clear();
        finally
            jsonObj.DisposeOf;
        end;

        end;

      procedure listverr(Sender: TObject);
    begin
        if Assigned(Sender) and (Sender is Exception) then
        begin
          //  FrmLogin.ExibirCampos;
            showmessage(Exception(Sender).Message);
        end;
    end;

    procedure TFrmLogin.StartLogin2;
    begin
      TThread.CreateAnonymousThread(
        procedure
        var
          Success: Boolean;
        begin
          try
            RequestLogin.Execute;
            Success := RequestLogin.Response.Status.Success;
          except
            Success := False;
          end;
          TThread.Queue(nil,
            procedure
            begin
              AfterLogin2(Success);
            end
          );
        end
      ).Start;
    end;

    procedure TFrmLogin.AfterLogin2(Success: Boolean);
     begin
        if Success then
       begin

    listvreq.Params.Clear;
    listvreq.AddParameter('type_store',ComboBox1.Selected.Text);  ///   ****
    listvreq.ExecuteAsync(listv, true, true, listverr);
       end
       else
      begin
    showmessage (' عفوا ...! لايمكن الاتصال بالخادم حاليا يرجى المحاولة لاحقا')
      end;


    on server side :

     


    procedure Tdm.DWEventsEventslistvReplyEvent(var Params: TDWParams;
      var Result: string);
    var
        type_store, erro : string;
        usuario : TUsuario;
        json : TJsonObject;
    begin
        try
            sleep(4000);
            type_store := Params.ItemsString['type_store'].AsString;

            json := TJsonObject.Create;

            usuario := TUsuario.Create(dm.conn);
            usuario.type_store := type_store;

            if NOT usuario.listv(erro) then
            begin
                //{"sucesso": "N", "erro":"Usuلrio nمo informado", "codusuario":"0"}
                json.AddPair('sucesso', 'N');
                json.AddPair('erro', erro);
             json.AddPair('id_store', '');
               json.AddPair('nom_store', '');
            end
            else
            begin
                json.AddPair('sucesso', 'S');
                json.AddPair('erro', '');
              json.AddPair('id_store', usuario.id_store.ToString);
                 json.AddPair('nom_store', usuario.nom_store);
            end;

            Result := json.ToString;

        finally
            json.DisposeOf;
            usuario.DisposeOf;
        end;

     

    and in class  i add called unit usuario
     

    function TUsuario.listv(out erro: string): Boolean;
    var
        qry : TFDQuery;

    begin
        try
            qry := TFDQuery.Create(nil);
            qry.Connection := FConn;

            with qry do
            begin
                Active := false;
                SQL.Clear;
    SQL.Add('SELECT * from saler  WHERE type_store = :any ');
                 ParamByName('any').Value := type_store;
                        Active := true;

                            if RecordCount > 0 then
                begin
                  id_store := FieldByName('id_store').AsInteger;
                      nom_store := FieldByName('nom_store').AsString;
                 erro := '';
                    Result := true;
                end
                else
                begin
                  //  id_store := 0;
                    erro := 'تعذر جلب بيانات المعلنين';
                    Result := false;
                end;

                DisposeOf;
            end;

        except on ex:exception do
        begin
            erro := 'خطأ في التحقق من صحة تسجيل الدخول: ' + ex.Message;
            Result := false;
        end;
        end;


     

     


  7. hello every on , i'm using this code to loop a sqllite database field called 'photos' and not doing the job for me 

    im using a timer for that named tmr1 
    where is the problem please thank you 

    ps : this loop stop when one of  fields  value is empty 
    tmr1.Enabled := False;
    if not FDTableTask.IsEmpty and not FDTableTask.FieldByName('photos').IsNull and
    FileExists(FDTableTask.FieldByName('photos').asString) then
      begin
     FDTableTask.next;
    // ImageEnView2.PrepareTransition;
     // ImageEnView2.RunTransition( TIETransitionType( 1 + random( ord( High( TIETransitionType )) - 2 )), 550);
    //  tmr1.Enabled := true;
     while  FDTableTask.EOF do begin
      FDTableTask.First;
    end;
    end;
    tmr1.Enabled := true;


  8. hello every one 
     I want to play videos one by one , when one finished the second one start and that on ,like slidshow but with videos not pictures ,

    using tMediaPlayer ,how can I approach that ? or is there a way to detect when start and end of a  video ?thank you 


  9. good morning every one ^^ how is every one doing ))
    1- i have fmx android app that s create sqllite db on create ,what's  the location of db on the phone and is it const location ? (does not change for every other phones)
    2- what's the proper way to copy it from that location to sd card (backup) ?
    thanks and take care ☺️

  10. 36 minutes ago, John van de Waeter said:

    Hi Tufik,

     

    Hard to say. You included camera, Database, ZXing, min/targetedSDK tweaking, etc.

    Too many things that can cause problems.

     

    Start with a blank app. Make sure it runs on all tested devices.

    Then add features one by one.


    true and thanks for reply and the advice i will try it 

     


  11. Hello every one ...
    I have this very important  question and its help a lot if any one can help me with it,
    I have an FMX  app working normally on some Android versions 5 and 5.1 and 4.4 and with some medication on Android 10  

    and not working at all on other one ,its crash in startup in 6 and 9  ,and on android 7.1 and 8 its stuck on splash screen 

    i have SDK and NDK and JAVA files set up correctly like the images shown bellow ,I did edit the AndroidManifest.template.xml so  minSdkVersion="19"  and targetSdkVersion="29"
    by the way the app request Camera permission and connect to fire-Dec database app on create cause im using ZXing project in my app 

    what's I'm missing here .

     

    1.png

    2.png

    3.png

    4.png

    7.png


  12. On 9/15/2020 at 1:05 AM, Remy Lebeau said:

    The simplest option is to use either TThread.CreateAnonymousThread(), eg:

    
    uses
      ..., System.Classes;
    
    procedure TFrmLogin.StartLogin;
    begin
      TThread.CreateAnonymousThread(
        procedure
        var
          Success: Boolean;
        begin
          try
            RequestLogin.Execute;
            Success := RequestLogin.Response.Status.Success;
          except
            Success := False;
          end;
          TThread.Queue(nil,
            procedure
            begin
              AfterLogin(Success);
            end
          );
        end
      ).Start;
    end;
    
    procedure TFrmLogin.AfterLogin(Success: Boolean);
    begin
      if Success then
      begin
        ShowMessage ('server up');
        do something ...
      end else
      begin
        ShowMessage ('server down');
        do something else ...
      end;
    end;

    Or similarly, TTask.Run():

    
    uses
      ..., System.Threading;
    
    procedure TFrmLogin.StartLogin;
    begin
      TTask.Run(
        procedure
        var
          Success: Boolean;
        begin
          try
            RequestLogin.Execute;
            Success := RequestLogin.Response.Status.Success;
          except
            Success := False;
          end;
          TThread.Queue(nil,
            procedure
            begin
              AfterLogin(Success);
            end
          );
        end
      );
    end;
    
    procedure TFrmLogin.AfterLogin(Success: Boolean);
    begin
      if Success then
      begin
        ShowMessage ('server up');
        do something ...
      end else
      begin
        ShowMessage ('server down');
        do something else ...
      end;
    end;

     

    I can't thank you  enough ,thank s a lot  


  13. Hi all Delphier , good morning 😀😀
    i have rest firemonkey app ,server , client
    im trying to check if the server is up or down from the client side using the code below , the code work fine , but when i run it its freeze the app for a while
    is there any proper way to do this ,thank you ,🤓☺️

    try

    RequestLogin.Execute;

    if FrmLogin.RequestLogin.Response.Status.Success then

    begin

    showmessage ('server up')
    do something .....

    end

    else

    except on e : exception do

    begin

    showmessage (' server down.... go home ')

    end

    end;


  14. i did get this form the programmer  who has written NetCom7 :
    you can pass that information to the server by packing it in the aData parameter (for example, you could pack the other client's info and the data with a TStringList.CommaText and pass that as aData). Now, the server will have to unpack the aData, again using TStringList.CommaText,
    and i'm trying it right now 


  15. @aehimself
    Thank a lot for  reply , and yes there is demo folder , but it s missing what  i'm looking for ,
    the demos contain chat application ,that all client can see the text message that one client sent 
    'see the picture'
    and i want like i said before 
    client 1 select client 2 to text with privately , i hope you understand the idea 

     

    Untitled.png


  16. hello,I'm nob , and i did tried today NetCom7 and i would like to say
    what an amazing project very fast , believe me i know because we have very low connection speed where i live ,
    any way ,

    i would like to ask you if any one can give us more demos or example about for example chat communication between two selected clients

    lets say client one , select client two to chat with , how do you implement that .
    thank you all and have a Delphi day

    link:
    https://github.com/DelphiBuilder/NetCom7

×