N 层与 C#?

发布于 2024-09-12 20:22:42 字数 300 浏览 1 评论 0原文

我正在考虑编写一个 WinForms 应用程序,并被一个看似简单的问题所困扰。

有一个服务器和数据库(SQL Server)开放端口是HTTP,HTTPS

有一个WinForms客户端。它需要将 TCP/IP 流(可能是 HTTP、SOAP、REST)连接到服务器。

有时,WinForms 客户端会离线,然后 WinForms 客户端会将其数据存储在数据库中。

当WinForms客户端与服务器联机时,将数据同步到服务器,从服务器获取所有最新数据并更新本地数据库。

我该怎么做?

新手问题

I am looking at writing a WinForms app and getting stumped over what seems to be simple issue.

There is a server and database (SQL Server) Open ports are HTTP, HTTPS

There is a WinForms client. It needs to connect a TCP/IP stream (possibly HTTP, SOAP, REST) to the server.

Sometimes the WinForms client goes off-line and then the WinForms client stores its data in a database.

When the WinForms client goes on-line to server, it synchronizes data to the server, gets all the latest data from the server and updates local database.

How do I do that?

Newbie question

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

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

发布评论

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

评论(7

故人如初 2024-09-19 20:22:42

正如您所承认的,这个问题表明您可能不知道从哪里开始寻找如何构建此类应用程序。

我从这里开始: http://msdn.microsoft.com/en- us/library/ms973279.aspx

对于新手来说,您描述的离线架构比不支持此架构要困难一些,请考虑首先使应用程序仅在线工作,然后添加离线功能。

另外,如果您有 Web 服务器,您几乎总是会使用 HTTP,SOAP 和 REST 是基于 HTTP 的策略。我不建议新开发人员查看使用直接 TCP/IP 的任何服务器通信。

编辑:回答相关问题 - 有大量的 ORM 和服务构建器,其中没有很多内置了对离线工作流程的支持,但 ODX 确实如此,但它可能有点过时了。 NHibernate 和 Castle 项目中的任何项目都是非常受欢迎的组件,适合您想要做的事情。

As you've conceded, this question shows you might not know where to begin looking for how to architect this kind of application.

I'd start here: http://msdn.microsoft.com/en-us/library/ms973279.aspx

The offline architecture you've described is a little tougher for a newbie than not supporting this, consider making the application only work online first, then add offline functionality.

Also, if you have a web server you will almost always use HTTP, SOAP and REST are strategies that sit on top of HTTP. I cannot recommend that a new developer look at any server communication using direct TCP/IP.

Edit: Answer to related question - there are tons of ORMs and service builders, not a lot of them have built in support for offline workflow but ODX does, but it might be a bit out of date. NHibernate and any of the projects in the Castle Project are very popular components for what you're looking to do also.

凶凌 2024-09-19 20:22:42

不知道微软对此的支持有多积极,但您可以查看智能客户端软件工厂,它似乎支持您需要的离线模式和智能重新连接。

http://msdn.microsoft.com/en-us/library/ff709809。 ASPX

No idea how actively this is still being supported by Microsoft, but you might check out the Smart Client Software Factory, it seems to support offline mode and smart reconnecting like you need.

http://msdn.microsoft.com/en-us/library/ff709809.aspx

ゃ懵逼小萝莉 2024-09-19 20:22:42

您可以用“服务”思维来解决这个问题 - 编写一个 WebService(最好是 WCF 服务) - 它形成 Winforms 应用程序之间的同步层。和远程数据库。

所以,你会有你的
1.本地WinformsApp。使用本地数据库(如您所希望的功能/轻量级)
2.Web服务
3.远程应用程序/DB

You could approach this with a 'Service' mindset - Write a WebService (preferably a WCF service) - that forms the synchronization tier between your Winforms app. and remote database.

So, you would have your
1. Local WinformsApp. with a local database (as functional/lightweight as you want it to be)
2. WebService
3. Remote app./DB

<逆流佳人身旁 2024-09-19 20:22:42

恕我直言,这通常不像听起来那么简单

  • 如果您能够从数据库到数据库,那么 SQL 复制可能是最简单的同步机制。
  • 但是,由于听起来您正在使用 SOA 方法,因此您可能需要查看内置离线支持的框架,例如 Ent Lib 复合应用程序块 和智能客户端软件工厂
  • 您还可以考虑使用队列(例如 MSMQ)来解决网络连接问题。

IMHO this isn't usually as simple as it may sound

  • If you were able to go DB to DB, then SQL replication could be the simplest mechanism for synchronisation.
  • However, since it sounds like you are using a SOA approach, you might need to look at frameworks which have offline support built in, such as the Ent Lib Composite Application Block and Smart Client Software Factory
  • You might also look at using Queues (e.g. MSMQ) to accomodate network connectivity problems.
羁绊已千年 2024-09-19 20:22:42

Microsoft 同步框架 (http://code.msdn.microsoft.com/sync) + WCF解决方案在这里:
http://code.msdn.microsoft.com/sync/ Release/ProjectReleases.aspx?ReleaseId=3762

无论如何,数据库同步并不是一项容易上手的任务。祝你好运。

Microsoft Sync Framework (http://code.msdn.microsoft.com/sync) + WCF solution here:
http://code.msdn.microsoft.com/sync/Release/ProjectReleases.aspx?ReleaseId=3762

Database synchronisation is not an easy task to get started with, by any means. Good luck.

少女的英雄梦 2024-09-19 20:22:42

通常,您需要一个本地数据库,或者至少需要一个本地缓存。

Generally, you need a local database, or at least a local cache.

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