Пример #1
0
        public static void Setup()
        {
            DB = new SqliteDB("Database.db");

            DB.CreateTables()
            .Add <Ticket>()
            .Commit();

            DB.CreateTables()
            .Add <TicketHist>()
            .Commit();
        }
Пример #2
0
        public static void run()
        {
            SqliteDB db = new SqliteDB("myStuff.db");

            Console.WriteLine($"Database is at {db.DatabaseFileName}");

            // Create a DB Schema
            db.CreateTables()
            .Add <MyData>()
            .Commit();

            db.Insert(new
            {
                MyUID  = Guid.NewGuid(),
                MyName = "Test"
            },
                      OnConflict.Ignore,
                      tableName: "MyData");

            for (int i = 0; i < 5; i++)
            {
                db.Insert(new MyData()
                {
                    MyId  = i * 3,
                    MyUID = Guid.NewGuid()
                });
            }
            var allInts = db.Query <int>("SELECT MyId FROM MyData", null).ToArray();
        }
Пример #3
0
        /// <summary>
        /// Configuração Banco de dados
        /// </summary>
        public static void Setup()
        {
            DB = new SqliteDB("MyShit.db");

            DB.CreateTables()
            .Add <Item>()
            .Commit();
        }
Пример #4
0
        public void Setup()
        {
            BD = new SqliteDB("BDSistemaEstoque.db");

            BD.CreateTables()
            .Add <ProdutoCadastro>()
            .Commit();
        }
Пример #5
0
        public static void initializeDb()
        {
            string curFile = @"C:\Program Files\Macetim\iplist.db";

            db = new SqliteDB(curFile);
            var result = db.CreateTables()
                         .Add <iplist>()
                         .Commit();
        }
        public static void run(SqliteDB db)
        {
            db.CreateTables()
            .Add <ReceitasModel>()
            .Commit();
            string path;

            //foreach (var file in Directory.GetFiles(@"N:\Organizando\Dados Crawlers\TSE\", "*.zip"))
            //{
            //    processaArquivo(db, file);
            //}

            processaArquivo2018_2020(db, @"N:\Organizando\Dados Crawlers\TSE\prestacao_de_contas_eleitorais_candidatos_2020.zip");
        }
Пример #7
0
        public static void run(SqliteDB database)
        {
            db = database;
            db.CreateTables()
            .Add <PessoalModel>()
            .Add <Deputado>()
            .Commit();

            var init = InitializationParams.Default002()
                       .SetConfig(c => c.Disable_AutoAnchorsLinks()
                                  .Set_DownloadDelay(0));

            var spider = new SimpleSpider("camara_gabinete", new Uri("https://www.camara.leg.br/"), init);

            spider.FetchCompleted += Spider_FetchCompleted;
            spider.AddPage(new Uri("https://www.camara.leg.br/deputados/quem-sao"), spider.BaseUri);
            spider.Execute();
        }
Пример #8
0
        private static void processaDadosFolha(int mes, int ano)
        {
            SqliteDB db = new SqliteDB("senadoresFolha.db");

            db.CreateTables()
            //.Add<Robops.Lib.Senado.Leg.Senador>()
            //.Add<Robops.Lib.Senado.Leg.FuncionarioGabinete>()
            .Add <Robops.Lib.Senado.Leg.Folha>()
            .Commit();

            var cat = new CatalogarFuncionariosSenadores();

            cat.Catalogar(ano);

            var dados = cat.Senadores;

            var jaTem = db.GetAll <Robops.Lib.Senado.Leg.Folha>()
                        .Select(o => $"{o.CodigoFuncionario}-{o.Referencia.Year}-{o.Referencia.Month}")
                        .ToHashSet();

            var funcionarios = dados.SelectMany(s => s.Gabinete)
                               .Distinct()
                               .Where(o => !jaTem.Contains($"{o.CodigoFuncionario}-{ano}-{mes}"))      // não já foi
                                                                                                       //.Take(500) // lotes ...
                               .ToArray();
            var codFuncionarios = funcionarios
                                  .Select(f => f.CodigoFuncionario)
                                  .ToArray();

            var itensFolha = CatalogarDadosFolha.CarregarFolhaFuncionarios(codFuncionarios, mes, ano);

            db.BulkInsert(itensFolha);
            // adicoina os faltantes
            var semInformacao = funcionarios
                                .Where(f => !itensFolha.Any(iF => iF.CodigoFuncionario == f.CodigoFuncionario))
                                .Select(func => new Robops.Lib.Senado.Leg.Folha()
            {
                CodigoFuncionario = func.CodigoFuncionario,
                Referencia        = new DateTime(ano, mes, 1)
            })
                                .ToArray();

            db.BulkInsert(semInformacao);
        }
