The services namespace provides runtime services, such as email processing, alert management, and task-scheduling.
Services are defined in metadata and can contain properties for configuration. A Service references a component and that component must implement the IServiceInfo interface.
Services can be marked as Singleton. This means that the application context object will create only one instance of the service for the life of the application.
Classes
| Class | Description | |
|---|---|---|
| AlertService |
The standard platform alert service. Currently alerts are provided via AJAX while users are logged into the application.
| |
| MailEventArgs |
Event args used with mail events, e.g. MailBeforeSend and MailAfterSend.
| |
| MailService |
The MailService object is a wrapper object around System.Web.Mail that can load it's configuration
properties from the repository database or used stand alone.
| |
| NamespaceDoc | ||
| ServiceBase |
Simple implementation of a service
| |
| ServiceInfos |
Holds a collection of services
| |
| UserSettingsRequiredException |
Exception thrown when required user email settings have not been configured.
|
Interfaces
| Interface | Description | |
|---|---|---|
| IAlertService |
Interface implemented by services providing alerts to users.
| |
| IDocStorageService |
Interface that implements document storage.
| |
| IEmailService |
Interface that implements an email service.
| |
| IServiceInfo |
Interface implmented by core services.
|
Enumerations
| Enumeration | Description | |
|---|---|---|
| EmailSendAttrs |
Controls email send behavior.
| |
| MailerAttrs |
Attributes describing aspects of an email message.
| |
| SendEmailFlags | ||
| ServiceAttrs |
Service attributes
| |
| SmtpAuthenticationType |
Specifies the authentication mechanism to use when authentication is required to
send messages to an SMTP service using a TCP/IP network socket.
|
Examples
The following example shows how to obtain a reference to the email service and send a message using a template.
CopyC#
private void Send(IAppContext appContext, string sendToList, string templateName, NameValueCollection nameValues) { ServiceInfos svs = appContext.Services; IEmailService mail = (IEmailService)svs.GetServiceInstance("SmtpMail"); NetQuarry.Template tmpl = appContext.Templates[templateName]; string body; string subject; if (tmpl == null) throw new ApplicationException(string.Format(this.TextItems.GetText(IDS_MISSING_TEMPLATE), templateName)); body = tmpl.Replace(nameValues); subject = tmpl.TextItems.GetText("Subject"); try { //--- leave the From field empty, it will default to the value configured in the studio mail.Send(string.Empty, sendToList, subject, body, true); } catch(Exception ex) { //--- log the error then re-throw DevLog.LogMessage("XIssue.Send", "sendMailError", ex); throw; } }