Approach for modeling a class to import/export information RRS feed

  • Question

  • In my web app (C#), we need to import/export an infinity of txt, xls and xml files. I would appreciate opinions or experiences on how would be an elegant (though easy way) to implement a class/componentto deal with this.

    BTW, the mechanism will be always the same, that is, import some information from a file (xml, txt or xls) and save it to the database (we are using an ORM), or read some information in DB and export it to a file (xml, txt or xls).

    Thursday, October 26, 2006 2:55 PM

All replies

  • What about requirements?

    • Are there requirements for the format of the files?
    • What database is being used?
    • Does it need to support multiple database types?
    • Do you always import / export the same datamodel or can the user choose what tables / data to import / export?

    P.S.: I don't like to be a nag, but it's almost impossible to give an opinion on this without at least an idea of what you're trying to do. That's why all the questions.

    Friday, October 27, 2006 7:10 AM
  • Lets say each type of file has a different kind of requirement. Its a financial app, that runs as backoffice. So I need to import information on quotes, operations, customer register etc (each of this has a different format) and export information on operations, consolidated balance accounts etc (each of this has a different format)

    I have to be able to import/export from MySql, Oracle and SqlServer

    Friday, October 27, 2006 1:43 PM
  • Ok, here we go.

    Obviously, you need a DAL, to support for the different database access types. Depending on the level of your users, you may want to be able to configure preset databases (can be handy for yourself as well).

    On top of that you want a layer to handle any conversion logic and send the data to the right DAL class for the selected database.

    And then you also want a layer to handle the reading from file. Depending on difference in files, you can use a single class or have multiple classes. This also depends on exact requirements (maintainability, etc.).

    Hope this gives you a direction for the design of your solution

    Monday, October 30, 2006 8:35 AM
  • Do you know any component for .net that might do something like what Access and Excel do when we try to import a txt file, asking for layout parameters...?
    Monday, October 30, 2006 4:11 PM
  • I don't think there is a component like that, but you could consider using office itself to do this bit for you. You can then read the data from office. In that case use Access, because reading from excel is in this case only feasable trough COM and that will not perform.

    If you can use access to import the data, then all you need is a datapump with maybe some conversion logic and you're all set.

    Tuesday, October 31, 2006 6:45 AM