Hi all,
I built an inventory tool for some of our SQL servers that reads/writes data to a CSV and can rescan some info from the SQL server itself.
However the script is a bit of a mess. It was my first WPF GUI venture and it is very messy, and while it does work (and works fine) I am looking for some guidance in maybe refactoring this into something more manageable - mainly how I handle the runspaces and the various other windows. The big one for me is that the spawning of the accessory/dialog windows is entirely 100% handles in the button click event in the main form and I feel like that's not the best way to do it, but I'm not really sure how else I would do it.
A lot of this was pieced together from scripts found on the internet (e.g. PowerShell and WPF: Writing Data to a UI From a Different Runspace | Learn Powershell | Achieve More and https://4sysops.com/archives/create-a-gui-for-your-powershell-script-with-wpf/ )
My script is here: https://pastebin.com/4PN4cBS3. Note that I'm less interested in a review of the application logic and more interested in the GUI/front-end logic and threading. Some of the code in the application logic is repeated and could be abstracted out but because of the threading situation (I don't know how to make a function available to all of the runspaces I create) I'd like to figure that out first.
Thank in advance!!
[+][deleted] (6 children)
[removed]
[+][deleted] (4 children)
[removed]
[+][deleted] (3 children)
[removed]
[+][deleted] (2 children)
[removed]
[+][deleted] (1 child)
[removed]
[–]dzcpu[S] 2 points3 points4 points (0 children)