protected void BtnField_Click(object sender, EventArgs e)
        {
            CollectionCommon common = new CollectionCommon();
            Uri    url      = new Uri(this.TxtListAddress.Text);
            string coding   = this.CodingType(this.RadlCodeType.SelectedValue);
            string httpPage = common.GetHttpPage(url, coding);
            string str3     = common.GetInterceptionString(httpPage, this.TxtFieldBegin.Text, this.TxtFieldEnd.Text);

            if (!string.IsNullOrEmpty(str3))
            {
                if (this.ChkDesignated.Checked)
                {
                    this.TxtShowCode.Text = this.TxtDesignated.Text;
                }
                else
                {
                    if (this.RadContent.Checked)
                    {
                        this.TxtShowCode.Text = str3;
                    }
                    if (this.RadKeyWord.Checked)
                    {
                        this.TxtShowCode.Text = CollectionCommon.CreateKeyWord(str3, DataConverter.CLng(this.TxtKeyWord.Text));
                    }
                    if (this.RadDate.Checked)
                    {
                        this.TxtShowCode.Text = DataConverter.CDate(str3).ToString();
                    }
                }
            }
        }
Пример #2
0
        private void TestField(XmlDocument ixml)
        {
            string           uriString        = (ixml.DocumentElement.SelectSingleNode("//url") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//url").InnerText.Trim();
            string           coding           = (ixml.DocumentElement.SelectSingleNode("//codeType") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//codeType").InnerText.Trim();
            string           startStr         = (ixml.DocumentElement.SelectSingleNode("//listBegin") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//listBegin").InnerText;
            string           overStr          = (ixml.DocumentElement.SelectSingleNode("//listEnd") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//listEnd").InnerText;
            string           input            = (ixml.DocumentElement.SelectSingleNode("//keyword") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//keyword").InnerText.Trim();
            string           filterRuleId     = (ixml.DocumentElement.SelectSingleNode("//filterRuleId") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//filterRuleId").InnerText.Trim();
            string           filter           = (ixml.DocumentElement.SelectSingleNode("//filter") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//filter").InnerText.Trim();
            string           str8             = (ixml.DocumentElement.SelectSingleNode("//fieldType") == null) ? "" : ixml.DocumentElement.SelectSingleNode("//fieldType").InnerText.Trim();
            CollectionCommon collectionCommon = new CollectionCommon();
            Uri       url         = new Uri(uriString);
            string    httpPage    = collectionCommon.GetHttpPage(url, coding);
            string    testContent = collectionCommon.GetInterceptionString(httpPage, startStr, overStr);
            FieldType none        = FieldType.None;

            if (Enum.IsDefined(typeof(FieldType), str8))
            {
                none = (FieldType)Enum.Parse(typeof(FieldType), str8);
            }
            switch (none)
            {
            case FieldType.TextType:
            case FieldType.ListBoxType:
            case FieldType.LookType:
            case FieldType.CountType:
            case FieldType.ColorType:
            case FieldType.TemplateType:
            case FieldType.AuthorType:
            case FieldType.SourceType:
            case FieldType.OperatingType:
            case FieldType.Producer:
            case FieldType.Trademark:
            case FieldType.TitleType:
                if (testContent.Length > 0xff)
                {
                    testContent = testContent.Substring(0, 0xff);
                }
                testContent = CommonFilter(filterRuleId, filter, collectionCommon, testContent);
                break;

            case FieldType.NumberType:
                testContent = DataConverter.CSingle(testContent).ToString();
                break;

            case FieldType.MoneyType:
                testContent = DataConverter.CDecimal(testContent).ToString();
                break;

            case FieldType.DateTimeType:
                testContent = DataConverter.CDate(testContent).ToString();
                break;

            case FieldType.BoolType:
                testContent = DataConverter.CBoolean(testContent).ToString();
                break;

            case FieldType.KeywordType:
                testContent = CollectionCommon.CreateKeyWord(CommonFilter(filterRuleId, filter, collectionCommon, testContent).Replace(",", "|").Replace(",", "|"), DataConverter.CLng(input));
                break;

            default:
                testContent = CommonFilter(filterRuleId, filter, collectionCommon, testContent);
                break;
            }
            if (string.IsNullOrEmpty(testContent))
            {
                testContent = "没有截取到代码,请加载内容页源代码重新设置下。";
            }
            XmlTextWriter writer = new XmlTextWriter(HttpContext.Current.Response.OutputStream, Encoding.UTF8);

            writer.Formatting  = Formatting.Indented;
            writer.Indentation = 4;
            writer.WriteStartDocument();
            writer.WriteStartElement("root", "");
            writer.WriteElementString("testContent", testContent);
            writer.WriteEndElement();
            writer.WriteEndDocument();
            writer.Close();
        }