Weavy Daemons

A daemon is task that runs in the background at a specified schedule.

Daemon class

To add a daemon you should first add a class that inherits from Weavy.Core.Models.Daemon. In the example below we add a daemon that sends a daily email with the current number of Apps, Spaces, and Users in the system.

Description - a description to use for the hook, e.g “A hook that automatically trashes comments with certain keywords”.

Schedule - a crontab expression representing the schedule when the daemon should run.

Fields

Daemon fields are pieces of information that can be added to a daemon. This can be useful if your daemon requires some kind of configuration or settings. Daemon fields have a name and a type. In the example above, we added a field for storing the Email address where the report should be sent.

For a property to be considered a daemon field, it must be declared as public read-write, i.e. the property has the public access modifier and have both a get and a set accessor.

Daemon fields must also have one of the following supported types:

enum

byte

short

int

long

bool

double

float

string

Guid

DateTime

TimeSpan

Nullables and Lists of the above types are also supported, e.g. int?, List<string> and List<DateTime?>.

Field attributes

By decorating your fields with one, or more, of the following attributes you can customize how the field is displayed, edited and/or validated.

Datatype

By default, Weavy will look at the property type (in this case IList<string>) when deciding which editor to use for the field. By decorating a field with the [DataType] attribute you can specify an additional type to associate with the field. This value will then be used by the UI to determine which editor to use for the field.

[DataType(DataType.EmailAddress)]publicstringEmail{get;set;}

Here we specify that the Email field should be treated as an email address instead of a plain string.

Display

The [Display] attribute lets you specify a name and description to use for the field.