/** -------------------------------------------------------------------- **/

        public void AddUrlQueueItem(string Url)
        {
            string NewUrl = Url;

            if (MacroscopePreferencesManager.GetIgnoreQueries())
            {
                NewUrl = MacroscopeUrlUtils.StripQueryString(Url: NewUrl);
            }

            if (MacroscopePreferencesManager.GetIgnoreHashFragments())
            {
                NewUrl = MacroscopeUrlUtils.StripHashFragment(Url: NewUrl);
            }

            if (!this.JobHistory.SeenHistoryItem(Url: NewUrl))
            {
                try
                {
                    MacroscopeJobItem JobItem;

                    JobItem = new MacroscopeJobItem(Url: NewUrl);

                    this.NamedQueueJobItems.AddToNamedQueue(
                        Name: MacroscopeConstants.NamedQueueUrlList,
                        Item: JobItem
                        );
                }
                catch (MacroscopeNamedQueueException ex)
                {
                    this.DebugMsg(string.Format("AddUrlQueueItem: {0}", ex.Message));
                }
            }

            this.AddToProgress(Url: NewUrl);
        }
Beispiel #2
0
        public void TestStripQueryString()
        {
            Dictionary <string, string> UrlList = new Dictionary <string, string> ();

            UrlList.Add("http://www.host.com/#aberdeen-angus", "http://www.host.com/#aberdeen-angus");

            UrlList.Add("http://www.host.com/product/list/#boris", "http://www.host.com/product/list/#boris");

            UrlList.Add("http://www.host.com/product/list/index.html#boris", "http://www.host.com/product/list/index.html#boris");

            UrlList.Add("http://www.host.com/?key1=value1&key2=value2&key3=value3#boris", "http://www.host.com/#boris");

            UrlList.Add("http://www.host.com/?key1=value1&key2=value2&key3=value3#gonzo", "http://www.host.com/#gonzo");

            UrlList.Add("http://www.host.com/index.html?key1=value1&key2=value2&key3=value3#gonzo", "http://www.host.com/index.html#gonzo");

            foreach (string Url in UrlList.Keys)
            {
                string UrlResult = MacroscopeUrlUtils.StripQueryString(Url);
                Assert.AreEqual(UrlList[Url], UrlResult, string.Format("NOT VALID: {0}", Url));
            }
        }
        /** -------------------------------------------------------------------- **/

        public void ForgetUrlQueueItem(string Url)
        {
            MacroscopeJobItem JobItem;
            string            NewUrl = Url;

            if (MacroscopePreferencesManager.GetIgnoreQueries())
            {
                NewUrl = MacroscopeUrlUtils.StripQueryString(Url: NewUrl);
            }

            if (MacroscopePreferencesManager.GetIgnoreHashFragments())
            {
                NewUrl = MacroscopeUrlUtils.StripHashFragment(Url: NewUrl);
            }

            JobItem = new MacroscopeJobItem(Url: NewUrl);

            this.NamedQueueJobItems.ForgetNamedQueueItem(
                Name: MacroscopeConstants.NamedQueueUrlList,
                Item: JobItem
                );
        }