为新网站激活 SharePoint 功能(装订???)

发布于 2024-09-10 04:40:17 字数 2571 浏览 3 评论 0原文

我正在开发一个共享点功能,当用户尝试删除站点时,该功能会在站点集合级别和站点级别对站点进行备份。当激活该功能时,该功能工作正常,现有网站集和网站不会出现问题。 为了提供更多图片,我通过 SiteDeleting 和 WebDeleting 事件中的代码进行备份。该事件通过FeatureActivated 事件连接起来。我知道这可以确保由于我的代码而仅为现有站点挂钩该事件(我在 FeatureActivated 事件中挂钩 SiteDeleting 和 WebDeleting 事件)。激活该功能后,如果我创建新的网站集/网站,该功能将不起作用(即删除网站时不会进行备份)。

我试图为新站点激活该事件,因此我查看是否会有类似的事件,例如站点创建,我可以在其中再次连接新站点的 SiteDeleting 和 WebDeleting 事件。但经过一番研究后我发现没有可以使用的网站创建事件。经过一番谷歌搜索后,我发现它可以通过一个称为装订的功能来完成,我们需要创建另一个功能,通过模板名称将此功能附加到新网站。我已经尝试安装这两个功能(我的原始功能和装订功能),但它似乎从未起作用...

我对共享点开发非常陌生,修复它需要时间。如果有人可以帮助我使该功能也适用于新站点,那就太好了。我相信我在 feature.xml 的范围参数中做错了。在 feature.xml 内容下面列出。

****SiteDeletFeature(我原来的功能)** Feature.xml

<?xml version="1.0" encoding="utf-8" ?>
<Feature Title="My SharePoint Delete Feature"
   Scope ="WebApplication" 
   ActivateOnDefault="True" 
   Hidden="false"
   Id="DA910034-F270-4932-90D0-05AE2EE13192"
   xmlns="http://schemas.microsoft.com/sharepoint/"
   ReceiverAssembly="My.Sharepoint.SiteDeleteFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=762e98b8afce5f9b"
   ReceiverClass="My.Sharepoint.SiteDeleteFeature.DeleteFeatureCallOut">
  <ElementManifests>
    <ElementManifest Location="Elements.xml"/>
  </ElementManifests>
</Feature>

SiteDeleteFeatureStapling Feature.xml

<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
 Id="D0495B32-9F78-4142-A456-48B3ECBFFD6C" 
 ActivateOnDefault="True"
 Title="My SharePoint Delete Feature"
 Description="My SharePoint Delete Feature"
 Version="0.0.0.0"
 Scope="Farm">
 <ElementManifests>
  <ElementManifest Location="FeatureStapling\FeatureStapling.xml" />
 </ElementManifests>
</Feature>

FeatureStapling.xml

<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="STS#0" />
 .
 .
 .//goes on, i have included all template names
 <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="MyCOMMUNITY" />
</Elements>

我已经在 SiteDeleteFeatureStapling 的 Scope 参数中尝试了各种选项,例如 Web、Site,但没有任何结果...

有人可以帮助我解决此问题吗...提前致谢!

问候 巴拉

I am developing a sharepoint feature which takes a backup of the site at sitecollection level and at site level whenevar a user tries to delete the site. The feature is working fine without issues for the existing sitecollection and sites when the feature is activated.
To give more picture, i am taking backup through code in events SiteDeleting and WebDeleting events. This events are hooked up using FeatureActivated event. I understand this ensures the event are hooked only up for the existing sites because of my code(i am hooking SiteDeleting and WebDeleting events in FeatureActivated event). After the feature activated, if i create a new site collection/sites the feature is not working(i.e backup is not taken when deleting the site).

I was trying to activate the event for new sites and hence i looked if there will be similar events like sitecreating where i can again hook up the SiteDeleting and WebDeleting events for new sites. But i came to know after some reasearch that there is no sitecreating event which can be used. After bit of googling i found that it can be done through a feature called stapling where we need to create another feature that attaches this feature to the new sites through template name. I have tried installing both the feature(my original and stapling feature) but it never seems to be working...

I am very new to sharepoint development and its taking time for fixing it. It will great if someone can help me to make the feature to work for the new sites as well.. I believe i am doing something wrong in scope parameter of feature.xml..listed below the feature.xml contents.

****SiteDeletFeature (My original Feature)**
Feature.xml

<?xml version="1.0" encoding="utf-8" ?>
<Feature Title="My SharePoint Delete Feature"
   Scope ="WebApplication" 
   ActivateOnDefault="True" 
   Hidden="false"
   Id="DA910034-F270-4932-90D0-05AE2EE13192"
   xmlns="http://schemas.microsoft.com/sharepoint/"
   ReceiverAssembly="My.Sharepoint.SiteDeleteFeature, Version=1.0.0.0, Culture=neutral, PublicKeyToken=762e98b8afce5f9b"
   ReceiverClass="My.Sharepoint.SiteDeleteFeature.DeleteFeatureCallOut">
  <ElementManifests>
    <ElementManifest Location="Elements.xml"/>
  </ElementManifests>
</Feature>

SiteDeleteFeatureStapling
Feature.xml

<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Feature xmlns="http://schemas.microsoft.com/sharepoint/"
 Id="D0495B32-9F78-4142-A456-48B3ECBFFD6C" 
 ActivateOnDefault="True"
 Title="My SharePoint Delete Feature"
 Description="My SharePoint Delete Feature"
 Version="0.0.0.0"
 Scope="Farm">
 <ElementManifests>
  <ElementManifest Location="FeatureStapling\FeatureStapling.xml" />
 </ElementManifests>
</Feature>

FeatureStapling.xml

<?xml version="1.0" encoding="utf-8" ?>
<!-- Copyright (c) Microsoft Corporation. All rights reserved. -->
<Elements xmlns="http://schemas.microsoft.com/sharepoint/">
 <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="STS#0" />
 .
 .
 .//goes on, i have included all template names
 <FeatureSiteTemplateAssociation Id="DA910034-F270-4932-90D0-05AE2EE13192" TemplateName="MyCOMMUNITY" />
</Elements>

I have tried various option in Scope parameter for SiteDeleteFeatureStapling like Web,Site but nothing worked out...

Could some one help me to fix this issue...Thanks in advance!

Regards
Bala

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你怎么这么可爱啊 2024-09-17 04:40:17

FeatureStapling.xml 必须具有范围 =“Farm”

SiteDeletFeature 必须具有范围 =“Web”

FeatureStapling.xml must have scope = "Farm"

SiteDeletFeature must have scope = "Web"

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文