Implementing the Sitefinity Notification Service
I have a custom module that contains a property called "Departments". I would like to give my end users the ability to subscribe/unsubscribe to create/update/delete notifications for specific departments. Is implementing the Sitefinity 5.x Notification Service seen here www.sitefinity.com/.../notification-service best way to handle this? If so does anyone have a working example on how to do this? I am not sure based on the documentation if I am putting this logic into my module, Global.asax, etc. If there is a better alternative to accomplish this can you please point me in the right direction.
Thanks,
Mike
Hi Mike,
You are on the right track. The notification service can be used for the purpose. I understand that you're not sure which parts should be done when.
There are two types of things you are doing when working with the notification service:
Hi,
I'm interested in using this service as well. My website is logging errors to a file, and I want the file to be e-mailed to the webmaster every day, and then delete the file. It all works fine with standard .NET classes, but I felt it would be good practice to use the Sitefinity Notification Service instead. Especially since I want to get to know it as I expect I need it for more complex jobs later.
I converted the second code snippet from www.sitefinity.com/.../message-jobs to VB:
Dim
ns = Telerik.Sitefinity.Services.SystemManager.GetNotificationService()
Dim
context =
New
Telerik.Sitefinity.Services.n ServiceContext(
"myNotificationAccount"
,
"MyCustomModule"
)
Dim
contextDictionary =
New
Dictionary(Of
String
,
String
)()
contextDictionary.Add(
"MergeData.Time"
, DateTime.UtcNow.ToString())
Dim
profileName =
"DefaultSmtpProfile"
'Name of an existing profile
Dim
subjectTemplate =
"Test notification"
Dim
bodyTemplate =
"Hi |Subscriber.FirstName| |Subscriber.LastName|, the time is: |MergeData.Time|"
Dim
tmpl =
New
MessageTemplateRequestProxy()
With
_
.Subject = subjectTemplate, _
.BodyHtml = bodyTemplate _
Dim
subscriber
As
ISubscriberRequest =
New
SubscriberRequestProxy()
With
_
.Email =
"test.subscriber@company.com"
, _
.FirstName =
"David"
, _
.LastName =
"Daniels"
, _
.ResolveKey =
"unique-identifier-in-the-specified-context"
_
'Creates and persists the subscription list
Dim
subscriptionList
As
ISubscriptionListRequest =
New
SubscriptionListRequestProxy()
With
_
.Title =
"SampleList"
, _
.ResolveKey =
"unique-identifier-in-the-specified-context"
, _
.Description =
"Sample subscirption lsit description."
_
Dim
subscriptionListId
As
Guid = ns.CreateSubscriptionList(context, subscriptionList)
'Subscribe the subscriber to the newly created subscription list
ns.Subscribe(context, subscriptionListId, subscriber)
'Create a message job
Dim
job
As
IMessageJobRequest =
New
MessageJobRequestProxy()
With
_
.MessageTemplate = tmpl, _
.SubscriptionsListId = subscriptionListId, _
.SenderProfileName = profileName _
'Send the message job for processing
Dim
messageJobId = ns.SendMessage(context, job, contextDictionary)