Jump to content

Recommended Posts

Posted

Hi all,

sometimes it happened that a form in two different sessions shared the same data module. What techniques should I adopt to avoid this from happening?

Posted

Hello,

Each user session in uniGUI should have its own instance of the DataModule.

Could you please clarify your specific case a bit more?
For example, where and how are you creating the DataModule?

Posted

Ciao,

Now I use this constructor for any TUniFrame inherited from TfmUGBase,  that are inserted in a TUniTabSheet, so it works very fine.

 

//TfmUGDialog is a TUniFrame

function TfmUGDialog.GetDataModule<T>(DMClass: TDataModuleClass): T;
begin
  Result := T(UniApplication.UniMainModule.GetModuleInstance(DMClass));
end;

 

//TfmUGBase inherit from TfmUGDialog

constructor TfmUGBase.CreateService(AOwner : TComponent; SqlConnection : TFDCustomConnection; aDataModuleClass : TDataModuleClass; aEnv : TAmbiente; Modulo : string; connectmode : TUserProfileLevel);
begin
  inherited CreateService(AOwner, SqlConnection, aDataModuleClass, aEnv, Modulo, connectmode);

  //create of datamodule

  FInstanceDM := GetDataModule<TdmUGBase>(aDataModuleClass);
  FInstanceDM.InitChild(SqlConnection, connectmode);
  FInstanceDM.Ambiente := aEnv;

  // binding of Datasource property of each data-aware component in the frame with TDatasource in FInstanceDM

  BindAllDataSourcesToSessionModule(FInstanceDM)
end;

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...