[mapguide-users] Resource data was not found

Robert Bray rbray at robertbray.net
Wed Oct 11 14:08:09 EDT 2006


This problem is not related to session timeout. MgMap.Open takes the 
name of the runtime map object, not a MapDefinition. Is this script 
invoked by an InvokeURL command? If so you should be getting the MAPNAME 
and SESSION parameters from the post data. The MAPNAME parameter should 
be passed into MgMap.Open as the second argument. The SESSION parameter 
should be used in the creation of MgUserInformation.

If you are not running this script from InvokeURL, then you need to call 
MgMap.Create instead, passing in an instance of MgResourceService, the 
resource id of the Map Definition, and name of the runtime instance of 
the map to create. There is no way to hook up a map created in this way 
back to the viewer however (or at least no way that I am aware of).

Bob


François Van Der Biest wrote:
> You might find a solution to your problem here : 
> http://www.nabble.com/How-to-check-if-session-is-expired--tf2218864.html#a6549987 
>
>
> It took me a lot of time to find this trick.
>
> F.
>
> Cory Gregor a écrit :
>> The code is blowing up on this line:  map.Open(ResourceService,
>> mgResourceID);
>> The browser is telling me " Resource datawas not found:  
>> RuntimeDataResource
>> data was not found: ....."
>>
>> Is the some IIS config problem maybe?  IIS 6 on Win2k3 Server.
>>
>> Here is the code...
>>
>>     //String mapDefinition =
>> "Library://Samples/FredWeber/Maps/Default.MapDefinition";
>>     //String webLayout = 
>> "Library://Samples/FredWeber/FredWeber.WebLayout";
>>     String sessionId = "";
>>     String NoLayers = "No Layers Selected";
>>
>>     try
>>     {
>>         MapGuideApi.InitializeSockets();
>>         InitializeWebTier();
>>
>>         MgUserInformation userInfo = new 
>> MgUserInformation("XXXX","YYYY");
>>         MgSite site = new MgSite();
>>
>>         site.Open(userInfo);
>>
>>         sessionId = site.CreateSession();
>>
>>         MgSiteConnection siteConnection = new MgSiteConnection();
>>         siteConnection.Open(userInfo);
>>
>>         MgResourceService ResourceService =
>> siteConnection.CreateService(MgServiceType.ResourceService) as
>> MgResourceService;
>>         MgFeatureService FeatureService =
>> siteConnection.CreateService(MgServiceType.FeatureService) as
>> MgFeatureService;
>>         MgFeatureQueryOptions QueryOptions = new 
>> MgFeatureQueryOptions();
>>
>>         MgResourceIdentifier mgResourceID = new
>> MgResourceIdentifier(mapDefinition);
>>                 MgMap map = new MgMap();
>>                 map.Open(ResourceService, mgResourceID);
>>         Response.Write("Got here");
>>         MgSelection selection = new MgSelection(map);
>>
>>         selection.Open(ResourceService, "map");
>>
>>         MgReadOnlyLayerCollection Layers = selection.GetLayers();
>>
>>         if (Layers.GetCount() > 0)
>>         {
>>             for (int i = 0; i < Layers.GetCount(); i++)
>>             {
>>
>>                 //Only check selected features in the Parcels layer.
>>
>>                 MgLayer Layer = Layers.GetItem(i);
>>
>>                 if (Layer != null && Layer.GetLayerDefinition() == new
>> MgResourceIdentifier("Default_Map Base_727(3)"))
>>                 {
>>                     //Create a filter containing the IDs of the 
>> selected                     //features on this layer
>>
>>                     string LayerClassName = Layer.GetFeatureClassName();
>>                     string selectionString = 
>> selection.GenerateFilter(Layer,
>> LayerClassName);
>>
>>                     //Get the feature resource for the selected layer
>>
>>                     string LayerFeatureId = Layer.GetFeatureSourceId();
>>                     MgResourceIdentifier LayerFeatureResource = new
>> MgResourceIdentifier(LayerFeatureId);
>>
>>                     //Apply the filter to the feature resource for 
>> the                     // selected layer. This returns
>>
>>
>>                     //an MgFeatureReader of all the selected features.
>>
>>                     QueryOptions.SetFilter(selectionString);
>>
>>                     MgFeatureReader FeatureReader =
>> FeatureService.SelectFeatures(LayerFeatureResource, LayerClassName,
>> QueryOptions);
>>
>>                     //Process each item in the MgFeatureReader, 
>> displaying
>> the                     //owner name and address
>>
>>                     while (FeatureReader.ReadNext())
>>                     {
>>
>>                         string val = 
>> FeatureReader.GetString("FeatureID");
>>
>>                         //FeatureReader.GetString("Layer");
>>
>>                         Response.Write(val);
>>
>>                     }
>>
>>                 }
>>
>>             }
>>
>>         }
>>
>>         else
>>         {
>>             Response.Write(NoLayers);
>>         }          
>>         MapGuideApi.TerminateSockets();
>>     }
>>     catch (MgException mge)
>>     {
>>         Response.Write(mge.GetMessage());
>>         Response.Write(mge.GetDetails());
>>         MapGuideApi.TerminateSockets();
>>     }
>>   
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe at mapguide.osgeo.org
> For additional commands, e-mail: users-help at mapguide.osgeo.org
>





More information about the Mapguide_users mailing list