Compartir a través de


Interfaz IRecordUndeclarationHandler

Proporciona una interfaz para el procesamiento personalizado de un elemento de lista como registro anular la declaración.

Espacio de nombres:  Microsoft.Office.RecordsManagement.RecordsRepository
Ensamblado:  Microsoft.Office.Policy (en Microsoft.Office.Policy.dll)

Sintaxis

'Declaración
<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

Comentarios

Cuando un elemento de lista está sin declarar como controlador de procesos personalizados de registro se puede agregar al implementar el método OnUndeclare en la interfaz IRecordUndeclarationHandler . Después de que el controlador ha procesado el elemento de lista (SPListItem), puede elegir lo que sucede cuando se devuelve de la enumeración RecordOperationResultCustomHandlerNotRun o continuar con el procesamiento devolviendo el valor correspondiente de RecordOperationResult predeterminado.

Ejemplos de código siguientes muestran cómo registrar un controlador de registro personalizado y crear un filtro de la declaración de aduana que administra la declaración de un registro y revocación de declaración.

Ejemplos

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;
        }
    }
}

Vea también

Referencia

Miembros IRecordUndeclarationHandler

Espacio de nombres Microsoft.Office.RecordsManagement.RecordsRepository

RecordOperationResult