private QueryResponse CreateJob(Contracts.JobTypes.Ftp.Model.FtpDownloadJob model) { string username = model.Username; string password = model.Password; try { if (new EncryptionFeatureToggle().FeatureEnabled) { username = AESGCM.SimpleEncrypt(username, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); password = AESGCM.SimpleEncrypt(password, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Error("ConfigurationError creating FtpDownload job.", ex); } var dataMap = new Dictionary <string, object> { { "ftpHost", model.FtpHost }, { "serverPort", model.ServerPort }, { "userName", username }, { "password", password }, { "localDirectoryPath", model.LocalDirectoryPath }, { "remoteDirectoryPath", model.RemoteDirectoryPath }, { "fileExtensions", model.FileExtensions }, { "cutOffTimeSpan", model.CutOffTimeSpan } }; return(base.CreateJob(model, typeof(FtpDownloadJob), dataMap, model.Description)); }
private QueryResponse CreateJob(Contracts.JobTypes.Sql.Model.SqlJob model) { var connectionString = model.ConnectionString; try { if (new EncryptionFeatureToggle().FeatureEnabled) { connectionString = AESGCM.SimpleEncrypt(connectionString, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Error("ConfigurationError creating SqlJob job.", ex); } var dataMap = new Dictionary <string, object> { { "connectionString", connectionString }, { "commandClass", model.CommandClass }, { "connectionClass", model.ConnectionClass }, { "commandStyle", model.CommandStyle }, { "providerAssemblyName", model.ProviderAssemblyName }, { "nonQueryCommand", model.NonQueryCommand }, { "dataAdapterClass", model.DataAdapterClass } }; return(base.CreateJob(model, typeof(SqlJob), dataMap, model.Description)); }
public void TestExecuteMethodInvokesConnectAndGetFilesMethods() { // Arrange SchedulerContainer.Container = new Container(); SchedulerContainer.Container.Configure(config => { config.For <IFtpLibrary>().Use(_mockFtpLibrary.Object); }); var ftpJob = new FtpDownloadJob(); var plainTextUserName = "******"; var plainTextPassword = "******"; var host = "ftp://testhost.com"; var localDirectoryPath = "C:/"; var fileExtensions = ".txt"; var userName = AESGCM.SimpleEncrypt(plainTextUserName, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); var password = AESGCM.SimpleEncrypt(plainTextPassword, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); IJobDetail jobDetail = new JobDetailImpl("TestFtpDownloadJob1", typeof(IJob)); jobDetail.JobDataMap.Add("ftpHost", host); jobDetail.JobDataMap.Add("localDirectoryPath", localDirectoryPath); jobDetail.JobDataMap.Add("fileExtensions", fileExtensions); jobDetail.JobDataMap.Add("userName", userName); jobDetail.JobDataMap.Add("password", password); _mockJobExecutionContext.SetupGet(p => p.MergedJobDataMap).Returns(jobDetail.JobDataMap); _mockJobExecutionContext.SetupGet(p => p.JobDetail).Returns(jobDetail); // Act ftpJob.Execute(_mockJobExecutionContext.Object); // Assert _mockFtpLibrary.Verify(i => i.Connect(host, 21, plainTextUserName, plainTextPassword, null, null), Times.Once); _mockFtpLibrary.Verify(i => i.GetFiles(It.IsAny <string>(), localDirectoryPath, fileExtensions, It.IsAny <TimeSpan>()), Times.Once); }