SPModerationInformation.Status property
Obtém ou define um valor que especifica o status de aprovação de conteúdo para um item.
Namespace: Microsoft.SharePoint
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Syntax
'Declaração
Public Property Status As SPModerationStatusType
Get
Set
'Uso
Dim instance As SPModerationInformation
Dim value As SPModerationStatusType
value = instance.Status
instance.Status = value
public SPModerationStatusType Status { get; set; }
Property value
Type: Microsoft.SharePoint.SPModerationStatusType
Um valor de SPModerationStatusType que especifica o status.
Examples
O exemplo de código a seguir aprova todos os itens pendentes em um conjunto de sites e retorna o local do item aprovado.
Dica
Para obter informações sobre como usar consultas Language-Integrated Query (LINQ) para recuperar itens de lista em SharePoint Foundation, consulte Managing Data with LINQ to SharePoint.
Dim siteCollection As New SPSite("https://localhost")
Dim subSites As SPWebCollection = siteCollection.AllWebs
Dim site As SPWeb
For Each site In subSites
Dim lists As SPListCollection = site.Lists
Dim list As SPList
For Each list In lists
If list.BaseType = SPBaseType.DocumentLibrary Then
Dim docLibrary As SPDocumentLibrary = _
CType(list, SPDocumentLibrary)
If Not docLibrary.IsCatalog AndAlso _
docLibrary.EnableModeration = True Then
Dim allItemsQuery As New SPQuery()
allItemsQuery.ViewAttributes = _
"ModerationType='Moderator'"
Dim docLibItems As SPListItemCollection = _
docLibrary.GetItems(allItemsQuery)
Dim docLibItem As SPListItem
For Each docLibItem In docLibItems
If docLibItem.ModerationInformation.Status = _
SPModerationStatusType.Pending Then
Console.WriteLine((site.Url + "/" + _
docLibItem.File.Url))
docLibItem.ModerationInformation.Comment = _
"Automatic Approval of items"
docLibItem.ModerationInformation.Status = _
SPModerationStatusType.Approved
docLibItem.Update()
End If
Next docLibItem
End If
End If
Next list
Next site
using (SPSite oSiteCollection = new SPSite("https://localhost"))
{
SPWebCollection collWebsites = oSiteCollection.AllWebs;
foreach (SPWeb oWebsite in collWebsites)
{
SPListCollection collLists = oWebsite.Lists;
foreach (SPList oList in collLists)
{
if (oList.BaseType == SPBaseType.DocumentLibrary)
{
SPDocumentLibrary oDocumentLibrary = (SPDocumentLibrary)oList;
if (!oDocumentLibrary.IsCatalog && oDocumentLibrary.EnableModeration ==
true)
{
SPQuery oQuery = new SPQuery();
oQuery.ViewAttributes =
"ModerationType='Moderator'";
SPListItemCollection collListItems =
oDocumentLibrary.GetItems(oQuery);
foreach (SPListItem oListItem in collListItems)
{
if (oListItem.ModerationInformation.Status ==
SPModerationStatusType.Pending)
{
Console.WriteLine(oWebsite.Url + "/" +
oListItem.File.Url);
oListItem.ModerationInformation.Comment =
"Automatic Approval of items";
oListItem.ModerationInformation.Status =
SPModerationStatusType.Approved;
oListItem.Update();
}
}
}
}
}
oWebsite.Dispose();
}
}
Dica
Determinados objetos implementam a interface IDisposable , e você deve evitar reter esses objetos na memória depois que eles não são mais necessários. Para obter informações sobre boas práticas de codificação, consulte Disposing Objects.