0

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);
    }
}
Dani Aguado
  • 215
  • 1
  • 14
  • It's a little hard to understand what the problem (the stories are beautiful but no body really care :-) ). Anyway, if you're using directories for the hierarchy - do it recursive, if you have a database add a parent_id column and use `connect`. pay attention, connect useful for select but for update you need to use a little trick - see this link: https://stackoverflow.com/questions/45296550/sql-syntax-for-update-query-with-connect-by-prior – AsfK Aug 03 '17 at 10:29
  • I know how to access recursively to the entities, that's not the problem. As described on the **question** section, the difficult thing is how to export everything at one file so it can be imported on another computer, on the client, after sending him the file via email. – Dani Aguado Aug 03 '17 at 10:35
  • save it **as data base table** (you can use csv file, take the idea). see the link in my first comment. **another option** is to use a tree (not binary one), then you can export a tree to file, one example: https://stackoverflow.com/questions/6239544/populate-treeview-with-file-system-directory-structure. **another way** - use xml/json file.. – AsfK Aug 03 '17 at 10:39
  • The tree option is the one I was valorating, but as I said on the question, maybe can be a huge and the program cannot handle the proccess of generating that tree.. but maybe, if noone have come to a better solution, I'll need to generate that tree then. – Dani Aguado Aug 03 '17 at 10:41

0 Answers0