Email Sending Issue in File Watcher Plugin  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

Email Sending Issue in File Watcher Plugin

Postby grandcentral » Thu Aug 11, 2016 4:45 pm

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      
grandcentral
I'm new here
I'm new here
 
Posts: 3
Joined: Thu Apr 01, 2010 12:14 pm

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

Postby Scott.Pearce » Thu Aug 11, 2016 5:07 pm

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.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Email Sending Issue in File Watcher Plugin

Postby grandcentral » Thu Aug 11, 2016 5:28 pm

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)?
grandcentral
I'm new here
I'm new here
 
Posts: 3
Joined: Thu Apr 01, 2010 12:14 pm

Re: Email Sending Issue in File Watcher Plugin

Postby Scott.Pearce » Thu Aug 11, 2016 5:36 pm

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).
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230

Re: Email Sending Issue in File Watcher Plugin

Postby grandcentral » Thu Aug 11, 2016 5:51 pm

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!
grandcentral
I'm new here
I'm new here
 
Posts: 3
Joined: Thu Apr 01, 2010 12:14 pm

Re: Email Sending Issue in File Watcher Plugin

Postby Scott.Pearce » Thu Aug 11, 2016 5:56 pm

No worries. Glad to hear it worked out!
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 765
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 230


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 4 guests