mgohil

Route is getting displayed same for Each user performing routing

Discussion created by mgohil on Oct 8, 2010
Hello All,
In ArcMap i have added Route Layer and published that Map to ArcGIS Server for performing Network Analysis.
I have added one MapResourceItem in MapResourceManager and that MapResourceItem is pointing to the Map Service that i have published for Network Analysis.
When i add the stops in Stop Layer and after the Route is getting solved Route Layer is getting displayed on Map.
The problem is that if user1 has added A and B stop and solved route and after that user2 has come and added C and D point and solved the route ,now user1 and user2 both will see the same route from C to D on Map.
I was not able to figure out the what the problem is.
In coding i am first fetching NALayer from MapResource then fetching NAContext from NALayer and then cakkubg context.Solve method.
 spatialMapFunctionality =
                      (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)MapCtrl.GetFunctionality(imfIndex);


       




        // Get a pointer to the local map resource
        localMapResource =
           (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)spatialMapFunctionality.MapResource;
        IServerContext serverContext = localMapResource.ServerContextInfo.ServerContext;
        IMapServerObjects mapServerObjects = (IMapServerObjects)localMapResource.MapServer;
        IMap map = mapServerObjects.get_Map(localMapResource.DataFrame);

        INALayer2 naLayer = null;
        int layerID = -1;

        IEnumLayer elayers = map.get_Layers(null, true);
        ILayer layer = elayers.Next();
        int i = 0;
        while (layer != null)
        {
            if ((layer is INALayer) && (((INALayer)layer).Context.Name == "Route"))
            {
                naLayer = layer as INALayer2;
                layerID = i;
                break;
            }
            ++i;
            layer = elayers.Next();
        }
INAClass naClass = naContext.NAClasses.get_ItemByName("Stops") as INAClass;
        naClass.DeleteAllRows();
      
        //add from point
        IPoint point = serverContext.CreateObject("esriGeometry.Point") as IPoint;
  point.PutCoords(X1, Y1);
            Utility.AddLocation(naContext, "Stops", point, fromaddr, 100);

  point.PutCoords(X2, Y2);
            Utility.AddLocation(naContext, "Stops", point, toaddr, 100);
   INAContext naContext = naLayer.Context;
   IGPMessages gpMessages = serverContext.CreateObject("esriGeodatabase.GPMessages") as IGPMessages;
        INASolver solver = naContext.Solver;
        solver.Solve(naContext, gpMessages,null);


Can anyone has idea why it's displaying the Same route and stops for all usres.

Thanks
Manish Gohil

Outcomes