示例#1
0
        /// <summary>
        /// [jmarino]  2011-06-16 Check for ContainsKey for a write added
        /// </summary>
        /// <param name="portalId"></param>
        /// <returns></returns>
        private static string GetCacheFolder(int portalId)
        {
            string cacheFolder;

            using (var readerLock = CacheFolderPath.GetReadLock())
            {
                if (CacheFolderPath.TryGetValue(portalId, out cacheFolder))
                {
                    return(cacheFolder);
                }
            }

            var        portalController = new PortalController();
            PortalInfo portalInfo       = portalController.GetPortal(portalId);

            string homeDirectoryMapPath = portalInfo.HomeDirectoryMapPath;


            if (!(string.IsNullOrEmpty(homeDirectoryMapPath)))
            {
                cacheFolder = string.Concat(homeDirectoryMapPath, "Cache\\Pages\\");
                if (!(Directory.Exists(cacheFolder)))
                {
                    Directory.CreateDirectory(cacheFolder);
                }
            }

            using (var writerLock = CacheFolderPath.GetWriteLock())
            {
                if (!CacheFolderPath.ContainsKey(portalId))
                {
                    CacheFolderPath.Add(portalId, cacheFolder);
                }
            }

            return(cacheFolder);
        }