Schematics digram On Server

1308
19
06-09-2010 09:46 PM
sandeepmidgule
New Contributor
Hii All,
  I just want to know how to generate schematic Diagram on ArcGis Server. i m doing electric tracing and also using ArcFM server..

Please Help Me,

Thanx In Advance
Sandeep K Midgule,
Tags (2)
0 Kudos
19 Replies
RickAnderson
Occasional Contributor III
From one of the developers here:


The builder context is a remote object that is created on the server :

pSchStandardBuilderCtxt = pServerContext.CreateObject("esriSchematic.SchematicStandardBuilderContext")

Then, in this remote object, they try to put a local object from a local class (EnumObjectConverter) :

EnumObjectConverter eocon = new EnumObjectConverter(pEnumFeature);
pSchStandardBuilderCtxt.InitialObjects = eocon as IEnumObject;

But their EnumObjectConverter class is not known on the server

I think this class should be registered on the server and they should instantiate their �??eocon�?� object as a remote object too.
0 Kudos
sanjeevsinha
New Contributor II
The access denied issue has been solved it was the license issue. now i am facing another issue.

getting error while creating diagram but the same code in the Desktop is running fine.

ERROR:

Message : Exception from HRESULT: 0x80040221
From : ESRI.ArcGIS.Schematic
Stack Trace : at ESRI.ArcGIS.Schematic.ISchematicBuilder.GenerateDiagram(String diagramName, ISchematicDiagramContainer DiagramContainer, IPropertySet pPropertySet, ISchematicBuilderContext pContext, ITrackCancel cancelTracker)

I have checked the innerException and found below code:

_ComPlusExceptionCode: -532459699 and HResult error code : -2146233088


Thanks for any help

sanjeev sinha
0 Kudos
sanjeevsinha
New Contributor II
Hi Rick,

Now the above code works without error but the created diagram is empty.

How to register the class (EnumObjectConverter "econ" ) on the server?.

Thanks
Sanjeev Sinha
0 Kudos
RickAnderson
Occasional Contributor III
Did you get this working?  You either need to compile the dll that contains this class on the server, or register it on the server with the command line registration commands from Microsoft.
0 Kudos
sanjeevsinha
New Contributor II
Hi Rick,

Now i am able to create the diagram using the code. Thanks for the help....

I am facing another problem. When trying to display the diagram on adf map, most of the time diagram not displaying properly.