Пример #9
0
        public static void run()
        {
            var db = new SqliteDB("myStuff.db");

            Console.WriteLine($"Database is at {db.DatabaseFileName}");

            // Create a DB Schema
            db.CreateTables()
            .Add <IntSample>()
            .Commit();

            // reset before sample
            db.Execute("DELETE FROM IntSample");

            var bobAccount = new IntSample()
            {
                Id   = 0, // will be generated
                Name = "bob"
            };
            //When using INT PrimaryKeys, the column becomes the sqlite's _rowid_
            var id = db.InsertOrReplace(bobAccount);

            Console.WriteLine($"Inserted with ID {id}");
            // bobAccount.Id is still zero

            // update bob
            bobAccount = db.Get <IntSample>(id);
            Console.WriteLine($"Name is still `{bobAccount.Name}`");
            Console.WriteLine($"Previous inserted ID was: `{id}` and  bobAccount.Id: `{bobAccount.Id}`");

            bobAccount.Name = "Bob's account";
            var id2 = db.InsertOrReplace(bobAccount);

            foreach (var bobs in db.GetAll <IntSample>())
            {
                Console.WriteLine($"Id: {bobs.Id} Name: {bobs.Name}");
            }
        }
Пример #10
0
        public async void Run(IBackgroundTaskInstance taskInstance)
        {
            _deferral = taskInstance.GetDeferral();
            SqliteDB db = new SqliteDB();

            db.CreateTables(); //Tables should only be created during startup.
            var restRouteHandler = new RestRouteHandler();


            //Register the controllers
            restRouteHandler.RegisterController <ListController>();
            restRouteHandler.RegisterController <CameraLookup>();
            restRouteHandler.RegisterController <HostController>();
            restRouteHandler.RegisterController <LoanController>();



            var configuration = new HttpServerConfiguration()
                                .ListenOnPort(8800)
                                .RegisterRoute("api", restRouteHandler)
                                .RegisterRoute(new StaticFileRouteHandler(@"Web"))
                                .EnableCors(); // allow cors requests on all origins
            //  .EnableCors(x => x.AddAllowedOrigin("http://specificserver:<listen-port>"));

            var httpServer = new HttpServer(configuration);

            _httpServer = httpServer;

            //Start background cron.
            var cron = new Cron.CameraReset();

            cron.StartTasks();


            await httpServer.StartServerAsync();
        }
Пример #11
0
        public static void run()
        {
            SqliteDB db = new SqliteDB("myStuff.db");

            Console.WriteLine($"Database is at {db.DatabaseFileName}");

            // Create a DB Schema
            var result = db.CreateTables()
                         .Add <MyData>()
                         .Commit();

            if (result.Length > 0 && result[0].WasTableCreated)
            {
                Console.WriteLine("A new table was created!");
            }

            var d = new MyData()
            {
                MyId           = (int)DateTimeOffset.Now.ToUnixTimeSeconds(),
                MyName         = "My name is bob",
                MyBirthDate    = DateTime.Now,
                MyUID          = Guid.Empty, // When empty, a new Guid will be generated
                MyWebsite      = new Uri("http://example.com"),
                MyFavColor     = System.Drawing.Color.FromArgb(101, 102, 103, 104),
                MyDecimalValue = 123.4M,
                MyDoubleValue  = 456.7,
                MyFloatValue   = 789.3f,
                MyEnum         = MyData.eIntEnum.Zero,
            };

            Console.WriteLine($"New data to insert: Id={d.MyId} MyUID={d.MyUID}");
            db.Insert(d);

            // get all data
            var allData = db.GetAll <MyData>();

            Console.WriteLine("All data:");
            foreach (var rowData in allData)
            {
                Console.WriteLine($" > {rowData.MyId} {rowData.MyName} {rowData.MyUID}");
            }

            //get "bob" data
            var bobs = db.Query <MyData>("SELECT * FROM MyData WHERE MyName LIKE @name ", new { name = "%bob%" });

            Console.WriteLine("All bob data:");
            foreach (var rowData in bobs)
            {
                Console.WriteLine($" > {rowData.MyId} {rowData.MyName} {rowData.MyUID}");
            }

            // change frst bob
            var firstBob = bobs.First();

            firstBob.MyName = "Changed bob";
            db.InsertOrReplace(firstBob);
            // show all data again
            Console.WriteLine("All data:");
            foreach (var rowData in allData)
            {
                Console.WriteLine($" > {rowData.MyId} {rowData.MyName} {rowData.MyUID}");
            }
        }