客户端向服务器发送信息并保存到数据库

发布于 2024-11-19 15:55:21 字数 250 浏览 2 评论 0原文

在我的 C# 应用程序中,客户端应将日志发送到服务器,并且相同的日志必须保存在 SQL Server 数据库中。 我应该如何做到这一点:

  • 客户端将日志保存在数据库中,服务器从数据库中读取 - 而不是(长延迟)
  • 客户端将日志保存在数据库中并同时将它们发送到服务器
  • 客户端仅发送到服务器,服务器将它们保存在数据库中

哪种方式更有效正确的?

编辑
LAN 网络中有很多客户端

In my C# app client should send logs to server and the same logs must be save in SQL Server database.
How should I do this:

  • client saves log in DB and server read from DB - rather not (long delay)
  • client saves log in DB and simultaneously sends them to the server
  • client only send to server and server saves them in DB

which way is more correct?

EDIT
There's many clients in the LAN network

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

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

发布评论

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

评论(2

獨角戲 2024-11-26 15:55:22

你的第二个选择是不行的!永远不要把一件事做两次。

我想说,如果您的客户端已经连接(并写入)到数据库,那么您的客户端也应该将任何日志直接写入数据库。 (选项 1)。在任何其他情况下,选项 3 似乎是最合适的。

Your second option is a no-go! Never do a single thing twice.

I'd say if your client already connects (and writes) to the database then your client should also write any logs directly into the database. (Option 1). In any other case option 3 seems the most appropriate.

愿得七秒忆 2024-11-26 15:55:21

让客户端仅与服务器通信。服务器将分析来自客户端的信息。然后,服务器将信息写入数据库和/或对客户端采取操作。这样,您就能够立即对客户端采取行动,并将信息保存在数据库中以供以后使用。这也是有道理的,因为只有一台计算机能够写入 SQL,而不是许多客户端都单独写入......

Have the client communicate only with the server. The server would analyze the information from the client. The server then writes the information to the database and/or takes action on the client. This way you get the ability to immediately act on the client and save the information in the database for possible use later. It also makes sense because then only one computer is able to write to SQL instead of your many clients all writing individually...

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