public void showDiagramUsingDiagramLayer(String diagramName, ESRI.ArcGIS.ADF.Web.UI.WebControls.Map SLDMap1)
        {

            IServerContext pServerContext = null;
            ISchematicWorkspace pSchWorkspace = null;
            ISchematicWorkspaceFactory pSchWorkspaceFac = null;
            ISchematicDataset pSchematicDataset = null;
            ISchematicDiagram finalSchemDiagram = null;
            ISchematicDiagramContainer diagcontainer = null;
            IEnumSchematicDiagram pEnumScheDiag = null;
            IEnumSchematicFolder pEnumScheFolder = null;
            ISchematicFolderContainer pSchematicFolderContainer = null;
            ISchematicLayer pSchLayer = null;
            ESRI.ArcGIS.Carto.ILayer pLayer = null;

            #region Schematic Function

            try
            {
                if (!SLDMap1.MapResourceManagerInstance.Initialized)
                    SLDMap1.MapResourceManagerInstance.Initialize();

                ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal gisresource = null;
                gisresource = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)(SLDMap1.MapResourceManagerInstance.GetResource(0));


                ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.ServerContextInfo servCtxInfo = gisresource.ServerContextInfo;
                pServerContext = servCtxInfo.ServerContext;


                ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality gisFunctionality = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality)SLDMap1.GetFunctionality(0);

                string errorMsg = "";



                ESRI.ArcGIS.Carto.IMapServer mapServer = pServerContext.ServerObject as ESRI.ArcGIS.Carto.IMapServer;
                ESRI.ArcGIS.Carto.IMapServerObjects mapServerObjects = (ESRI.ArcGIS.Carto.IMapServerObjects)mapServer;
                ESRI.ArcGIS.Carto.IMap pMap = mapServerObjects.get_Map(mapServer.DefaultMapName);


                ESRI.ArcGIS.Geodatabase.IWorkspace pWorkSpace = getWrkSpace(SLDMap1,gisresource, false); //fLayer.FeatureClass.FeatureDataset.Workspace;

                pSchWorkspaceFac = pServerContext.CreateObject("esriSchematic.SchematicWorkspaceFactory") as ISchematicWorkspaceFactory;

                pSchWorkspace = pSchWorkspaceFac.Open(pWorkSpace);
                pSchematicDataset = pSchWorkspace.get_SchematicDatasetByName("RAPDRP.NewSchematicDataset");

                diagcontainer = (ISchematicDiagramContainer)pSchematicDataset;
                pEnumScheDiag = diagcontainer.SchematicDiagrams;
                pSchLayer = pServerContext.CreateObject("esriSchematic.SchematicLayer") as ISchematicLayer;
                for (int i = 0; i < diagcontainer.SchematicDiagrams.Count; i++)
                {
                    finalSchemDiagram = pEnumScheDiag.Next();
                    if (finalSchemDiagram != null)
                    {
                        if (finalSchemDiagram.Name == diagramName)
                        {
                            pSchLayer.SchematicDiagram = finalSchemDiagram;
                            pLayer = (ESRI.ArcGIS.Carto.ILayer)pSchLayer;
                            break;
                        }
                    }

                }

                if (pLayer == null)
                {
                    //Checking if diagram exist in folder.
                    pSchematicFolderContainer = pSchematicDataset as ISchematicFolderContainer;
                    pEnumScheFolder = pSchematicFolderContainer.SchematicFolders;
                    ISchematicFolder pSF = pEnumScheFolder.Next();
                    Boolean canExist = false;
                    while (pSF != null)
                    {

                        diagcontainer = (ISchematicDiagramContainer)pSF;
                        pEnumScheDiag = diagcontainer.SchematicDiagrams;
                        finalSchemDiagram = pEnumScheDiag.Next();
                        while (finalSchemDiagram != null)
                        {
                            if (finalSchemDiagram.Name == diagramName)
                            {
                               
                                pSchLayer.SchematicDiagram = finalSchemDiagram;

                                pLayer = (ESRI.ArcGIS.Carto.ILayer)pSchLayer;
                                canExist = true;
                                break;
                            }
                            finalSchemDiagram = pEnumScheDiag.Next();
                        }
                        if (canExist) break;
                        pSF = pEnumScheFolder.Next();
                    }
                }
                if (pLayer != null)
                {
                    pLayer.Name = diagramName;
                    pLayer.Visible = true;
                    //Delete already exist layer
                    if (pMap.LayerCount > 0)
                    {
                        deleteAllLayers(pMap);
                    }
                    //Add layer
                    pMap.AddLayer(pLayer);
                   
                    //pMap.MoveLayer(pLayer, 1);
                    //(basically here making the layer visibility on)
                    MapFunctions(gisFunctionality);
                    pMap.AreaOfInterest = pLayer.AreaOfInterest;
                    mapServerObjects.RefreshServerObjects();
                    IEnvelope env = pServerContext.CreateObject("esriGeometry.Envelope") as IEnvelope;
                    env = (IEnvelope)pLayer.AreaOfInterest;
                    ESRI.ArcGIS.ADF.Web.Geometry.Envelope pEnvelope = ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.Converter.FromIEnvelope(env);
                    SLDMap1.Page.Session["DiagramFullExtent"] = pEnvelope;
                    SLDMap1.Extent = pEnvelope;
                    SLDMap1.Refresh();
                    SLDMap1.RefreshResource(SLDMap1.MapResourceManagerInstance.ResourceItems[0].Name);
                }

            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                if (pServerContext != null)
                    pServerContext.ReleaseContext();

            }
-----------------------------------------------------------------------------------------------

