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

  ClassDescription
Public classAlert
A user alert object for alerts managed in the xot_alerts table.
Public classAlertService
The standard platform alert service. Currently alerts are provided via AJAX while users are logged into the application.
Public classAlertSettings
Configuration settings regarding alert/page-message delivery. These specifically apply to page-message as created through DisplayMessage(String, String, AlertDelivery, Int32, AlertAttrs) or one of its overloads.
Public classCarrierInfo
Carrier information obtained from Twilio. See https://www.twilio.com/docs/api/rest/lookups.
Public classEmailBounceReader
Scheduled task that polls the SendGrid API for bounces, spamreports, ...
Public classEmailManager
Service implementation of the IEmailManager
Public classHttpRequestExtensions
Extension methods for HttpRequest objects.
Public classInvalidPhoneNumberException
Thrown when a phone number lookup returns 404 (invalid phone number).
Public classMailEventArgs
Event args used with mail events, e.g. MailBeforeSend and MailAfterSend.
Public classMailgunListener
Mailgun webhook handler
Public classMailService
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.
Public classMailUtils
Various utility methods for working with email.
Public classNumberCapabilities
The posible capabilities of a twilio phone number to receive various types of communications. A particular phone number may have any combination of these capabilities.
Public classPhoneNumberInfo
Phone number information obtained from Twilio. See https://www.twilio.com/docs/api/rest/lookups.
Public classSendGridEvent
An event to be processed by OnProcessRequest(HttpContext). Correponds, generally, to the xot_email_event table. https://sendgrid.com/docs/API_Reference/Webhooks/event.html for more SendGrid documentation on Event Webhooks.
Public classSendGridListener
Generic handler for SendGrid's notification API. https://sendgrid.com/docs/API_Reference/Webhooks/event.html for more SendGrid documentation on Event Webhooks.
Public classSendGridListener..::..ParseCharsetRequest
The SendGrid "Character Set and Header Decoding" information for its Inbound Parse Webhook, https://sendgrid.com/docs/API_Reference/Webhooks/parse.html.
Public classSendGridListener..::..ParseEnvelope
The SendGrid envelope for its Inbound Parse Webhook, https://sendgrid.com/docs/API_Reference/Webhooks/parse.html.
Public classServiceBase
Simple implementation of a service
Public classServiceInfos
Holds a collection of IServiceInfo object describing available services.
Public classSystemMailExtensions
Email message extensions
Public classTwilioListener
Listener for Twilio requests.
Public classTwilioNumber
A twilio phone number. See the REST API: INCOMING PHONE NUMBERS twilio documentation page.
Public classTwilioPhoneNumber
Describes a Twilio phone number used for voice or SMS.
Public classUniqueArgs
Custom platform parameters provided in the original email as SendGrid "Unique Arguments" via unique_args. When a SendGrid event is received it will include the "Unique Arguments" provided in the original email.
Public classUserSettingsRequiredException
Exception thrown when required user email settings have not been configured.

Interfaces

  InterfaceDescription
Public interfaceIAlertService
Interface implemented by services providing alerts to users.
Public interfaceIDocStorageService
The interface for services that implement document storage. Note that objects implementing this interface should also implement the IServiceInfo interface required of all platform services.

At this time there are two document storage implementations based on this interface:

  • DBDocStorageViaMapper - Documents are stored in a database using an IMapper configured on the service.
  • S3DocumentStorage - Documents are ultimately stored in Amazon Simple Storage Service (Amazon S3) with local database caching.

Public interfaceIDynamsoftScan
The interface for the Dynamsoft Dynamic Web TWAIN scanner service. The service supports use of the Dynamsoft Dynamic Web TWAIN ActiveX/Plugin component.
Public interfaceIEmailManager
Generic way to control the email manager
Public interfaceIEmailService
Interface that implements an email service.
Public interfaceIMessage
Implemented by Message services
Public interfaceIPushNotification
The interface through which one can interact with the Push Notification sending service
Public interfaceIServiceInfo
Interface implmented by core services.
Public interfaceIShortUrl
Interface through which one requests short urls from a service (e.g. the bitly service which uses https://bitly.com/).
Public interfaceITwilioAuthentication
A small interface for a service to generate tokens for Twilio's javascript libraries
Public interfaceITwilioNumbers
The interface used to maintain twilio phone numbers. The interface is implemented by the TwilioSMS service.
Public interfaceITwilioVoice
Manages the voice interface with Twilio.

Enumerations

  EnumerationDescription
Public enumerationAlertAttrs
Attributes for use with alerts and page messages (created via DisplayMessage(Alert) or one of its overloads). See Alert.
Public enumerationAlertDelivery
The available delivery method for alerts (page-messages) as created through DisplayMessage(String, String, AlertDelivery, Int32, AlertAttrs) or one of its overloads.
Public enumerationDocStorageOptions
Public enumerationEmailManagerAttributes
Email manager behavior attributes
Public enumerationEmailManagerType
The type of email manager service
Public enumerationEmailSendAttrs
Controls email send behavior.
Public enumerationEmailSendStatus
The type of email manager service
Public enumerationMailerAttrs
Attributes describing aspects of an email message.
Public enumerationPhoneServiceAttrs
Attributes affecting the behaviour of phone services. This affects implementing the IMessage and ITwilioVoice interfaces, specically the TwilioSMS" service.
Public enumerationSendEmailFlags
Public enumerationServiceAttrs
Service attributes
Public enumerationSmtpAuthenticationType
Specifies the authentication mechanism to use when authentication is required to send messages to an SMTP service using a TCP/IP network socket.
Public enumerationTwilioTokenType
The different types of token's we can generate for Twilio's javascript libraries to allow them to make REST calls with our account.

Examples

The following example shows how to obtain a reference to the email service and send a message using a template.
 Copy imageCopy
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;
    }
}

See Also