protected void FindAllResults() { CompanyModel cMod = new CompanyModel(); ResultModel rMod = new ResultModel(); MyUserModel muMod = new MyUserModel(); List <Company> myComps = cMod.GetAllCompanies(); List <MyUser> users = muMod.GetAllMyUsers(); string[] myTrigs = new string[7]; myTrigs[0] = "Hiring"; myTrigs[1] = "Merger"; myTrigs[2] = "Sales Growth"; myTrigs[3] = "Contract"; myTrigs[4] = "Training"; myTrigs[5] = "New Location"; myTrigs[6] = "New CFO"; string finalStatus = ""; int numRequests = 0; if ((myComps.Count < 1) || (myComps == null)) { litStatus.Text = "Problem with companies list."; finalStatus += "Problem with companies list."; } foreach (Company c in myComps) { litStatus.Text = "Checking for news about " + c.Name + "."; finalStatus += "Checking for news about " + c.Name + "."; string sear = c.Name; string[] res = MakeRequest(sear); numRequests++; string htmlBody = ""; if (res.Length < 1) { litStatus.Text = "Nothing found for " + c.Name + "."; finalStatus += "Nothing found for " + c.Name + "."; } else { List <int> skips = new List <int>(); string finalTrigger = ""; for (int j = 0; j < res.Length; j = j + 3) { string title = res[j]; string desc = res[j + 2]; string trig = TestRelevance(c.Name, title, desc); if ((trig == "False") || (trig == "") || (trig == null)) { skips.Add(j); skips.Add(j + 1); skips.Add(j + 2); } else { finalTrigger = trig; } } litStatus.Text = "Creating new result for " + c.Name + "."; finalStatus += "Creating new result for " + c.Name + "."; Result newRes = new Result(); string myComp = c.Name; newRes.Company = myComp; newRes.DateSearched = DateTime.Now; //FIX THIS newRes.Triggers = finalTrigger; //FIX THIS htmlBody += "<ul>"; for (int j = 0; j < res.Length; j = j + 3) { if (!skips.Contains(j)) { htmlBody += "<li>" + "<a href=\"" + res[j + 1] + "\">" + res[j] + "</a>" + "<p style=\"display:none;\">" + res[j + 2] + "</p>" + "</li>"; } if (j == (res.Length - 3)) { htmlBody += "</ul>"; } } //For if ((htmlBody == "<ul></ul>") || (HasDuplicates(newRes))) { //do nothing } else { newRes.BodyText = htmlBody; rMod.InsertResult(newRes); //Put result in user's shit foreach (MyUser m in users) { string uComps = m.Companies; if ((myComp != null) && (uComps != null) && (uComps.Contains(myComp)) && (m.Triggers.Contains(finalTrigger))) { string resultString = m.Results; string newResultString = ""; if ((resultString == null) || (resultString == "")) { newResultString = newRes.ID.ToString(); } else { newResultString = newRes.ID.ToString() + "," + resultString; } MyUser newUse = new MyUser(); newUse.AccountType = m.AccountType; newUse.BillingCycle = m.BillingCycle; newUse.Companies = m.Companies; newUse.Email = m.Email; newUse.FirstName = m.FirstName; newUse.GUI = m.GUI; newUse.ID = m.ID; newUse.LastLogin = m.LastLogin; newUse.LastName = m.LastName; newUse.Newsletter = m.Newsletter; newUse.Results = newResultString; newUse.StartDate = m.StartDate; newUse.Triggers = m.Triggers; newUse.UserName = m.UserName; muMod.UpdateMyUser(m.ID, newUse); } //if ucomps } //foreach } //end else } //if res.length } // foreach Company c in comps finalStatus += "This operation took " + numRequests.ToString() + " requests."; litFinalStatus.Text = finalStatus; } //FindAllResults()