简体   繁体   English

使用Umbraco轮廓归档表单时,有什么方法可以挂钩事件? 使用Umbraco 4.7.2和Umbraco Contour 1.12?

[英]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. 我正在尝试创建一个功能,在使用Umbraco Contour时可以跟踪何时归档表单。 Typically Umbraco code base has a series of events which I can hook into. 通常,Umbraco代码库具有一系列可以挂接到的事件。 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: 据我所知,在存档表单时没有引发任何特定事件,但是您可以尝试订阅FormStorage.FormUpdated事件,然后从那里检查表单是否已存档,然后执行代码:

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)
        {
            ...
        }
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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