Esempio n. 1
0
 private static void showExample <T>(ConfigurationDB db, string typeName, string key, string category, T valueToInsert, T defaultValue)
 {
     // force delete due to multiple executions
     db.RemoveConfig(key, category);
     Console.WriteLine($"---{typeName} example---");
     Console.WriteLine($"Current {typeName}: {db.GetConfig(key, category, defaultValue)}");
     Console.WriteLine($"Saving a new {typeName}: {valueToInsert}");
     db.SetConfig(key, category, valueToInsert);
     Console.WriteLine($"Current {typeName}: {db.GetConfig(key, category, defaultValue)}");
 }
Esempio n. 2
0
        public static void run()
        {
            var db  = new NoSqliteStorage("robops_servidores.db");
            var cfg = new ConfigurationDB("robops_servidores.db");

            int comecarPagina = cfg.GetConfig("LastPage", "", 1440);

            // catalogar todos os servidores
            for (int i = comecarPagina; ; i++)
            {
                var resultado = FetchHelper.FetchResourceJson <ConsultaServidores>(buildJsonUri(i));

                Console.WriteLine($"{DateTime.Now.ToLongTimeString()} Pagina {i} - {resultado.data.Length} lidos");
                db.Store(resultado.data, d => d.id);
                cfg.SetConfig("LastPage", "", i);

                //foreach (var d in resultado.data)
                //{
                //    db.Store(d.id, d);
                //}

                if (resultado.data.Length < 50)
                {
                    break; // terminou
                }
            }
        }