学习011-03-04 Optimistic Concurrency Control(乐观并发控制)

Optimistic Concurrency Control(乐观并发控制)

The optimistic concurrency control (OCC) mechanism is used in XAF applications if you inherit from any of the base persistent classes (with the exception of the XPLiteObject). This topic describes how data collisions are handled in an XAF application.
如果您从任何基本持久类(XPLiteObject除外)继承,则在XAF应用程序中使用乐观并发控制(OCC)机制。本主题介绍如何在XAF应用程序中处理数据冲突。

Object-Level Locking(对象级锁定)

Consider the following scenario. Two users access the same object, and edit it from different workstations. The first user makes modifications to the object’s properties and persists them in a database. The second user also makes modifications, but tries to persist them after the first user has already done so. In this case, the second user will receive the following message.
考虑以下场景。两个用户访问同一个对象,并从不同的工作站对其进行编辑。第一个用户对对象的属性进行修改并将它们持久化在数据库中。第二个用户也进行修改,但在第一个用户已经这样做之后尝试持久化它们。在这种情况下,第二个用户将收到以下消息。

In WinForms applications:
在WinForms应用程序中:
在这里插入图片描述

In ASP.NET Web Forms applications:
在ASP.NET Web窗体应用程序中:
在这里插入图片描述

After refreshing the object (if required), the second user will be able to make modifications against the renewed object and persist them. If the first user deleted the object, the second user will not be able to make any modifications, and will instead receive the following message.
刷新对象后(如果需要),第二个用户将能够针对更新的对象进行修改并将其持久化。如果第一个用户删除了对象,第二个用户将无法进行任何修改,而是会收到以下消息。

在这里插入图片描述

Field-Level Locking(字段级锁定)

In multi-user data-aware applications, there are times when one user edits a record while another user is editing the same record. As long as the changes being made do not affect the same field (e.g., one user modifies the task description while another user attaches a file), XAF applications can resolve the situation, and merge simultaneous changes made by different users. To enable field-level locking, set the static XpoDefault.TrackPropertiesModifications property to true.
在多用户数据感知应用程序中,有时一个用户编辑记录,而另一个用户正在编辑同一记录。只要所做的更改不影响同一字段(例如,一个用户修改任务描述,而另一个用户附加文件),XAF应用程序就可以解决这种情况,并合并不同用户同时进行的更改。要启用字段级锁定,请将静态XpoDefault.TrackPropertiesModifications属性设置为true。

In the Program.cs file of a WinForms application project:
在WinForms应用程序项目的Program. cs文件中:

C# 
static void Main() {
    DevExpress.Xpo.XpoDefault.TrackPropertiesModifications = true;
    // ...
}

In the Global.asax.cs file of an ASP.NET Web Forms application project:
在ASP.NET Web Forms应用程序项目的Global. asax.cs文件中:

C# 
protected void Session_Start(object sender, EventArgs e) {
    DevExpress.Xpo.XpoDefault.TrackPropertiesModifications = true;
    // ...
}

When this property is set to true and a user modifies an object that was already changed by another user, a dialog window that suggests merging changes is displayed.
当此属性设置为true并且用户修改已被其他用户更改的对象时,将显示一个建议合并更改的对话框窗口。

In WinForms applications:
在WinForms应用程序中:
在这里插入图片描述

In ASP.NET Web Forms applications:
在ASP.NET Web窗体应用程序中:
在这里插入图片描述

Merging is possible when users modify the values of different fields. If both users change the same field value, merging is not possible, and the user can either refresh data or cancel saving.
当用户修改不同字段的值时,可以合并。如果两个用户都更改了相同的字段值,则无法合并,用户可以刷新数据或取消保存。

In WinForms applications:
在WinForms应用程序中:
在这里插入图片描述

In ASP.NET Web Forms applications:
在ASP.NET Web窗体应用程序中:
在这里插入图片描述

The dialogs illustrated above are provided by the ProcessDataLockingInfoController Controller from the SystemModule module.
上面显示的对话框由SystemModule模块中的ProcessDataLockingInfoController控制器提供。

Note
To see field-level locking in action, refer to the Concurrent Modifications section of Feature Center demo installed with XAF. By default, the Feature Center demo is installed in %PUBLIC%\Documents\DevExpress Demos 24.1\Components\XAF\FeatureCenter.NETFramework.XPO.
要查看正在运行的字段级锁定,请参阅随XAF安装的功能中心演示的并发修改部分。默认情况下,功能中心演示安装在%PUBLIC%\Documents\DevExpress Demos 24.1\Components\XAF\FeatureCenter. NETFramework.XPO中。

View-Level Locking(视图级锁定)

Besides concurrency control at the data level, the LockController from the SystemWindowsForms module tracks changes at the View level (in WinForms applications). It displays the following message when an object is being modified in two or more different Views.
除了数据级别的并发控制之外,SystemWindowsForms模块中的LockController还在View级别(在WinForms应用程序中)跟踪更改。当一个对象在两个或多个不同的视图中被修改时,它会显示以下消息。
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

汤姆•猫

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值