SPListItem item = list.GetItemById(99);
bool IsPublished = (item.Versions[0].Level == SPFileLevel.Published)
[LogException]
public override void ItemUpdating(SPItemEventProperties properties)
{
base.ItemUpdating(properties);
if (properties.ListItem == null)
return;
var item = properties.ListItem;
if (IsItemPublishing(item))
{
OnItemPublishing(item);
}
}
private bool IsItemPublishing(SPListItem item)
{
var iBefore = Convert.ToString(properties.BeforeProperties["vti_level"]);
var iAfter = Convert.ToString(properties.AfterProperties["vti_level"]);
return (item.Level == SPFileLevel.Published && iBefore.Equals("1") && iAfter.Equals("1"));
}
private void OnItemPublishing(SPListItem item)
{
// ...
}
if (documentList.EnableModeration && documentList.EnableVersioning)
{
foreach(var item in documentList.Items)
{
if(item.ModerationInformation.Status != SPModerationStatusType.Approved) continue;
var allVersions = item.Versions;
foreach (SPListItemVersion version in allVersions)
{
if (version.Level == SPFileLevel.Published)
{
yield return version.ListItem;
}
}
}
}