Exemple #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());
        }
Exemple #2
0
        public void DownloadZipCodes()
        {
            var ds = new Traffk.Bal.Data.Rdb.TraffkGlobal.DataSource
            {
                TenantId           = 3,
                DataSourceSettings = new Traffk.Bal.Settings.DataSourceSettings
                {
                    Web = new Traffk.Bal.Settings.DataSourceSettings.WebSettings
                    {
                        CredentialsKeyUri = Traffk.Bal.Services.Vault.CommonSecretUris.ZipCodesComCredentialsUri,
                        LoginPageConfig   = new Traffk.Bal.Settings.DataSourceSettings.WebSettings.WebLoginPageConfig
                        {
                            LoginPage         = new Uri("https://www.zip-codes.com/account_login.asp"),
                            UsernameFieldName = "loginUsername",
                            PasswordFieldName = "loginPassword"
                        },
                        DownloadUrls = new[]
                        {
                            new Uri("https://www.zip-codes.com/account_database.asp?type=csv&product=25"), //CSV Delux DB
                            new Uri("https://www.zip-codes.com/account_database.asp?type=csv&product=38"), //CSV Delux DB with Business
                            new Uri("https://www.zip-codes.com/account_database.asp?type=cs&product=89"),  //CSV Zip9
                        }
                    }
                }
            };

            GDB.DataSources.Add(ds);
            GDB.SaveChanges();
            Backgrounder.Enqueue <IDataSourceSyncJobs>(z => z.DataSourceFetchAsync(ds.DataSourceId));
            //            RJM.Add(Hangfire.Common.Job.FromExpression<IDataSourceSyncJobs>(z => z.DataSourceFetchAsync(ds.DataSourceId)), Cron.Daily());
        }
Exemple #3
0
        public async Task <IActionResult> DataSourceCreate(DataSource dataSource)
        {
            var tenant = await Current.GetTenantAsync();

            dataSource.TenantId = tenant.TenantId;
            GDB.DataSources.Add(dataSource);
            await GDB.SaveChangesAsync();

            SetToast(AspHelpers.ToastMessages.Saved);

            return(RedirectToAction("Index"));
        }