debugging BatchPrint  Topic is solved

Discussions relating to plugin development, and the Jiwa API.

debugging BatchPrint

Postby perry » Fri Sep 11, 2020 10:47 am

Hi All,
Jiwa 7.2.1

I found that I cannot step through/debug any code related to processing individual candidates.
It won't work whether I put breakpoint nor System.Diagnostics.Debugger.Break() inside those event handler.

I thought the code doesn't run but it actually does.

Code: Select all
        Public Sub Setup(ByVal JiwaForm As JiwaApplication.IJiwaForm, ByVal Plugin As JiwaApplication.Plugin.Plugin) Implements JiwaApplication.IJiwaFormPlugin.Setup
            Dim form As JiwaSalesUI.BatchPrinting.MainForm = JiwaForm

            System.Diagnostics.Debugger.Break()
            AddHandler form.BatchPrint.ProcessStart, AddressOf BPStart  'YES
            AddHandler form.BatchPrint.ProcessingCandidate, AddressOf BPProcessing  'NO
            AddHandler form.BatchPrint.ProcessEnd, AddressOf BPEnd  'YES
            AddHandler form.BatchPrint.Candidates.BeforeProcess, AddressOf CDBefore  'NO
            AddHandler form.BatchPrint.Candidates.ActionProcessComplete, AddressOf CDComplete 'NO


        End Sub
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: debugging BatchPrint

Postby perry » Fri Sep 11, 2020 6:05 pm

Maybe I should description the task I have.

From batch print/email, instead of 1 email per invoice, I need to consolidate attachments into single email.

The plan is to let user define a list of email actions and process as per normal. However, the code will intercept each email action and instead exporting the PDF file. At the end of the processing, I will create another email and attach all PDF files.

The problem I correctly have is, the New Exception I raised inside the processing event doesn't stop the action from being processed.
i.e. I get the file exported as PDF, however, I also receive an email.

Code: Select all
Private Sub CDBefore(Candidate As Candidate)
            If Not consolidate Then Exit Sub

     'some code here to setup the print report object
fullFileName = System.IO.Path.Combine(tempFolderPath, fileName) + ".pdf"
                Candidate.Manager.PrintReportObject.CrystalReportObject.ExportToDisk(CrystalDecisions.Shared.ExportFormatType.PortableDocFormat, fullFileName)
'above code would generate a pdf in temp folder, so I assume this code is executed?

                attachments.Add(fullFileName)  ' <== attachments is a string list that is defined in the class but attachments is empty at the end of the process so I'm not sure what is wrong.

            Throw New Exception("Consolidated") 'this doesn't stop the email
            Throw New JiwaApplication.Exceptions.ClientCancelledException 'nor this...
        End Sub
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: debugging BatchPrint

Postby perry » Fri Sep 11, 2020 6:30 pm

ok, I found that I used the wrong event. the correct event should be
Code: Select all
form.BatchPrint.CandidateActionProcessBefore


Now my problem is, I cant cancel the single action by throwing an exception, it will cancel the entire process.
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15

Re: debugging BatchPrint  Topic is solved

Postby perry » Fri Sep 11, 2020 11:09 pm

ok all sorted.
I created a menu item instead of intercepting Process event, manually created an emailMessage (EM_Main) with multiple attachments.
And also an email log for each sales order to point to same email message (it surprisingly worked).
Perry Ma
S. Programmer
Lonicera Pty Ltd
http://www.lonicera.com.au
perry
Frequent Contributor
Frequent Contributor
 
Posts: 173
Joined: Mon Oct 27, 2008 2:26 pm
Topics Solved: 15


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 9 guests

cron