Plugin Scheduler Service. File stays in pending

Discussions relating to plugin development, and the Jiwa API.

Re: Plugin Scheduler Service. File stays in pending

Postby DannyC » Wed Mar 04, 2020 7:58 am

why use the JiwaImportQManager to import XML documents?

Because that's whats provided for us in the standard File Watcher plugin. I'm sure I'm not the only one who takes that as the "best practise" then just customizes around that ideal.

If there's a better way of importing XML documents, it might be an opportunity to tweak the standard File Watcher plugin to show us.

I'll try wrapping that line in a try catch.
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Plugin Scheduler Service. File stays in pending

Postby SBarnes » Wed Mar 04, 2020 8:03 am

If the XML you are receiving is in the format needed for the sales order, just create the business logic object, call create new and then call deserialise with handing it the the XML File read into a string similar to what you have now.

Then you just need to call save on the order.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Plugin Scheduler Service. File stays in pending

Postby DannyC » Wed Mar 04, 2020 8:29 am

So I've tried putting that line in a try catch thus:
Code: Select all
      Try
         queueItem.Process()
      Catch ex As System.Exception
         XMLWatcher.LogToEventLog(String.Format("Error importing '{0}'", ex.Message), System.Diagnostics.EventLogEntryType.Error)
         Throw New System.Exception(ex.Message)   
      End Try   


Unfortunately it still just hangs on the queueItem.Process() line. It doesn't get into the catch, so I'm assuming no exception is thrown.
The XML file just stays in the Pending folder. Nothing in the event log.
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Plugin Scheduler Service. File stays in pending

Postby DannyC » Wed Mar 04, 2020 8:35 am

just create the business logic object, call create new and then call deserialise


Like this?
Code: Select all
      Try
         Dim NewSalesOrderObject As JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder
            NewSalesOrderObject = NewSalesOrderObject = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaFinancials.Jiwa.JiwaSales.SalesOrder.SalesOrder)(Nothing)         
         NewSalesOrderObject.CreateNew()
         NewSalesOrderObject.Deserialise(FileName)
         NewSalesOrderObject.Save(False, False)
      Catch ex As System.Exception
         XMLWatcher.LogToEventLog(String.Format("Error importing '{0}'", ex.Message), System.Diagnostics.EventLogEntryType.Error)
         Throw New System.Exception(ex.Message)   
      End Try   


EDIT: Just tried, but the CreateNew needs a debtor seed. Got no idea who the debtor is as it's embedded somewhere in the XML file.
Do I even need the CreateNew?
Last edited by DannyC on Wed Mar 04, 2020 8:45 am, edited 2 times in total.
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Plugin Scheduler Service. File stays in pending

Postby Scott.Pearce » Wed Mar 04, 2020 8:37 am

Exactly.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Plugin Scheduler Service. File stays in pending

Postby DannyC » Wed Mar 04, 2020 8:51 am

Ah ha!
So I ditched the CreateNew. I don't have the debtor seed so I'm just going straight to deserialise.

And I finally get an understandable error! Thing is, the error indicates an error in the XML file, but it looks good to me.
Code: Select all
Error importing 'There is an error in XML document (1, 1).'
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Plugin Scheduler Service. File stays in pending

Postby SBarnes » Wed Mar 04, 2020 8:59 am

Is there a a blank line at the top, I am pretty sure the 1,1 is line 1 column 1?

It might help to pot the file.
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

Re: Plugin Scheduler Service. File stays in pending

Postby DannyC » Wed Mar 04, 2020 9:05 am

Here's the file.
No blank line at the beginning.
Attachments
0000003583.xml
(1.08 KiB) Downloaded 53 times
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

Re: Plugin Scheduler Service. File stays in pending

Postby Scott.Pearce » Wed Mar 04, 2020 9:06 am

Check it with a hex editor and compare it to a working file. I bet there is a hidden character there.
Scott Pearce
Senior Analyst/Programmer
Jiwa Financials
User avatar
Scott.Pearce
Senpai
Senpai
 
Posts: 742
Joined: Tue Feb 12, 2008 11:27 am
Location: New South Wales, Australia
Topics Solved: 221

Re: Plugin Scheduler Service. File stays in pending

Postby SBarnes » Wed Mar 04, 2020 9:08 am

Also try reading it in in the order screen
Regards
Stuart Barnes
SBarnes
Shihan
Shihan
 
Posts: 1617
Joined: Fri Aug 15, 2008 3:27 pm
Topics Solved: 175

PreviousNext

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests

cron