本文整理汇总了C#中SPListItem.UpdateOverwriteVersion方法的典型用法代码示例。如果您正苦于以下问题:C# SPListItem.UpdateOverwriteVersion方法的具体用法?C# SPListItem.UpdateOverwriteVersion怎么用?C# SPListItem.UpdateOverwriteVersion使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPListItem
的用法示例。
在下文中一共展示了SPListItem.UpdateOverwriteVersion方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ApproveItem
private static bool ApproveItem(SPWeb web, SPList list, SPListItem item)
{
string url = SPUtility.ConcatUrls(web.Site.Url, item.ParentList.DefaultDisplayFormUrl + "?ID=" + item.ID);
try
{
if (list.EnableVersioning && list.EnableModeration)
{
web.AllowUnsafeUpdates = true;
if (item.ModerationInformation != null)
{
if (item.ModerationInformation.Status != SPModerationStatusType.Approved)
{
SPUser spUser = Utility.GetUserById(web, AuditLogger.User);
item[SPBuiltInFieldId.Editor] = spUser;
item.UpdateOverwriteVersion();
item.ModerationInformation.Status = SPModerationStatusType.Approved;
item.ModerationInformation.Comment = string.Format("Approved by IntegrityCheck on behalf of {0} on {1}", spUser.Name, DateTime.Now.ToString());
item.SystemUpdate();
string details = "Approved by IntegrityCheck";
AuditLogger.LogApprovalStatus(item.Title + "|" + url, details);
return !AuditLogger.IsError;
}
else
{
log.TraceWarning(string.Format("Item {0}?ID={1} is already approved", SPUtility.ConcatUrls(item.Web.Url, item.ParentList.DefaultDisplayFormUrl)));
return true;
}
}
}
}
catch (Exception ex)
{
log.TraceException(ex);
RecordLastException(ex);
string details = "Error occurred while approving content by Integrity Check. Details: " + ex.Message;
AuditLogger.LogException(item.Title + "|" + url, details);
}
return false;
}