public void ExecuteNonQuery <CONNECTION_TYPE, COMMAND_TYPE, ADAPTER_TYPE>(string connectionString, string commandText, string commandStyle) where CONNECTION_TYPE : DbConnection, new() where COMMAND_TYPE : DbCommand where ADAPTER_TYPE : DbDataAdapter, new() { try { if (new EncryptionFeatureToggle().FeatureEnabled) { connectionString = AESGCM.SimpleDecrypt(connectionString, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Warn("ConfigurationError executing SqlJob job.", ex); } using (var dbControl = new DbControl <CONNECTION_TYPE, COMMAND_TYPE, ADAPTER_TYPE>(connectionString)) { DbCommand command = (null != commandStyle && commandStyle.ToLower() == "storedprocedure") ? dbControl.GetStoredProcedureCommand(commandText) : dbControl.GetSqlStringCommand(commandText); try { dbControl.ExecuteNonQuery(command); } catch (Exception ex) { Logger.Error(string.Format("Error in SqlJob ({0}): ", _jobName), ex); throw new JobExecutionException(ex.Message, ex, false); } } }
public Contracts.JobTypes.Sql.Model.SqlJob Get(Guid id) { Logger.Debug("Entered SqlJobsController.Get()."); var authorizedJobGroups = _permissionsHelper.GetAuthorizedJobGroups().ToList(); IJobDetail jobDetail; try { jobDetail = _schedulerCore.GetJobDetail(id); } catch (Exception ex) { Logger.Info(string.Format("Error getting JobDetail: {0}", ex.Message)); return(null); } if (jobDetail != null && (authorizedJobGroups.Contains(jobDetail.Key.Group) || authorizedJobGroups.Contains("*"))) { var connectionString = jobDetail.JobDataMap.GetString("connectionString"); try { if (new EncryptionFeatureToggle().FeatureEnabled) { connectionString = AESGCM.SimpleDecrypt(connectionString, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Warn("ConfigurationError getting SqlJob job.", ex); } return(new Contracts.JobTypes.Sql.Model.SqlJob { Id = id, JobName = jobDetail.Key.Name, JobGroup = jobDetail.Key.Group, SchedulerName = _schedulerCore.SchedulerName, ConnectionString = connectionString, CommandClass = jobDetail.JobDataMap.GetString("commandClass"), ConnectionClass = jobDetail.JobDataMap.GetString("connectionClass"), CommandStyle = jobDetail.JobDataMap.GetString("commandStyle"), ProviderAssemblyName = jobDetail.JobDataMap.GetString("providerAssemblyName"), NonQueryCommand = jobDetail.JobDataMap.GetString("nonQueryCommand"), DataAdapterClass = jobDetail.JobDataMap.GetString("dataAdapterClass"), Description = jobDetail.Description }); } if (jobDetail == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } throw new HttpResponseException(HttpStatusCode.Unauthorized); }
public void Execute(IJobExecutionContext context) { JobDataMap data = context.MergedJobDataMap; var jobName = context.JobDetail.Key.Name; string ftpHost = GetRequiredParameter(data, FtpHost, jobName); string serverPort = GetOptionalParameter(data, ServerPort); string userName = GetOptionalParameter(data, UserName); string password = GetOptionalParameter(data, Password); string localDirectoryPath = GetRequiredParameter(data, LocalDirectoryPath, jobName); string remoteDirectoryPath = GetOptionalParameter(data, RemoteDirectoryPath); string cutOff = GetOptionalParameter(data, CutOff); string fileExtensions = GetRequiredParameter(data, FileExtensions, jobName); // Set defaults int port = (!string.IsNullOrEmpty(serverPort) ? Int32.Parse(serverPort) : 21); cutOff = (!string.IsNullOrEmpty(cutOff) ? cutOff : "1.00:00:00"); // 1 day // Validate cutOffTimeSpan format TimeSpan cutOffTimeSpan; if (!TimeSpan.TryParse(cutOff, out cutOffTimeSpan)) { var err = string.Format("Invalid cutOffTimeSpan format [{0}] specified.", cutOff); Logger.ErrorFormat("Error in FtpDownloadJob ({0}): {1}", jobName, err); throw new JobExecutionException(err); } try { if (new EncryptionFeatureToggle().FeatureEnabled) { userName = AESGCM.SimpleDecrypt(userName, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); password = AESGCM.SimpleDecrypt(password, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Warn("ConfigurationError executing FtpDownloadJob job.", ex); } // Get files try { using (var ftpLibrary = ObjectFactory.GetInstance <IFtpLibrary>()) { ftpLibrary.Connect(ftpHost, port, userName, password); ftpLibrary.GetFiles(remoteDirectoryPath, localDirectoryPath, fileExtensions, cutOffTimeSpan); } } catch (Exception ex) { Logger.Error(string.Format("Error in FtpDownloadJob ({0}):", jobName), ex); throw new JobExecutionException(ex.Message, ex, false); } }
public Contracts.JobTypes.Ftp.Model.FtpDownloadJob Get(Guid id) { Logger.Debug("Entered FtpJobsController.Get()."); IJobDetail jobDetail; try { jobDetail = _schedulerCore.GetJobDetail(id); } catch (Exception ex) { Logger.WarnFormat("Error getting JobDetail: {0}", ex.Message); return(null); } string username = jobDetail.JobDataMap.GetString("userName"); string password = jobDetail.JobDataMap.GetString("password"); try { if (new EncryptionFeatureToggle().FeatureEnabled) { username = AESGCM.SimpleDecrypt(username, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); password = AESGCM.SimpleDecrypt(password, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Warn("ConfigurationError getting FtpDownload job.", ex); } return(new Contracts.JobTypes.Ftp.Model.FtpDownloadJob { Id = id, JobName = jobDetail.Key.Name, JobGroup = jobDetail.Key.Group, SchedulerName = _schedulerCore.SchedulerName, FtpHost = jobDetail.JobDataMap.GetString("ftpHost"), ServerPort = jobDetail.JobDataMap.GetString("serverPort"), Username = username, Password = password, LocalDirectoryPath = jobDetail.JobDataMap.GetString("localDirectoryPath"), RemoteDirectoryPath = jobDetail.JobDataMap.GetString("remoteDirectoryPath"), FileExtensions = jobDetail.JobDataMap.GetString("fileExtensions"), CutOffTimeSpan = jobDetail.JobDataMap.GetString("cutOffTimeSpan"), Description = jobDetail.Description }); }
private void decrypt(ref ClientConfiguration configuration) { var clientKey = configuration.ClientKeys.First(); var key256 = new byte[32]; var nonSecretOrg = Encoding.UTF8.GetBytes(clientKey.Key); for (int i = 0; i < 32; i++) { key256[i] = Convert.ToByte(i % 256); } configuration.Server = AESGCM.SimpleDecrypt(configuration.Server, key256, nonSecretOrg.Length); configuration.EmailUserName = AESGCM.SimpleDecrypt(configuration.EmailUserName, key256, nonSecretOrg.Length); configuration.EmailPassword = AESGCM.SimpleDecrypt(configuration.EmailPassword, key256, nonSecretOrg.Length); }
public Contracts.JobTypes.Sql.Model.SqlJob Get(Guid id) { Logger.Debug("Entered SqlJobsController.Get()."); IJobDetail jobDetail; try { jobDetail = _schedulerCore.GetJobDetail(id); } catch (Exception ex) { Logger.Info(string.Format("Error getting JobDetail: {0}", ex.Message)); return(null); } string connectionString = jobDetail.JobDataMap.GetString("connectionString"); try { if (new EncryptionFeatureToggle().FeatureEnabled) { connectionString = AESGCM.SimpleDecrypt(connectionString, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Warn("ConfigurationError getting SqlJob job.", ex); } return(new Contracts.JobTypes.Sql.Model.SqlJob { Id = id, JobName = jobDetail.Key.Name, JobGroup = jobDetail.Key.Group, SchedulerName = _schedulerCore.SchedulerName, ConnectionString = connectionString, CommandClass = jobDetail.JobDataMap.GetString("commandClass"), ConnectionClass = jobDetail.JobDataMap.GetString("connectionClass"), CommandStyle = jobDetail.JobDataMap.GetString("commandStyle"), ProviderAssemblyName = jobDetail.JobDataMap.GetString("providerAssemblyName"), NonQueryCommand = jobDetail.JobDataMap.GetString("nonQueryCommand"), DataAdapterClass = jobDetail.JobDataMap.GetString("dataAdapterClass"), Description = jobDetail.Description }); }
public IEnumerable <Contracts.JobTypes.Sql.Model.SqlJob> Get() { Logger.Debug("Entered SqlJobsController.Get()."); var authorizedJobGroups = _permissionsHelper.GetAuthorizedJobGroups(); var jobDetailsMap = _schedulerCore.GetJobDetails(authorizedJobGroups, typeof(SqlJob)); var retval = new List <Contracts.JobTypes.Sql.Model.SqlJob>(); foreach (var mapItem in jobDetailsMap) { string connectionString = mapItem.Key.JobDataMap.GetString("connectionString"); try { if (new EncryptionFeatureToggle().FeatureEnabled) { connectionString = AESGCM.SimpleDecrypt(connectionString, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } catch (Exception ex) { Logger.Warn("ConfigurationError getting SqlJob jobs.", ex); } retval.Add(new Contracts.JobTypes.Sql.Model.SqlJob { Id = mapItem.Value, JobName = mapItem.Key.Key.Name, JobGroup = mapItem.Key.Key.Group, SchedulerName = _schedulerCore.SchedulerName, ConnectionString = connectionString, CommandClass = mapItem.Key.JobDataMap.GetString("commandClass"), ConnectionClass = mapItem.Key.JobDataMap.GetString("connectionClass"), CommandStyle = mapItem.Key.JobDataMap.GetString("commandStyle"), ProviderAssemblyName = mapItem.Key.JobDataMap.GetString("providerAssemblyName"), NonQueryCommand = mapItem.Key.JobDataMap.GetString("nonQueryCommand"), DataAdapterClass = mapItem.Key.JobDataMap.GetString("dataAdapterClass") }); } return(retval); }
public Contracts.JobTypes.Ftp.Model.FtpDownloadJob Get(Guid id) { Logger.Debug("Entered FtpJobsController.Get()."); var authorizedJobGroups = _permissionsHelper.GetAuthorizedJobGroups().ToList(); IJobDetail jobDetail; try { jobDetail = _schedulerCore.GetJobDetail(id); } catch (Exception ex) { Logger.WarnFormat("Error getting JobDetail: {0}", ex.Message); return(null); } if (jobDetail != null && (authorizedJobGroups.Contains(jobDetail.Key.Group) || authorizedJobGroups.Contains("*"))) { string username = jobDetail.JobDataMap.GetString("userName"); string password = jobDetail.JobDataMap.GetString("password"); string sshPrivateKeyPassword = jobDetail.JobDataMap.GetString("sshPrivateKeyPassword"); try { if (new EncryptionFeatureToggle().FeatureEnabled) { username = AESGCM.SimpleDecrypt(username, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); if (!string.IsNullOrEmpty(password)) { password = AESGCM.SimpleDecrypt(password, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } if (!string.IsNullOrEmpty(sshPrivateKeyPassword)) { sshPrivateKeyPassword = AESGCM.SimpleDecrypt(sshPrivateKeyPassword, Convert.FromBase64String(ConfigurationManager.AppSettings["SchedulerEncryptionKey"])); } } } catch (Exception ex) { Logger.Warn("ConfigurationError getting FtpDownload job.", ex); } return(new Contracts.JobTypes.Ftp.Model.FtpDownloadJob { Id = id, JobName = jobDetail.Key.Name, JobGroup = jobDetail.Key.Group, SchedulerName = _schedulerCore.SchedulerName, FtpHost = jobDetail.JobDataMap.GetString("ftpHost"), ServerPort = jobDetail.JobDataMap.GetString("serverPort"), Username = username, Password = password, LocalDirectoryPath = jobDetail.JobDataMap.GetString("localDirectoryPath"), RemoteDirectoryPath = jobDetail.JobDataMap.GetString("remoteDirectoryPath"), FileExtensions = jobDetail.JobDataMap.GetString("fileExtensions"), CutOffTimeSpan = jobDetail.JobDataMap.GetString("cutOffTimeSpan"), Description = jobDetail.Description, SshPrivateKeyPath = jobDetail.JobDataMap.GetString("sshPrivateKeyPath"), SshPrivateKeyPassword = sshPrivateKeyPassword }); } if (jobDetail == null) { throw new HttpResponseException(HttpStatusCode.NotFound); } throw new HttpResponseException(HttpStatusCode.Unauthorized); }