(Guid) del método SPAlertCollection.Delete
Elimina la alerta con el GUID especificado de la colección.
Espacio de nombres: Microsoft.SharePoint
Ensamblado: Microsoft.SharePoint (en Microsoft.SharePoint.dll)
Sintaxis
'Declaración
Public Sub Delete ( _
idAlert As Guid _
)
'Uso
Dim instance As SPAlertCollection
Dim idAlert As Guid
instance.Delete(idAlert)
public void Delete(
Guid idAlert
)
Parámetros
idAlert
Tipo: System.GuidPara eliminar la alerta.
Excepciones
Excepción | Condición |
---|---|
SPException | La alerta no existe o acaba de eliminar. |
Comentarios
Este método elimina la alerta especificada de la base de datos.
Ejemplos
En el ejemplo de código siguiente se recorre en iteración todos los sitios Web en la colección de sitios actual y elimina las alertas de un usuario especificado.
Private Sub Button1_Click(sender As Object, e As System.EventArgs)
Dim siteCollection As SPSite = SPControl.GetContextSite(Context)
Dim sites As SPWebCollection = siteCollection.AllWebs
Dim site As SPWeb
For Each site In sites
DeleteAlerts(site)
Next web
End Sub 'Button1_Click
Public Sub DeleteAlerts(site As SPWeb)
Dim users As SPUserCollection = site.Users
Dim user As SPUser
For Each user In users
If user.LoginName = TextBox1.Text Then
Dim alerts As SPAlertCollection = user.Alerts
Dim i As Integer
For i = alerts.Count - 1 To 0 Step -1
Dim guid As System.Guid = alerts(i).ID
alerts.Delete(guid)
Next i
End If
Next user
Dim subsite As SPWeb
For Each subsite In web.Webs
DeleteAlerts(subsite)
Next subsite
End Sub 'DeleteAlerts
private void Button1_Click(object sender, System.EventArgs e)
{
SPSite oSiteCollection = SPContext.Current.Site;
SPWebCollection collWebsites = oSiteCollection.AllWebs;
foreach (SPWeb oWebsite in collWebsites)
{
DeleteAlerts(oWebsite);
oWebsite.Dispose();
}
}
public void DeleteAlerts(SPWeb oWebsite)
{
SPUserCollection collUsers = oWebsite.Users;
foreach (SPUser oUser in collUsers)
{
if (oUser.LoginName == TextBox1.Text)
{
SPAlertCollection collAlerts = oUser.Alerts;
for (int i = collAlerts.Count - 1; i > -1; i--)
{
System.Guid guid = collAlerts[i].ID;
collAlerts.Delete(guid);
}
}
}
Nota
Determinados objetos implementan la interfaz de IDisposable y, a continuación, se debe evitar la conservación de estos objetos en la memoria que ya no se necesitan. Para obtener información acerca de buenas prácticas de codificación, vea Disposing Objects.