Hi David:<br><br>Thank you for your reply.<br>I try it referenced the Developer's Guide Version 1.2RC2.<br>And I modified my code in your way.<br>Then I got this exception : <br><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">
OSGeo.MapGuide.MgUnclassifiedException: An unclassified exception occurred.</font><br><br>Error points to the first line : <br> MgUserInformation userInfo = new MgUserInformation(mgSessionId);<br> MgSiteConnection siteConnection = new MgSiteConnection();
<br> siteConnection.Open(userInfo);<br><br>I gather that in order to make changes permanent should be logined in Administrator.<br>The codes look like this :<br><br>MgUserInformation userInfo = new MgUserInformation("Administrator", "admin");
<br>MgSiteConnection siteConnection = new MgSiteConnection();<br>siteConnection.Open(userInfo);<br>//Create a MgResourceService <br>MgResourceService resourceService = siteConnection.CreateService(MgServiceType.ResourceService
) as MgResourceService;<br><br>And I got another exception :<br><font face="Arial, Helvetica, Geneva, SunSans-Regular, sans-serif ">OSGeo.MapGuide.MgInvalidArgumentException: Invalid argument(s):<br>        [0] = " "<br>
The string cannot be empty.<br><br>Error points to the first line:<br>// Open the map<br>MgMap map = new MgMap();<br>map.Open(resourceService, "Sheboygan");<br></font><br>So I refer to the developer's Guide, and created a session in this way :
<br><br>MgSite site = siteConnection.GetSite();<br>string sessionID = site.CreateSession();<br>userInfo.SetMgSessionId(sessionID);<br><br>I use this session to create a MgResourceService to do some modifications.<br>But I get confusion in how to save the map.
<br>I try 3 save methods, but I still got some error exceptions.<br><br>Could you provide me some specific method in how to create & save map status permanently ?<br>Or, could you give me a complete code to demonstrate how to manipulate and modify the data in the Library:// ?
<br><div style="direction: ltr;"></div><br>Thank you for your help.<br><br>patrick<br><br><br><div><span class="gmail_quote">
On 7/9/07, <b class="gmail_sendername">David Hequet</b> <<a href="mailto:david.hequet@free.fr" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">david.hequet@free.fr</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<br>To make changes permanent you have to work in Library repository insteed of<br>Session repository,<br>here is a php sample, after a modification, we save the layer :<br><br>IN SESSION:<br>// modification here..<br>$byteSource = new MgByteSource($layerDefinition,strlen($layerDefinition));
<br>$byteSource->SetMimeType(MgMimeType::Xml);<br>$resourceID = new<br>MgResourceIdentifier("Session:$mgSessionId//$layerName.LayerDefinition");<br>$resourceService->SetResource($resourceID,$byteSource->GetReader(), null);
<br><br>PERMANENT:<br>// modification here...<br>$byteSource = new MgByteSource($layerDefinition, strlen($layerDefinition));<br>$byteSource->SetMimeType(MgMimeType::Xml);<br>$resourceId =new<br>MgResourceIdentifier("Library://LayerName.LayerDefinition");
<br>$resourceService->SetResource($resourceId, $byteSource->GetReader(), null);<br><br>Just do it :)<br></blockquote></div>