40 lines
1.4 KiB
C#
40 lines
1.4 KiB
C#
using BackupPipefy.Infrastructure.Data;
|
|
using BackupPipefy.Infrastructure.Services;
|
|
using Microsoft.EntityFrameworkCore;
|
|
using Microsoft.Extensions.Configuration;
|
|
|
|
class Program
|
|
{
|
|
static async Task Main(string[] args)
|
|
{
|
|
var builder = new ConfigurationBuilder()
|
|
.SetBasePath(Directory.GetCurrentDirectory())
|
|
.AddJsonFile("appsettings.json", optional: false);
|
|
|
|
var config = builder.Build();
|
|
|
|
string connStr = config["Database:ConnectionString"];
|
|
int pipeId = int.Parse(config["Pipefy:PipeId"]);
|
|
int requestsPerMinute = int.Parse(config["Pipefy:RequestsPerMinute"]);
|
|
string clientId = config["Pipefy:ClientId"];
|
|
string clientSecret = config["Pipefy:ClientSecret"];
|
|
string tokenUrl = config["Pipefy:TokenUrl"];
|
|
string personalAccessToken = config["Pipefy:PersonalAccessToken"];
|
|
|
|
var options = new DbContextOptionsBuilder<BackupContext>()
|
|
.UseNpgsql(connStr)
|
|
.Options;
|
|
|
|
using var context = new BackupContext(options);
|
|
context.Database.Migrate();
|
|
|
|
var tokenService = new PipefyTokenService(clientId, clientSecret, tokenUrl, useProxy: true, personalAccessToken);
|
|
var pipefyClient = new PipefyClient(tokenService, useProxy: true);
|
|
|
|
var service = new BackupService(pipefyClient, context, requestsPerMinute);
|
|
|
|
await service.RunBackup(pipeId);
|
|
|
|
Console.WriteLine("Backup concluído!");
|
|
}
|
|
} |