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 がラップされ、「サンドボックス コード ホスト サービスがビジー状態で要求を処理できないため、サンドボックス コードの実行要求が拒否されました」というメッセージがスローされます。

パラメータに何か問題がありますか、それとも実際の作成を代わりにワークフローに委任する必要がありますか?

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 に答える