Example #1
0
        public int NumberOfServices(string serverName)
        {
            int iCount = 0;

            IGISServerConnection2 pGISServerConnection = new GISServerConnection() as IGISServerConnection2;

            pGISServerConnection.Connect(serverName);

            IServerObjectAdmin4 pServerObjectAdmin = pGISServerConnection.ServerObjectAdmin as IServerObjectAdmin4;

            IEnumServerObjectConfiguration objConfigs = pServerObjectAdmin.GetConfigurations();
            IServerObjectConfiguration3    icfg       = objConfigs.Next() as IServerObjectConfiguration3;

            while (icfg != null)
            {
                string stemp = icfg.Name.ToUpper();
                iCount++;

                icfg = objConfigs.Next() as IServerObjectConfiguration3;
            }

            COMUtil.ReleaseObject(icfg);
            COMUtil.ReleaseObject(objConfigs);
            COMUtil.ReleaseObject(pServerObjectAdmin);
            COMUtil.ReleaseObject(pGISServerConnection);

            return(iCount);
        }
Example #2
0
        public bool Exists(string serverName, string serviceName)
        {
            IGISServerConnection2 pGISServerConnection = new GISServerConnection() as IGISServerConnection2;

            pGISServerConnection.Connect(serverName);
            IServerObjectConfiguration3    icfg               = null;
            IEnumServerObjectConfiguration objConfigs         = null;
            IServerObjectAdmin4            pServerObjectAdmin = pGISServerConnection.ServerObjectAdmin as IServerObjectAdmin4;

            try
            {
                // Get Configurations from the server
                objConfigs = pServerObjectAdmin.GetConfigurations();

                icfg = objConfigs.Next() as IServerObjectConfiguration3;

                while (icfg != null)
                {
                    if (icfg.Name.ToUpper() == serviceName.ToUpper())
                    {
                        return(true);
                    }
                    icfg = objConfigs.Next() as IServerObjectConfiguration3;
                }

                return(false);
            }
            catch (Exception ex)
            {
                throw ex;
            }
            finally
            {
                COMUtil.ReleaseObject(icfg);
                COMUtil.ReleaseObject(objConfigs);
                COMUtil.ReleaseObject(pServerObjectAdmin);
                COMUtil.ReleaseObject(pGISServerConnection);
            }
        }