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

  • 相关阅读:
    hdu 1704 Rank(floyd传递闭包)
    codeforces 85D. Sum of Medians(线段树or分块)
    hdu 1706 The diameter of graph(folyd计数)
    hdu 4705 Y(树形DP)
    hdu 4123 Bob’s Race(树形DP+rmq)
    hdu 2196 Computer(树形DP)
    hdu 3534 Tree(树形DP)
    hdu 6017 Girls Love 233(dp)
    [HDU5903]Square Distance(DP)
    HDU5878~HDU5891 2016网络赛青岛
  • 原文地址:https://www.cnblogs.com/frankzye/p/1801535.html
Copyright © 2011-2022 走看看