Migration de composants WebPart à l’aide de l’API de migration
L’API de migration prend en charge la possibilité de migrer des composants WebPart vers SharePoint Online à l’aide du package PRIME en appelant CSOM/REST/SOAP WS pour obtenir les données et les propriétés du composant WebPart afin de générer le package PRIME.
L’un des avantages de l’utilisation de l’API de migration pour la migration de votre composant WebPart est la possibilité de migrer vos composants WebPart en un seul appel et d’améliorer les performances. La partie du manifeste inclut le composant WebPart lorsque vous importez la page associée. À l’aide de l’API de migration, vous pouvez placer tous les composants WebPart que vous avez sur cette page.
Utilisation de la DLL sérialiseur
Il existe deux attributs gérés d’une manière unique qui nécessite l’utilisation de la DLL sérialiseur des propriétés utilisateur WebPart.
Il existe un défi technique pour générer les valeurs de propriété pour AllUsersProperties et PerUserProperties lors de la création du package PRIME. Ce problème est dû au fait que les valeurs de propriété sont des objets blob codés en BASE64, qui sont des propriétés de composant WebPart sérialisées et des informations de connexion de composant WebPart.
Pour obtenir le .dll Serializer, procédez comme suit :
- Installez le client SPMT sur votre ordinateur local : Installez SPMT.
- Accédez à l’emplacement d’installation de SPMT
- Recherchez et copiez le microsoft.sharepoint.migration.webpart.serializer.dll et vous pouvez le copier dans votre projet.
Pour obtenir la liste complète des composants WebPart pris en charge, consultez :
Schéma:
Pour obtenir une explication des champs SPWebPart , consultez :
Exemple de schéma de composant WebPart PRIME
<!-- SPFile definition -->
<xs:complexType name="SPFile">
<xs:sequence>
<xs:element name="Properties" type="Dictionary" minOccurs="0" />
<xs:element name="Versions" type="SPFileVersionCollection" minOccurs="0" maxOccurs="1" />
<xs:element name="WebParts" type="SPWebPartCollection" minOccurs="0" maxOccurs="1" />
<xs:element name="Links" type="SPLinkCollection" minOccurs="0" maxOccurs="1" />
<xs:element name="EventReceivers" type="SPEventReceiverDefinitionCollection" minOccurs="0" maxOccurs="1" />
<xs:element name="VersionEvents" type="SPFileVersionEventCollection" minOccurs="0" maxOccurs="1" />
</xs:sequence>
……
</xs:complexType>
<!-- SPWebPartCollection definition -->
<xs:complexType name="SPWebPartCollection">
<xs:sequence>
<xs:element name="WebPart" type="SPWebPart" minOccurs="1" maxOccurs="unbounded" />
</xs:sequence>
</xs:complexType>
<!-- SPWebPart definition -->
<xs:complexType name="SPWebPart">
<xs:sequence>
<xs:choice minOccurs="0" maxOccurs="35">
<xs:element name="Script" minOccurs="0" maxOccurs="1" />
<xs:element name="PagedRowset" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="PagedClientCallbackRowset" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="PagedRecurrenceRowset" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="ViewFields" type="SPFieldLinkCollection" minOccurs="0" maxOccurs="1" />
<xs:element name="ViewData" minOccurs="0" maxOccurs="1" />
<xs:element name="Query" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="RowLimit" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="RowLimitExceeded" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="Toolbar" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="Formats" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="Aggregations" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="List" minOccurs="0" maxOccurs="1" />
<xs:element name="MetaData" minOccurs="0" maxOccurs="1" />
<xs:element name="View" minOccurs="0" maxOccurs="1" />
<xs:element name="ViewStyle" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="ViewBody" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="ViewEmpty" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="ViewFooter" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="ViewHeader" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="ViewBidiHeader" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="GroupByFooter" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="GroupByHeader" minOccurs="0" maxOccurs="unbounded" />
<xs:element name="CalendarViewStyles" minOccurs="0" maxOccurs="1" />
<xs:element name="CalendarSettings" minOccurs="0" maxOccurs="1" />
<xs:element name="ListFormBody" minOccurs="0" maxOccurs="1" />
<xs:element name="Xsl" minOccurs="0" maxOccurs="1" />
<xs:element name="XslLink" minOccurs="0" maxOccurs="1" />
<xs:element name="JS" minOccurs="0" maxOccurs="1" />
<xs:element name="JSLink" minOccurs="0" maxOccurs="1" />
<xs:element name="ParameterBindings" minOccurs="0" maxOccurs="1" />
<xs:element name="OpenApplicationExtension" minOccurs="0" maxOccurs="1" />
<xs:element name="Mobile" minOccurs="0" maxOccurs="1" />
<xs:element name="MobileItemLimit" minOccurs="0" maxOccurs="1" />
<xs:element name="Method" minOccurs="0" maxOccurs="1" />
<xs:element name="WebParts" minOccurs="0" maxOccurs="1" />
<xs:element name="InlineEdit" minOccurs="0" maxOccurs="1" />
<xs:element name="Joins" minOccurs="0" maxOccurs="1" />
<xs:element name="ProjectedFields" minOccurs="0" maxOccurs="1" />
<xs:element name="SpotlightInfo" minOccurs="0" maxOccurs="1" />
<xs:element name="Visualization" minOccurs="0" maxOccurs="unbounded" />
</xs:choice>
</xs:sequence>
<xs:attribute name="Name" type="Guid" use="required" />
<xs:attribute name="ListId" type="Guid" use="optional" />
<xs:attribute name="ListRootFolderUrl" type="xs:string" use="optional" />
<xs:attribute name="Type" type="xs:string" use="optional" />
<xs:attribute name="UserId" type="xs:int" use="optional" />
<xs:attribute name="DisplayName" type="xs:string" use="optional" />
<xs:attribute name="WebPartTypeId" type="Guid" use="optional" />
<xs:attribute name="Assembly" type="xs:string" use="optional" />
<xs:attribute name="Class" type="xs:string" use="optional" />
<xs:attribute name="SolutionId" type="Guid" use="optional" />
<xs:attribute name="Version" type="xs:string" use="optional" />
<xs:attribute name="BaseViewID" type="xs:string" use="optional" />
<xs:attribute name="WebPartZoneID" type="xs:string" use="optional" />
<xs:attribute name="IsIncluded" type="xs:string" use="optional" />
<xs:attribute name="WebPartOrder" type="xs:string" use="optional" />
<xs:attribute name="FrameState" type="xs:string" use="optional" />
<xs:attribute name="Source" type="xs:string" use="optional" />
<xs:attribute name="AllUsersProperties" type="xs:string" use="optional" />
<xs:attribute name="PerUserProperties" type="xs:string" use="optional" />
<xs:attribute name="WebPartIdProperty" type="xs:string" use="optional" />
<xs:attribute name="ContentTypeId" type="xs:string" use="optional" />
<!-- For files (major [default] or minor) -->
<xs:attribute name="Level" type="xs:string" use="optional" />
<!-- Flags -->
<xs:attribute name="Flags" type="xs:string" use="optional" />
<xs:attribute name="Scope" type="xs:string" use="optional" />
<xs:attribute name="Hidden" type="xs:boolean" use="optional" />
<xs:attribute name="Threaded" type="xs:boolean" use="optional" />
<xs:attribute name="ReadOnly" type="xs:boolean" use="optional" />
<xs:attribute name="RecurrenceRowset" type="xs:boolean" use="optional" />
<xs:attribute name="FPModified" type="xs:boolean" use="optional" />
<xs:attribute name="ModerationType" type="xs:string" use="optional" />
<xs:attribute name="Personal" type="xs:boolean" use="optional" />
<xs:attribute name="OrderedView" type="xs:boolean" use="optional" />
</xs:complexType>
Contrôles de sécurité
En raison de la conception du contrôle de sécurité côté serveur, le comportement suivant :
- Si noScript est désactivé, continuez la migration de tous les composants WebPart comme actuellement
- Si NoScript est activé, commencez par case activée sécurité au niveau du composant WebPart
- Si SafeAgainstScript a la valeur false, ne l’importez pas
- Si SafeAgainstScript a la valeur true, case activée la sécurité au niveau de la propriété du composant WebPart
- Si le composant WebPart a une propriété avec « RequiresDesignerPermission », ignorez ce composant WebPart (ou ignorez cette propriété si possible)
- Sinon, continuez à migrer ce composant WebPart
Voici la liste des composants WebPart qui seront ignorés par le code côté serveur (traité comme un composant WebPart non approuvé) lorsque NoScript est activé :
- XsltListViewWebPart
- ContentEditorWebPart
- ContentByQueryWebPart
- SiteFeedWebPart
- ScriptEditorWebPart
- ContactFieldControl
- SearchBoxScriptWebPart
- PageViewerWebPart
- ProfileBrowser
- UserTasksWebPart
- SocialCommentWebPart
- SilverlightWebPart
- RSSAggregatorWebPart
- SummaryLinkWebPart
- TableOfContentsWebPart
- UserDocsWebPart
- SPTimelineWebPart
- XmlWebPart
- SiteDocuments
- CategoryResultsWebPart
Forum aux questions
Question : Comment faire extraire les propriétés du composant WebPart comme entrée pour l’API de sérialisation ? Réponse: Les propriétés du composant WebPart se trouvent dans <l’élément webpart> dans la réponse de l’opération « GetWebPartProperties2 » dans « WebPartPagesWebService ». Recherchez les détails de la charge utile dans WSDL '/_vti_bin/WebPartPage.asmx ? WSDL'.
Question: Comment récupérer les informations de connexion du composant WebPart en tant qu’entrée pour l’API de sérialisation ? Réponse: Les connexions de composants WebPart se trouvent dans <les éléments SPWebPartConnection> de la page du composant WebPart dans la réponse de l’opération « GetWebPartPage » dans « WebPartPagesWebService ».
Indicateurs d’affichage : reportez-vous à ceci, par exemple, tous les indicateurs d’affichage. Vous devez convertir toutes les valeurs d’indicateur en élément PRIME « flags ».
Annexe
Exemple d’élément XmlNode des propriétés du composant WebPart v2
<WebPart xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/WebPart/v2" ID="1c845edf-42c6-4094-a105-302015642f43">
<Title>Content Editor</Title>
<FrameType>Default</FrameType>
<Description>Allows authors to enter rich text content.</Description>
<IsIncluded>true</IsIncluded>
<ZoneID>wpz</ZoneID>
<PartOrder>0</PartOrder>
<FrameState>Normal</FrameState>
<Height />
<Width />
<AllowRemove>true</AllowRemove>
<AllowZoneChange>true</AllowZoneChange>
<AllowMinimize>true</AllowMinimize>
<AllowConnect>true</AllowConnect>
<AllowEdit>true</AllowEdit>
<AllowHide>true</AllowHide>
<IsVisible>true</IsVisible>
<DetailLink />
<HelpLink />
<HelpMode>Modeless</HelpMode>
<Dir>Default</Dir>
<PartImageSmall />
<MissingAssembly></MissingAssembly>
<PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge>
<IsIncludedFilter />
<ExportControlledProperties>true</ExportControlledProperties>
<ConnectionID>00000000-0000-0000-0000-000000000000</ConnectionID>
<ID>g_d6def51c_7a91_40fe_9f59_de9ceed5c347</ID>
<Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>
<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>
<ContentLink xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<Content xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
<PartStorage xmlns="http://schemas.microsoft.com/WebPart/v2/ContentEditor" />
</WebPart>
Exemple d’élément XmlNode des propriétés du composant WebPart v3
<webPart xmlns="http://schemas.microsoft.com/WebPart/v3">
<metaData>
<type name="Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c" />
<importErrorMessage></importErrorMessage>
</metaData>
<data>
<properties>
<property name="ShowWithSampleData" type="bool">False</property>
<property name="Default" type="string" />
<property name="NoDefaultStyle" type="string" />
<property name="CacheXslStorage" type="bool">True</property>
<property name="ViewContentTypeId" type="string" />
<property name="XmlDefinitionLink" type="string" />
<property name="ManualRefresh" type="bool">False</property>
<property name="ListUrl" type="string" null="true" />
<property name="ListId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">a316c9a6-e664-426b-9069-77cabd22429c</property>
<property name="TitleUrl" type="string">/Lists/TestPromotedLinks</property>
<property name="EnableOriginalValue" type="bool">False</property>
<property name="Direction" type="direction">NotSet</property>
<property name="ServerRender" type="bool">False</property>
<property name=" ViewFlags " type="Microsoft.SharePoint.SPViewFlags, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">Html, TabularView, Hidden, Ordered</property>
<property name="AllowConnect" type="bool">True</property>
<property name="ListName" type="string">{A316C9A6-E664-426B-9069-77CABD22429C}</property>
<property name="ListDisplayName" type="string" null="true" />
<property name="AllowZoneChange" type="bool">True</property>
<property name="ChromeState" type="chromestate">Normal</property>
<property name="DisableSaveAsNewViewButton" type="bool">True</property>
<property name="ViewFlag" type="string" />
<property name="DataSourceID" type="string" />
<property name="ExportMode" type="exportmode">All</property>
<property name="AutoRefresh" type="bool">False</property>
<property name="FireInitialRow" type="bool">True</property>
<property name="AllowEdit" type="bool">True</property>
<property name="Description" type="string" />
<property name="HelpMode" type="helpmode">Modeless</property>
<property name="BaseXsltHashKey" type="string" null="true" />
<property name="AllowMinimize" type="bool">True</property>
<property name="CacheXslTimeOut" type="int">86400</property>
<property name="ChromeType" type="chrometype">Default</property>
<property name="Xsl" type="string" null="true" />
<property name="JSLink" type="string" null="true" />
<property name="CatalogIconImageUrl" type="string">/_layouts/15/images/itgen.png?rev=23</property>
<property name="SampleData" type="string" null="true" />
<property name="UseSQLDataSourcePaging" type="bool">True</property>
<property name="TitleIconImageUrl" type="string" />
<property name="PageSize" type="int">-1</property>
<property name="ShowTimelineIfAvailable" type="bool">True</property>
<property name="Width" type="string" />
<property name="DataFields" type="string" />
<property name="Hidden" type="bool">False</property>
<property name="Title" type="string" />
<property name="PageType" type="Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">PAGE_NORMALVIEW</property>
<property name="DataSourcesString" type="string" />
<property name="AllowClose" type="bool">True</property>
<property name="InplaceSearchEnabled" type="bool">False</property>
<property name="WebId" type="System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089">00000000-0000-0000-0000-000000000000</property>
<property name="Height" type="string" />
<property name="GhostedXslLink" type="string">main.xsl</property>
<property name="DisableViewSelectorMenu" type="bool">True</property>
<property name="DisplayName" type="string" />
<property name="IsClientRender" type="bool">False</property>
<property name="XmlDefinition" type="string"><View Name="{2B37E456-6FD3-4708-AC83-5D7B0D13E9B4}" Type="HTML" Hidden="TRUE" OrderedView="TRUE" DisplayName="" Url="/SitePages/TestPage.aspx" Level="1" BaseViewID="3" ContentTypeID="0x" ><Query><OrderBy><FieldRef Name="TileOrder" Ascending="TRUE"/><FieldRef Name="Modified" Ascending="FALSE"/></OrderBy></Query><ViewFields><FieldRef Name="Title"/><FieldRef Name="BackgroundImageLocation"/><FieldRef Name="Description"/><FieldRef Name="LinkLocation"/><FieldRef Name="LaunchBehavior"/><FieldRef Name="TileOrder"/></ViewFields><RowLimit Paged="TRUE">30</RowLimit><JSLink>clienttemplates.js</JSLink><XslLink Default="TRUE">main.xsl</XslLink><Toolbar Type="Standard"/></View></property>
<property name="InitialAsyncDataFetch" type="bool">False</property>
<property name="AllowHide" type="bool">True</property>
<property name="ParameterBindings" type="string"><ParameterBinding Name="dvt_sortdir" Location="Postback;Connection" /><ParameterBinding Name="dvt_sortfield" Location="Postback;Connection" /><ParameterBinding Name="dvt_startposition" Location="Postback" DefaultValue="" /><ParameterBinding Name="dvt_firstrow" Location="Postback;Connection" /><ParameterBinding Name="OpenMenuKeyAccessible" Location="Resource(wss,OpenMenuKeyAccessible)" /><ParameterBinding Name="open_menu" Location="Resource(wss,open_menu)" /><ParameterBinding Name="select_deselect_all" Location="Resource(wss,select_deselect_all)" /><ParameterBinding Name="idPresEnabled" Location="Resource(wss,idPresEnabled)" /><ParameterBinding Name="NoAnnouncements" Location="Resource(wss,noXinviewofY_LIST)" /><ParameterBinding Name="NoAnnouncementsHowTo" Location="Resource(wss,noXinviewofY_DEFAULT)" /></property>
<property name="DataSourceMode" type="Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c">List</property>
<property name="AutoRefreshInterval" type="int">60</property>
<property name="AsyncRefresh" type="bool">False</property>
<property name="HelpUrl" type="string" />
<property name="MissingAssembly" type="string">Cannot import this Web Part.</property>
<property name="XslLink" type="string" null="true" />
<property name="SelectParameters" type="string" />
</properties>
</data>
</webPart>
Exemple d’élément XmlNode de connexion de composant WebPart
<WebPartPages:SPWebPartConnection ConsumerConnectionPointID="DFWP Filter Consumer ID" ConsumerID="g_bcca2ac1_f0f1_4640_af30_8a0730ca840e" ID="c1638508205" ProviderConnectionPointID="ITransformableFilterValues" ProviderID="g_7fc41891_2e27_4835_99c8_5b6f80feb20f"><WebPartPages:TransformableFilterValuesToParametersTransformer ConsumerFieldNames="PageType" ProviderFieldNames="Page Field"></WebPartPages:TransformableFilterValuesToParametersTransformer>
</WebPartPages:SPWebPartConnection>