SPListItem.SystemUpdate 方法
命名空间: Microsoft.SharePoint
程序集: Microsoft.SharePoint(位于 Microsoft.SharePoint.dll 中)
语法
声明
Public Sub SystemUpdate
用法
Dim instance As SPListItem
instance.SystemUpdate()
public void SystemUpdate()
备注
当调用SystemUpdate方法时,事件被触发修改报告更改日志和审核日志中,但不是会发送通知并属性未被降级到文档。
调用此方法是调用SystemUpdate(Boolean)与false相同。
示例
下面的示例是一个控制台应用程序使用SystemUpdate方法对列表项进行更改。
Imports System
Imports Microsoft.SharePoint
Module ConsoleApp
Sub Main()
Using site As SPSite = New SPSite("https://localhost")
Using web As SPWeb = site.OpenWeb()
Dim list As SPList = web.GetList("/lists/announcements/")
If list.ItemCount > 0 Then
' Get an item to modify.
Dim item As SPListItem = list.Items(0)
' Report the current state of the item.
ReportState("Before", item)
' Modify it.
If item.HasUniqueRoleAssignments Then
item.ResetRoleInheritance()
Else
item.BreakRoleInheritance(True)
End If
' Update without changing the modified time.
item.SystemUpdate()
' Report the new state of the item.
ReportState("After", item)
End If
End Using
End Using
Console.ReadLine()
End Sub
Sub ReportState(ByVal state As String, ByVal item As SPListItem)
Console.WriteLine(state)
Console.WriteLine("HasUniqueRoleAssigments: {0}", item.HasUniqueRoleAssignments)
Console.WriteLine("Modified: {0}", item(SPBuiltInFieldId.Modified))
If item.Fields.ContainsField("Modified_x0020_By") Then
Console.WriteLine("Modified by: {0}", item(SPBuiltInFieldId.Modified_x0020_By))
End If
Console.WriteLine()
End Sub
End Module
using System;
using Microsoft.SharePoint;
namespace Test
{
class ConsoleApp
{
static void Main(string[] args)
{
using (SPSite site = new SPSite("https://localhost"))
{
using (SPWeb web = site.OpenWeb())
{
SPList list = web.GetList("/lists/announcements/");
if (list.ItemCount > 0)
{
// Get an item to modify.
SPListItem item = list.Items[0];
// Report the current state of the item.
ReportState("Before", item);
// Modify it.
if (item.HasUniqueRoleAssignments)
item.ResetRoleInheritance();
else
item.BreakRoleInheritance(true);
// Update without changing the modified time.
item.SystemUpdate();
// Report the new state of the item.
ReportState("After", item);
}
}
}
Console.ReadLine();
}
static void ReportState(string state, SPListItem item)
{
Console.WriteLine(state);
Console.WriteLine("HasUniqueRoleAssigments: {0}", item.HasUniqueRoleAssignments);
Console.WriteLine("Modified: {0}", item[SPBuiltInFieldId.Modified]);
if (item.Fields.ContainsField("Modified_x0020_By"))
Console.WriteLine("Modified by: {0}", item[SPBuiltInFieldId.Modified_x0020_By]);
Console.WriteLine();
}
}
}