Page 1 of 1

Email Sending Issue in File Watcher Plugin

PostPosted: Thu Aug 11, 2016 4:45 pm
by grandcentral
Hi,
I am hoping someone can help me with this issue with the File Watcher Plugin.
Basically I am trying to get the File Watcher to send an email notification when a file fails to import. I have setup the email and am able to send emails fine thru the Email Maintenance form.

I have uncommented the appropriate lines of code in the File Watcher Plugin but am getting an error when compiling. I am getting an error of 'Overload resolution failed because no accessible 'CreateBusinessLogic' accepts this number of arguments' on line 728 which is the line of code:
Dim email As JiwaApplication.JiwaEmail.EmailMessage = JiwaApplication.BusinessLogicFactory.Instance.CreateBusinessLogic(Of JiwaApplication.JiwaEmail.EmailMessage)

Any help?

Below is that section of code from the plugin:
Code: Select all
         Catch ex As System.Exception
            ' Move to failed folder
            System.IO.File.Move(pendingFileNameAndPath, Path.Combine(Me.FailedFolder, System.IO.Path.GetFileName(pendingFileNameAndPath)))
            LogToEventLog(String.Format("Failed to import File '{0}' - Error: {1}", FullPath, ex.Message), System.Diagnostics.EventLogEntryType.Error)
            
            Dim email As JiwaApplication.JiwaEmail.EmailMessage = JiwaApplication.BusinessLogicFactory.Instance.CreateBusinessLogic(Of JiwaApplication.JiwaEmail.EmailMessage)
            email.SystemSettings.UseOutlookForEmail = False ' Cannot use outlook from within a Windows Service - make sure your other system settings like SMTP server are configured.
            email.CreateNew()
            email.EmailTo = "daniel@***.com.au"
            email.EmailSubject = "PO7 File Import Failed"
            email.EmailBody = String.Format("Document '{0}' failed to import - error message is '{1}'", pendingFileNameAndPath, ex.Message)
            email.Save()
         End Try      

Re: Email Sending Issue in File Watcher Plugin  Topic is solved

PostPosted: Thu Aug 11, 2016 5:07 pm
by Scott.Pearce
The method of instantiating business logic via the factory has changed since the File Watcher plugin was written. Change the line:

Code: Select all
Dim email As JiwaApplication.JiwaEmail.EmailMessage = JiwaApplication.BusinessLogicFactory.Instance.CreateBusinessLogic(Of JiwaApplication.JiwaEmail.EmailMessage)


to:

Code: Select all
Dim email As JiwaApplication.JiwaEmail.EmailMessage = JiwaApplication.BusinessLogicFactory.Instance.CreateBusinessLogic(Of JiwaApplication.JiwaEmail.EmailMessage)(Nothing)


Edit:

The parameter we are passing as "Nothing" is for when a UI is attached to the business logic, since the file watcher has no UI, we can pass "Nothing" to the factory.

Re: Email Sending Issue in File Watcher Plugin

PostPosted: Thu Aug 11, 2016 5:28 pm
by grandcentral
Hi Scott,
Thanks for the help, I actually tried adding the (Nothing) after searching thru some old threads, but the email still didnt send when a file failed to upload and was moved to the 'failed' folder (the plugin did compile though).
So now that I have added the (Nothing) it still does not seem to create the email, have you got any ideas on how to test the email functionality? I presume it is supposed to create a new email in the Email Maintenance area on fail yeah (which at this point it does not)?

Re: Email Sending Issue in File Watcher Plugin

PostPosted: Thu Aug 11, 2016 5:36 pm
by Scott.Pearce
Hmmm. The emailing engine was also changed since that plugin was written.

Which email plugin are you using?

Go to Jiwa->System Settings->Plugins->Plugin Maintenance, and then look at which out of the following plugins are enabled:

Email - Configuration Office365 REST
Email - Configuration Outlook
Email - Configuration SMTP

Post back here which are enabled (if there are more than 1 of the above enabled, that's a problem, so check each).

Re: Email Sending Issue in File Watcher Plugin

PostPosted: Thu Aug 11, 2016 5:51 pm
by grandcentral
Well this is very embarrassing to say! We have two File Watcher plugins installed and I was editing the unactive one, hence why nothing was coming thru.
Sorry about that Scott, thanks for all the help!

Re: Email Sending Issue in File Watcher Plugin

PostPosted: Thu Aug 11, 2016 5:56 pm
by Scott.Pearce
No worries. Glad to hear it worked out!