IRecordUndeclarationHandler - Interface
Fournit une interface pour un traitement personnalisé d'annulation de déclaration d'un élément de liste en tant qu'enregistrement.
Espace de noms : Microsoft.Office.RecordsManagement.RecordsRepository
Assembly : Microsoft.Office.Policy (dans Microsoft.Office.Policy.dll)
Syntaxe
'Déclaration
<SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel := True)> _
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public Interface IRecordUndeclarationHandler
'Utilisation
Dim instance As IRecordUndeclarationHandler
[SharePointPermissionAttribute(SecurityAction.InheritanceDemand, ObjectModel = true)]
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public interface IRecordUndeclarationHandler
Remarques
Lorsqu'un élément de liste n'est pas déclaré comme gestionnaire de traitement enregistrement personnalisé peut être ajouté par l'implémentation de la méthode OnUndeclare de l'interface IRecordUndeclarationHandler . Une fois que le gestionnaire a traité l'élément de liste (SPListItem), il peut choisir ce qui se passe lorsqu'il est retourné à partir de l'énumération RecordOperationResultCustomHandlerNotRun ou poursuivre le traitement en retournant la valeur correspondante de la RecordOperationResult par défaut.
Les exemples de code suivants montrent comment inscrire un gestionnaire d'enregistrements personnalisés et créer un filtre personnalisé déclaration qui gère cette action et la déclaration d'enregistrement.
Exemples
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;
}
}
}
Voir aussi
Référence
IRecordUndeclarationHandler - Membres
Microsoft.Office.RecordsManagement.RecordsRepository - Espace de noms