简体   繁体   中英

Is there any way to hook to an event when a form is archived withing Umbraco contour? Using Umbraco 4.7.2 and Umbraco Contour 1.12?

I am trying to create a feature where I can track when a form is archived when Using Umbraco Contour. Typically Umbraco code base has a series of events which I can hook into. However I don't see one here.

The other idea was to have a trigger or something on the database but wanted to see if there was a code only solution to this approach.

As far as I know there isn't any specific event that's raised when a form is archived, but you could try subscribing to the FormStorage.FormUpdated event and from there check if the form is archived, then execute your code:

using System;
using umbraco.BusinessLogic;
using Umbraco.Forms.Core;
using Umbraco.Forms.Data.Storage;

public class FormArchiveListener : ApplicationBase
{
    public FormArchiveListener()
    {
        FormStorage.FormUpdated += new EventHandler<FormEventArgs>(FormStorage_FormUpdated);
    }

    void FormStorage_FormUpdated(object sender, FormEventArgs e)
    {
        FormStorage storage = (FormStorage) sender;

        if (e.Form.Archived)
        {
            ...
        }
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM