[mapguide-users] Re: Passing the SessionId to a new map does not
reflect the changes made
SteveS
steve.calpoly at gmail.com
Mon Dec 19 18:06:00 EST 2011
it can be time consuming but is not necessarily difficult. Here is some
sample code to help you modify and copy XML files from the library to
session repository.
//copy dynamic map to session repository
string mapName="ABC";
MgByteReader mapByteReader = resourceService.GetResourceContent(new
MgResourceIdentifier("Library://MAPS/" + mapName + ".MapDefinition"));
XmlDocument mapDoc = new XmlDocument();
mapDoc.PreserveWhitespace = true;
mapDoc.LoadXml(mapByteReader.ToString());
int layerCount = mapDoc.GetElementsByTagName("ResourceId").Count;
for (int i = 0; i < layerCount; i++)
{
string innerText =
mapDoc.GetElementsByTagName("ResourceId").Item(i).InnerText;
string innerTextFinal = innerText.Replace("Library://LAYERS/",
"Session:" + sessionId + "//");
mapDoc.GetElementsByTagName("ResourceId").Item(i).InnerText =
innerTextFinal;
}
MgResourceIdentifier newMap = new MgResourceIdentifier("Session:" +
sessionId + "//" + mapName + ".MapDefinition");
resourceService.SetResource(newMap, new
MgByteReader(mapDoc.OuterXml, "text/xml"), null);
--
View this message in context: http://osgeo-org.1803224.n2.nabble.com/Passing-the-SessionId-to-a-new-map-does-not-reflect-the-changes-made-tp7043424p7110147.html
Sent from the MapGuide Users mailing list archive at Nabble.com.
More information about the mapguide-users
mailing list