[mapguide-users] How can we make the changes stored in the map in programming methods ?

Tsai Chih-Cheng cctsai82 at gmail.com
Tue Jul 10 11:03:30 EDT 2007


Hi David:

Thank you for your reply.
I try it referenced the Developer's Guide Version 1.2RC2.
And I modified my code in your way.
Then I got this exception :
OSGeo.MapGuide.MgUnclassifiedException: An unclassified exception occurred.

Error points to the first line :
    MgUserInformation userInfo = new MgUserInformation(mgSessionId);
    MgSiteConnection siteConnection = new MgSiteConnection();
    siteConnection.Open(userInfo);

I gather that in order to make changes permanent should be logined in
Administrator.
The codes look like this :

MgUserInformation userInfo = new MgUserInformation("Administrator",
"admin");
MgSiteConnection siteConnection = new MgSiteConnection();
siteConnection.Open(userInfo);
//Create a MgResourceService
MgResourceService resourceService = siteConnection.CreateService(
MgServiceType.ResourceService ) as MgResourceService;

And I got another exception :
OSGeo.MapGuide.MgInvalidArgumentException: Invalid argument(s):
[0] = " "
The string cannot be empty.

Error points to the first line:
// Open the map
MgMap map = new MgMap();
map.Open(resourceService, "Sheboygan");

So I refer to the developer's Guide, and created a session in this way :

MgSite site = siteConnection.GetSite();
string sessionID = site.CreateSession();
userInfo.SetMgSessionId(sessionID);

I use this session to create a MgResourceService to do some modifications.
But I get confusion in how to save the map.
I try 3 save methods, but I still got some error exceptions.

Could you provide me some specific method in how to create & save map status
permanently ?
Or, could you give me a complete code to demonstrate how to manipulate and
modify the data in the Library:// ?

Thank you for your help.

patrick


On 7/9/07, David Hequet <david.hequet at free.fr> wrote:
>
>
> To make changes permanent you have to work in Library repository insteed
> of
> Session repository,
> here is a php sample, after a modification, we save the layer :
>
> IN SESSION:
> // modification here..
> $byteSource = new MgByteSource($layerDefinition,strlen($layerDefinition));
>
> $byteSource->SetMimeType(MgMimeType::Xml);
> $resourceID = new
> MgResourceIdentifier("Session:$mgSessionId//$layerName.LayerDefinition");
> $resourceService->SetResource($resourceID,$byteSource->GetReader(), null);
>
>
> PERMANENT:
> // modification here...
> $byteSource = new MgByteSource($layerDefinition,
> strlen($layerDefinition));
> $byteSource->SetMimeType(MgMimeType::Xml);
> $resourceId =new
> MgResourceIdentifier("Library://LayerName.LayerDefinition");
> $resourceService->SetResource($resourceId, $byteSource->GetReader(),
> null);
>
> Just do it :)
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/mapguide-users/attachments/20070710/cede7b49/attachment.html


More information about the mapguide-users mailing list