Page 1 of 1

Extending Inventory CSV Import with VB  Topic is solved

PostPosted: Mon Jun 19, 2017 10:06 pm
by pricerc
Further to https://forums.jiwa.com.au/viewtopic.php?f=26&t=565, and with thanks to Mike for some direction and the extra supplier stuff, I have combined the P1-P10 price extensions and the Supplier/Supplier Warehouse SpareX fields into the attached VB-based plugin.

...not because I have anything against C#; I just need my code to be understandable by people who may need to be talked through 'tweaking' said code.

... complete with anonymous delegates that as a rule, I don't like ... but that's a discussion for a different forum

Re: Extending Inventory CSV Import with VB

PostPosted: Mon Jun 19, 2017 10:34 pm
by Mike.Sheen
Hi Ryan,

pricerc wrote:Further to https://forums.jiwa.com.au/viewtopic.php?f=26&t=565, and with thanks to Mike for some direction and the extra supplier stuff, I have combined the P1-P10 price extensions and the Supplier/Supplier Warehouse SpareX fields into the attached VB-based plugin.

...not because I have anything against C#; I just need my code to be understandable by people who may need to be talked through 'tweaking' said code.

... complete with anonymous delegates that as a rule, I don't like ... but that's a discussion for a different forum


Cool - thanks for sharing!

PS: once you create a function to act as a delegate - it's not really anonymous - it's just a delegate function. I notice also you made your delegates shared - which is fine - but you don't have to, even a private function would work.
Also, the "If Diagnostics.Debugger.IsAttached Then Diagnostics.Debugger.Break()" lines are probably an oversight left in for debugging - but I'm not judging ;) - Happy to see others contributing - more to come, I hope!

Re: Extending Inventory CSV Import with VB

PostPosted: Tue Jun 20, 2017 7:16 am
by pricerc
Mike.Sheen wrote:Hi Ryan,
PS: once you create a function to act as a delegate - it's not really anonymous - it's just a delegate function. I notice also you made your delegates shared - which is fine - but you don't have to, even a private function would work.!


Mike, there's still an anonymous delegate in there (well, 10 of them, for setting the Px prices) - although I moved the logic for creating them to a named method (GetSetPriceDelegate), that method nonetheless returns an anonymous delegate :)

The 'Shared' methods come from CodeRush, which I use for refactoring. The code in those methods was embedded where they're called from before I got CodeRush to extract the methods. Since that bit of code that I extracted had no references to instance properties, CodeRush has created them as Shared, which improves performance slightly in some scenarios (although probably not noticeably in this one, since this class won't be getting instantiated in volume).


Mike.Sheen wrote:Also, the "If Diagnostics.Debugger.IsAttached Then Diagnostics.Debugger.Break()" lines are probably an oversight left in for debugging - but I'm not judging ;)

Actually, I know it's probably bad, but I mostly leave those in. Since I'm the only one who ever has a debugger attached, nobody ever notices, so I haven't stressed about it.

Of course I also hope that anyone using the code looks at it a bit first, and makes changes suitable for the environment it's going into. For example, the captions and auto-mapping strings for the spare fields should be customised for how they are used in the target environment.

Mike.Sheen wrote:Happy to see others contributing - more to come, I hope!

Happy to share, I hope it encourages others to do the same!

I'd like to share more, although most of the mods I'm making are highly customer-specific. Even with this one, I've only supplied the BusinessLogic part of the whole plugin we've deployed, since the rest of if wasn't relevant to this discussion.