WikiCrawler/Batch/NPGallery/NPSDirectoryQuery.cs
/// <summary>
/// Queries the directory and returns true if the specified person is an NPS employee.
/// </summary>
Queries the directory and returns true if the specified person is an NPS employee.
Queries the directory and returns true if the specified person is an NPS employee .
public static bool QueryDirectory(string firstName, string lastName)
		{
			bool cachedValue;
			if (s_cache.TryGetValue(new PersonName(firstName, lastName, false), out cachedValue))
			{
				return cachedValue;
			}
			Console.WriteLine("NPS Directory Query: " + lastName + ", " + firstName);
			WebRequest request = WebRequest.Create(string.Format(Endpoint, firstName, lastName));
			using (StreamReader reader = new StreamReader(request.GetResponse().GetResponseStream()))
			{
				string text = reader.ReadToEnd();
				if (text.Contains("<b>N A M E </b>"))
				{
					s_cache[new PersonName(firstName, lastName, true)] = true;
					return true;
				}
				else if (text.Contains("<h4>Sorry, we're experiencing technical difficulties. Please try again later.</h4>"))
				{
					return false;
				}
				else
				{
					s_cache[new PersonName(firstName, lastName, false)] = false;
					return false;
				}
			}
		}
public static bool QueryDirectory ( string firstName , string lastName ) { bool cachedValue ; if ( s_cache . TryGetValue ( new PersonName ( firstName , lastName , false ) , out cachedValue ) ) { return cachedValue ; } Console . WriteLine ( " " + lastName + " " + firstName ) ; WebRequest request = WebRequest . Create ( string . Format ( Endpoint , firstName , lastName ) ) ; using ( StreamReader reader = new StreamReader ( request . GetResponse ( ) . GetResponseStream ( ) ) ) { string text = reader . ReadToEnd ( ) ; if ( text . Contains ( " " ) ) { s_cache [ new PersonName ( firstName , lastName , true ) ] = true ; return true ; } else if ( text . Contains ( " " ) ) { return false ; } else { s_cache [ new PersonName ( firstName , lastName , false ) ] = false ; return false ; } } }
Queries the directory and returns true if the specified person is an NPS employee.
Queries the directory and returns true if the specified person is an NPS employee .
//TODO: switch to positive instead of negative check
firstName
string
lastName
string