将 IntraWeb 应用程序作为服务运行时访问事件

发布于 2024-10-01 02:34:18 字数 214 浏览 3 评论 0原文

我正在将独立的 Intraweb 应用程序作为服务运行。现在我需要实现一个函数来编写 数据库表的“心跳”时间戳。我已经在其他使用的服务应用程序中完成了此操作 TService Classm,我可以在其中使用 OnAfterInstall、OnExecute 等事件。

有没有一种方法可以在作为服务运行的独立网络内应用程序中使用这些事件?

感谢

沃尔夫冈提供的所有信息

I'm running my Standalone Intraweb App as a service. Now i need to implement a function that writes
a "heartbeat" timestamp to a database table. I've done this in other service app that uses
the TService Classm where i can use Events like OnAfterInstall, OnExecute etc.

Is there a way i can use that events in a standalone intraweb app running as service ?

Thanks for all info

Wolfgang

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

栖竹 2024-10-08 02:34:18

我开始在我自己的 Intraweb 应用程序中执行此操作,但因为 IWServiceWizard 隐藏了包括主执行循环在内的服务详细信息,所以我在服务器端完成了所有操作,我使用的是应用程序模式。

我在会话类上定义了一个心跳方法(RunSQL 是我自己的数据访问层对象 DBConnection 上的一个方法,这可能是 TADOConnection 的一个简单包装器)。

function TIWUserSession.UpdateHeartbeat: boolean;
var
  sSQL : string;
begin
  sSQL := 'UPDATE Heartbeats SET LastComms = getdate()'+
          ' WHERE SessionID = '+ IntToStr(FSessionID);

  Result := DBConnection.RunSQL(sSQL);
end;

完成此操作后,每当用户打开新网页时调用此方法(例如)就很简单了。

procedure TIWMyPage.IWAppFormCreate(Sender: TObject);
begin
  inherited;

  Session.UpdateHeartbeat;
end;

只要用户执行与服务器通信的操作,即使它是异步事件 (AJAX),也可以使用此方法。

procedure TIWMyPage.btnRefreshAsyncClick(Sender: TObject; 
  EventParams: TStringList);
begin
  Session.UpdateHeartbeat;
end;

I started doing exactly this in my own Intraweb application, though because the IWServiceWizard hides the service details including the main Execute loop, I did it all server-side, I was using Application Mode.

I defined a heartbeat method on my session class (RunSQL is a method on my own Data Access Layer object DBConnection, this could be a simple wrapper around TADOConnection).

function TIWUserSession.UpdateHeartbeat: boolean;
var
  sSQL : string;
begin
  sSQL := 'UPDATE Heartbeats SET LastComms = getdate()'+
          ' WHERE SessionID = '+ IntToStr(FSessionID);

  Result := DBConnection.RunSQL(sSQL);
end;

Once I'd done this it was trivial to call this method (for example) whenever a user opened a new web page.

procedure TIWMyPage.IWAppFormCreate(Sender: TObject);
begin
  inherited;

  Session.UpdateHeartbeat;
end;

This can also be used whenever the user does something that communicates with the server, even if it's an asynchronous event (AJAX).

procedure TIWMyPage.btnRefreshAsyncClick(Sender: TObject; 
  EventParams: TStringList);
begin
  Session.UpdateHeartbeat;
end;
优雅的叶子 2024-10-08 02:34:18

Intraweb 支持 TIWTimer,因此将时间戳发送到数据库应该非常简单。编码的细节取决于详细规范。

Intraweb supports TIWTimer, so sending a timestamp to the database should be pretty straightforward. Specifics of coding depend on detailed specifications.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文