Пример #1
0
        /// <summary>
        /// 更新全部书籍
        /// </summary>
        public static void BooksUpdate(object ob)
        {
            //获取全部书籍
            DataTable   dt    = SQLiteDBHelper.ExecuteDataTable("select *from Books", null);
            List <Book> Books = ModelConvertHelper <Book> .DataTableToList(dt);

            foreach (Book book in Books)
            {
                //获取初始搜索文本
                string html = GetHtml.GetHttpWebRequest(book.Url);

                BookSource bs = GetBookSource(book.Source);

                //检测书源有效性
                if (bs.Title is null)
                {
                    Tips tips = new Tips(book.Name + "的书源不存在,请检查书源是否已经被删除掉?");
                    tips.Show();
                    return;
                }
                //获取最新章节
                string LatestChapters = Tool.GetRegexStr(html, bs.NewestRegular).Trim();

                //获取更新时间
                string Update = Tool.GetRegexStr(html, bs.UpdateRegular).Trim();

                SQLiteDBHelper.ExecuteNonQuery("Update Books set 'Newest' = '" + LatestChapters + "', 'Update' = '" + Tool.GetUpdataDate(Update) + "' where Id =" + book.Id, null);
            }
            ((MainWindow)ob).Dispatcher.Invoke(new Action(() =>
            {
                ((MainWindow)ob).DataContext = DataFetch.GetBooks();
            }));
        }
Пример #2
0
        /// <summary>
        /// 获取全部书源
        /// </summary>
        /// <returns>返回全部书源</returns>
        public static List <BookSource> GetBookSources()
        {
            //获取DataTable
            DataTable dt = SQLiteDBHelper.ExecuteDataTable("select *from BookSource where State=1", null);

            //获取所有书源
            return(ModelConvertHelper <BookSource> .DataTableToList(dt));
        }
Пример #3
0
        /// <summary>
        /// 获取我的书架
        /// </summary>
        /// <param name="fattening">判断是否为养肥区,默认不是</param>
        /// <returns></returns>
        public static List <Book> GetBooks(bool fattening = false)
        {
            int Fattening = fattening ? 1 : 0;

            //获取DataTable
            DataTable   dt    = SQLiteDBHelper.ExecuteDataTable("select *from Books where Fattening=" + Fattening, null);
            List <Book> Books = ModelConvertHelper <Book> .DataTableToList(dt);

            foreach (Book book in Books)
            {
                book.Newest = Tool.InterceptStr(book.Newest);
            }

            //获取所有书籍
            return(Books);
        }
Пример #4
0
        public static void c()
        {
            //row["Name"] = "张三";
            //row["Month"] = "2016-01";
            //row["Area"] = "江夏区";
            //row["DfMoney"] = 1;

            DataTable     dt         = InitTable();
            List <string> DataColumn = new List <string>()
            {
                "DfMoney"
            };
            string        DynamicColumn    = "Month";
            List <string> AllDynamicColumn = null;

            //DataTablePivotOne dp1 = new DataTablePivotOne();
            //DataTable dtResult = new DataTablePivotOne().DataTablePivot(dt, DimensionList, DynamicColumn, DataColumn, out AllDynamicColumn);

            #region DataTable行转列1
            DataTable dtResult = RowToColumn(dt, DataColumn, DynamicColumn, out AllDynamicColumn);
            #endregion

            #region List集合行转列(dynamiclinq)
            List <string> DimensionList = new List <string> {
                "Name", "Area"
            };
            AllDynamicColumn = null;
            IList <money> list = ModelConvertHelper <money> .DataTableToList(dt);//先转集合

            List <dynamic> dlist = DynamicLinqDemo.DynamicLinq <money>(list.ToList(), DimensionList, "Month", out AllDynamicColumn);
            //var dlistC= dlist.ToList();
            //dlist.OrderBy(s=>s.Name).ToList();
            var            gArea    = dlist.GroupBy(s => s.Area);
            List <dynamic> dlistNew = new List <dynamic>();
            foreach (var itemArea in gArea)
            {
                dlistNew.Add(itemArea);
            }
            //var G
            //dlistNew.Add(itemArea);
            #endregion
            Console.WriteLine(JsonConvert.SerializeObject(dtResult, Formatting.Indented));
            Console.Read();
        }