Ejemplo n.º 1
0
        /// <summary>
        /// 保存&更新书源
        /// </summary>
        private void Keep_Click(object sender, RoutedEventArgs e)
        {
            BookSource bookSource = new BookSource();

            bookSource.Title                   = sourceName.Text.Trim();
            bookSource.Url                     = sourceUrl.Text.Trim();
            bookSource.SearchUrl               = SearchUrl.Text;
            bookSource.AddressRangeRegular     = AddressRangeRegular.Text.Replace("'", "''");
            bookSource.AddressCuttingRegular   = AddressCuttingRegular.Text.Replace("'", "''");
            bookSource.AddressRegular          = AddressRegular.Text.Replace("'", "''");
            bookSource.BookNameRegular         = BookNameRegular.Text.Replace("'", "''");
            bookSource.AuthorRegular           = AuthorRegular.Text.Replace("'", "''");
            bookSource.UpdateRegular           = UpdateRegular.Text.Replace("'", "''");
            bookSource.NewestRegular           = NewestRegular.Text.Replace("'", "''");
            bookSource.DetailsRegular          = DetailsRegular.Text.Replace("'", "''");
            bookSource.StateRegular            = StateRegular.Text.Replace("'", "''");
            bookSource.DirectoryScopeRegular   = DirectoryScopeRegular.Text.Replace("'", "''");
            bookSource.DirectoryCuttingRegular = DirectoryCuttingRegular.Text.Replace("'", "''");
            bookSource.DirectoryTieleRegular   = DirectoryTieleRegular.Text.Replace("'", "''");
            bookSource.DirectoryUrlRegular     = DirectoryUrlRegular.Text.Replace("'", "''");
            bookSource.ContentTitleRegular     = ContentTitleRegular.Text.Replace("'", "''");
            bookSource.ContentRegular          = ContentRegular.Text.Replace("'", "''");
            bookSource.ImageRegular            = ImageRegular.Text.Replace("'", "''");
            bookSource.State                   = 1;


            //这个是更新原有源
            if (((Button)sender).Content.ToString() != "保存当前书源")
            {
                int id = Convert.ToInt32(Keep.Tag);
                bookSource.Id = id;
                string Msg  = DataFetch.SourceUpdate(bookSource) ? "更新成功~" : "更新失败!";
                Tips   tips = new Tips(Msg);
                tips.Show();
                //加载书源
                ListSource.ItemsSource = DataFetch.GetBookSources();
            }
            else //这个是增加新源
            {
                if (state_search && state_details && state_Catalog && state_Text)
                {
                    if (sourceName.Text.Trim().Length > 0 && sourceName.Text != "请输入新书源名~" && sourceUrl.Text.Trim().Length > 0 && sourceUrl.Text != "请输入新书源URL~")
                    {
                        string Msg = DataFetch.SourceAdd(bookSource) ? "添加成功~" : "添加失败!";
                        new Tips(Msg).Show();
                    }
                    else
                    {
                        new Tips("请输入书源名和书源链接!").Show();
                    }
                }
                else
                {
                    new Tips("请将其他页面的内容全部填写完毕,并保证准确无误后在进行提交!").Show();
                }
            }
            //加载书源
            ListSource.ItemsSource = DataFetch.GetBookSources();
            Empty();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 获取目录
        /// </summary>
        private void GetDirectory_Click(object sender, RoutedEventArgs e)
        {
            string url = List_url.Text.Trim();

            //获取范围化的文本
            string html = Tool.GetRegexStr(GetHtml.GetHttpWebRequest(url), DirectoryScopeRegular.Text).Trim();

            //得到被分割的目录
            string[] List = html.Split(new string[] { DirectoryCuttingRegular.Text }, StringSplitOptions.RemoveEmptyEntries);


            //这个是处理的目录
            List <GetDirectory> NewList = new List <GetDirectory>();

            int Newid = 0;

            foreach (string chapter in List)
            {
                string NewUrl = Tool.GetRegexStr(chapter, DirectoryUrlRegular.Text).Trim();
                if (NewUrl.Length > 3)
                {
                    Newid++;
                    string NewTitle = Tool.GetRegexStr(chapter, DirectoryTieleRegular.Text).Trim();
                    NewList.Add(new GetDirectory()
                    {
                        Id = Newid, Title = NewTitle, Url = NewUrl
                    });
                }
            }

            Catalog.ItemsSource = NewList;
            if (NewList.Count > 1)
            {
                state_Catalog = true;
            }
            Tips tips = new Tips("目录获取完毕~");

            tips.Show();
        }