Example #1
0
        /// <summary>
        ///     获取配置实体
        /// </summary>
        /// <returns></returns>
        public static Config GetConfig()
        {
            if (File.Exists(SysConfig.HtmlFormatConfigPath))
            {
                XmlSerializer xmlSerializer = new XmlSerializer(typeof(Config));
                Config        config        = xmlSerializer.Deserialize(new MemoryStream(File.ReadAllBytes(SysConfig.HtmlFormatConfigPath))) as Config;
                if (config == null)
                {
                    return(null);
                }

                string[] datas = config.WrapTag.Replace("\r", "").Split('\n');
                if (datas.Length > 1)
                {
                    if (!datas[1].StartsWith("|"))
                    {
                        datas[1] = "|" + datas[1];
                    }
                    config.WrapTag = datas[0] + datas[1] + datas[1].ToUpper();
                    config.WrapTag = config.WrapTag.Trim('|');
                }
                config.WrapTag = StringFormat.EscapeCharacterDecode(config.WrapTag);

                datas = config.WhiteTag.Replace("\r", "").Split('\n');
                if (datas.Length > 1)
                {
                    if (!datas[1].StartsWith("|"))
                    {
                        datas[1] = "|" + datas[1];
                    }
                    config.WhiteTag = datas[0] + datas[1] + datas[1].ToUpper();
                    config.WhiteTag = config.WhiteTag.Trim('|');
                }
                config.WhiteTag = StringFormat.EscapeCharacterDecode(config.WhiteTag);

                datas = config.IndentTag.Replace("\r", "").Split('\n');
                if (datas.Length > 1)
                {
                    if (!datas[1].StartsWith("|"))
                    {
                        datas[1] = "|" + datas[1];
                    }
                    config.IndentTag = datas[0] + datas[1] + datas[1].ToUpper();
                    config.IndentTag = config.IndentTag.Trim('|');
                }
                config.IndentTag = StringFormat.EscapeCharacterDecode(config.IndentTag);

                config.WrapTagTo         = StringFormat.EscapeCharacterDecode(config.WrapTagTo);
                config.WhiteTagTo        = StringFormat.EscapeCharacterDecode(config.WhiteTagTo);
                config.IndentTagTo       = StringFormat.EscapeCharacterDecode(config.IndentTagTo);
                config.OutputTitleFormat = StringFormat.EscapeCharacterDecode(config.OutputTitleFormat);
                return(config);
            }
            return(null);
        }
Example #2
0
        /// <summary>
        /// 根据输入,返回任务数据实体
        /// </summary>
        /// <returns></returns>
        private Task GetTaskModelFromInput()
        {
            Task t = new Task();

            t.TaskName               = txtTaskName.Text;
            t.SourceName             = txtSourceName.Text;
            t.GatherModel            = GetGatherModelText();
            t.StartUrl               = txtStartUrl.Text;
            t.ListPageUrl            = StringFormat.EscapeCharacterDecode(txtListPageUrl.Text);
            t.WebTitle               = StringFormat.EscapeCharacterDecode(txtWebTitle.Text);
            t.WebContent             = StringFormat.EscapeCharacterDecode(txtWebContent.Text);
            t.ContentPageUrl         = StringFormat.EscapeCharacterDecode(txtContentPageUrl.Text);
            t.SavePath               = txtSavePath.Text;
            t.IsSaveOnlyFile         = ckbIsSaveOnlyFile.Checked;
            t.IsStartClearMessageBox = ckbIsStartClearMessageBox.Checked;
            t.DefaultEncode          = cmbDefaultEncode.Text;
            t.IsDealSamePage         = ckbIsDealSamePage.Checked;
            t.FirstPageMark          = StringFormat.EscapeCharacterDecode(txtFirstPageMark.Text);
            t.SamePageMark           = StringFormat.EscapeCharacterDecode(txtSamePageMark.Text);
            t.GatherCountMax         = (long)nudGatherCountMax.Value;
            return(t);
        }