Custom Modules / Business Layer / Resource Settings

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

Please do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.

This forum is for discussing mojoPortal development

This forum is only for questions or discussions about working with the mojoPortal source code in Visual Studio, obtaining the source code from the repository, developing custom features, etc. If your question is not along these lines this is not the right forum. Please try to post your question in the appropriate forum.

You can monitor commits to the repository from this page. We also recommend developers to subscribe to email notifications in the developer forum as occasionally important things are announced.

Before posting questions here you might want to review the developer documentation.

Do not post questions about design, CSS, or skinning here. Use the Help With Skins Forum for those questions.
This thread is closed to new posts. You must sign in to post in the forums.
7/29/2011 12:37:05 PM
Gravatar
Total Posts 6

Custom Modules / Business Layer / Resource Settings

Hi,

I'm creating some custom features for our site which need a Business Layer etc as they get data from web services. I've set up my custom projects as described here: http://techblog.strongeye.com/archive/2009/12/16/creating-a-mojoportal-module.aspx so I have project myProject.Data, MyProject.Business and MyProject.UI

In my Business Layer I need to run the XML responses through an XSLT to format the data to pass to the custom features. The location/names of these XSLTs need to be changeable without changing code & recompiling. 

I've tried to replicate what happens in the mojoPortal.Business project and currently have a Properties folder with resource files in it. However I'm getting errors with them. If I name the resource file Resources.resx I get errors as I'm conflicting the the mojoPortal Resources class, but it seems to want the file to be named 'resources' is automatically appended when I try to create the ResourceManager.  If I name it something else I can compile but get error:

Could not find any resources appropriate for the specified culture or the neutral culture.  Make sure "myProject.Business.Properties.MyResourceFile.resources" was correctly embedded or linked into assembly "myProject.Business" at compile time, or that all the satellite assemblies required are loadable and fully signed

I'm trying to access the resource file though a resource manager:

System.Resources.ResourceManager("MyProject.Business.Properties.Resources", typeof(MyBusinessLayer).Assembly);

Is it possible to have settable business layer properties in a resource file or do I need to do this in an entirely different way? I do have resource files for the custom features which I then access with mojoPortal.Web.Settings, which works great.

7/29/2011 12:52:02 PM
Gravatar
Total Posts 18439

Re: Custom Modules / Business Layer / Resource Settings

Resource files are for localization of strings not for property storage. I would think of using a custom xml config file for things you want to be able to change.

The only thing is in order to resolve the path to your custom config file so you could read it using system.IO classes or XmlDocument is that you would need a reference in your business layer to System.Web, so that you could resolve the path to your file like this:

string pathToFile = System.Web.Hosting.HostingEnvironment.MapPath("~/pathtoyourcustom.config")

then you can open it as xml and process it.

Hope that helps,

Joe

7/29/2011 6:24:36 PM
Gravatar
Total Posts 355

Re: Custom Modules / Business Layer / Resource Settings

Kate,

Since the name/location string is a variable that you'll need to be able to change "on the fly" - have you considered making it a config entry for the module itself?

7/31/2011 5:05:11 AM
Gravatar
Total Posts 104

Re: Custom Modules / Business Layer / Resource Settings

KateS,  Did you copy resource file from mojoportal projects to your custom project or you create a new one by adding new Item?

Some times I got such as this error message when I works by resources that copied from other projects.

When I create a new resource file and add the keys from main resource file,it works for me.

(I wrote it about your problem by using resources not about what you have to do)

 

regards

Mehdi

8/1/2011 12:29:04 PM
Gravatar
Total Posts 6

Re: Custom Modules / Business Layer / Resource Settings

Ashlan - no, these are new resource files. Thanks for the suggestion though.

Sounds like configs might be the right way to do this. I was wanting to avoid those as I didn't want to have to edit server files to switch to a new xslt. I was hoping I could somehow arrange it so our admin users of the site could create the xslt, upload a new version to their allowed directory & then use the mojoportal admin pages to set which xslt to use. The values don't need to change on the fly - my code won't set them - it just would've been nice to have a way of changing them without editing server files.

Joe - I think I may be misunderstanding how the module settings / resource files work in mojo. I don't need localisation, just values. I thought that the resource file changed the label/text displayed to describe the setting on the admin edit panel, and the value is stored in the database - is that not correct? I do have this working perfectly on the custom controls themselves, I was trying to replicate it in the Business Layer which standardises the XML that passes to the custom controls.

You must sign in to post in the forums. This thread is closed to new posts.