简体   繁体   English

在 ASP.NET MVC 中,如何避免或提醒人们编辑相同的表单或尝试编辑过时的数据?

[英]In ASP.NET MVC, how can I avoid or alert people from editing the same form or trying to edit stale data?

I have an ASP.NET MVC site, and I have a web page where you can see aa list of orders.我有一个 ASP.NET MVC 站点,还有一个 web 页面,您可以在其中看到订单列表。

You can double-click on a row and that will open up a detail page (an entitled user will see a large form with lot of text boxes, text areas, radio buttons, etc.).您可以双击一行,这将打开一个详细信息页面(授权用户将看到一个带有大量文本框、文本区域、单选按钮等的大表单)。

Originally there was only one entitled person to an order, so no issues, but now the users are forming teams and in some cases there are several people (10+) that are entitled to edit the same order, so they may have the detail web page up at the same time.最初只有一个有权编辑订单的人,所以没有问题,但现在用户正在组建团队,在某些情况下有几个人(10+)有权编辑同一个订单,所以他们可能有详细信息 web同时向上翻页。

There are two issues that now exists.现在存在两个问题。

  1. People are now complaining that they are making changes that are immediately getting overridden, because other people are editing the same orders at the same time and it's creating a lot of confusion.人们现在抱怨他们所做的更改立即被覆盖,因为其他人在同一时间编辑相同的订单,这造成了很多混乱。

  2. If people are leaving the detail page up all day, they might have a very old version of the view (as multiple other people may have saved changes throughout the day).如果人们整天都离开详细信息页面,他们可能会有一个非常旧的视图版本(因为其他人可能一整天都保存了更改)。 Nothing notified them that their version of the page is out of date and then should refresh the page before editing.没有任何通知他们他们的页面版本已过时,然后应该在编辑之前刷新页面。

I am looking for suggestions on the best way to deal with the two issues above.我正在寻找有关处理上述两个问题的最佳方法的建议。

Also, if there are certain libraries or patterns that can be leveraged (versus building something from scratch).此外,如果有某些库或模式可以利用(相对于从头开始构建)。

Regarding concurrency, you have two options:关于并发,您有两种选择:

  1. Pessimistic concurrency (locking).悲观并发(锁定)。

    You need to implement a locking system where you issue locks on readonly or update/delete您需要实施一个锁定系统,在该系统中您对只读或更新/删除发出锁定

  2. Optimistic concurrency乐观并发

    Add a LastUpdated timestamp column to your table and use it in WHERE (along with the ID) on update/delete.LastUpdated时间戳列添加到您的表中,并在更新/删除时在WHERE (连同 ID)中使用它。 If 0 rows are affected, then you are trying to update/delete out of date data.如果 0 行受到影响,那么您正在尝试更新/删除过时的数据。

Read this about how to handle this in ASP.NET MVC with Entity Framework .在 ASP.NET MVC with Entity Framework中阅读有关如何处理问题的信息。

You can also implement a system to notify that users on the same page.您还可以实施一个系统来通知同一页面上的用户。 One way is to use SignalR and creating a group per page.一种方法是使用SignalR并为每个页面创建一个 You can broadcast in realtime that the values where changed and even load the new values.您可以实时广播更改的值,甚至加载新值。

暂无
暂无

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

相关问题 ASP.net MVC 2.0 使用同一个表单进行添加和编辑 - ASP.net MVC 2.0 using the same form for adding and editing 如何在ASP.NET MVC中处理同一表单上的编辑和删除按钮? - How to handle an edit and delete button on the same form in ASP.NET MVC? 如何让我的控制器从他在 ASP.NET MVC 中的一个视图中捕获表单提交的数据 - How can I make my controller catch the data submitted by a form from one of his views in ASP.NET MVC 如何避免ASP.NET MVC中的多个表单提交? - How to avoid multiple submit of form in ASP.NET MVC? 如何在同一项目中的ASP.NET MVC控制器中从ASP.NET Web API获取数据 - How get data from asp.net web api in asp.net mvc controller in the same project 如何使用JavaScript从ASP.Net MVC中的表单获取“验证消息”的值? - How can I get the value of Validation Message from form in ASP.Net MVC, using javascript? 如何从ASP.NET MVC中的同一操作重定向到另一个视图或外部站点? - How can I redirect to either another view or an external site from the same action in ASP.NET MVC? 如何从ASP.NET MVC中的控制器调用JavaScript警报 - How to invoke javascript alert from controller in asp.net mvc 如何在 ASP.NET Core MVC 中的 Edit 方法的下拉字段中显示 selectedValue(来自数据库) - How can I display the selectedValue (from database) in a dropdown-field from the Edit method in ASP.NET Core MVC 我如何在ASP.NET C#MVC3中将数据从数据表导出到Excel? - How can i export the data from a data table to excel in asp.net c# mvc3?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM