1

我有一个“项目列表”(标题、领导、成员、站点 URL),它应该引用具有项目列表的站点下的团队站点。所以我SPItemEventReceiver在沙盒解决方案中添加了一个功能来做到这一点。

ItemAdding(properties)中,我调用以下内容:

string projectName = properties.AfterProperties["Title"].ToString();
SPWeb currentWeb = properties.Web;
SPWeb subweb = currentWeb.Webs.Add(projectName, projectName, 
  "Project site for " + projectName, (uint) currentWeb.Locale.LCID, 
  Microsoft.SharePoint.SPWebTemplate.WebTemplateSTS, true, false);

但是在调试时,对 Add 的调用会SPException为 FAILED 的 HResult 代码抛出一个包装 COMException,并显示消息The sandboxed code execution request was denied 因为沙盒代码主机服务太忙而无法处理该请求。

参数有问题,还是应该将实际创建委托给工作流?

4

2 回答 2

0

以下尝试: public override void ItemAdding(SPItemEventProperties properties) { base.ItemAdding(properties);

          // Get the web where the event was raised
          SPWeb spCurrentSite = properties.OpenWeb();

          //Get the name of the list where the event was raised          
          String curListName = properties.ListTitle;

          //If the list is our list named SubSites the create a new subsite directly below the current site
          if (curListName == "SubSites")
          {
              //Get the SPListItem object that raised the event
              SPListItem curItem = properties.ListItem;
              //Get the Title field from this item. This will be the name of our new subsite
              String curItemSiteName = properties.AfterProperties["Title"].ToString();
              //Get the Description field from this item. This will be the description for our new subsite
              string curItemDescription = properties.AfterProperties["Description"].ToString();
              //Update the SiteUrl field of the item, this is the URL of our new subsite
              properties.AfterProperties["SiteUrl"] = spCurrentSite.Url + "/" + curItemSiteName;

              //Create the subsite based on the template from the Solution Gallery
              SPWeb newSite = spCurrentSite.Webs.Add(curItemSiteName, curItemSiteName, curItemDescription, Convert.ToUInt16(1033), "{8FCAD92C-EF01-4127-A0B6-23008C67BA26}#1TestProject", false, false);
                 //Set the new subsite to inherit it's top navigation from the parent site, Usefalse if you do not want this.
                 newSite.Navigation.UseShared = true;
                 newSite.Close();


           }
      }
于 2012-02-17T10:50:54.590 回答
0

似乎是一些僵局的情况;我通过使用事件后 ItemAdded 解决了我的特殊情况(从 AfterProperties 中的设置值更改为更新 ListItem)。在那里,出于某种原因,对 Webs.Add() 的调用正常完成......

于 2012-02-20T12:05:10.900 回答