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 Mike.Sheen » Wed Mar 04, 2020 11:04 am

SBarnes wrote:your suggested work around was create the form and it worked.


That must have been when I was much younger and more reckless.
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Plugin Scheduler Service. File stays in pending

Postby SBarnes » Wed Mar 04, 2020 11:06 am

:lol:

The code is still in use at the client's today.
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 11:19 am

Changed the encoding to utf-8.
Still got the error during import. But it does work fine when doing XML Import via the GUI. Encoding doesn't seem to make a difference - even the utf-16 version imported OK via the GUI.

I am generating the XML file.
The client has a couple of different Jiwa databases. A purchase order from one database creates an XML file (via a plugin I've written) and is saved to disk. The user drops it into the watch folder and is imported as a sales order in a second database.
They generate the XML via a button on the ribbon and basically just does this:
Code: Select all
      string TextOut = "";
      TextOut = "<?xml  and so on.......  just trying to get around the forum software detection of XML
      foreach (JiwaFinancials.Jiwa.JiwaPurchaseOrders.Line poLine in purchOrder.Lines)
      {
         TextOut += "<Line>";
         TextOut += "<PartNo>" + poLine.SupplierPartNo + "</PartNo>";
         TextOut += "<QuantityOrdered>" + poLine.Quantity + "</QuantityOrdered>";
         TextOut += "</Line>";
      }
      TextOut += "</Lines></JiwaDocument>";
      
      return TextOut;


I guess there's a better way to generate the XML file?

And to answer Stuart's suggestion of changing the service logon account. Just tried & tested. Still the same error.
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 11:35 am

Why could you not either

A. Use the Rest API and do it live.

or

B. Again do it live by log on to the other Jiwa and create the sales order

In other words why use a file at all?
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 Mike.Sheen » Wed Mar 04, 2020 11:50 am

DannyC wrote:I am generating the XML file.


The error you get - "There is an error in XML document (1, 1)" means the XML deserializer is upset with the very first character of your xml file.

You should specify the encoding of the file to be UTF-16 when you write it - some good examples of that can be seen here.

That'll put the BOM (byte order mark) in the first few bytes of the file, and then fussy XML deserializers shouldn't complain.

Joel Spolsky has a nice and oft cited article on this topic, which is worth a read in case you're bewildered how something which should be so simple isn't: The Absolute Minimum Every Software Developer Absolutely, Positively Must Know About Unicode and Character Sets (No Excuses!)
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Plugin Scheduler Service. File stays in pending

Postby DannyC » Wed Mar 04, 2020 12:54 pm

You should specify the encoding of the file to be UTF-16 when you write it

Tried that via
Code: Select all
System.IO.File.WriteAllText(purchOrderForm.DialogSave.FileName,XMLFileContents,System.Text.Encoding.Unicode)


The file opens cleanly in IE (it didn't previously) and also XMLPad, Notepad++ etc.

I thought we were on a winner, until I tried importing it & it still generated that log error. So I tried saving the file encoded as utf-8, with the XML tag also specifying same.
Code: Select all
System.IO.File.WriteAllText(purchOrderForm.DialogSave.FileName,XMLFileContents,System.Text.Encoding.UTF8)


Copied the file to the Watch folder. Still no go. The error still appears in the log
There is an error in XML document (1, 1).

As far as I can tell, there's some kind of corruption with Windows on this server.
a different version of some .NET component or something
I think I'll just ditch running the plugin scheduler service on this server & try on a different server. Fortunately this client has a TS server and a SQL server. The service is running on their TS server. I'll get it running on the SQL server and see what transpires.
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 Mike.Sheen » Wed Mar 04, 2020 1:05 pm

DannyC wrote:As far as I can tell, there's some kind of corruption with Windows on this server.


When you earlier said you could import the file from the sales order form ok - was that running on the same machine as the one the Plugin Scheduler service that was having the problem?
Mike Sheen
Chief Software Engineer
Jiwa Financials

If I do answer your question to your satisfaction, please mark it as the post solving the topic so others with the same issue can readily identify the solution
User avatar
Mike.Sheen
Overflow Error
Overflow Error
 
Posts: 2440
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 755

Re: Plugin Scheduler Service. File stays in pending

Postby DannyC » Wed Mar 04, 2020 1:16 pm

Yep, service & Jiwa client running on same machine.

I think this issue may remain a mystery. Stuart has come up with a much better solution.
Based on viewtopic.php?f=27&t=491 I will just create a sales order in the other database. No need for a file.

Give me a few hours to knock up that code & we'll see how it goes.

Danny
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 3:53 pm

Give me a few hours to knock up that code & we'll see how it goes.

Bingo!

Works in test, so I will deploy to their live database & get the users to test it.

EDIT: 1 day later, users have tested & we're good!
So now, instead of exporting a XML file, dropping it into Watch & hoping the service hasn't hung/stopped/or this weird mystery with the encoding or whatever, I'm just hooking into the second database & creating the sales order.

So the original issue remains but this workaround is actually a better solution.
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 » Thu Mar 26, 2020 5:16 pm

This issue has reared its ugly head again.
Different client, different problem I'm trying to solve.

Once again, I am trying to use the salesOrder.deserialise method to import an XML file but am stuck on this error again.

Encoding is fine. I can open the file successfully in Notepad, Notepad++, HxD, XMLPad.

Maybe it's a .Net thing on my laptop?
User avatar
DannyC
Senpai
Senpai
 
Posts: 635
Joined: Fri Mar 22, 2013 12:23 pm
Topics Solved: 29

PreviousNext

Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron