简体   繁体   English

从 winforms 应用程序更新远程 web 数据库的最佳方法

[英]Best way to update remote web database from winforms app

I have a question that is perhaps slightly towards architecture and design rather than syntax problem....我有一个问题可能与架构和设计有关,而不是语法问题......

I have a c# winforms app on my desktop which I have built which is similar to a CRM.我的桌面上有一个 c# winforms 应用程序,它是我构建的,类似于 CRM。 I make updates to customers records as they submit orders/invoices etc and what I would like to do is to build (or buy) a module that will update a remote database that sits behind a website onto hich registered clients log in. I want the clients to be able to see the status of their invoice/purchase etc as I have updated it on the winforms app.我在客户提交订单/发票等时更新他们的记录,我想做的是构建(或购买)一个模块,该模块将更新位于网站后面的远程数据库到注册客户登录。我想要客户能够看到他们的发票/购买等的状态,因为我已经在 winforms 应用程序上更新了它。

I can think of a couple of options of the top of my head but would like to know more if you have done something similar我可以想到几个选项,但如果你做过类似的事情,我想知道更多

Things I am considering are;我正在考虑的事情是;

  1. >Replication - I think this is overkill as the updates are not huge, are one way only, and not critical they are in real time, and also I am running SQL express on the winforms app. >复制 - 我认为这是矫枉过正,因为更新不是很大,只是一种方式,而且并不重要,它们是实时的,而且我在 winforms 应用程序上运行 SQL express。 This can be changed but rather not这可以改变,但不能
  2. >create a text/xml file that gets created and uploaded to the web server to a location that is monitored every 5 minutes and then updates the web database. >创建一个 text/xml 文件,该文件被创建并上传到 web 服务器到每 5 分钟监控一次的位置,然后更新 web 数据库。 - I am not hosting the website myself so I do not have complete control over what I can install but I suspect I can install a .NET 'filewatcher' - 我不是自己托管网站,所以我无法完全控制我可以安装的内容,但我怀疑我可以安装 .NET 'filewatcher'

Anyway, I would appreciate your thought on my 'problem'无论如何,我会很感激你对我的“问题”的想法

thanks谢谢

I think your best bet is to create a web service of some kind (I like using ServiceStack.net to create simple REST ones, much cleaner imo than WCF).我认为您最好的选择是创建某种 web 服务(我喜欢使用 ServiceStack.net 创建简单的 REST 服务,比 WCF 更清洁 imo)。 This will sit on the server and be responsible for the server-side sync piece.这将位于服务器上并负责服务器端同步部分。

On the client, you could either have the winforms app fire off the call to the web service based on some threshold of activity, or you could have a windows service that you install with the winforms app which does it in a scheduled job or on a timer.在客户端上,您可以让 winforms 应用程序根据某些活动阈值触发对 web 服务的调用,或者您可以拥有一个 windows 服务,您可以使用 winforms 应用程序安装该服务,该服务在计划的作业中或在计时器。

You'll want to be sure that you're doing all your calls over SSL of course, and make sure you're authenticating the clients, but that's the basic architectural approach I'd take.当然,您需要确保您通过 SSL 进行所有调用,并确保您正在验证客户端,但这是我将采用的基本架构方法。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM