本文整理汇总了C#中SPWeb.ProcessBatchData方法的典型用法代码示例。如果您正苦于以下问题:C# SPWeb.ProcessBatchData方法的具体用法?C# SPWeb.ProcessBatchData怎么用?C# SPWeb.ProcessBatchData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SPWeb
的用法示例。
在下文中一共展示了SPWeb.ProcessBatchData方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: BatchDeleteItems
public static void BatchDeleteItems(SPList splTask, SPQuery query,SPWeb web)
{
// Set up the variables to be used.
StringBuilder methodBuilder = new StringBuilder();
string batch = string.Empty;
string batchFormat = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" +
"<Batch onError=\"Return\">{0}</Batch>";
string methodFormat = "<Method ID=\"{0}\">" +
"<SetList Scope=\"Request\">{1}</SetList>" +
"<SetVar Name=\"ID\">{2}</SetVar>" +
"<SetVar Name=\"Cmd\">Delete</SetVar>" +
"</Method>";
// Get the list containing the items to update.
//PList list = WorkFlowUtil.GetWorkflowList(listName);
// Query to get the unprocessed items.
SPListItemCollection unprocessedItems = splTask.GetItems(query);
// Build the CAML delete commands.
foreach (SPListItem item in unprocessedItems)
{
methodBuilder.AppendFormat(methodFormat, "1", item.ParentList.ID, item.ID.ToString());
}
// Put the pieces together.
batch = string.Format(batchFormat, methodBuilder.ToString());
// Process the batch of commands.
string batchReturn = web.ProcessBatchData(batch.ToString());
}
示例2: DeleteItemsAndList
private static void DeleteItemsAndList(SPList list, SPWeb targetWeb)
{
StringBuilder deleteBatch = new StringBuilder();
deleteBatch.Append("<?xml version=\"1.0\" encoding=\"UTF-8\"?><Batch>");
string mask = "<Method><SetList Scope=\"Request\">" + list.ID + "</SetList><SetVar Name=\"ID\">{0}</SetVar><SetVar Name=\"Cmd\">Delete</SetVar></Method>";
foreach (SPListItem item in list.Items)
{
deleteBatch.Append(string.Format(mask, item.ID));
}
deleteBatch.Append("</Batch>");
targetWeb.ProcessBatchData(deleteBatch.ToString());
list.Delete();
}
示例3: ValidateAndCreatePage
public static String ValidateAndCreatePage(SPWeb rootWeb, String documentName, String documentDesc, String pageName, String webPartName)
{
try
{
SPList list;
try
{
list = rootWeb.Lists[documentName];
}
catch
{
list = null;
}
if (list == null)
{
rootWeb.Lists.Add(documentName, documentDesc, SPListTemplateType.DocumentLibrary);
try
{
list = rootWeb.Lists[documentName];
}
catch (Exception)
{
list = null;
}
}
if (list != null)
{
string postInformation = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<Method>" + "<SetList Scope=\"Request\">"
+ list.ID + "</SetList>" + "<SetVar Name=\"ID\">New</SetVar>" + "<SetVar Name=\"Cmd\">NewWebPage</SetVar>"
+ "<SetVar Name=\"Type\">WebPartPage</SetVar>" + "<SetVar Name=\"WebPartPageTemplate\">1</SetVar>"
+ "<SetVar Name=\"Title\">" + pageName + "</SetVar>" + "<SetVar Name=\"Overwrite\">true</SetVar>" + "</Method>";
rootWeb.ProcessBatchData(postInformation);
try
{
foreach (SPListItem listItem in list.Items)
{
if (listItem.DisplayName.ToLower() == pageName.ToLower())
{
AddWebPartToPage(rootWeb, listItem.Url, webPartName, "", 0);
return "Process Completed";
}
}
}
catch (Exception)
{
return "Unable to Create a Page in the Document Library";
}
}
return "Unable to Create Document Library. Verify the Permission.";
}
catch (Exception ex)
{
return ex.Message;
}
}