File watcher updating Sales Order acting strange  Topic is solved

Discussions relating to Jiwa 7 plugin development, and the Jiwa 7 API.

File watcher updating Sales Order acting strange

Postby indikad » Wed Feb 03, 2016 9:21 pm

Jiwa version 7.0.135
I am not sure how to explain this so here is the scenario.
1. using csv import - using the event ( CSVSalesOrderWatcher.FileImport) to import a CSV file to EDIT an existing sales order. No matter what I do I get the following error ( in windows logs )
"Failed to import File 'C:\Temp\Watch\TestFile_so0054000.csv' - Error: Index (zero based) must be greater than or equal to zero and less than the size of the argument list."

Worse - the second line ( the last line ) of the order has been changed - The quantity ordered is copied to quantity Back ordered ( see screen shot ). Both lines had the Demand field set equal to ordered field before the operation. ( Note there is plenty of stock on hand )

While my final aim is to update the Quantity Del, the code I am testing with does not do any updates to the order - yet this happens ! see simplified code below. and the sample file attached.

HELP!

Code: Select all
   Dim salesOrder As JiwaSales.SalesOrder.SalesOrder = JiwaApplication.Manager.Instance.BusinessLogicFactory.CreateBusinessLogic(Of JiwaSales.SalesOrder.SalesOrder)(Nothing)      
               
      Using csvParser As New FileIO.TextFieldParser(FileName)            
         csvParser.TextFieldType = FileIO.FieldType.Delimited
         csvParser.Delimiters = New String() {","}
         csvParser.HasFieldsEnclosedInQuotes = False
            
         Dim csvFields As String()
         Dim previousOrderNo As String = Nothing
         Dim newKey As String = ""
         Dim debtor As JiwaApplication.Entities.Debtor.Debtor = New JiwaApplication.Entities.Debtor.Debtor
         Dim inventory As JiwaApplication.Entities.Inventory.Inventory = New JiwaApplication.Entities.Inventory.Inventory
         Dim sInvNo As String = "
         
            csvFields = csvParser.ReadFields   
            sInvNo  = "0054000" ' csvFields(0).ToString().Trim() '-- JiwaInvoiceNo            
            Dim salesOrderLine As JiwaSales.SalesOrder.SalesOrderLine                   
            Dim sLineId As String = "3be372b3446949ffb882" 'csvFields(2).ToString().Trim()                     
            Dim qtyThisDel As Decimal  = 0            
            CSVSalesOrderWatcher.LogToEventLog("Updated sales order InvNo: " + sInvNo + " FileName: " + FileName , System.Diagnostics.EventLogEntryType.SuccessAudit)
                        
      End Using   

Attachments
TestFile_so0054000.csv
(122 Bytes) Downloaded 406 times
ScreenShot.png
ScreenShot.png (10.42 KiB) Viewed 2182 times
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: File watcher updating Sales Order acting strange

Postby indikad » Fri Feb 05, 2016 1:24 pm

I am trying out a few different scenarios with this now to see if it is data related - will update.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: File watcher updating Sales Order acting strange

Postby indikad » Fri Feb 05, 2016 2:03 pm

I've just found the code works if the sevice "Jiwa 7 Plugin Scheduler Service" is set to run under admin rights ( as opposed to the Local System account ).
detected this by chance as I was wondering why my debug information to file dump was not working too.
looks good.
indikad
Frequent Contributor
Frequent Contributor
 
Posts: 182
Joined: Thu Jun 18, 2009 1:14 pm
Topics Solved: 2

Re: File watcher updating Sales Order acting strange  Topic is solved

Postby Mike.Sheen » Sun Feb 07, 2016 2:29 pm

indikad wrote:I've just found the code works if the sevice "Jiwa 7 Plugin Scheduler Service" is set to run under admin rights ( as opposed to the Local System account ).
detected this by chance as I was wondering why my debug information to file dump was not working too.
looks good.


Glad you got it working.

This seems to be a bug / oversight with the standard "File Watcher" plugin - it's trying to log to an event log source containing the plugin name:

Code: Select all
       Public Sub LogToEventLog(ByVal Message As String, ByVal EventLogEntryType As System.Diagnostics.EventLogEntryType)
      Dim Log As New System.Diagnostics.EventLog("Application")
      Log.Source = String.Format("Jiwa Plugin : {0}", Me.Plugin.Name )
      Log.WriteEntry(Message, EventLogEntryType)
      Log.Close()
   End Sub


Which is in the case of our standard File Watcher plugin, "Jiwa Plugin : File Watcher". No such event log source exists - so it's probably upset with that.

When you install Jiwa, we create a "Jiwa 7" event log source - so if the plugin used
Code: Select all
      Log.Source ="Jiwa 7"

instead of
Code: Select all
      Log.Source = String.Format("Jiwa Plugin : {0}", Me.Plugin.Name )


Then it would *probably* work as the local system account. An alternative is to create the event log source to match what the File watcher is using : "Jiwa Plugin : File Watcher".

I've logged this as bug 12462.
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: 2583
Joined: Tue Feb 12, 2008 11:12 am
Location: Perth, Republic of Western Australia
Topics Solved: 807


Return to Technical and or Programming

Who is online

Users browsing this forum: No registered users and 3 guests