简体   繁体   English

处理服务断开连接-排队呼叫

[英]Handling Service Disconnection - Queuing Calls

I posted another question recently about a problem i was having with some pattern code, and it was suggested to me that i might not be using the correct pattern to solve my problem in the first place, as such i thought i would post this question. 我最近发布了另一个有关我与某些模式代码有关的问题的问题,并向我建议我可能没有使用正确的模式来解决我的问题,因为我以为我会发布此问题。

The problem i'm trying to solve is such: 我要解决的问题是这样的:

I have a WPF client that will be run from remote offices, it's pretty simple handling data entry and editing, they connect to WCF services hosted at our end (before going to a DB). 我有一个WPF客户端,它将从远程办公室运行,这非常简单,可以处理数据输入和编辑,它们可以连接到我们末端托管的WCF服务(在进入数据库之前)。 The problem is that the client connection is unreliable and can drop out constantly. 问题是客户端连接不可靠,并且会不断丢失。

So, my idea was to use the command pattern, and queue the command (such as update, delete) and when the connection returns execute the commands. 因此,我的想法是使用命令模式,对命令进行排队(例如更新,删除),并在连接返回时执行命令。

However, it was suggested that the command pattern might not be a good fit here. 但是,建议在这里使用命令模式可能不太合适。 So my questions would be: 所以我的问题是:

Is the command pattern a good match? 命令模式很合适吗? If not, why? 如果没有,为什么?

The command pattern will help you to be sure that "all or nothing" of your modifications will be taken into account. 命令模式将帮助您确保将“全部或全部”修改内容考虑在内。 Because you will send only one request to your WCF service, which will unstack all the "commands" and reply by OK/KO. 因为您将仅向WCF服务发送一个请求,该请求将取消堆叠所有“命令”并通过OK / KO进行答复。

But, if your form only exposes one object (if your viewmodel presents only one model), then you just have to call one update WCF method MyClassService.SaveMyObjectAsync(myObject). 但是,如果您的表单仅公开一个对象(如果您的视图模型仅提供一个模型),则只需调用一个更新WCF方法MyClassService.SaveMyObjectAsync(myObject)。 And I don't understand why you would use the command pattern. 而且我不明白为什么要使用命令模式。

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

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