简体   繁体   中英

Config/Settings for a Microsoft CRM 2011 Form Silverlight Control

Need an idea on best practise in finding a solution.

We are looking at developing Silverlight controls for CRM forms that will need to reference a common configuration file for data. It is a file that will need to be maintained periodically every once in a while. We don't want to be hardcoding values into the Silverlight control.

My question is... Where/What/How do we provide a config file for a Silverlight control?

I tried uploading a JS web resource that simply was a JSON array full of settings that I tried to access from the Silverlight control. All I got were permission errors when I used both the admin account and my domain account to do a Http get of the file and parse it. Can someone confirm that this could work if I manage to work through these annoying permission errors?

My next thought was having a CRM entity full of settings that the Silverlight control could make ODATA calls to in order to get its config data. I'm not 100% sold on the idea though.

Perhaps there is another way people have been using - if so - I'd love to see what you are doing. This could really prevent us from coming to a Silverlight enriched solution that we are after.

Thanks in advance

We use the configuration entity method quite often and I think it works well.

You should be able to use your initial method as well... I know in a few places we've done some XML configuration in a web resource that we've retrieved in Silverlight, parsed, and done something with.

We go about this in two ways.

  1. We have a configuration entity for settings that might be changed on a customer site by their administrator.
  2. For other configuration data that is unlikely to be changed, we install an XML web resource. This method means we can store a lot of data without having to create and manage complex entities (or relationships if required). If set as an unmanaged/customizable web resource, then the text editor can be used to make changes, although remember that these changes must not break the XML schema/syntax.

This xml web resource can be retrieved in Silverlight using WebClient.DownloadStringAsync() as shown below.

private void GetXmlConfiguration(string resourceName)
{
    var webClient = new WebClient();
    webClient.DownloadStringCompleted += OnGetConfigurationXmlCompleted;
    webClient.DownloadStringAsync(new Uri("../Data/" + resourceName, UriKind.Relative));
}

private void OnGetConfigurationXmlCompleted(object sender, DownloadStringCompletedEventArgs e)
{
    if (e.Error == null && !string.IsNullOrEmpty(e.Result))
    {
        //use xml string here
    }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM