Given that we now can add to the inventory Import, like adding Notes, debtor specific pricing etc. Has anybody embarked on creating a plugin to import debtor partno, that they are willing to share.
Thanks.
Ernst wrote:Oh my G. on that..
Imports JiwaFinancials.Jiwa.JiwaApplication
Imports JiwaFinancials.Jiwa.JiwaApplication.Notes
Imports JiwaFinancials.Jiwa.JiwaApplication.Plugin
Imports JiwaFinancials.Jiwa.JiwaInventory
Imports JiwaFinancials.Jiwa.JiwaInventory.Import
Imports System
Imports System.Collections
Imports System.Runtime.CompilerServices
Public Class BusinessLogicPlugin
Inherits MarshalByRefObject
Implements IJiwaBusinessLogicPlugin
Public Sub New()
MyBase.New()
End Sub
Private Sub AppendProperties(ByVal destinationPropertyCollection As JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationPropertyCollection)
Dim newDestinationProperty As DestinationProperty = destinationPropertyCollection.Manager.CollectionItemFactory.CreateCollectionItem(Of DestinationProperty)()
newDestinationProperty.RecID = "Inventory.Note.NoteType"
newDestinationProperty.Caption = "Inventory Note Type"
newDestinationProperty.SetterMethod = Sub(inventory As Inventory, value As String, rowData As String, row As String(), rowNo As Integer, mapping As Mapping) Me.SetNoteInfo(inventory, value, rowData, row, rowNo, mapping)
Dim strArrays() As String = { "InventoryNoteType", "Inventory Note Type", "NoteType", "Note Type" }
newDestinationProperty.Aliases = strArrays
destinationPropertyCollection.Add(newDestinationProperty)
newDestinationProperty = destinationPropertyCollection.Manager.CollectionItemFactory.CreateCollectionItem(Of DestinationProperty)()
newDestinationProperty.RecID = "Inventory.Note.NoteText"
newDestinationProperty.Caption = "Inventory Note Text"
newDestinationProperty.SetterMethod = Sub(inventory As Inventory, value As String, rowData As String, row As String(), rowNo As Integer, mapping As Mapping) Me.SetNoteInfo(inventory, value, rowData, row, rowNo, mapping)
strArrays = New String() { "InventoryNoteText", "Inventory Note Text", "NoteText", "Note Text", "Note" }
newDestinationProperty.Aliases = strArrays
destinationPropertyCollection.Add(newDestinationProperty)
End Sub
Private Sub DestinationProperties_ReadEnd(ByVal sender As Object, ByVal e As EventArgs)
Me.AppendProperties(DirectCast(sender, JiwaFinancials.Jiwa.JiwaInventory.Import.DestinationPropertyCollection))
End Sub
Public Overrides Function InitializeLifetimeService() As Object
Return Nothing
End Function
Private Sub SetNoteInfo(ByRef Inventory As JiwaFinancials.Jiwa.JiwaInventory.Inventory, ByVal Value As String, ByVal RowData As String, ByVal Row As String(), ByVal RowNo As Integer, ByVal Mapping As JiwaFinancials.Jiwa.JiwaInventory.Import.Mapping)
Dim noteTypeDescription As String = ""
Dim noteText As String = ""
Dim myLoop As Integer = 1
Dim strArrays As String() = Row
Dim num As Integer = 0
While num < CInt(strArrays.Length)
Dim cell As String = strArrays(num)
Dim recID As String = Mapping.MappingCollection(myLoop).DestinationProperty.RecID
If (recID IsNot Nothing) Then
If (recID = "Inventory.Note.NoteType") Then
noteTypeDescription = cell.Trim()
Mapping.MappingCollection(myLoop).HasBeenSet = True
ElseIf (recID = "Inventory.Note.NoteText") Then
noteText = cell.Trim()
Mapping.MappingCollection(myLoop).HasBeenSet = True
End If
End If
myLoop = myLoop + 1
num = num + 1
End While
Dim noteType As JiwaFinancials.Jiwa.JiwaApplication.Notes.NoteType = Nothing
If (noteTypeDescription.Trim().Length > 0) Then
Dim found As Boolean = False
For Each existingNoteType As JiwaFinancials.Jiwa.JiwaApplication.Notes.NoteType In Inventory.Notes.NoteTypeCollection
If (existingNoteType.Description.ToUpper() = noteTypeDescription.ToUpper()) Then
noteType = existingNoteType
found = True
Exit For
End If
Next
If (Not found) Then
Throw New Exception(String.Format("Note Type '{0}' not found", noteTypeDescription))
End If
End If
Dim note As JiwaFinancials.Jiwa.JiwaApplication.Notes.Note = Inventory.Manager.CollectionItemFactory.CreateCollectionItem(Of JiwaFinancials.Jiwa.JiwaApplication.Notes.Note)()
If (noteType IsNot Nothing) Then
note.NoteType = noteType
End If
note.NoteText = noteText
Inventory.Notes.Add(note)
End Sub
Public Sub Setup(ByVal JiwaBusinessLogic As IJiwaBusinessLogic, ByVal Plugin As JiwaFinancials.Jiwa.JiwaApplication.Plugin.Plugin) Implements IJiwaBusinessLogicPlugin.Setup
If (TypeOf JiwaBusinessLogic Is JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport) Then
Dim inventoryImport As JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport = DirectCast(JiwaBusinessLogic, JiwaFinancials.Jiwa.JiwaInventory.Import.InventoryImport)
Me.AppendProperties(inventoryImport.DestinationProperties)
AddHandler inventoryImport.DestinationProperties.ReadEnd, New IJiwaCollection.ReadEndEventHandler(Of DestinationProperty)(AddressOf Me.DestinationProperties_ReadEnd)
End If
End Sub
End Class
AddHandler inventoryImport.DestinationProperties.ReadEnd, New IJiwaCollection.ReadEndEventHandler(Of DestinationProperty)(AddressOf Me.DestinationProperties_ReadEnd)
Public Interface IJiwaCollection(Of T)
Event Adding(ByVal item As T, ByRef e As System.ComponentModel.CancelEventArgs)
Event Added(ByVal item As T)
Event Removing(ByVal item As T)
Event Removed(ByVal item As T)
Event Changed(ByVal item As T, ByVal e As System.ComponentModel.PropertyChangedEventArgs)
Event ClearStart(sender As Object, e As System.EventArgs)
Event Cleared(sender As Object, e As System.EventArgs)
Event ReadEnd(sender As Object, e As System.EventArgs)
Event SaveEnd As IJiwaCommonInterfaces.SaveEndDelegate
Event ReOrdered(sender As Object, e As System.EventArgs)
ReadOnly Property Count As Integer
Default ReadOnly Property Item(ByVal RecID As String) As T
Default ReadOnly Property Item(ByVal index As Integer) As T
ReadOnly Property Contains(ByVal RecID As String) As Boolean
Property Reading As Boolean
Property IsAdding As Boolean
Property IsRemoving As Boolean
Property IsReordering As Boolean
Property RecIDIsGUID As Boolean
Property Tag As Object
Property AsynchronousSave As Boolean
Property IsSaving As Boolean
Property Manager As Manager
Property SuppressItemNoAdjustment As Boolean
Sub Add(ByVal item As T)
Sub Remove(ByVal item As T)
Sub RemoveAll()
Sub Clear()
Sub CleanUp()
Sub Read()
Sub iSave()
Sub Save()
Sub Setup()
Function GetEnumerator() As System.Collections.IEnumerator
End Interface
Public Event ReadEnd(sender As Object, e As System.EventArgs) Implements IJiwaCollection(Of T).ReadEnd
Public Class DestinationPropertyCollection
Inherits JiwaApplication.JiwaCollection(Of DestinationProperty)
Return to Technical and or Programming
Users browsing this forum: Google [Bot] and 0 guests