Jump to content

hendrang

Members
  • Posts

    55
  • Joined

  • Last visited

  • Days Won

    1

Posts posted by hendrang

  1. Use critical sections for this.

     

    Hello Farshad Mohajeri,

     

    Thank you for your help.

     

    It works with critical sections.

     

    I have another question. :)

    Is it possible to reject / terminate concurrent call a procedure/function,

    in this case not using critical section.

    I mean the second client call for the procedure/function will be informed that

    the procedure/function is being called by other client.

     

    Thanks

  2. Hi All,

     

    How to prevent a procedure/function been called simultaneously by 2 or more clients ?

     

    I use a global variable as a flag.

    code like this :

    var
     isCalled: Boolean; // Global variable
    
    function TMainForm.UpdateData: Boolean;
    begin
     if isCalled then
       Exit(False); // exit cause this function is being called by other client
    
     isCalled:= True; 
     .
     <my code>
     <my code>
     .
     isCalled:= False; // set isCalled to False in order other client can call this function
     Exit(True);
    end;
    

     

    It works but I think this is not safe because there is still possibility this function been called

    simultaneously if this function is called at the same time by two or more clients.

     

    is there any other way ?

     

    Thanks in advance.

    Hendra

  3. In unigui applications, each user session can't share same vars/objects, becouse each user session have her own thread, then better way is create ojects/vars into unimainmodule.

     

    Remove ClientModule1 from autocreate, declare public var on mainmodule class, and create it on mainmodule.oncreate

     

    procedure TUniMainModule.UniGUIMainModuleCreate(Sender: TObject);
    begin
     Client:=TClientModule1.Create(self);
    end;

     

    then, in mainform you must access UnimainModule.Client

     

    Procedure TMainForm.UniBitBtn1Click(Sender: TObject);
    var
     i,x: Integer;
    begin
     UniListBox1.Clear;
     for I := 1 to 10 do begin
       x:= UniMainModule.Client.ServerMethods2Client.RetValue(i);
       UniListBox1.Items.Add(IntToStr(x));
     end;
    end;

     

    Hello Docjones,

     

    I works, problem solved. :)

     

    Thanks for your help.

  4. Hi all,

     

    My unigui apps call a simple function in a Datasnap application simultaneously.

    I am using Delphi XE.

     

    the function in Datasnap is:

    function TServerMethods2.RetValue(aVal:Integer): Integer;
    begin
     Sleep(1000); // pause execution for simulating simultaneous execution
     Exit(aVal);
    end;

    the function just return back the parameter value, no other calculation.

     

    and the code to call the RetValue function in uniGui application :

    procedure TMainForm.UniBitBtn1Click(Sender: TObject);
    var
     i,x: Integer;
    begin
     UniListBox1.Clear;
     for I := 1 to 10 do begin
       x:= ClientModule1.ServerMethods2Client.RetValue(i);
       UniListBox1.Items.Add(IntToStr(x)); // Return value in listbox
     end;
    end;
    

     

    and the correct result is :

    post-930-0-76166400-1354233797.jpg

     

    but if I call the DataSnap function simultaneously by opening the uniGui in two firefox tabs, it retuns variety

    wrong value.

     

    post-930-0-24353800-1354233986.jpg post-930-0-17451000-1354233994.jpg

     

     

    post-930-0-82027600-1354234051.jpg post-930-0-39842000-1354234043.jpg

     

     

    How can I solve the problem and thanks in advance.

     

    Thanks

    Hendra

  5. The easiest (but not the best) way is to create a hidden unilabel and store variable in its caption so you can access it in client browser.

    The right way is to create your own "namespace" in javascript globals and store variables there with UniSession.AddJS(), something like this

     

    window.MyVars = window.MyVars || {};
    window.MyVars.Salary = 1000;
    
    ...
    
    function OnClick(sender, e)
    {
     if window.MyVars.Salary < 10000 then ...
    
    

     

    Hi. Thanks for your help.

  6. Hi All,

     

    Please help.

    I am newbie in Web Application

     

    I want the ClientEvent OnClick Execute ajaxRequest with EventName depend on an variable value declare in MainForm

     

    For example :

     

    Salary is variable declare in MainForm

     

    function OnClick(sender, e)

    {

    if (Salary < 10000)

    {

    ajaxRequest(sender, 'Event1');

    }

    else

    {

    ajaxRequest(sender, 'Event2');

    }

    }

     

    Please help me to correct the function above.

     

    Thanks in advance.

  7. Did you install on the 2.22.22.222 computer

    the Firebird client.

    Since you're using ADO did you install, configure and test the ODBC driver ?

     

    Hi,

    Firebird server run on 2.22.22.222 (Web server) and 3.33.33.333 (client computer)

    Maybe Firebird server need not run on 2.22.22.222 (Web server) cause Database now on 3.33.33.333, I will test it later.

     

    I use Anydac not ADO, not configure and test the ODBC driver.

  8. Can you ping db server from web server?

    Hi, thanks and sorry for my late reply.

     

    Yes I can ping db Server(client computer) from web server and vice versa.

     

    And the process connecting database is done in client computer, this mean

    the user in client computer try to connect his local database.

     

    I also try to remote connect the client database (I can ping the client computer) from my computer with Desktop application (create with VCL Delphi not uniGUI) but failed either.

     

    the error message is :

     

    Unable to complete network request to host 'xx.xx.xxxx' <- client ip address

    failed to establish a connection.

     

     

    I used to be able remote connect the client database use the desktop application but now fail to connect.

     

    So I think this is not because of UniGUI application, but network connection problem.

     

    I use Logmein Hamachi to connect client computer.

  9. Hi All,

     

    I am using AnyDac component and firebird database.

     

    Suppose that the Web Server IP Address is 2.22.22.222 and the web application

    want to connect database reside in client computer (IP Address 3.33.33.333)

     

    with code like this :

     

    idx:= ADConnection1.Params.IndexOfName('Database');

    ADConnection1.Params[idx]:= 'Database= 3.33.33.333:C:\Employee.fdb';

    ADConnection1.Connected:= True;

     

    raise Ajax Error : Server unavailable

     

    My plan is not to host the web application and the database in the same computer.

     

    as I read article Database Security Best Practices :

     

    Separate the Database and Web Servers

     

    so that mean the web application computer and database server computer will have different IP Address.

     

    Thanks in advance.

  10. You save local and like upload the file to web?

    Then you must use UniFileUpload, for

    Download use unisession.sendfile.

     

    Ok, I will try it in my client computer tomorrow

    unisession.sendfile act like download file so client user may should open the file first

    and then save it to the target directory.

     

     

    Thanks.

  11. Hi,

     

    no problem, use UniSession.SendFile Method for this.

     

    We do the same, we create a Excel file with flexcelreport from TMS

    and the Unisession.sendfile method.

     

    Hi Gerhard Kimmeringer, Thank you for your help.

     

    I am new in web application,

    can you kindly help what the code in my case use UniSession.SendFile Method,

    I am using NativeExcel.

    Suppose the client user want to save the excel to directory C:\Reports

     

    In desktop application the code is :

    WorkBook.SaveAs('c:\Reports\Report.xls');

     

    Regards,

    Hendra

  12. Hi All,

     

    My application need to convert data to Excel file and save the Excel file to client computer (harddisk/flash disk).

     

    Can web Application save the Excel to Client Computer ?

     

    with code :

     

    WorkBook.SaveAs('c:\Report.xls');

     

    the report.xls will be saved in web server harddisk not in the client harddisk.

     

     

    Thanks in advance

  13. Hi All,

     

    uniDBGrid has a different behavior in editting a cell value between desktop and web mode.

    In desktop mode, in a selected cell we can just type a new value then the selected value will be overwrite,

    but in web mode before typing we should type Enter key to unselect the cell value.

     

    How can I change this behavior so in web mode dbgrid can be like in desktop mode ?

     

    thank in advance

     

    Sorry for my bad english.

×
×
  • Create New...