[mapguide-users] MgLayerBase::GetClassDefinition fails on MGOS1.2RC2
Takashige Nakagawa
ta-nakagawa at apptec.co.jp
Fri Aug 24 01:57:45 EDT 2007
Hi, all.
Now I'm writing some test programs on MGOS 1.2 RC2. In the codes below,
MgLayerBase::GetClassDefinition causes an exception "Class not found."
When I use MgFeatureService ( as I do on Ver 1.1 ) instead , everything
works fine.
Is there something I do wrong?
Regards.
Takashige
----Codes-------------------------------------------
String doTest()
{
NameValueCollection parameters = GetRequestParameters(Request);
String sessionId = GetParameter(parameters, "_session_id_");
String mapName = GetParameter(parameters, "_mapname_");
String layerName = GetParameter(parameters, "_layername_");
MgUserInformation userInfo = new MgUserInformation(sessionId);
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
MgMap map = new MgMap(siteConnection);
map.Open(mapName);
MgLayerBase layer = GetLayerByName(map, layerName);
// Version1.1 ******* Works fine on ver 1.2 !
//MgFeatureService featureService = _
// siteConnection.CreateService(MgServiceType.FeatureService) as
MgFeatureService;
//MgClassDefinition classDef = GetClassDefinitionV11(featureService,
layer);
// Version1.2 ******* Fails! What's wrong?? *******************
MgClassDefinition classDef = layer.GetClassDefinition();
return layerName;
}
MgClassDefinition GetClassDefinitionV11(MgFeatureService featureService,
MgLayerBase layer)
{
String featureSourceId = layer.GetFeatureSourceId();
MgResourceIdentifier featureSourceResId = new
MgResourceIdentifier(featureSourceId);
String featureClassName = layer.GetFeatureClassName();
String[] schemaClass = featureClassName.Split(new char[] { ':' });
String schemaName = schemaClass[0];
String className = schemaClass[1];
return featureService.GetClassDefinition(featureSourceResId,
schemaName, className);
}
NameValueCollection GetRequestParameters(HttpRequest request)
{
if ("POST" == request.HttpMethod)
{
return request.Form;
}
else
{
return request.QueryString;
}
}
String GetParameter(NameValueCollection parameters, String name)
{
String strval = parameters[name];
if (null == strval)
return "";
return strval.Trim();
}
MgLayerBase GetLayerByName(MgMap map, String layerName)
{
MgLayerCollection layers = map.GetLayers();
MgLayerBase layer = null;
for (int i = 0; i < layers.GetCount(); i++)
{
MgLayerBase nextLayer = layers.GetItem(i);
if (nextLayer.GetName() == layerName)
{
layer = nextLayer;
break;
}
}
return layer;
}
------------------------------------------------------------------------
More information about the mapguide-users
mailing list