Windchill Business Analytics: Programming Journal
Part 09 - Running Multiple Queries in Sequence
Last Updated: August 31, 2016
With the main loop complete, it's time to start revisiting what the purpose of the program is. I want to query data and display it in a different and meaningful form to the user. This sometimes requires manipulation and often requires lots of data being pulled from many different database tables. It is not always possible to get everything I need in one query and it is certainly not possible to get all the data for the many (yes, there will be more than the 1) charts and tables that the final program will have. The first step is to look at how to grab all the data necessary for the entire program in the same single loop. I will need to run multiple queries that will each need its own manipulation, processing, and possibly XML format.
Having a Windows Form GUI is nice but it is really just getting in the way and cluttering the code. My program's interface will be the one the user sees which is the html anyways so I will start by converting the GUI program into a console version.
Having a Windows Form GUI is nice but it is really just getting in the way and cluttering the code. My program's interface will be the one the user sees which is the html anyways so I will start by converting the GUI program into a console version.
program.cs
You can see how much simpler the code now it. I still have my timer but where did my query and big XML creation stuff go? I figured it was going to be a real mess placing all the (100s?) or queries in a single main program file and then having to scroll through all of them to fix something. I prefer as little scrolling as possible. I created a Queries class which houses query functions 1-4. The separate file keeps all of my queries away from the main program while I am coding. I plan to create a new query class and file for each of the main sections of the program later on but to prove that it works I have added a few extra queries for testing.
Queries.cs
It should be fairly obvious by now that this is more of a code separation a cleanup. I am simply repeating all the same steps of connection to the database, executing the query, and then displaying the display for functions 1-3 and generating the xml for function 4. Nothing special going on here. A quick running of the program proves it is working.
At this point, it is a matter of deciding what queries to run, what to do with each dataset, and then creating a function for each new query.