削除後に個人用ページのカスタマイズをバックアップおよび復元することは可能ですか?

sharepoint.stackexchange https://sharepoint.stackexchange.com//questions/78990

質問

ユーザーが自分の個人ビューでページ上のWebパーツを削除、追加、または並べ替えるようにするためのカスタムコードがあります。これは、テンプレートを使用してモジュールによって作成された公開Webパーツページです。

このページを更新する方法は、Webパーツを削除する方法を説明しますか。(明らかに、ignoreIfalreadyExists= trueのWebパーツを設定すると、ページに追加されます。)これまでの場合、ページを削除して再作成しています。これにより、ユーザーが行った可能性があるWebパーツのパーソナライゼーションを破壊し、現在は本番環境ではもう受け入れられません。

ページを削除して再作成した後に、ユーザーの個人ビューをバックアップおよび復元する方法はありますか?

役に立ちましたか?

解決

In simple terms doing something like (important here is of course PersonalizationScope.User):

        SPLimitedWebPartManager webPartManager = SPContext.Current.Web.GetLimitedWebPartManager(this.Request.Url.ToString(), PersonalizationScope.User);
        int wpCounter = webPartManager.WebParts.Count; //get counter
        /*either start looping or for a single web part use*/        
WebPart webPart = webPartManager.WebParts[wpId];
         /*do something with the web part*/

But this has 1 important limitation - it only works for Web parts placed in Web part zone. In addition there is a method (actually part of the ASP.NET Web part infrastructure) called SavePersonalizationState via the Personalization property on each Web part, see more here (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.personalizationprovider.savepersonalizationstate(v=vs.90).aspx). I haven't really been in a situation to try myself!

The biggest challenge would be maybe to collect personalization data for all users. Maybe the fact that it uses the Provider pattern could help, by using the FindState method (http://msdn.microsoft.com/en-us/library/system.web.ui.webcontrols.webparts.personalizationprovider.findstate(v=vs.90).aspx) to extract all data.

ライセンス: CC-BY-SA帰属
所属していません sharepoint.stackexchange
scroll top