Best way to integrate existing database

Topics: Customizing Orchard, Writing modules
Oct 30, 2011 at 4:50 PM

I have a fairly large site that I'm interested in migrating to Orchard. I'm curious about the best way to go about this. The site has an extensive admin application (literally dozens of content types [though I'm not sure that they're completely analogous to Orchard "content types"]), a large SQL database (around 80 tables, over a hundred stored procedures, etc.), and a LOT of data. We dynamically server over a 100k pages from this database.

A sample of the types of content that are stored in the database:

Knowledgebase articles


Events (trade shows, seminars, etc)

Home page blurbs (similar to a blog post, I guess)

Discussion forum

Product documentation (mostly manuals)

News items (articles, press releases, etc.)

Now, I don't want to reimplement the entire database. The admin interface code is pretty much a lost cause as far as integration goes - most of it's in classic ASP *sniff*. So, in the interest of really using Orchard, I'm curious how I can:

1. Add pages to the Orchard admin site that let administrators maintain these items.

2. Keep these items in their existing database, separate from the Orchard database

3. Retain the existing SQL stored procedures that my admin site calls to manipulate these items. One of my requirements is to limit access to this sort of application-specific data (ie, everything that doesn't go in the Orchard database) to stored procedure access. (My site currently uses a database account that only has rights to execute sprocs, and it has to stay that way for any data that isn't Orchard-specific.)

4. Several of these areas are tied to external applications - services that export to our CRM and accounting systems, generation of proprietary format subsets of some of the tables for inclusion in a client application that we sell, etc - so, again, keeping the existing database structure is a must.

5. How can I extend the Orchard permissions feature to include more granular rights? I need some users to be able to edit News items, but deny them rights to, for instance, product documentation. Currently, I have a table that defines rights per-user, which works well as the users don't fit into nice groups like "editor" and "contributor." Permissions are often disjoint, incomplete (some can only edit *some* pages within the documentation area)

I don't want to create a separate admin module as obviously it would be ideal if editors, etc for these things could show up in the Orchard site. 

I've looked at this example:

which answers some of my questions, but doesn't really go into how to keep the data in a separate database.

Apologies for number of queries in a single post, and thanks in advance for your assistance.



Nov 1, 2011 at 9:30 PM

Classic ASP is pretty much a lost cause here. Accessing an external database is possible, but you'll have to redo all those pages or keep them as they are in a completely different site.

Nov 1, 2011 at 9:44 PM

OK, so to get to your specific questions:

  1. If you are ready to remake those in Orchard, you would create an admin controller in your module and just opt out of the ambient transaction around your data access code (do a search on the discussions, there are some other examples of that).
  2. Sure, see 1.
  3. No problem, it's your code that will access that other database, you're in control.
  4. Not sure what the question is here :)
  5. The permission system is fully extensible. Look for files named permissions.cs throughout existing modules for simple examples. The Quanta module also enables per item permissions. You could do something similar with your own external content.

Save for running your old code in a frame though, you'd have to build an Orchard module.