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); }
private string GetNodeID(string webURL) { string id = string.Empty; DBLookup lookup = new DBLookup(); if (webURL.IndexOf("http://") != -1) { webURL = webURL.Substring(webURL.IndexOf('/', "http://".Length + 1)); } //if (webURL.IndexOf("/index.html") != -1) webURL = webURL.Replace("/index.html", ""); List <string> nodeURLs = lookup.PerformDBLookup(webURL); if (nodeURLs.Count > 0) { id = nodeURLs[0].Replace("node/", ""); } return(id); }
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; }
private string GetNodeID(string webURL) { string id = string.Empty; DBLookup lookup = new DBLookup(); if (webURL.IndexOf("http://") != -1) webURL = webURL.Substring(webURL.IndexOf('/', "http://".Length + 1)); //if (webURL.IndexOf("/index.html") != -1) webURL = webURL.Replace("/index.html", ""); List<string> nodeURLs = lookup.PerformDBLookup(webURL); if (nodeURLs.Count > 0) { id = nodeURLs[0].Replace("node/", ""); } return id; }