当前位置: 首页>>代码示例>>C#>>正文


C# SPWeb.ProcessBatchData方法代码示例

本文整理汇总了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());
        }
开发者ID:porter1130,项目名称:C-A,代码行数:33,代码来源:Program.cs

示例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();
        }
开发者ID:ThorstenHans,项目名称:DotNetRocks,代码行数:14,代码来源:ContentPackFeatureService.cs

示例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;
     }
 }
开发者ID:Santhoshonet,项目名称:SP2010Library,代码行数:55,代码来源:WebPart.cs


注:本文中的SPWeb.ProcessBatchData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。