Hi, i have a very tough problem for me to solve, and i thought and searched alot and came down t one conclusion which i will mention down. the problem is i have a client that wants to create a websites based on a Common functionality, so let us call it Modules, so what i thought is to use MVC Contrib Portable Areas, which are great ideas to plug Modules, but i have a big problem, let us say i created a Blog module which will be implemented in a new site he want, now some users have unique requirements like one of them needs to add Gallery of pictures to each article, or List of references in each article. this would be easy in normal situation where you have one site to work on, so all what you have to do is
- add a new gallery table with Foreign key to the Blog table.
- regenerate Linq2SQl code and update the Model.
- add new form elements to the Create,Edit,Delete Views .
- add the logic in the controller.
but in my situation it is complicated and time cumbersome because of 2 reasons
- if the new functionality is cool and client decide to implement it in all sites, then i have to repeat the work for each site.
- if the functionality is unique it will create inconsistency for me in future
that is why as first step to solve the problem i used Portable Areas to create Addons for each Module, now this will definitely ease my work by dragging 1 DLL for each new Module or Addon, but i have a little problem here, which
- because the new Module or Addin is a Dll, how can i create such a functionality in My Admin panel to install the new Addon or find any new added Module/Addon dragged new DLLS to the Main Application
- What is best practice to create an installation procedure inside the Portable Area, like Update the DB, New Routes,etc..
Now to the biggest Problem which is specific to Module Addon :) let us take back the Article Gallery Addon, if i follow the logic i have mentioned above by creating it as a Portable area, it would be easier to create a functionality in the Module Code to loop through all Installed Addons and list them in the CRUD Views, but because i isolated the Addon and don't want to manually update the Main Module Code for the Reasons Above there will be no way for doing CRUD operations for the new Addons in Sync with the main module because there is no Foreign Key Relation, again because as i said above it may be Optional, so i thought of the following solution which i hope there would be a better one
First in Installation Process i will create a Table for the Gallery Addon, but instead of creating a foreign Key relation i will create a manual Foreign Key which will get populated by Generating a Unique ID in the Main Module Controller when i create record by using the following code then store it in ViewData and just pass it to the Addon Controller when i create the new Record,
private string GenerateId()
{
long i = 1;
foreach (byte b in Guid.NewGuid().ToByteArray())
{
i *= ((int)b + 1);
}
return string.Format("{0:x}", i - DateTime.Now.Ticks);
}
ViewData["FK"] = GenerateId();
but here are my Concerns
- Is this way feasible or just plain Stupid.
- is this technique will generate a truly unique key.
i am extremely sorry if my question is lame, but this is the best place to ask and i think many people would want to have such a functionality and hope someone will answer me thanks in advanced.