SPWeb.ProcessBatchData-Methode

Verarbeitet die angegebenen Befehle zum Senden mehrerer Anforderungen an den Server pro Transaktion.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)

Syntax

'Declaration
Public Function ProcessBatchData ( _
    strBatchData As String _
) As String
'Usage
Dim instance As SPWeb
Dim strBatchData As String
Dim returnValue As String

returnValue = instance.ProcessBatchData(strBatchData)
public string ProcessBatchData(
    string strBatchData
)

Parameter

  • strBatchData
    Typ: System.String

    Eine Collaborative Application Markup Language (CAML) , die enthält die Befehle, die aus einer Batch -Element als auch eine beliebige Anzahl von untergeordneten Method Elemente, die in jeder SharePoint Foundation remote Procedure Call (RPC) angeben eines besteht.

Rückgabewert

Typ: System.String
Die Ergebnisse der Prozesse.

Hinweise

Wenn Sie diese Methode verwenden, um ein Dokument in einer Dokumentbibliothek zu löschen, übergeben Sie den Dateipfad der owsfileref -Variablen in die Method -Elemente.

Beispiele

Im folgenden Codebeispiel wird die ProcessBatchData -Methode, um die Ankündigungsliste einer angegebenen Website in der aktuellen Websitesammlung zwei Elemente hinzuzufügen verwendet.

Using webSite As SPWeb = SPContext.Current.Site.OpenWeb("Website")
    Dim list As SPList = webSite.Lists("Announcements")

    Dim guid As System.Guid = list.ID
    Dim myGuid As String = guid.ToString()

    Dim strPost As String = "<?xml version='1.0' encoding='UTF-8'?>" _
        & "<ows:Batch OnError='Return'>" _ 
        & "<Method ID='A1'>" _
            & "<SetList> & myGuid & "</SetList>" _
            & "<SetVar Name='ID'>New</SetVar>" _
            & "<SetVar Name='Cmd'>Save</SetVar>" _
            & "<SetVar Name='urn:schemas-microsoft-com:office:office#Title'>" _
                & "New Manager</SetVar><SetVar Name=" _
                & "'urn:schemas-microsoft-com:office:office#Body'>" _
                & "Congratulations to Mary for her promotion!</SetVar>" _
            & "<SetVar Name=" _
                & "'urn:schemas-microsoft-com:office:office#Expires'>" _
                & "2003-09-14T00:00:00Z</SetVar></Method>" _
        & "<Method ID='A2'>" _
            & "<SetList>" & myGuid & "</SetList>" _
            & "<SetVar Name='ID'>New</SetVar>" _
            & "<SetVar Name='Cmd'>Save</SetVar>" _
            & "<SetVar Name='urn:schemas-microsoft-com:office:office#Title'>" _
                & "New Technical Consultant</SetVar>" _
            & "<SetVar Name='urn:schemas-microsoft-com:office:office#Body'>" _
                & "Welcome to the team, John!</SetVar>" _
            & "<SetVar Name=" _
                & "'urn:schemas-microsoft-com:office:office#Expires'>" _
                & "2003-10-15T00:00:00Z</SetVar></Method></ows:Batch>"

    Dim processBatch As String = webSite.ProcessBatchData(strPost)
End Using
using (SPWeb oWebsite = SPContext.Current.Site.OpenWeb("Website_URL"))
{
    SPList oList = oWebsite.Lists["Announcements"];
    System.Guid guid = oList.ID;
    string strGuid = guid.ToString();

    string strPost = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
        "<ows:Batch OnError=\"Return\">" +
            "<Method ID=\"A1\"><SetList>" + strGuid + "</SetList>" +
                "<SetVar Name=\"ID\">New</SetVar>" +
                "<SetVar Name=\"Cmd\">Save</SetVar>" +
                "<SetVar Name=" +
                    "\"urn:schemas-microsoft-com:office:office#Title\">" +
                    "New Manager</SetVar>" +
                "<SetVar Name=" +
                    "\"urn:schemas-microsoft-com:office:office#Body\">" +
                    "Congratulations to Mary for her promotion!</SetVar>" +
                "<SetVar Name=" +
                    "\"urn:schemas-microsoft-com:office:office#Expires\">" +
                    "2003-09-14T00:00:00Z</SetVar>" + 
            "</Method>" +
            "<Method ID=\"A2\">" +
                "<SetList>" + strGuid + "</SetList>" +
                "<SetVar Name=\"ID\">New</SetVar>" +
                "<SetVar Name=\"Cmd\">Save</SetVar>" +
                "<SetVar Name=" +
                    "\"urn:schemas-microsoft-com:office:office#Title\">" +
                    "New Technical Consultant</SetVar>" +
                "<SetVar Name=" +
                    "\"urn:schemas-microsoft-com:office:office#Body\">" +
                    "Welcome to the team, John!</SetVar>" +
                "<SetVar Name=" +
                    "\"urn:schemas-microsoft-com:office:office#Expires\">" +
                    "2007-10-15T00:00:00Z</SetVar>" + 
            "</Method>" +
        "</ows:Batch>";

    string strProcessBatch = oWebsite.ProcessBatchData(strPost);
}

Hinweis

Bestimmte Objekte die IDisposable -Schnittstelle implementieren, und Sie müssen vermeiden, diese Objekte im Arbeitsspeicher beibehalten, wenn sie nicht mehr benötigt werden. Informationen zu bewährten Codierung finden Sie unter Disposing Objects.

Siehe auch

Referenz

SPWeb Klasse

SPWeb-Member

Microsoft.SharePoint-Namespace