コード例 #1
0
        /// <summary>
        /// Determines the ID of an entity based on its direct URL.
        /// </summary>
        /// <param name="requestPath">The direct URL.</param>
        /// <param name="moduleName">Name of the module to which the entity belongs.</param>
        /// <returns></returns>
        private string ResolveEntityId(string requestPath, string moduleName)
        {
            var entityId = "0";

            // Extract Direct URL identifier from request URL
            var directUrl = requestPath
                .Substring(requestPath.LastIndexOf("/") + 1)
                .Replace(".aspx", string.Empty);

            // First attempt to find entity ID in cache
            var cacheKey = "DirectUrlEntityId_" + moduleName + "_" + directUrl;

            if (_cache.Contains(cacheKey))
            {
                entityId = (string)_cache.Get(cacheKey);
            }
            else
            {
                // Get entity ID from service
                var dispatcher = new ServiceDispatcher();
                entityId = dispatcher.GetModuleEntityIdFromDirectUrl(moduleName, directUrl);

                _cache.Put(cacheKey, entityId);
            }

            return entityId;
        }