Sharepoint: создание веб-каталога из обработчика событий элемента

У меня есть "список проектов" (заголовок, ведущий, участники, 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 обертывание COMException для кода HResult FAILED с сообщением Запрос на выполнение изолированного кода был отклонен, так как служба узла изолированного кода была слишком занята для обработки запроса.

Что-то не так с параметрами, или я должен вместо этого делегировать фактическое создание в рабочий процесс?

2 ответа

Попробуем сделать следующее: public override void ItemAdding(свойства SPItemEventProperties) { 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();


           }
      }

Кажется, какая-то тупиковая ситуация; Я решил свой конкретный случай, используя вместо этого элемент ItemAdded после события (вместо изменения значений в AfterProperties на обновление ListItem). Там по какой-то причине вызов Webs.Add() завершается нормально...

Другие вопросы по тегам