Page 2 of 5

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 7:58 am
by DannyC
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.

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 8:03 am
by SBarnes
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.

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 8:29 am
by DannyC
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.

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 8:35 am
by DannyC
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?

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 8:37 am
by Scott.Pearce
Exactly.

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 8:51 am
by DannyC
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).'

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 8:59 am
by SBarnes
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.

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 9:05 am
by DannyC
Here's the file.
No blank line at the beginning.

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 9:06 am
by Scott.Pearce
Check it with a hex editor and compare it to a working file. I bet there is a hidden character there.

Re: Plugin Scheduler Service. File stays in pending

PostPosted: Wed Mar 04, 2020 9:08 am
by SBarnes
Also try reading it in in the order screen