예제 #1
0
        //得到服务器上下文
        public static IServerContext GetServerContext(System.Web.UI.Page page)
        {
            if (page == null)
            {
                return(null);
            }
            try
            {
                ESRI.ArcGIS.Server.IServerObjectManager serverObjectManager;
                string sesionSom = PublicConst.Lbl_Session_SOM;
                //1.连接服务器
                // 获得SOM,并放入Session变量中
                if (page.Session[sesionSom] == null)
                {
                    // 用ADF connection 库
                    ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsServerConnection =
                        new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection();
                    agsServerConnection.Host = PublicConst.Lbl_ConnectHost;
                    agsServerConnection.Connect();

                    serverObjectManager     = agsServerConnection.ServerObjectManager;
                    page.Session[sesionSom] = serverObjectManager;
                }
                else
                {
                    serverObjectManager = page.Session[sesionSom] as ESRI.ArcGIS.Server.IServerObjectManager;
                }
                //根据服务名来创建上下文
                ESRI.ArcGIS.Server.IServerContext serverContext =
                    serverObjectManager.CreateServerContext(PublicConst.Lbl_MapSvr_China, PublicConst.Lbl_SvrType_MapSvr);
                return(serverContext);
            }
            catch (Exception ex)
            {
                ServerConnectException sEx = new ServerConnectException("Server 连接出错", ex);
                throw ex;
            }
        }
        static void Main(string[] args)
        {
            // Must run as an user in the agsadmin group on the SOM
            ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsServerConnection =
                new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection();
            agsServerConnection.Host = "localhost";
            agsServerConnection.Connect();
            ESRI.ArcGIS.Server.IServerObjectAdmin2 serverObjectAdmin =
                agsServerConnection.ServerObjectAdmin as ESRI.ArcGIS.Server.IServerObjectAdmin2;

            // This name must match those defined for property pages
            string extensionName = "IUCNRedListSOE";

            // Check command line arguments to see if SOE is to be unregistered
            if (args.Length == 1 && args[0] == "/unregister")
            {
                // Check whether the SOE is registered
                if (ExtensionRegistered(serverObjectAdmin, extensionName))
                {
                    // Delete the SOE
                    serverObjectAdmin.DeleteExtensionType("MapServer",
                        extensionName);
                    Console.WriteLine(extensionName +
                        " successfully unregistered");
                }
                else
                    Console.WriteLine(extensionName +
                        " is not registered with ArcGIS Server");
            }
            else
            {
                // Check whether the SOE is registered
                if (!ExtensionRegistered(serverObjectAdmin, extensionName))
                {
                    // Use IServerObjectExtensionType3 to get access to info properties
                    ESRI.ArcGIS.Server.IServerObjectExtensionType3 serverObjectExtensionType =
                        serverObjectAdmin.CreateExtensionType() as ESRI.ArcGIS.Server.IServerObjectExtensionType3;

                    // Must match the namespace and class name of the class implementing IServerObjectExtension
                    serverObjectExtensionType.CLSID = "IUCNRedListSOE.IUCNRedListSOE";
                    //serverObjectExtensionType.CLSID = "{C41E8674-F186-4a0c-8FC9-AAB7885EFD00}";
                    serverObjectExtensionType.Description = "Echos input text";
                    serverObjectExtensionType.Name = extensionName;

                    // Name that will be shown in the capabilities list on property pages
                    serverObjectExtensionType.DisplayName = "IUCN Red List Server Object Extension";

                    // Use info properties to define capabilities and msd support
                    serverObjectExtensionType.Info.SetProperty("SupportsMSD", "true");

                    // Required to enable exposure of SOE with ArcGIS Server REST endpoint
                    serverObjectExtensionType.Info.SetProperty("SupportsREST", "true");

                    // Register the SOE with the server
                    serverObjectAdmin.AddExtensionType("MapServer", serverObjectExtensionType);

                    Console.WriteLine(extensionName + " successfully registered with ArcGIS Server");
                }
                else
                    Console.WriteLine(extensionName + " is already registered with ArcGIS Server");
            }

            Console.ReadLine();
        }
