SBarnes wrote:Hi All
What is necessary in vb.net code for both Jiwa version 6 and Jiwa version 7 to be able to serialize a sales order object to XML and deserialize a sales order object from XML?
Hi Stuart,
In both version 6 and 7 our sales order business logic has serialisation and deserialisation capabilities.
With version 6 there are the methods "GenerateXML" and "ConsumeXML", in version 7 all our business logic have a Serialise and Deserialise method, but in version 7 we overloaded those methods so it can accept or return either an XML document, or a representation of the
POCO objects we use for serialisation/deserialisation.
In version 7 the code to read and serialise a sales order to an XML file from a stand-alone VB.NET application is as simple this:
- Code: Select all
Imports JiwaFinancials.Jiwa
Public Class TestClass
Private Sub SerialiseSalesOrder(ByVal InvoiceID As String)
JiwaApplication.Manager.Instance.Logon("JiwaMike", "JiwaDemo", JiwaFinancials.Jiwa.JiwaODBC.database.AuthenticationModes.JiwaAuthentication, "Admin", "password")
Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaSales.SalesOrder.SalesOrder)()
salesOrder.Read(InvoiceID) ' If you don't know the invoice ID, we have a Find method to obtain it from the Invoice No. instead.
Dim xmlString as String
Dim fileName as String = "C:\test.xml"
salesOrder.Serialise(xmlString)
My.Computer.FileSystem.WriteAllText(fileName , xmlString, True)
Console.WriteLine(String.Format("Invoice No. {0} is has been saved as {1}.", salesOrder.InvoiceNo, fileName))
JiwaApplication.Manager.Instance.LogOff()
End Sub
End Class
You don't need to save it to file - my example above was just illustrating serialisation to a file. The above code is very similar to what happens when you click on the "Export to XML" button on the sales order ribbon in version 7. If you're interested, I adapted code from the
on-line reference to construct the above sample.
Deserialising in version 7 is much the same, but just reading the file and calling the Deserialise method instead, and passing the XML or POCO object in as an argument (there is an import from XML ribbon button also on sales order in version 7).
Version 6 is similar in concept, but requires some more overhead in the connection to Jiwa and instantiating the sales order business logic - that would be a fair chunk of code to post, so I'm not going to post it here unless you have a specific requirement for it.
Note also in Version 7 that whilst it is easy and supported to write your own applications using our API, it might be a neater solution to use our plugin framework. You can write your own .NET code in our plugin and each Jiwa client will read that from the database, compile it and execute it when desired (a button click, an action such as printing, or even on a scheduled basis using the plugin scheduler service). That way you don't need to deploy your application to all the clients that need it, it's already done for you!
If you have a specific problem you're trying to solve and need some more guidance just post back here with more detail.
I hope this was of use,
Mike