private int ReplaceURLs()
{
string matchText = @"href=""";
DBLookup dbLookup = new DBLookup();
int numReplaced = 0;
for (int loc = centerContent.IndexOf(matchText); loc != -1; loc = centerContent.IndexOf(matchText, loc + matchText.Length))
{
string lookupText = string.Empty;
int startLoc = loc + matchText.Length;
lookupText = centerContent.Substring(startLoc, centerContent.IndexOf('"', startLoc) - startLoc);
string fullText = lookupText;
lookupText = lookupText.Trim();
lblCurrentURL.Text = lookupText;
Application.DoEvents();
//if (!IsValidLink(lookupText)) continue;
List <string> foundNodes = new List <string>();
//Make sure to search for lookup text only when non-blank URL is found
if (!string.IsNullOrWhiteSpace(lookupText))
{
string startURLText = "http", endURLText = "energy.gov/";
int startURLpos = lookupText.IndexOf(startURLText), endURLpos = lookupText.IndexOf(endURLText);
if (startURLpos != -1 && endURLpos != -1) // if it is a fully qualified URL remove server/domain name from search string
{
string eereURLText = lookupText.Substring(startURLpos, endURLpos + endURLText.Length - startURLpos);
lookupText = lookupText.Replace(eereURLText, "");
}
foundNodes = dbLookup.PerformDBLookup(lookupText);
}
if (foundNodes.Count > 0)
{
centerContent = centerContent.Replace(fullText, foundNodes[0]);
numReplaced++;
txtReplaced.Text += fullText + Environment.NewLine;
}
else
{
if (fullText.IndexOf("node/") == -1)
{
txtAttention.Text += fullText + Environment.NewLine;
}
}
}
return(numReplaced);
}