共用方式為


SPWeb.ProcessBatchData method

處理用於將多個要求傳送到每個交易伺服器指定的指令。

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

Syntax

'宣告
Public Function ProcessBatchData ( _
    strBatchData As String _
) As String
'用途
Dim instance As SPWeb
Dim strBatchData As String
Dim returnValue As String

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

參數

  • strBatchData
    Type: System.String

    Collaborative Application Markup Language (CAML)包含命令, Batch項目和任何數目的每個指定SharePoint Foundation遠端程序呼叫 (RPC) 方法的次級Method元素所組成。

傳回值

Type: System.String
處理程序的結果。

備註

若要使用這個方法來刪除文件庫中的文件,將傳遞給owsfileref變數Method項目中的檔案路徑。

Examples

下列程式碼範例會使用ProcessBatchData方法來將兩個項目加入至指定的站台目前的網站集合中的 [宣布] 清單。

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);
}
注意事項注意事項

某些物件實作IDisposable介面,並且您必須避免之後不再需要保留這些物件在記憶體中。良好的程式碼撰寫方式的相關資訊,請參閱Disposing Objects

請參閱

參照

SPWeb class

SPWeb members

Microsoft.SharePoint namespace