コード例 #1
0
        /// <summary>
        /// Retrieves the services directory URL for the ArcGIS Server indicated by the passed-in URL
        /// </summary>
        public static async Task <string> GetServicesDirectoryURL(string url, string proxyUrl)
        {
            string restUrl = null;

            ServerInfo info = await ArcGISServerDataSource.GetServerInfo(url, proxyUrl);

            if (info != null && info.AuthenticationInfo != null && info.AuthenticationInfo.SupportsTokenAuthentication)
            {
                // Construct services directory URL from info URL.  Services directory URL is required for
                // IdentityManager to resolve token retrieval endpoint properly.
                restUrl = info.BaseUrl;
                if (restUrl.Contains("?"))
                {
                    restUrl = restUrl.Split('?')[0];
                }

                restUrl = restUrl.TrimEnd('/');
                if (restUrl.EndsWith("/info", StringComparison.OrdinalIgnoreCase))
                {
                    restUrl = restUrl.Substring(0, restUrl.Length - 4) + "services";
                }
            }

            return(restUrl);
        }
コード例 #2
0
        /// <summary>
        /// Get the instance-level metadata for the ArcGIS Server instance specified by the connection string
        /// </summary>
        public async static Task <ServerInfo> GetServerInfo(string connectionString, string proxyUrl)
        {
            var        candidateUrls = getCandidateUrls(connectionString).ToArray();
            ServerInfo serverInfo    = null;

            foreach (var url in candidateUrls)
            {
                foreach (var info in m_cachedServerInfos)
                {
                    if (url == info.Url)
                    {
                        serverInfo = info;
                        break;
                    }
                }
            }

            if (serverInfo == null)
            {
                var dataSource = new ArcGISServerDataSource();
                serverInfo = await dataSource.getServerInfo(connectionString, proxyUrl);
            }

            return(serverInfo);
        }
コード例 #3
0
        /// <summary>
        /// Get the instance-level metadata for the ArcGIS Server instance specified by the connection string
        /// </summary>
        public async static Task<ServerInfo> GetServerInfo(string connectionString, string proxyUrl)
        {
            var candidateUrls = getCandidateUrls(connectionString).ToArray();
            ServerInfo serverInfo = null;
            foreach (var url in candidateUrls)
            {
                foreach (var info in m_cachedServerInfos)
                {
                    if (url == info.Url)
                    {
                        serverInfo = info;
                        break;
                    }
                }
            }

            if (serverInfo == null)
            {
                var dataSource = new ArcGISServerDataSource();
                serverInfo = await dataSource.getServerInfo(connectionString, proxyUrl);
            }

            return serverInfo;
        }
コード例 #4
0
        /// <summary>
        /// Retrieves the token URL for the ArcGIS Server indicated by the passed-in URL
        /// </summary>
        public static async Task<string> GetTokenURL(string url, string proxyUrl)
        {
            string restUrl = null;

            ArcGISServerDataSource dataSource = new ArcGISServerDataSource();
            ServerInfo info = await dataSource.GetServerInfo(url, proxyUrl);
            if (info != null && info.AuthenticationInfo != null && info.AuthenticationInfo.SupportsTokenAuthentication)
            {
                // Construct services directory URL from info URL.  Services directory URL is required for
                // IdentityManager to resolve token retrieval endpoint properly.
                restUrl = info.Url;
                if (restUrl.Contains("?"))
                    restUrl = restUrl.Split('?')[0];

                restUrl = restUrl.TrimEnd('/');
                if (restUrl.EndsWith("/info", StringComparison.OrdinalIgnoreCase))
                    restUrl = restUrl.Substring(0, restUrl.Length - 4) + "services";
            }

            return restUrl;
        }