예제 #1
0
        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);
        }
예제 #2
0
        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();
            }
        }