[mapguide-users] Error while creating resourceservice

yash227 yash227 at gmail.com
Fri Sep 5 04:26:19 PDT 2014


hi all,

       I am new using map guide open source. I am developing web application
using mapguide .net configuration.My application has functionality like
that, when user selects mapname from dropdownlist then page  gets reloads
and map changes. But when I use this code:

string webconfig = @"C:\Program Files\OSGeo\MapGuide\Web\www\webconfig.ini";
        MapGuideApi.MgInitializeWebTier(webconfig);
        MgSiteConnection siteConn = new MgSiteConnection();
        MgUserInformation userInfo = null;
        userInfo = new MgUserInformation("Administrator", "admin");
        MgSite site = new MgSite();
        siteConn.Open(userInfo);

XmlDocument doc = new XmlDocument();

MgResourceService resourceService4 =
siteConn.CreateService(MgServiceType.ResourceService) as MgResourceService;
        MgResourceIdentifier layerDefResId4 = new
MgResourceIdentifier(appdef.ToString());
        MgByteReader byteReader1 =
resourceService4.GetResourceContent(layerDefResId4);

        MgByteReader rd1 = resourceService4.GetResourceContent(new
MgResourceIdentifier(appdef.ToString()));

doc.PreserveWhitespace = true;
        doc.LoadXml(resourceService4.GetResourceContent(new
MgResourceIdentifier(appdef.ToString())).ToString());

XmlNodeList MapResIdNodeList;
        XmlElement root = doc.DocumentElement;
        MapResIdNodeList = root.SelectNodes("//ResourceId");
        int nRes = MapResIdNodeList.Count;

        for (int i = 0; i < nRes - 1; i++)
        {
            XmlNode MapResIdNode = MapResIdNodeList.Item(i);
            String MapRes = MapResIdNode.InnerText;
            int index1 = MapRes.LastIndexOf('/') + 1;
            int index2 = MapRes.IndexOf("MapDefinition") - 2;
            int length = index2 - index1 + 1;
            string mapName = MapRes.Substring(index1, length);
            if (!mapList.ContainsKey(mapName))
            {
                mapList.Add(mapName, MapRes);



                //MgResourceService resourceService5 =
siteConn.CreateService(MgServiceType.ResourceService) as MgResourceService;
                MgResourceIdentifier layerDefResId5 = new
MgResourceIdentifier("Library://Sambandh/Layer/" + mapName +
".LayerDefinition");
                MgByteReader byteReader5 =
resourceService4.GetResourceContent(layerDefResId5);
                MgByteReader rd5 = resourceService4.GetResourceContent(new
MgResourceIdentifier("Library://Sambandh/Layer/" + mapName +
".LayerDefinition"));
                XmlDocument laydoc5 = new XmlDocument();
                laydoc5.PreserveWhitespace = true;
                laydoc5.LoadXml(resourceService4.GetResourceContent(new
MgResourceIdentifier("Library://Sambandh/Layer/" + mapName +
".LayerDefinition")).ToString());
                laydoc5.GetElementsByTagName("Filter").Item(0).InnerText =
"Vill_Id='" + Session["village"].ToString() + "'";
                resourceService4.SetResource(layerDefResId5, new
MgByteReader(laydoc5.OuterXml, "text/xml"), null);

            }
        }


this code works only for 5 to 6  time after this in gives an error something
like:

Problem\n Failed to Keep Session alive. Your Session has Ideal for too long
etc.. AnyOne Know about this  error.



--
View this message in context: http://osgeo-org.1560.x6.nabble.com/Error-while-creating-resourceservice-tp5160319.html
Sent from the MapGuide Users mailing list archive at Nabble.com.


More information about the mapguide-users mailing list