IDataLoader - RyanMarinoff/ISW-Prism GitHub Wiki
All code that would be used to read and write the files for the website would be placed within the IDataLoader
. This will be a static class so that it does not need to be instantiated. It will basically be just a couple of function calls, ready to be compiled as a .dll in a future update.
Data Store
The storage of the data is within the IDataLoader as a sub-class named IData. This subclass is marked private to prevent unwanted access to the raw data within the database.
IData
Categories, Option Categories, Options, Vendors, and Products (Includes the ParentProduct with the associated ChildProduct) are stored as a List of their objects.
Accessors
Each type of data is accessed via static properties. There will be a property made for each need, including properties that will count and format data in the appropriate manner for each call. Each call will be made for each of the lists within IData
. So to make it easy to read here, the following format will be used:
[Property][call] - [Description]
[Property]
will be the list that is needed, be it Categories, Option Categories, etc. If below I use [Property]
, then it is assumed this call is used for each data storage. [call]
will be replaced with the name of the call.
[Property]Count
- Returns the number of items within the list. This will return -1 if the list has not been initialized.
LoadOptions
| LoadCategories
| LoadVendors
With the first three public functions, you will pass the file location (as a string
). The function will fill the appropriate list with the data that is presented within the file location.
LoadProducts
This public function will require the data of the Options
, Categories
and Vendors
to be already loaded. Due to this, the function will throw an Exception
if the appropriate data is not ready.
ParentProduct
is the main data storage unit. This will contain all products that are within the database, including all child products. ChildProduct
will be created upon need and placed within the appropriate ParentProduct
.
First fill in all product information. Then determine if the item is a parent or child product. The database always will list the parent product before the child product. This will be changed within the code in the future to accommodate when this is not true.
ProcessData
This private function will read the data file, determine the headings and data, format it into a Dictionary
of string
|string
, and then return that Dictionary
to the caller. This is used within the functions that process the different models.
CreateCSV
Not implemented yet...
This function will take two lists, a string
and an object
(either Options, Categories, Vendors, or Products) and write the data into a CSV file that can be used to upload to the website database. The string will be the fields that have been changed, and the objects will be the items that were changed.