Пример #1
0
        static void Main(string[] args)
        {
            var delay = int.Parse(ConfigurationManager.AppSettings["GetPageDelay"]);
            //var pgCon = ConfigurationManager.ConnectionStrings["PgCon"].ConnectionString;
            var sqliteCon = ConfigurationManager.ConnectionStrings["SqliteCon"].ConnectionString;

            PlacesConfig.SetSqliteConnection(sqliteCon);
            //PlacesConfig.SetPgConnection(pgCon);
            Stat.Program.RunAsync(delay);
            //RunAsync();
            Console.ReadLine();
        }
Пример #2
0
        public static async void RunAsync(int delay)
        {
            Stat.Places.PlacesConfig.Delay = delay;

            //var sql = String.Format("SELECT \"NAME\",\"URL\",\"CODE\",\"PLACETYPE\" FROM public.stat WHERE \"NAME\"='{0}'", "中华人民共和国");
            //command.Connection = PgConnection;
            //var china = PlacesConfig.PgConnection.QueryFirstOrDefault<Nation>(sql, new Nation()
            //{
            //});

            var fi = new FileInfo(@"DB\sptest1.sqlite");

            fi.Delete();
            var fib = new FileInfo(@"DB\sptest1back.sqlite");

            File.Copy(@"DB\sptest1back.sqlite", @"DB\sptest1.sqlite");

            PlacesConfig.SetSqliteConnection(ConfigurationManager.ConnectionStrings["SqliteCon"].ConnectionString);
            var command    = new SQLiteCommand();
            var connection = PlacesConfig.SQLiteConnection;

            connection.Open();
            command.Connection = connection;
            var sql    = String.Format("SELECT * FROM PLACES WHERE NAME = '{0}';  ", "中华人民共和国");
            var result = connection.Query("SELECT * FROM PLACES;");
            var china  = connection.QueryFirstOrDefault <Nation>(sql);

            china.AutoStoreMembersToDB = true;

            //connection.Query<Nation>("SELECT * FROM PLACES WHERE NAME = '{0}'  ", "z"     )
            //command.Connection = PlacesConfig.SQLiteConnection;
            //command.Connection.Open();



            //new SQLiteConnection("")

            //var china = new Nation();
            //china.Url = "http://www.stats.gov.cn/tjsj/tjbz/tjyqhdmhcxhfdm/2017/";
            //china.Name = "中华人民共和国";

            //await china.GetMembersAsync();
            china.MembersAutoGetMembers = true;
            await china.GetMembersAsync();

            //foreach (var province in china.Members)
            //{
            //    //Trace.WriteLine(province.Name);
            //    //break;
            //    var tryProvince = (Province)province;
            //    tryProvince.AutoStoreMembersToDB = true;
            //    await tryProvince.GetMembersAsync();
            //    foreach (var city in province.Members)
            //    {
            //        //Trace.WriteLine(city.GetFullname());
            //        var tryCity = (City)city;
            //        tryCity.AutoStoreMembersToDB = true;
            //        await tryCity.GetMembersAsync();
            //        //var tryFullname = tryCity.GetFullname();
            //        //Trace.WriteLine(tryFullname);
            //        foreach (var county in tryCity.Members)
            //        {
            //            var tryCounty = county as County;
            //            tryCounty.AutoStoreMembersToDB = true;
            //            await tryCounty.GetMembersAsync();
            //            foreach (var town in county.Members)
            //            {
            //                var tryTown = town as Town;
            //                tryTown.AutoStoreMembersToDB = true;
            //                await tryTown.GetMembersAsync();
            //                foreach (var village in tryTown.Members)
            //                {
            //                    var tryVillage = village as Village;
            //                    var tryFullname = tryVillage.GetFullname();
            //                    //Trace.WriteLine(tryFullname);
            //                    Console.WriteLine(tryFullname);
            //                }
            //                //Trace.WriteLine(tryTown.GetFullname());
            //            }
            //            //Trace.WriteLine(tryCounty.GetFullname());
            //        }
            //        //Trace.WriteLine(tryCity.GetFullname());
            //    }
            //}
        }