Products

Solutions

Resources

Partners

Community

Blog

About

QA

Ideas Test

New Community Website

Ordinarily, you'd be at the right spot, but we've recently launched a brand new community website... For the community, by the community.

Yay... Take Me to the Community!

Welcome to the DNN Community Forums, your preferred source of online community support for all things related to DNN.
In order to participate you must be a registered DNNizen

HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsEventsEventsNotificationsNotifications
Previous
 
Next
New Post
11/1/2006 9:05 AM
 
No problem, I'm glad it worked for you.  Let me know if you find any bugs or whatever, so we can make sure this thing is done right - I'll try to have any bug fixes up asap, if we find any.


I did find the problem - or "a" problem in the event notification code, so I'm working on that now and should have a fix posted within a day or two, if anyone wants that too.


 
New Post
11/1/2006 9:46 AM
 
I have fixed the events notifications and the events enrollments code.  They both were the same problem, it appears that the events module was calling the wrong method of the DotNetNuke mail class.  I did it the quick and dirty way - I simply copied some of the code from the DNN mail class and put it into the Events module, so that it correctly queries the DNN framework for the right SMTP settings.

You will need to modify this file: EventNotification.vb
I only modified a few lines, but here is the whole method, just copy and paste:


  Private Sub SendEventNotifications()

            Dim objEventInfoHelper As EventInfoHelper = New EventInfoHelper
            Dim objEventNotificationController As EventNotificationController = New EventNotificationController
            Dim objEventNotification As EventNotificationInfo
            Dim dayEventEvents As New ArrayList
            Dim NotifyTime As DateTime
            Dim EventStartDateTime As DateTime
            Dim subject As String
            Dim body As String
            Dim attachment As StringBuilder
            Dim SMTPServer As String = Nothing
            Dim SMTPAuthentication As String = Nothing
            Dim SMTPUsername As String = Nothing
            Dim SMTPPassword As String = Nothing

            ' SMTP server configuration
            If Convert.ToString(Common.Globals.HostSettings("SMTPServer")) <> "" Then
                SMTPServer = Convert.ToString(Common.Globals.HostSettings("SMTPServer"))
            End If
            If Convert.ToString(Common.Globals.HostSettings("SMTPAuthentication")) <> "" Then
                SMTPAuthentication = Convert.ToString(Common.Globals.HostSettings("SMTPAuthentication"))
            End If
            If Convert.ToString(Common.Globals.HostSettings("SMTPUsername")) <> "" Then
                SMTPUsername = Convert.ToString(Common.Globals.HostSettings("SMTPUsername"))
            End If
            If Convert.ToString(Common.Globals.HostSettings("SMTPPassword")) <> "" Then
                SMTPPassword = Convert.ToString(Common.Globals.HostSettings("SMTPPassword"))
            End If


            Me.Status = "Sending Event Notifications"

            '*** Get Event Dates for the next 7 days (UTC Time)
            Dim startDate As DateTime = Date.UtcNow
            Dim endDate As DateTime = startDate.AddDays(7)

            '*** Load Events  (Note 0 in Module ID will get all events for Notification)
            '***  NOTE: All Event Date/Times are stored in Original TimeZone internally.  The
            '***        Also, NOTE, go back 7 days just to catch up, if scheduler has not been run
            objEventInfoHelper.LoadEventDateRange(0, startDate.AddDays(-7), endDate, True)

            '*** For Each Event Returned
            For Each oEventEvent As EventInfo In objEventInfoHelper.EventEvents
                'Adjust Begin Time to UTC
                NotifyTime = objEventInfoHelper.ConvertDateTimeToTZ(oEventEvent.EventTimeBegin, oEventEvent.TimezoneOffset, 0)
                '*** Calculate notification time
                Select Case oEventEvent.ReminderTimeMeasurement
                    Case "m"
                        NotifyTime = NotifyTime.AddMinutes(oEventEvent.ReminderTime * -1)
                    Case "h"
                        NotifyTime = NotifyTime.AddHours(oEventEvent.ReminderTime * -1)
                    Case "d"
                        NotifyTime = NotifyTime.AddDays(oEventEvent.ReminderTime * -1)
                End Select

                '*** Determine if notification time has expired
                If NotifyTime <= DateTime.UtcNow Then
                    ' See if we've already sent this notification (for recurring dates)
                    objEventNotification = objEventNotificationController.EventsNotificationGet(oEventEvent.EventID, NotifyTime)
                    If objEventNotification Is Nothing Then
                        'Localize and Get TimeZone
                        Dim modl As DotNetNuke.Entities.Modules.ModuleController = New DotNetNuke.Entities.Modules.ModuleController
                        Dim settings As Hashtable = modl.GetModuleSettings(oEventEvent.ModuleID)
                        Dim timeZones As NameValueCollection = Me.GetTimeZones(CType(settings("notifylanguage"), String).ToLower)
                        Dim TZ As String = timeZones.Get(oEventEvent.TimezoneOffset.ToString)

                        '*** If not send event notification
                        subject = oEventEvent.EventName
                        body = String.Format(CType(settings("notifymessage"), String), oEventEvent.EventName, Format(oEventEvent.EventDateBegin, "D"), Format(oEventEvent.EventTimeBegin, "T"), TZ)
                        body += "<br><br>" + System.Web.HttpUtility.HtmlDecode(oEventEvent.EventDesc).Replace(vbCrLf, "").Trim
                        body += "<br><br>" + oEventEvent.Reminder
                        DotNetNuke.Services.Mail.Mail.SendMail(oEventEvent.ReminderFrom, oEventEvent.Notify, "", "", MailPriority.Normal, subject, MailFormat.Html, System.Text.Encoding.UTF8, body, "", SMTPServer, SMTPAuthentication, SMTPUsername, SMTPPassword)

                        '*** Save Notification (so we don't send again)
                        objEventNotification = New EventNotificationInfo
                        objEventNotification.EventID = oEventEvent.EventID
                        objEventNotification.NotifyByDateTime = NotifyTime
                        objEventNotificationController.EventsNotificationSave(objEventNotification)
                    End If
                End If
            Next

            '**** Delete Expired EventNotifications (older than 7 days)
            objEventNotificationController.EventsNotificationDelete(startDate.AddDays(-7))

            Me.Status = "Event Notifications Send Successfully"
            Me.ScheduleHistoryItem.Succeeded = True

        End Sub

