Page 1 of 1

File watcher updating Sales Order acting strange

PostPosted: Wed Feb 03, 2016 9:21 pm
by indikad
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   


Re: File watcher updating Sales Order acting strange

PostPosted: Fri Feb 05, 2016 1:24 pm
by indikad
I am trying out a few different scenarios with this now to see if it is data related - will update.

Re: File watcher updating Sales Order acting strange

PostPosted: Fri Feb 05, 2016 2:03 pm
by indikad
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.

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

PostPosted: Sun Feb 07, 2016 2:29 pm
by Mike.Sheen
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.