Ejemplo n.º 1
0
        private void Ftp(TraffkGlobalDbContext gdb, string ftpHost, string credentialsUri, int tenantId, string filePattern, params string[] folderPaths)
        {
            var ds = new Traffk.Bal.Data.Rdb.TraffkGlobal.DataSource
            {
                TenantId           = tenantId,
                DataSourceSettings = new Traffk.Bal.Settings.DataSourceSettings
                {
                    FTP = new Traffk.Bal.Settings.DataSourceSettings.FtpSettings
                    {
                        CredentialsKeyUri = credentialsUri,
                        Hostname          = ftpHost,
                        Port        = 22,
                        FolderPaths = folderPaths,
                        FilePattern = filePattern,
                    },
                    DecompressItems = true,
                }
            };

            gdb.DataSources.Add(ds);
            gdb.SaveChanges();
            var rjm = (ITraffkRecurringJobManager) new TenantedBackgroundJobClient(gdb, new HardcodedTraffkTenantFinder(tenantId));

            rjm.Add(Hangfire.Common.Job.FromExpression <IDataSourceSyncJobs>(z => z.DataSourceFetchAsync(ds.DataSourceId)), Hangfire.Cron.Hourly());
        }
Ejemplo n.º 2
0
 public DataController(TraffkTenantModelDbContext db,
                       CurrentContextServices current,
                       ILogger logger,
                       ICacher cacher,
                       TraffkGlobalDbContext gdb) : base(AspHelpers.MainNavigationPageKeys.Manage, db, current, logger, cacher)
 {
     GDB = gdb;
 }
Ejemplo n.º 3
0
 private void DeerwalkFtp(TraffkGlobalDbContext gdb, int tenantId, string filePattern, params string[] folderPaths)
 => Ftp(
     gdb,
     "ftp.deerwalk.com",
     Traffk.Bal.Services.Vault.CommonSecretUris.DeerwalkFtpCredentialsUri,
     tenantId,
     filePattern,
     folderPaths
     );
Ejemplo n.º 4
0
 private void TraffkFtp(TraffkGlobalDbContext gdb, int tenantId, string filePattern, params string[] folderPaths)
 => Ftp(
     gdb,
     "traffk.ftptoday.com",
     Traffk.Bal.Services.Vault.CommonSecretUris.TraffkFtpTodayCredentialsUri,
     tenantId,
     filePattern,
     folderPaths
     );
Ejemplo n.º 5
0
 public TenantedBackgroundJobClient(TraffkGlobalDbContext gdb, ITraffkTenantFinder finder, IJobInfoFinder jobInfoFinder = null, ICurrentUser currentUser = null)
 {
     Inner               = new BackgroundJobClient();
     GDB                 = gdb;
     Finder              = finder;
     CurrentUser         = currentUser;
     RecurringJobManager = new RecurringJobManager();
     TenantId            = Finder.GetTenantIdAsync().ExecuteSynchronously();
     JobInfoFinder       = jobInfoFinder;
 }
Ejemplo n.º 6
0
 public JobsController(
     TraffkTenantModelDbContext db,
     CurrentContextServices current,
     ILogger logger,
     IBackgroundJobClient backgrounder,
     TraffkGlobalDbContext gdb
     )
     : base(AspHelpers.MainNavigationPageKeys.Setup, db, current, logger)
 {
     Backgrounder = backgrounder;
     GDB          = gdb;
 }
Ejemplo n.º 7
0
 public EtlJobRunner(
     IOptions <EtlJobRunnerConfig> configOptions,
     Bal.Data.Rdb.TraffkTenantModel.TraffkTenantModelDbContext ttmDb,
     IOptions <BlobStorageServices.Config> blobConfig,
     IHttpClientFactory httpClientFactory,
     TraffkGlobalDbContext globalContext,
     IJobInfoFinder jobInfoFinder,
     ILogger logger)
     : base(globalContext, jobInfoFinder, logger)
 {
     ConfigOptions     = configOptions;
     HttpClientFactory = httpClientFactory;
     TtmDb             = ttmDb;
     BlobConfigOptions = blobConfig;
 }
Ejemplo n.º 8
0
 public DataSourceSyncRunner(
     IJobInfoFinder jobInfoFinder,
     IHttpClientFactory httpClientFactory,
     JobRunnerProgram jobRunnerProgram,
     TraffkGlobalDbContext gdb,
     Bal.Data.Rdb.TraffkTenantShards.TraffkTenantShardsDbContext tdb,
     IVault vault,
     IOptions <BlobStorageServices.Config> blobConfig,
     Serilog.ILogger logger)
     : base(gdb, jobInfoFinder, logger)
 {
     HttpClientFactory = httpClientFactory;
     BlobConfig        = blobConfig;
     Vault             = vault;
     TenantName        = tdb.TenantFindByTenantId(jobInfoFinder.JobInfo.TenantId.Value).Result.First().TenantName;
 }
Ejemplo n.º 9
0
        protected BaseJobRunner(
            TraffkGlobalDbContext globalContext,
            IJobInfoFinder jobInfoFinder,
            ILogger logger)
        {
            GlobalContext = globalContext;
            InstanceId    = Interlocked.Increment(ref InstanceId_s);
            JobInfo       = jobInfoFinder.JobInfo;

            Logger = logger.ForContext(new ILogEventEnricher[]
            {
                new PropertyEnricher(nameof(InstanceId), InstanceId),
                new PropertyEnricher(nameof(JobInfo.JobId), JobInfo?.JobId),
                new PropertyEnricher(typeof(Type).Name, GetType().Name),
            });

            Logger.Information(ConstructedText);
        }
Ejemplo n.º 10
0
 public TenantedJobRunner(
     TraffkTenantModelDbContext db,
     TraffkGlobalDbContext globalContext,
     IJobInfoFinder jobInfoFinder,
     CurrentTenantServices current,
     ITableauAdminService tableauAdminService,
     ILogger logger,
     ITableauVisualServices tableauVisualService,
     BlobStorageServices blobStorageService,
     IBackgroundJobClient innerBackgroundJobClient)
     : base(globalContext, jobInfoFinder, logger)
 {
     DB                       = db;
     Current                  = current;
     TableauAdminService      = tableauAdminService;
     TableauVisualService     = tableauVisualService;
     BlobStorageService       = blobStorageService;
     InnerBackgroundJobClient = innerBackgroundJobClient;
 }
Ejemplo n.º 11
0
 public TenantManagementJobsRunner(
     IJobInfoFinder jobInfoFinder,
     TraffkGlobalDbContext gdb,
     Serilog.ILogger logger,
     TraffkTenantShardsDbContext tdb,
     TraffkTenantShardManagerDbContext smdb,
     IPasswordHasher <ApplicationUser> passwordHasher,
     ServiceClientCredentialFactory credentialFactory,
     IOptions <Config> configOptions,
     DbContextOptions <TraffkTenantModelDbContext> rdbOptions)
     : base(gdb, jobInfoFinder, logger)
 {
     CredentialFactory = credentialFactory;
     ConfigOptions     = configOptions;
     RdbOptions        = rdbOptions;
     Smdb           = smdb;
     Tdb            = tdb;
     PasswordHasher = passwordHasher;
 }