예제 #3
0
파일: Program.cs 프로젝트: yinxd/arcstache
        static void Main(string[] args)
        {
            // Must run as an user in the agsadmin group on the SOM
            ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection agsServerConnection =
                new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection();
            agsServerConnection.Host = "localhost";
            agsServerConnection.Connect();
            ESRI.ArcGIS.Server.IServerObjectAdmin2 serverObjectAdmin =
                agsServerConnection.ServerObjectAdmin as ESRI.ArcGIS.Server.IServerObjectAdmin2;

            // This name must match those defined for property pages
            string extensionName = "arcstache";

            // Check command line arguments to see if SOE is to be unregistered
            if (args.Length == 1 && args[0] == "/unregister")
            {
                // Check whether the SOE is registered
                if (ExtensionRegistered(serverObjectAdmin, extensionName))
                {
                    // Delete the SOE
                    serverObjectAdmin.DeleteExtensionType("MapServer", extensionName);
                    Console.WriteLine(extensionName + " successfully unregistered");
                }
                else
                {
                    Console.WriteLine(extensionName + " is not registered with ArcGIS Server");
                }
            }
            else
            {
                // Check whether the SOE is registered
                if (!ExtensionRegistered(serverObjectAdmin, extensionName))
                {
                    // Use IServerObjectExtensionType3 to get access to info properties
                    ESRI.ArcGIS.Server.IServerObjectExtensionType3 serverObjectExtensionType =
                        serverObjectAdmin.CreateExtensionType() as ESRI.ArcGIS.Server.IServerObjectExtensionType3;

                    // Must match the namespace and class name of the class implementing IServerObjectExtension
                    serverObjectExtensionType.CLSID = "ArcStache.ArcStache";
                    //serverObjectExtensionType.CLSID = "{91EB05FE-7970-45F3-A51B-664310938EFF}";
                    serverObjectExtensionType.Description = "ArcStache creates a tile cache of vector data in ArcGIS Server JSON and GeoJSON formats";
                    serverObjectExtensionType.Name        = extensionName;

                    // Name that will be shown in the capabilities list on property pages
                    serverObjectExtensionType.DisplayName = "ArcStache";

                    // Use info properties to define capabilities and msd support
                    serverObjectExtensionType.Info.SetProperty("SupportsMSD", "true");

                    // Required to enable exposure of SOE with ArcGIS Server REST endpoint
                    serverObjectExtensionType.Info.SetProperty("SupportsREST", "true");

                    // Register the SOE with the server
                    serverObjectAdmin.AddExtensionType("MapServer", serverObjectExtensionType);

                    Console.WriteLine(extensionName + " successfully registered with ArcGIS Server");
                }
                else
                {
                    Console.WriteLine(extensionName + " is already registered with ArcGIS Server");
                }
            }

            Console.ReadLine();
        }
        private IServerContext GetServerContext(string sMapServiceName)
        {
            // *** Using Web ADF Common API           
          ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection gisconnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection();
            gisconnection.Host = _serverName;

            gisconnection.Connect();

            _SOM = gisconnection.ServerObjectManager;

            // *** Change the map server object name as needed 
            int counter = 0;
            IServerContext mapContext = null;
            while ((mapContext == null) && (counter < 3))
            {
                try
                {
                    mapContext = _SOM.CreateServerContext(sMapServiceName, "MapServer");
                }
                catch
                {

                }
                counter += 1;
            }

            if (mapContext == null)
            {
                try
                {
                    if ( _sContextMapService != null )
                        mapContext = _SOM.CreateServerContext(_sContextMapService, "MapServer");
                }
                catch
                {

                }
            }

            return mapContext;
        }
예제 #5
0
        static void Main(string[] args)
        {
            // Must run as an user in the agsadmin group on the SOM
            var agsServerConnection = new ESRI.ArcGIS.ADF.Connection.AGS.AGSServerConnection {
                Host = "localhost"
            };

            agsServerConnection.Connect();

            var serverObjectAdmin = agsServerConnection.ServerObjectAdmin as ESRI.ArcGIS.Server.IServerObjectAdmin2;

            if (serverObjectAdmin == null)
            {
                throw new NullReferenceException("agsServerConnection.ServerObjectAdmin as ESRI.ArcGIS.Server.IServerObjectAdmin2");
            }

            // This name must match those defined for property pages
            string extensionName = Common.Names.SoeName;

            // Check command line arguments to see if SOE is to be unregistered
            if (args != null && args.Length == 1 && string.Equals(args.First(), "/unregister"))
            {
                // Check whether the SOE is registered
                if (ExtensionRegistered(serverObjectAdmin, extensionName))
                {
                    // Delete the SOE
                    serverObjectAdmin.DeleteExtensionType("MapServer", extensionName);
                    Console.WriteLine(extensionName + " successfully unregistered");
                }
                else
                {
                    Console.WriteLine(extensionName + " is not registered with ArcGIS Server");
                }
            }
            else
            {
                // Check whether the SOE is registered
                if (!ExtensionRegistered(serverObjectAdmin, extensionName))
                {
                    // Use IServerObjectExtensionType3 to get access to info properties
                    var serverObjectExtensionType = serverObjectAdmin.CreateExtensionType() as ESRI.ArcGIS.Server.IServerObjectExtensionType3;

                    // Must match the namespace and class name of the class implementing IServerObjectExtension
                    if (serverObjectExtensionType != null)
                    {
                        serverObjectExtensionType.CLSID       = "DaveTimmins.SampleExtension.Extension";
                        serverObjectExtensionType.Description = "Extends ArcGIS Server to allow custom operations.";
                        serverObjectExtensionType.Name        = extensionName;

                        // Name that will be shown in the capabilities list on property pages
                        serverObjectExtensionType.DisplayName = "Sample SOE Extension";

                        // Required to support MSD
                        serverObjectExtensionType.Info.SetProperty("SupportsMSD", "true");

                        // Required to enable exposure of SOE with ArcGIS Server REST endpoint
                        serverObjectExtensionType.Info.SetProperty("SupportsREST", "true");

                        // Register the SOE with the server
                        serverObjectAdmin.AddExtensionType("MapServer", serverObjectExtensionType);

                        Console.WriteLine(extensionName + " successfully registered with ArcGIS Server");
                    }
                }
                else
                {
                    Console.WriteLine(extensionName + " is already registered with ArcGIS Server");
                }
            }

            Console.WriteLine();
            Console.WriteLine("Press any key to finish.");
            Console.ReadKey(true);
        }