Compartilhar via


IRecordUndeclarationHandler interface

Fornece uma interface para processamento personalizado de declaração de um item da lista como registro.

Namespace:  Microsoft.Office.RecordsManagement.RecordsRepository
Assembly:  Microsoft.Office.Policy (em Microsoft.Office.Policy.dll)

Sintaxe

'Declaração
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Interface IRecordUndeclarationHandler
'Uso
Dim instance As IRecordUndeclarationHandler
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public interface IRecordUndeclarationHandler

Comentários

Quando um item de lista não está declarado como registro de processamento personalizado manipulador pode ser adicionado ao implementar o método OnUndeclare na interface IRecordUndeclarationHandler . Depois que o manipulador tiver processado o item de lista (SPListItem), ele pode escolher o que acontece quando ele retorna CustomHandlerNotRun da enumeração RecordOperationResult ou continuar com o padrão de processamento, retornando o valor de RecordOperationResult correspondente.

Os exemplos de código a seguir demonstram como registrar um manipulador de registros personalizados e criar um filtro de declaração personalizada que gerencia a declaração do registro e declaração.

Exemplos

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Office.RecordsManagement.RecordsRepository;
using Microsoft.SharePoint;

namespace Microsoft.SDK.SharePoint.Samples 
{
    /// <summary>
    /// RegisterDeclarationFilter registers the DeclarationFilter assembly with the server 
    /// to handle record declaration and undeclaration.
    /// </summary>
    class RegisterDeclarationFilter
    {
        private const string ASSEMBLY_STRONG_NAME = "DeclarationFilter, Version=1.0.0.0, Culture=neutral, PublicKeyToken=991a95319bfcc113";
        private const string CLASS_NAME = "Microsoft.SDK.SharePoint.Samples.DeclarationFilter";

        /// <summary>
        /// Registers the DeclarationFilter assembly on the given site.
        /// </summary>
        /// <param name="args">command line arguments, the first one must be a valid site URL</param>
        /// <exception cref="System.ArgumentException">empty command line arguments</exception>
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                throw new ArgumentException("Must supply site URL");
            }

            SPSite site = new SPSite(args[0]);
            Records.RegisterCustomCodeForRecordDeclaration(site,
                ASSEMBLY_STRONG_NAME, 
                CLASS_NAME);
        }
    }
}

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Microsoft.Office.RecordsManagement.RecordsRepository;
using Microsoft.SharePoint;

namespace Microsoft.SDK.SharePoint.Samples
{
    /// <summary>
    /// DeclarationFilter is a custom handler for record declaration and undeclaration.
    /// </summary>
    /// <remarks>
    /// <para>
    /// DeclarationFilter filters out items which should not be declared or undeclared before record processing. 
    /// If an item should not be declared as record, sets the property "_do_not_declare_record" to true.
    /// If a record item should not be undeclared, sets the property "_do_not_undeclare_record" to true.
    /// </para>
    /// <para>
    /// DeclarationFilter implements IRecordDeclarationHandler and IRecordUndeclarationHandler to handle both record declaration and undeclaration.
    /// When an item is declared record, DeclarationFilter checks whether the item has the "_do_not_declare_record" property set to true, if so it cancels the record declaration.
    /// When a record is undeclared, DeclarationFilter checks if whether the item has the "_do_not_undeclare_record" property set to true, if so it cancels the undeclaration.
    /// </para>
    /// </remarks>
    class DeclarationFilter : IRecordDeclarationHandler, IRecordUndeclarationHandler
    {
        /// <summary>
        /// This is the name of the property we assign to items that should not be declared as record.
        /// </summary>
        public const string PROPERTY_DO_NOT_DECLARE = "_do_not_declare_record";

        /// <summary>
        /// This is the name of the property we assign to records that should not be undeclared.
        /// </summary>
        public const string PROPERTY_DO_NOT_UNDECLARE = "_do_not_undeclare_record";

        #region IRecordDeclarationHandler Members

        /// <summary>
        /// Checks and filters out item marked with "_do_not_declare_record" for record declaration.
        /// </summary>
        /// <remarks>
        /// Checks whether item is marked with "_do_not_declare_record". If so then cancels record declaration, 
        /// otherwise contniue default record declaration processing.
        /// </remarks>
        /// <param name="item">the item to be declared as record</param>
        /// <returns>
        /// RecordOperationResult.CancelRecordProcessing if item should not be declared;
        /// RecordOperationResult.ContinueRecordProcessing otherwise.
        /// </returns>
        RecordOperationResult IRecordDeclarationHandler.OnDeclare(SPListItem item)
        {
            // checks if item is marked as "_do_not_declare_record"
            if (CheckRecordFilterProperty(item, PROPERTY_DO_NOT_DECLARE))
            {
                // item mared as "_do_not_declare_record", cancel processing
                return RecordOperationResult.CancelRecordProcessing;
            }
            else
            {
                // continue with default processing
                return RecordOperationResult.ContinueRecordProcessing;
            }
        }

        #endregion

        #region IRecordUndeclarationHandler Members

        /// <summary>
        /// Checks and filters out item marked with "_do_not_undeclare_record" for record undeclaration.
        /// </summary>
        /// <remarks>
        /// Checks whether item is marked with "_do_not_undeclare_record" If so then cancels record undeclaration, 
        /// otherwise contniue default record undeclaration processing.
        /// </remarks>
        /// <param name="item">the item to be undeclared</param>
        /// <returns>
        /// RecordOperationResult.CancelRecordProcessing if item should not be undeclared; 
        /// RecordOperationResult.ContinueRecordProcessing otherwise.
        /// </returns>
        RecordOperationResult IRecordUndeclarationHandler.OnUndeclare(SPListItem item)
        {
            // checks if item is marked as "_do_not_undeclare_record"
            if (CheckRecordFilterProperty(item, PROPERTY_DO_NOT_UNDECLARE))
            {
                // item mared as "_do_not_undeclare_record", cancel processing
                return RecordOperationResult.CancelRecordProcessing;
            }
            else
            {
                // continue with default processing
                return RecordOperationResult.ContinueRecordProcessing;
            }
        }

        #endregion

        /// <summary>
        /// Checks the given record filter property on the given item.
        /// </summary>
        /// <param name="item">the item</param>
        /// <param name="propertyName">the record filter property</param>
        /// <returns>the property value, false if not found.</returns>
        private static bool CheckRecordFilterProperty(SPListItem item, string propertyName)
        {
            bool result = false;
            if (item.Properties.Contains(propertyName))
            {
                object property = item.Properties[propertyName];
                if (property != null)
                {
                    result = string.Equals(bool.TrueString, (string)property, StringComparison.OrdinalIgnoreCase);
                }
            }
            return result;
        }
    }
}

Ver também

Referência

IRecordUndeclarationHandler membros

Microsoft.Office.RecordsManagement.RecordsRepository namespace

RecordOperationResult