|
|
|
stevechubboy.com Joined: 1/20/2006
Posts: 42
|
|
|
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.
|
|
|
|
| |
|
|
stevechubboy.com Joined: 1/20/2006
Posts: 42
|
|
|
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.
|
|
|
|
| |
|
|
Joined: 3/2/2004
Posts: 16
|
|
|
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.
|
|
|
|
| |
|
|
stevechubboy.com Joined: 1/20/2006
Posts: 42
|
|
|
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.
|
|
|
|
| |
|
|
Joined: 6/11/2005
Posts: 22
|
|
|
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?
|
|
|
|
| |