Application plugins allow you to perform customization tasks at certain application-level events.

An application plugin implements the IStonefieldQueryApplicationPlugin interface in Interfaces.dll and uses the StonefieldQueryApplicationPlugin attribute. Your plugin needs references to the Collections, Enums, Interfaces, PluginManager, and System.ComponentModel.Composition assemblies (the first four are Stonefield Query assemblies and the latter is a .NET assembly). It may also need references to other Stonefield Query assemblies, depending on what the plugin does; these can be found in the SQWeb\bin folder.

Studio can generate the source code for a plugin for you; see the Generating Plugin Source Code topic for details.

IStonefieldQueryApplicationPlugin

Here's the definition of IStonefieldQueryApplicationPlugin:

using Stonefield.Security;
using System;
using System.Collections.Generic;
using System.Diagnostics.Contracts;

namespace Stonefield.Query.Plugins
{
    /// <summary>
    /// The interface that Application plugins must implement.
    /// </summary>
    public interface IStonefieldQueryApplicationPlugin :
        IStonefieldQueryBasePlugin
    {
        /// <summary>
        /// Called after setup tasks are done.
        /// </summary>
        /// <returns>
        /// True if the application can continue.
        /// </returns>
        bool AfterSetup();

        /// <summary>
        /// Called before the user has logged in.
        /// </summary>
        /// <param name="userName">
        /// The name of the user logging in.
        /// </param>
        /// <returns>
        /// True if the application can continue.
        /// </returns>
        bool BeforeLogin(string userName);

        /// <summary>
        /// Called after the user has logged in.
        /// </summary>
        /// <param name="user">
        /// A reference to the logged-in user.
        /// </param>
        /// <returns>
        /// True if the application can continue.
        /// </returns>
        bool AfterLogin(IUser user);

        /// <summary>
        /// Called when the application is shutting down.
        /// </summary>
        void OnShutdown();

        /// <summary>
        /// Called when a support ticket should be created because
        /// of an exception.
        /// </summary>
        /// <param name="exception">
        /// The exception that occurred.
        /// </param>
        /// <param name="attachments">
        /// A list of attachments for the ticket.
        /// </param>
        /// <param name="message">
        /// The message for the ticket.
        /// </param>
        /// <returns>
        /// Anything the plugin code wants to return to the caller.
        /// </returns>
        object CreateSupportTicket(Exception exception,
            List<string> attachments, string message);
    }
}

(As with all plugins that derive from IStonefieldQueryBasePlugin, it also has an Application member; see the Plugins topic for information about Application.)

StonefieldQueryApplicationPlugin

The StonefieldQueryApplicationPlugin attribute on the plugin class has the usual set of parameters all plugin attributes do; see the Plugins topic for details. Here's an example:

[StonefieldQueryApplicationPlugin("{9857FB9C-2BA2-46A5-8F8F-60D33B6ABE33}",
    "SampleApplicationPlugin",
    PluginSource.Custom, 
    Version = "1.0.0.0", 
    ExecutionPriority = 5)]
public class SampleApplicationPlugin :
    IStonefieldQueryApplicationPlugin

Plugin methods

Application plugins have the following methods:

See Also

Plugins