zoukankan      html  css  js  c++  java
  • [转]Adding a custom action to the MOSS expiration policy

    Adding a custom action to the MOSS expiration policy

    Office SharePoint 2007 out of the box has a policy framework, that can help with information management in your organization. On of the out of the box policies is the expiration policy. You can setup a policy for a site collection, content type of SharePoint List that will expire your item after a certain number of days, months or years after one of the date field values in your item. You can expire all whitepapers for example 5 years after they have been last modified.
    expire1

    The action to SharePoint will perform when the item expires depends on you, Out of the box there are 2 options: The items is deleted or a workflow is started. If a workflow is available for the content type or list, it will be listed in the dropdown.
    expire2

    It is also possible to create your own actions. After you have created and registered your action, it will show up in the “Perform this action” dropdown in the screenshot above.

    Step 1 – Implement the interface

    To create a custom action, you need to implement the IExpirationAction interface that can be found in the namespace Microsoft.Office.RecordsManagement.Features.

        public class ExpirationSendWarning : IExpirationAction 
        {
            public void OnExpiration(Microsoft.SharePoint.SPListItem item, 
                System.Xml.XmlNode parametersData, DateTime expiredDate)
            {
                // Do whatever you need to do with you item when it expires
            }
        }

    You need to put this in a strong named assembly and add it to the GAC.

    Step 2 – Create the registration xml

    After creating the expiration action, you need to register it by creating an xml file. You will find an example below. The featureId attribute of the PolicyResource element is important. This needs to be the ID of the out of the box expiration policy. The rest is pretty clear.  Save this xml to a file called “actionmanifest.xml”

        <?xml version="1.0" encoding="utf-8" ?>
        <p:PolicyResource id="TST.POC.PolicyFeatures.ExpirationSendWarning"
              featureId="Microsoft.Office.RecordsManagement.PolicyFeatures.Expiration"
              type="Action"  xmlns:p="urn:schemas-microsoft-com:office:server:policy">
          <p:LocalizationResources>dlccore</p:LocalizationResources>
          <p:Name>ExpirationSendWarning</p:Name>
          <p:Description>Sends a warning on the reminder date</p:Description>
          <p:Publisher>Ton Stegeman</p:Publisher>
          <p:AssemblyName>
            TST.POC.PolicyOfTruth, Version=1.0.0.0, Culture=neutral,
            PublicKeyToken=503edd7b21a430b3
          </p:AssemblyName>
          <p:ClassName>TST.POC.PolicyFeatures.ExpirationSendWarning</p:ClassName>
        </p:PolicyResource>

    Step 3 – Register the expiration action

    The last step is to register the action. To do that, you run the example piece of code below from any type of application you like best:

        string actionmanifest = System.IO.File.ReadAllText("actionmanifest.xml");
        PolicyResourceCollection.Add(actionmanifest);

    The PolicyResourceCollection can be found in the namespace “Microsoft.Office.RecordsManagement.InformationPolicy”. Both for step 1 and 3 you need a reference to Microsoft.Office.Policy.dll

  • 相关阅读:
    linux 经常使用配置
    Binder Proxy技术方案
    Android 通过系统使用NotificationListenerService 监听各种Notification的用法
    苟富贵勿相忘
    使用instantclient_11_2 和PL/SQL Developer工具包连接oracle 11g远程数据库
    JAVA: httpclient 具体解释——第五章;
    Unity入门
    向架构师进军---&gt;怎样编写软件架构文档
    SendMessage、PostMessage原理
    用GDB调试程序(一)
  • 原文地址:https://www.cnblogs.com/frankzye/p/1801535.html
Copyright © 2011-2022 走看看