Jump to content

jlrozano

Members
  • Posts

    13
  • Joined

  • Last visited

Posts posted by jlrozano

  1. Dear Juan,

     

    thanks for the quick responce.

    Indeed in this way is works fine.

     

    Does that mean that all the sqlquery's also has to be defined in the

    TUniMainModule part or is this only valid for the variables.

     

    Again thank you very much and kindly regards

    Leo Nillesen.

     

     

    I don't understand what you mean with'sqlquery's'. TSQLQuey components? In any case, when you drag and drop a TQuery component into UniMainModule, it's a private field of object UniMainModule, so it's private for this session, (each seassion have it's own TQuery Object). Any component, object or variable defined as part of TUniMainModule class is private for each session because each session has it's own TUniMainModule object via UniMainModule function.

  2. Yes, both sessions can see the GV_data content because it's a module global var.

     

    If you declare GV_data as TUniMainModule var, then both session have it own GV_Data and can't see the value of another session var:

     

    TUniMainModule = class(TUniGUIMainModule)

    private

     

    public

    { Public declarations }

    GV_data: String;

    end;

     

    .....

     

    procedure TMainForm.UniButton1Click(Sender: TObject);

    begin

    UniMainModule.GV_Data := UniEdit1.Text;

    end;

     

    procedure TMainForm.UniButton2Click(Sender: TObject);

    begin

    UniEdit2.Text := UniMainModule.GV_Data;

    end;

  3. As far I understand, each session create it owned TUniMainModule object, so, each field (not class var) of it, is unique for this session and only can accessed by this session.

     

    However, a global var or class var (static class var), are common to all session. It's as application variables, instead session variables. This var types can be accessed by all session and must be protected by critical section

  4. Thank you! Very nice idea!

    In application, I think the object should be created in ServerModule.....Right?

    If someone can make a example, it would be better.

     

     

    This class can be defined into a new unit. When you need a connection, use it. It is a static class, so it is shared by all sessions. Only use as example:

     

    var

    LCn: TConnection;

    begin

    ....

    LCn := TConnectionPool.Get;

    try

    <your code>

    finally

    TConnectionPool.Release(cn);

    end;

  5. I think you can use a static class as

     

     

    TConnectionPool = class

    private

    class var FConnectionList: TThreadList;

    class procedure CloseAll;

    public

    class function Get: TConnection;

    class procedure Release( cn: TConnection);

    end

     

    .....

     

    function TConnectionPoll.Get;

    var

    LList: TList;

    begin

    LList := FConnectionList.LockList;

    try

    if LList.Count = 0 then

    Result := TConnection.Create(....)

    else

    begin

    Result := TConnection(LList[0]);

    LList.Delete(0);

    end

    finally

    FConnectionList.UnLockList;

    end;

    end;

     

     

    procedure TConnectionPool.CloseAll;

    var

    LList: TList;

    LIndex: integer;

    begin

    try

    for LIndex := 0 to LList.Count-1 do

    TConnection(LLIst.Free);

    LList.Clear;

    finally

    FConnectionList.UnLockList;

    end;

    end;

     

    procedure TConnectionPool.Release(cn: TConnection);

    var

    LList: TList;

    begin

    LList := FConnectionList.LockList;

    try

    if LList.Count< MaxPoolSize then

    LList.Add(cn)

    else

    cn.Free;

    finally

    FConnectionList.UnLockList;

    end;

    end;

     

    ....

     

    initialization

    TConnectionPool.FConnectionList := TThreadList.Create;

    finalization

    TConnectionPool.CloseAll;

    TConnectionPool.FConnectionList.Free;

    End..

     

    ( code is not real, only as example idea).

     

    Use:

     

    ....

    var

    LCn: TConnection;

    begin

    ....

    LCn := TConnectionPool.Get;

    try

    <your code>

    finally

    TConnectionPool.Release(cn);

    end;

    .....

  6. Use TFileFileUpload OnComplete event:

     

    procedure TNuevoPedido.UniFileUpload1Completed(Sender: TObject;

    AStream: TFileStream);

    var F: TFileStream;

    begin

    UniListBox1.Items.Add(UniFileUpload1.FileName);

    F:= TFileStream.Create('<Your file name and path',fmCreate);

    F.CopyFrom(ASTream);

    F.Free;

    end;

×
×
  • Create New...