public void MapFunctions(ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality gisFunctionality)
        {

            ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality pMapFunctionality = gisFunctionality;
            ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal mapResourceLocal = (ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapResourceLocal)pMapFunctionality.Resource;
            System.Collections.Generic.Dictionary<string, bool> visibleLayers = new System.Collections.Generic.Dictionary<string, bool>();
            foreach (ESRI.ArcGIS.ADF.ArcGISServer.LayerDescription layerDescription in mapResourceLocal.MapDescription.LayerDescriptions)
            {
                if (!(layerDescription.LayerID == 0))
                {
                    visibleLayers.Add(layerDescription.LayerID.ToString(), true);
                }
                else
                {
                    visibleLayers.Add(layerDescription.LayerID.ToString(), true);
                }
            }

            // Register changes to server object - dynamic layer added.
            mapResourceLocal.RefreshServerObjects();

            // Reset the visibility of the layers in the resource's map description to what it was before updating the map service.
            foreach (System.Collections.Generic.KeyValuePair<string, bool> layerVisiblePair in visibleLayers)
            {
                if (!(layerVisiblePair.Key.Contains("0")))
                {
                    ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality.UpdateVisibleLayer(
                                   mapResourceLocal.MapDescription, layerVisiblePair.Key, layerVisiblePair.Value);

                }
                else
                {

                    ESRI.ArcGIS.ADF.Web.DataSources.ArcGISServer.MapFunctionality.UpdateVisibleLayer(
                                                      mapResourceLocal.MapDescription, layerVisiblePair.Key, false);


                }

            }

        }



Thanks
Sanjeev Kumar Sinha
0 Kudos
RickAnderson
Occasional Contributor III
This "most of the time diagram not displaying properly" needs some further explanation please.  Is there anything in particular that is different about diagrams that do display vs. diagrams that don't display?  Do the diagrams that don't display work fine if you go to a full extent (i.e. is it just a problem of initial extent)?

We think the problem is just that the published map didn't have a large enough extent to cover the future diagrams.  The extent of the original published map is the 'full extent' on server.  So if you later generate new diagrams that are beyond this initial extent, then they will not be visible or may only partially be visible.  If you re-open the published map, click full extent and re-publish, these diagrams should all be visible.  If that is the case, then the issue you have is just making sure to make the initial extent of the published map much larger.
0 Kudos
sanjeevsinha
New Contributor II
Hi Rick,

Some strange thing is happening while display the schematic diagram (adding the layer dynamically on the fly). Here I am giving you the idea of our application.

I have one application (main application) with

a. webcontrol (combobox contains the all schematic diagram name and a button to view the diagram).
b. webcontrol (use to create the schematic diagram using code.)
c. SchematicViewer.aspx page (contains the above code).

Once the user created the dygram the combobox list in webcontrol (a) is automatically updated.
I am opening the SchematicViewer.aspx using javascript on click event of view button in the webcontrol (a) and sending the diagram name in querystring with url. (window.open("SchematicViewer.aspx?DiagramName = ABC");)

The strange thing is

1. when the SchematicViewer.aspx page is getting open by the Webcontrol the diagram is not visible.
but If i copy the url of the current opened SchematicViewer.aspx and open the NEW IE . In the New IE window the diagram is visible.

If i change the name of the diagram in the new IE window and press refresh button then again diagram is not visible and if i close this window and reopen again (IE directly ) and paste the url in the new current opened IE then diagram is visible.

Writing again to understand you if the above is not clear to you.

1. Main Application with user control to view the schematic. (when ever open the schematicviewer.aspx using this usercontrol diagram is not visible). (http://SchematicViewer.aspx?DiagramName=ABC")

2. Diretly opening the IE from Desktop shortcut and providing the same url (http://SchematicViewer.aspx?DiagramName=ABC") then the diagram is visible. But If i change the diagram name from ABC to other name like ABC to ABC123 then diagram is not visible.

3. But If i close this (Step 2) window and do the same STEP 2 then diagram is visible.


I try all the thing to display diagram using webcontrol with javascript but no luck.

Thanks you very much for help......

Thanks & Regards
Sanjeev Sinha
0 Kudos
RickAnderson
Occasional Contributor III
No idea.  Looks like a bug in the ADF, not specific to schematics.
0 Kudos
pavulurisuneetha
New Contributor
I am trying to generate the schematic diagram in Arcgis server9.3 using above coding,but diagram generated as empty.
How to register the EnumObjectConverter class in server.I am able to generate the diagram using GP service(geoprocessing).
But i am fail using the code.Please help me,i am struggling so many days.


thanks&Regards
Suneetha.Pavuluri
0 Kudos
RickAnderson
Occasional Contributor III
There isn't a schematic server at 9.x.  Schematics server came about in 10.1.
0 Kudos