private static void Load(object dummy)
        {
            _ITPersonNames     = new List <string>();
            _ITEmailAddresses  = new List <string>();
            _AllEmailAddresses = new List <string>();
            // Reload the cache file from Active Directory every 4 hours,
            // or if the file does not exist.
            string   cacheFullName = RTSettings.GetConfigFilePath(_CacheFileName);
            FileInfo cacheFile     = new FileInfo(cacheFullName);

            if (cacheFile.Exists && DateTime.UtcNow.Subtract(cacheFile.LastWriteTimeUtc).TotalHours <= 4)
            {
                LoadFromFile(cacheFullName);
            }
            else
            {
                LoadFromActiveDirectory();
                SaveToFile(cacheFullName);
            }
            // Could add extra elements to any of these collections here,
            // for example email addresses of external partners or from
            // a personal profile.
            _ITPersonNames.Sort();
            _ITEmailAddresses.Sort();
            _AllEmailAddresses.Sort();
            // Release the lock so other threads can access this data.
            _AccessLock.Release();
        }
Example #2
0
        public static string[] GetFileContents(string fileName)
        {
            FileContents matchedFile = _Files.Find(
                delegate(FileContents contents) { return(contents.FileName.Equals(fileName, StringComparison.InvariantCultureIgnoreCase)); }
                );

            if (matchedFile == null)
            {
                string fullPath = RTSettings.GetConfigFilePath(fileName);
                matchedFile          = new FileContents();
                matchedFile.FileName = fileName;
                matchedFile.Lines    = File.ReadAllLines(fullPath);
                _Files.Add(matchedFile);
            }
            return(matchedFile.Lines);
        }