08-19-2020, 08:59 PM
I have some SA programs that have worked for years and am in the process of moving to a different host system which runs in a virtual machine. Some of my Intraweb 15 programs run fine but others crash every night on the VM, even though, to the best of my knowledge I designed them all the same way and they never did so on the old physical machine. Original code was developed in Intraweb 5 with changes where forced on me during compiling since then as I have moved to more recent versions of Intraweb.
I am wondering whether part of the issue may be due to the way I use TUserSession rather than TIWUserSession in many cases because I have multiple datamodules in each program.
What exactly is the purpose and difference between a UserSession and a IWUserSession. Recent examples in the Intraweb documentation use a UserSessionUnit which is mostly based on TIWUserSession and declare links to datamodules within this. Is it better to do things this way or should it not matter?
Any suggestions for ways to improve or implement a currently preferred way to do things would be appreciated. I have also noted in various documentation that since IW 14 one should declare the aSession as a descendent of TIWUserSession with (nil, aSession) but, since I use UserSessions, this does not compile.
My current general program structure is to have, say, two datamodules with definitions something like the following
unit datamodule1;
interface
uses
various items listed here;
type
Tdatamodule1 = class(TDataModule)
various data components;
private
public
published
end;
function datamodule1: Tdatamodule1;
implementation
use
various items here;
function datamodule1: Tdatamodule1;
Result := TUserSession(WebApplication.data).datamodule1;
end;
various procedure here;
end.
In the ServerController unit I have:
unit ServerController;
interface
uses
datamodule1name, datamodule2name,
various other items listed here;
type
TIWServerController = class(TIWServerControllerBase)
procedure IWServerControllerBaseNewSession(aSession: TIWApplication);
procedure IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
various data components;
private
public
end;
TUserSession = class(TComponent)
public
MainForm : TMainForm;
datamodule1 : Tdatamodule1;
datamodule2 : Tdatamodule2;
various other usersession items defined here;
end;
function UserSession: TUserSession;
function IWServerController: TIWServerController;
implementation
uses
various items defined here;
function IWServerController: TIWServerController;
begin
Result := TIWServerController(WebApplication.Data);
end;
function UserSession: TUserSession;
begin
Result := TUserSession(WebApplication.Data);
end;
procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
vMainForm := TMainForm.Create(WebApplication);
end;
procedure TIWServerController.IWServerControllerBaseNewSession(aSession := TIWApplication);
begin
aSession := TUserSession.Creat(nil);
end;
procedure TUserSession.Destroy;
begin
various items get destroyed here;
inherited Destroy;
end;
end.
I am wondering whether part of the issue may be due to the way I use TUserSession rather than TIWUserSession in many cases because I have multiple datamodules in each program.
What exactly is the purpose and difference between a UserSession and a IWUserSession. Recent examples in the Intraweb documentation use a UserSessionUnit which is mostly based on TIWUserSession and declare links to datamodules within this. Is it better to do things this way or should it not matter?
Any suggestions for ways to improve or implement a currently preferred way to do things would be appreciated. I have also noted in various documentation that since IW 14 one should declare the aSession as a descendent of TIWUserSession with (nil, aSession) but, since I use UserSessions, this does not compile.
My current general program structure is to have, say, two datamodules with definitions something like the following
unit datamodule1;
interface
uses
various items listed here;
type
Tdatamodule1 = class(TDataModule)
various data components;
private
public
published
end;
function datamodule1: Tdatamodule1;
implementation
use
various items here;
function datamodule1: Tdatamodule1;
Result := TUserSession(WebApplication.data).datamodule1;
end;
various procedure here;
end.
In the ServerController unit I have:
unit ServerController;
interface
uses
datamodule1name, datamodule2name,
various other items listed here;
type
TIWServerController = class(TIWServerControllerBase)
procedure IWServerControllerBaseNewSession(aSession: TIWApplication);
procedure IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
various data components;
private
public
end;
TUserSession = class(TComponent)
public
MainForm : TMainForm;
datamodule1 : Tdatamodule1;
datamodule2 : Tdatamodule2;
various other usersession items defined here;
end;
function UserSession: TUserSession;
function IWServerController: TIWServerController;
implementation
uses
various items defined here;
function IWServerController: TIWServerController;
begin
Result := TIWServerController(WebApplication.Data);
end;
function UserSession: TUserSession;
begin
Result := TUserSession(WebApplication.Data);
end;
procedure TIWServerController.IWServerControllerBaseGetMainForm(var vMainForm: TIWBaseForm);
begin
vMainForm := TMainForm.Create(WebApplication);
end;
procedure TIWServerController.IWServerControllerBaseNewSession(aSession := TIWApplication);
begin
aSession := TUserSession.Creat(nil);
end;
procedure TUserSession.Destroy;
begin
various items get destroyed here;
inherited Destroy;
end;
end.