SharePoint 2007:如何在事务中执行一系列操作?

发布于 2024-07-14 01:03:18 字数 270 浏览 9 评论 0原文

我很想知道如何在事务中的 SharePoint 上下文中执行一系列操作。 例如,我希望能够执行如下操作:

context.BeginTransaction();
listItemA.Update();
listItemB.Update();
context.CommitTransaction();

我知道使用 OOTB API 不可能做到这一点,但必须有人弄清楚如何实现这一点。 是否可以获取对数据库连接的引用来处理事务? 或者还有其他想法吗?

I would love to know how to perform a series of operations in a SharePoint context within a transaction. For example, I would like to be able to do something like the following:

context.BeginTransaction();
listItemA.Update();
listItemB.Update();
context.CommitTransaction();

I know this isn't possible with the OOTB APIs, but someone has got to have figured out how to accomplish this. Is it possible to get a reference to the database connection in order to handle the transaction? Or any other ideas?

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

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

发布评论

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

评论(6

神仙妹妹 2024-07-21 01:03:19

只需使用 Recycle() 即可。 在 GUID[] 中跟踪 GUID。 如果打开 RecycleBin 失败
并通过 GUID 恢复/删除所有内容

GUID[] guids = new GUID[];
SPWeb web;
SPListItem item;
SPList list;

try
{
    foreach item in list

    GUID current = item.Recycle()
    guids.add(current);

    item.Delete();
}
catch{
    if one fails : web.RecycleBin.Restore(guids);
}

if all succeed : web.RecycleBin.Delete(guids):

Simply use Recycle(). Keep track of the GUID in a GUID[]. If one fails open de RecycleBin
and restore/delete all by GUID

GUID[] guids = new GUID[];
SPWeb web;
SPListItem item;
SPList list;

try
{
    foreach item in list

    GUID current = item.Recycle()
    guids.add(current);

    item.Delete();
}
catch{
    if one fails : web.RecycleBin.Restore(guids);
}

if all succeed : web.RecycleBin.Delete(guids):
祁梦 2024-07-21 01:03:19

如果您使用版本控制,您可以尝试签出项目、执行更新并签入的解决方案。如果需要回滚,只需撤消签出即可。

也许可以工作?

If you use versioning you could try a solution that checks out your item, performs updates and checks in. If rollback is needed, just undo the checkout.

Could work maybe??

一场春暖 2024-07-21 01:03:19

另一种选择是使用工作流程,此处提到。 如 Windows SharePoint Services 如何处理工作流活动中所述:

Windows SharePoint Services 运行
工作流程直到到达某个点
它无法继续进行,因为它是
等待某个事件发生:for
例如,用户必须指定一个任务
已完成。 只在这个“承诺”
点”Windows SharePoint
服务提交所做的更改
以前的 Windows SharePoint
特定于服务的工作流活动。
这些更改被批量化为
单个 SQL 事务。

Another option is to use workflow, mentioned here. As stated in How Windows SharePoint Services Processes Workflow Activities:

Windows SharePoint Services runs the
workflow until it reaches a point
where it cannot proceed because it is
waiting for some event to occur: for
example, a user must designate a task
as completed. Only at this "commit
point" does Windows SharePoint
Services commit the changes made in
the previous Windows SharePoint
Services-specific workflow activities.
Those changes are batched into a
single SQL transaction.

猥︴琐丶欲为 2024-07-21 01:03:19

没有Sharepoint 不提供类似SQL 服务器的事务功能。

正如 Rutger Hemrika 所言,这是一种比我迄今为止见过的任何其他方法都要好得多的方法。

No Sharepoint does not provide SQL server like transaction capability.

As Rutger Hemrika posted, thats a far better way of doing it than anyhing else that I have seen until now.

烦人精 2024-07-21 01:03:19

Sharepoint 不提供开箱即用的事务支持。 这是关于 为 SharePoint 构建 System.Transactions 资源管理器 的一个很好的资源,尽管我会保存并将任何关键数据直接存储到 RDB 中。

Sharepoint does not offer transaction support out of the box. Here is a good resource on Building a System.Transactions resource manager for SharePoint Though I would save the effort and store any critical data directly into a RDB.

凑诗 2024-07-21 01:03:18

尽管 SharePoint 在技术上使用 SQL 作为存储支持,但我们不应该将其视为基于数据库的应用程序。 SP 创建了某种虚假文件系统,我们通过 API 与之交互。 因此,从开发人员的角度来看,Sharepoint 几乎不需要交易。

不幸的是,这几乎就是它的全部内容了:) 即使考虑尝试直接参与数据库也会导致旧约痛苦。 撕裂衣服、哀嚎、咬牙切齿;)

Although SharePoint technically uses SQL as a storage backing, we're not supposed to treat it like a database-based application. SP creates a faux-filesystem of sorts, which is what we interact with via the API. So from the developer perspective, Sharepoint is pretty much transaction-less.

Unfortunately that's pretty much all there is to it :) Even thinking about trying to get involved with the database directly will result in Old Testament pain. Rending of garments, wailing and gnashing of teeth ;)

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