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?
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?
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
SBarnes wrote:Hi Mike,
Firstly thanks for the as always for the quick reply, the reason for my question is that currently our sales force use an in house application that runs a number of PowerPoint presentations of our products and then lets the sales rep key in their orders which produces an excel file of the order for human readability and an xml file which is currently imported into 6.5.13 through the orders screen when it reaches head office by our customer service.
Currently the two files are sent to head office simply as email attachments through outlook, I am looking to change the system of transport to use a self hosted web service (probably in web api as wcf would over complicate things) that would take the XML logon to Jiwa and use the xml serialise/deserialise interface to put the order into the system and then send the invoice back to client as XML and hence remove the manual step from customer service and be able to record the invoice number on the client side.
I could write the data directly into the database tables but breaking the business logic and reinventing the wheel would not be a smart thing to do, hence the reason for my question, but given we are still currently running 6.5.13 due to other systems Jiwa interacts with I still have to code this under version 6 but will need to move it to version 7 eventually, any help on the version 6 code would be appreciated.
Thanks.
(probably in web api as wcf would over complicate things) that would take the XML logon to Jiwa and use the xml serialise/deserialise interface to put the order into the system and then send the invoice back to client as XML and hence remove the manual step from customer service and be able to record the invoice number on the client side
SBarnes wrote:Now I just need some help putting, the code together to save the order
SBarnes wrote:Now I just need some help putting, the code together to save the order, one other question I had also thought of is what does Jiwa do at the object level when an order is imported and the debtor account is on hold as I know the UI won't let you save the order?
Dim XMLDocument As String
Dim FileName As String
FileName = "C:\test.xml"
Dim handle As Integer
handle = FreeFile
Open FileName For Input As handle
XMLDocument = Input(LOF(handle), handle)
Close handle
Dim logicalWarehouseID As String
logicalWarehouseID = "ZZZZZZZZZZ0000000000"
Dim serverName As String
serverName = "JiwaMike"
Dim databaseName As String
databaseName = "JiwaDemo_060513"
Dim userName As String
userName = "JiwaLogin"
Dim password As String
password = "JiwaApplicationLogin123"
Dim connectionString As String
connectionString = "Provider=SQLOLEDB;" & _
"Data Source=" & serverName & ";" & _
"Initial Catalog=" & databaseName & ";" & _
"User ID=" & userName & ";" & _
"Password=" & password & ";"
Dim database As JiwaODBC.database
Set database = New JiwaODBC.database
database.ConnectionDetails = connectionString
Dim SystemProfile As JiwaSysProfile.clsSysProfile
Set SystemProfile = New JiwaSysProfile.clsSysProfile
SystemProfile.Load ("C:\Program Files\Jiwa Financials\Jiwa\Jiwa.xml")
Dim JLib As JiwaLib.StdFunctions
Set JLib = New JiwaLib.StdFunctions
Set JLib.database = database
Dim CommonLib As JiwaCommonLib.StdFunctions
Set CommonLib = New JiwaCommonLib.StdFunctions
Set CommonLib.database = database
If database.MakeConnections(Me.hWnd) = True Then
Dim userMustChangePassword As Boolean
Dim passwordLastChangedDateTime As Date
If database.DoLogOn("Admin", "password", userMustChangePassword, passwordLastChangedDateTime) = True Then
Dim salesOrder As JiwaSalesOrder.clsSalesOrder
Set salesOrder = New JiwaSalesOrder.clsSalesOrder
Set salesOrder.database = database
Set salesOrder.JiwaCommLib = CommonLib
Set salesOrder.JLib = JLib
Set salesOrder.SystemProfile = SystemProfile
salesOrder.Setup e_SalesOrderNormalSalesOrder, logicalWarehouseID
Dim NewSalesOrderID As String
If salesOrder.ConsumeXML(XMLDocument, NewSalesOrderID) = e_SalesOrderReturnCodeSuccess Then
If salesOrder.SaveOrder(-1, False, False) = e_SalesOrderReturnCodeSuccess Then
MsgBox "Saved Order " & salesOrder.InvoiceNo & "."
Else
MsgBox salesOrder.ErrorString
End If
Else
MsgBox salesOrder.ErrorString
End If
Else
MsgBox database.ErrorMessage
End If
Set JLib = Nothing
Set CommonLib = Nothing
Set SystemProfile = Nothing
database.BreakConnections
Set database = Nothing
Else
MsgBox database.ErrorMessage
End If
SBarnes wrote:Hi Mike
Great news I was able to get the code running and post the order, as always thanks for all your help.
I just have one last question is there a way to get the warehouseID without hard coding the value to ZZZZZZZZZZ0000000000 I tried WarehouseID = Database.CurrentLogicalWarehouseID; but got a null value which of course meant consuming the XML failed?
Thanks
Database.CurrentLogicalWarehouseID = SystemProfile.GetValue("JiwaDocument/Parameters/InventoryParams/LastLogicalWarehouseID")
Return to Technical / Programming
Users browsing this forum: No registered users and 3 guests