예제 #1
0
        protected void Analyze_Click(object sender, EventArgs e)
        {
            try
            {
                var counter = new util.Analyser(textUrlOrText.Text, radioAnalyzeUrl.Checked,
                                                textStopWords.Text);
                analyzeDic(checkBoxCalculateWordsOnPage.Checked, gridViewWords, counter.GetWordsDictionary, "wordsTable");
                analyzeDic(checkBoxCalculateKeywordsOnPage.Checked, gridViewKeywords, counter.GetKeywordsDictionary,
                           "keywordsTable");

                if (checkBoxCalculateExternalLinks.Checked)
                {
                    labelExternalLinkNumber.Text = String.Format("Number of external links: {0}",
                                                                 counter.GetExternalLinksNumber());
                }
                else
                {
                    labelExternalLinkNumber.Text = "";
                }
            }
            catch (UriFormatException)
            {
                labelErrorText.Text       = "Incompatible url format";
                textUrlOrText.BorderColor = Color.Red;
            }
            catch (WebException ex)
            {
                labelErrorText.Text       = ex.Message;
                textUrlOrText.BorderColor = Color.Red;
            }
        }
예제 #2
0
        protected void Analyze_Click(object sender, EventArgs e)
        {
            try
            {
                isUrlPassed = (txtWords.Rows == 1) ? true : false;
                var counter = new util.Analyser(txtWords.Text, isUrlPassed, textStopWords.Text);
                analyseWords(gridViewWords, counter.AddWordsCountToDictionary, "wordsTable");
                analyseWords(gridViewKeywords, counter.GetKeywordsCount, "keywordsTable");

                labelExternalLinkNumber.Text = String.Format("Number of external links: {0}", counter.GetExternalLinksCount());
            }
            catch (UriFormatException)
            {
                labelErrorText.Text  = "Incompatible url format";
                txtWords.BorderColor = Color.Red;
            }
            catch (WebException ex)
            {
                labelErrorText.Text  = ex.Message;
                txtWords.BorderColor = Color.Red;
            }
        }