If you do not have access or do not want to re-compile using Visual Studio, then you can do the App_Code conversion that I posted earlier in this thread.  Please post any bug reports or things like that here so I can know if these fixes are working properly.  I will be sure to post asap if you find any bugs.

You can download the work I've done here:  Events_Fixed
It is a zip file, and to use my code you will need to do the following:
Had to recompile a dll (Because of the Events Scheduler), and you'll have to insert the included section into your web.config.  You will need to delete all the dlls in the bin folder that have to do with the events module.

DotNetNuke.Events.WebControls
DotNetNuke.Modules.Events.* (there are 3 or 4 of them...)

That *should* work.  Let me know if there are any kinks.  Its working on two of our production servers, so I know it works - I'm sure we'll run into something, but thats cool, we'll get it worked out and re-post fixes.

 
New Post
11/5/2006 5:05 PM
 

Many thanks for taking care of this schubboy,

Is there any way you could provide a dll with the latest compiled code for 4.3.5?  Forgive me if I'm asking an ignorant question.

 
New Post
11/6/2006 8:56 AM
 
Thanks, and no problem, I'm glad to help -

If you download the zip file I linked to in my last post (above this), there is the only dll you will need in there (for v4.3.5, I have NOT tested this with any other version of DNN).  It is the scheduler's dll.  All the other ones are fine, although they have the same bug in them, it won't affect this module. 

I am trying to get in touch (via some other forums) with people who can either tell me how to write my code differently to be compatible (which I'm pretty sure I'm doing it right, I did a lot of research on the msdn documentation) or how to get the appropriate lines of code changed.

For this one though, the my zip file has all you will need.
 
New Post
11/12/2006 4:57 PM
 

My apologies for such a simple question but just to clarify, the only DLL in your zip file that I need to copy is:  "DotNetNuke.DNNScheduler.dll?

 
Previous
 
Next
HomeHomeDNN Open Source...DNN Open Source...Module ForumsModule ForumsEventsEventsNotificationsNotifications


These Forums are dedicated to discussion of DNN Platform and Evoq Solutions.

For the benefit of the community and to protect the integrity of the ecosystem, please observe the following posting guidelines:

  1. No Advertising. This includes promotion of commercial and non-commercial products or services which are not directly related to DNN.
  2. No vendor trolling / poaching. If someone posts about a vendor issue, allow the vendor or other customers to respond. Any post that looks like trolling / poaching will be removed.
  3. Discussion or promotion of DNN Platform product releases under a different brand name are strictly prohibited.
  4. No Flaming or Trolling.
  5. No Profanity, Racism, or Prejudice.
  6. Site Moderators have the final word on approving / removing a thread or post or comment.
  7. English language posting only, please.
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out
What is Liquid Content?
Find Out