public LinkFeedParams ModifySubscription(ObjectId recordid, ObjectId resultsid, string htmlTags, HashSet <string> keywords) { LinkFeedParams parameters = null; if (links.ContainsKey(resultsid)) { if (links[resultsid].htmlTags == htmlTags) { links[resultsid].ReplaceKeywords(keywords); parameters = links[resultsid]; } else { IHtmlRecord record = DataManager.Instance.GetHtmlRecord(recordid); record.RemoveResults(resultsid, id); IHtmlResults results = record.AddResults(htmlTags, id); parameters = new LinkFeedParams(record.recordid, results.resultsid, record.domain.AbsoluteUri, results.htmlTags, keywords); DataManager.Instance.SaveHtmlRecord(record); links.Add(results.resultsid, parameters); } } return(parameters); }
public void RemoveAllLinks() { foreach (LinkFeedParams linkParams in links.Values) { IHtmlRecord record = DataManager.Instance.GetHtmlRecord(linkParams.recordid); record.RemoveResults(linkParams.resultsid, id); } }
public void SaveHtmlRecord(IHtmlRecord record) { Database.Instance.htmlCollection.Save(record, WriteConcern.Acknowledged); if (!jobSchedule.JobInSchedule(record.recordid)) { jobSchedule.AddNewJob(record.recordid, DateTime.UtcNow); scheduleJobsProc.Interrupt(); } }
public void RemoveLink(ObjectId resultsid) { if (links.ContainsKey(resultsid)) { ObjectId recordid = links[resultsid].recordid; IHtmlRecord record = DataManager.Instance.GetHtmlRecord(recordid); record.RemoveResults(resultsid, id); links.Remove(resultsid); DataManager.Instance.SaveHtmlRecord(record); } }
public IHtmlRecord CreateHtmlRecord(Uri domain) { IHtmlRecord record = Database.Instance.htmlCollection.FindOneAs <HtmlRecord> (Query.EQ("url", domain.AbsoluteUri)) as IHtmlRecord; if (record == null) { record = new HtmlRecord(domain); } return(record); }
public LinkFeedParams AddLinkFeed(string url, string htmlTags, HashSet <string> keywords) { if (!links.Any(pair => pair.Value.url == url && pair.Value.htmlTags == htmlTags)) { IHtmlRecord record = DataManager.Instance.CreateHtmlRecord(new Uri(url)); IHtmlResults results = record.AddResults(htmlTags, id); LinkFeedParams parameters = new LinkFeedParams(record.recordid, results.resultsid, record.domain.AbsoluteUri, results.htmlTags, keywords); DataManager.Instance.SaveHtmlRecord(record); links.Add(results.resultsid, parameters); return(parameters); } else { throw new Exception(); } }
public List <Tuple <LinkFeedParams, List <UserLink> > > GetAllLinkFeeds() { List <Tuple <LinkFeedParams, List <UserLink> > > linkFeeds = new List <Tuple <LinkFeedParams, List <UserLink> > >(); foreach (KeyValuePair <ObjectId, LinkFeedParams> pair in links) { IHtmlRecord record = DataManager.Instance.GetHtmlRecord(pair.Value.recordid); IHtmlResults results = record.GetHtmlResults(pair.Value.resultsid); List <UserLink> userLinks; if (pair.Value.keywords != null) { userLinks = results.GetLinkFeedResults(pair.Value.keywords); } else { userLinks = results.GetLinkFeedResults(new HashSet <string>()); } linkFeeds.Add(new Tuple <LinkFeedParams, List <UserLink> >(pair.Value, userLinks)); pair.Value.UpdateTimeStamp(); } return(linkFeeds); }