Hi David :<br><br>Thank you for your quick reply, I have read your VB code but I have not try it..<br>Actually, my job is to develop an application for user interacting with the ajax viewer.<br>When user logined for authorization, he did something making the layer and feature source changes, then the code save theses changes.
<br><br>So, answer your question, I think my job isn't making changes without using the viewer neither making the changes before the viewer loads.<br><br>But I am going to do my best to try your code today.<br>Appreciate for your support.
<br><br><br><div><span class="gmail_quote">On 7/11/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>Are you trying to the change without using the viewer? or before the viewer
<br>loads?<br>Here is what the viewer do when loading :<br><br>1. Initialize web tier with an ini file.<br>2. Connect to the site.<br>3. Instantiate an MgMap object.<br>4. Call MgMap.Create to actually create it.<br>5. Save the MgMap object to your session with
MgMap.Save.<br><br>then you can use MgMap.open("mymap")<br><br>Here is the code to simulate this:<br><br>MapGuideApi.MgInitializeWebTier(@"C:\yourpath\WebServerExtensions\www\webconfig.ini");<br> MgUserInformation userInfo = new MgUserInformation("Anonymous", "");
<br> MgSite site = new MgSite();<br> site.Open(userInfo);<br> String sessionId = site.CreateSession();<br><br> //Associate a session ID with the MgSiteConnection Object<br> MgUserInformation userInfo_new = new MgUserInformation(sessionId);
<br> MgSiteConnection siteConnection = new MgSiteConnection();<br> siteConnection.Open(userInfo_new);<br><br> MgResourceService resourceSrvc =<br>(MgResourceService)siteConnection.CreateService(MgServiceType.ResourceService
);<br> MgMap map = new MgMap();<br> MgResourceIdentifier resId = new<br>MgResourceIdentifier("Library://Samples/Sheboygan/Maps/Sheboygan.MapDefinition");<br> String mapName = resId.GetName();<br> map.Create
(resourceSrvc, resId, mapName);<br><br> MgResourceIdentifier mapStateId = new MgResourceIdentifier("Session:" +<br>sessionId + "//" + mapName + "." + MgResourceType.Map);<br> map.Save(resourceSrvc, mapStateId);
<br> Response.Write("Done. The map name is " + map.GetName());<br><br>about using Administrator insteed of Anonymous, i think you'r right.<br><br><br>Tsai Chih-Cheng wrote:<br>><br>> 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>> OSGeo.MapGuide.MgUnclassifiedException
: An unclassified exception<br>> occurred.<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<br>> Administrator.<br>> The codes look like this :<br>><br>> MgUserInformation userInfo = new MgUserInformation("Administrator",
<br>> "admin");<br>> MgSiteConnection siteConnection = new MgSiteConnection();<br>> siteConnection.Open(userInfo);<br>> //Create a MgResourceService<br>> MgResourceService resourceService = siteConnection.CreateService
(<br>> MgServiceType.ResourceService ) as MgResourceService;<br>><br>> And I got another exception :<br>> 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>><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<br>> status
<br>> permanently ?<br>> Or, could you give me a complete code to demonstrate how to manipulate and<br>> modify the data in the Library:// ?<br>><br>> Thank you for your help.<br>><br>> patrick<br>>
<br>><br>> On 7/9/07, David Hequet <<a href="mailto:david.hequet@free.fr" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">david.hequet@free.fr</a>> wrote:<br>>><br>>><br>>> To make changes permanent you have to work in Library repository insteed
<br>>> 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
<br>>> MgByteSource($layerDefinition,strlen($layerDefinition));<br>>><br>>> $byteSource->SetMimeType(MgMimeType::Xml);<br>>> $resourceID = new<br>>> MgResourceIdentifier("Session:$mgSessionId//$layerName.LayerDefinition");
<br>>> $resourceService->SetResource($resourceID,$byteSource->GetReader(),<br>>> null);<br>>><br>>><br>>> PERMANENT:<br>>> // modification here...<br>>> $byteSource = new MgByteSource($layerDefinition,
<br>>> strlen($layerDefinition));<br>>> $byteSource->SetMimeType(MgMimeType::Xml);<br>>> $resourceId =new<br>>> MgResourceIdentifier("Library://LayerName.LayerDefinition");<br>>> $resourceService->SetResource($resourceId, $byteSource->GetReader(),
<br>>> null);<br>>><br>>> Just do it :)<br>>><br>><br>> _______________________________________________<br>> mapguide-users mailing list<br>> <a href="mailto:mapguide-users@lists.osgeo.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mapguide-users@lists.osgeo.org</a><br>> <a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.osgeo.org/mailman/listinfo/mapguide-users
</a><br>><br>><br><br>--<br>View this message in context:
<a href="http://www.nabble.com/How-can-we-make-the-changes-stored-in-the-map-in-programming-methods---tf4044102s16610.html#a11537116" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://www.nabble.com/How-can-we-make-the-changes-stored-in-the-map-in-programming-methods---tf4044102s16610.html#a11537116
</a><br>Sent from the MapGuide Users mailing list archive at <a href="http://Nabble.com" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">Nabble.com</a>.<br><br>_______________________________________________
<br>mapguide-users mailing list<br><a href="mailto:mapguide-users@lists.osgeo.org" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">
mapguide-users@lists.osgeo.org</a><br><a href="http://lists.osgeo.org/mailman/listinfo/mapguide-users" target="_blank" onclick="return top.js.OpenExtLink(window,event,this)">http://lists.osgeo.org/mailman/listinfo/mapguide-users
</a><br></blockquote></div><br>