Background
I'm developing an internal app for the company I work for.
The company is an Industrial Engineering Consultory, and we have to make studies of times, methods, etc, etc.
The thing is, I'm now creating the internal version which will generate the methods, get the inputs, etc etc.
I'm running a REST API which will run in local network in the office, that contains user information, what projects is the user working in, etc... but then it comes the difficult part I don't know how to deal with.
My boss put as requirement that everything should be in files, so he can make a backup everyday. Actually, they work with Excel files, and everything is organised on a local server/repository with a folder hierarchy where all these excel files reside.
Now, they are giving the clients a USB Pendrive with that folder with all in Excels and so on: not too professional as you can guess. The target with this new software is to give the clients an application (which will be developed later) where they can open a file, called projectname.project, or something like that. When the import the file, they got all the project on it, and they can see all the info, studies, statistics, etc etc.
Problem
The hierarchy of the system is divided as follows:
- Company
- Project 1
- Project 2
- Project 3
- Report Type 1
- Report Type 2
- Study 1
- Study 2
- Study 3
- Task 1
- Task 2
- Task 3
Now, for the local application, the one used by our employees, everything is being stored separately and be loaded as they need it from our internal server. I'm opting for the Binary save to file, as found in a lot of answers here on SO.
The problem comes when I have to export this in some format that the client can import and see completely: he cannot be receiving 10 files, he must receive one that loads all the project on the client app (to be developed).
Question
Being said that, that the info is stored on files locally, referenced by a MySQL database that make the relations between them, the users, etc.
How can I generate a file, with whatever extension, that can be given to a client by email and they can just go to the new app and just open the file and have access to all the hierarchy I write above those lines? The process is like merging all the files in just one, but how can I do that?
My first approach is to create another app (or a section in the app) that will generate a huge Object Class called Project, and then save that Project Object to a file, but I'm not sure if it's gonna work, as there maybe like 100 task for every study, 50 studies for every project...
Actual code
There is not much to show regarding the problem, what I do now with every part of the project is to save that Object Class to a file and reference it on the database.
I generate the files and read them as follows:
public static void WriteToBinaryFile<T>(string filePath, T objectToWrite, bool append = false)
{
using (Stream stream = File.Open(filePath, append ? FileMode.Append : FileMode.Create))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
binaryFormatter.Serialize(stream, objectToWrite);
}
}
public static T ReadFromBinaryFile<T>(string filePath)
{
using (Stream stream = File.Open(filePath, FileMode.Open))
{
var binaryFormatter = new System.Runtime.Serialization.Formatters.Binary.BinaryFormatter();
return (T)binaryFormatter.Deserialize(stream);
}
}