public LibreOfficeUnoConversion(JobsHostConfiguration config) { //Needed by UNO SDK5. //http://stackoverflow.com/questions/31856025/bootstrap-uno-api-libreoffice-exception //look at comments of funbit. We need to set UNO_PATH and soffice should be in the PATH //of the system. var sofficePath = config.GetPathToLibreOffice(); var unoPath = Path.GetDirectoryName(sofficePath); Environment.SetEnvironmentVariable("UNO_PATH", unoPath, EnvironmentVariableTarget.Process); Environment.SetEnvironmentVariable("PATH", Environment.GetEnvironmentVariable("PATH") + @";" + unoPath, EnvironmentVariableTarget.Process); _config = config; Logger = NullLogger.Instance; }
public Boolean Start(JobsHostConfiguration config) { Console.WriteLine("Starting"); _config = config; BuildContainer(config); var allPollers = _container.ResolveAll <IPollerJob>(); if (allPollers.Length == 0) { _logger.Error("No poller configured, jobs assembly does not contains class that inherits from AbstractOutOfProcessPollerJob or the name of assemblies does not contains Jobs in the name."); } foreach (var poller in allPollers) { _logger.InfoFormat("Poller: {0} - IsOutOfProcess {1} - IsActive {2} - Type {3}", poller.QueueName, poller.IsOutOfProcess, poller.IsActive, poller.GetType().Name); } var testResult = ExecuteTests(); if (!testResult) { _logger.Error("Execution of Initial test failed, cannot start"); return(false); } var queuePoller = allPollers.SingleOrDefault(p => p.IsOutOfProcess && p.QueueName.Equals(_queueName, StringComparison.OrdinalIgnoreCase) && p.IsActive); if (queuePoller == null) { _logger.ErrorFormat("No configured poller for queue {0}", _queueName); return(false); } else { _logger.InfoFormat("Start poller for queue {0} implemented by {1}", _queueName, queuePoller.GetType().Name); queuePoller.Start(new List <String>() { _serverAddress.AbsoluteUri }, _handle); } return(true); }
public TikaAnalyzer(JobsHostConfiguration jobsHostConfiguration) { JobsHostConfiguration = jobsHostConfiguration; var tikaHome = JobsHostConfiguration.GetConfigValue("TIKA_HOME"); if (!File.Exists(tikaHome)) { throw new Exception(string.Format("Tika not found on {0}", tikaHome)); } var tikaLocation = Path.GetDirectoryName(tikaHome); var allTikaFiles = Directory.GetFiles(tikaLocation, "tika*.jar"); tikaPaths = new List<string>(); tikaPaths.Add(tikaHome); foreach (var tikaFile in allTikaFiles) { if (File.Exists(tikaFile) && !(tikaFile == tikaHome)) { tikaPaths.Add(tikaFile); } } }
private void BuildContainer(JobsHostConfiguration config) { _container = new WindsorContainer(); ContainerAccessor.Instance = _container; _container.Register(Component.For <JobsHostConfiguration>().Instance(config)); _container.Kernel.Resolver.AddSubResolver(new CollectionResolver(_container.Kernel, true)); _container.Kernel.Resolver.AddSubResolver(new ArrayResolver(_container.Kernel, true)); _container.AddFacility <LoggingFacility>(config.CreateLoggingFacility); _container.AddFacility <StartableFacility>(); _container.AddFacility <TypedFactoryFacility>(); _container.Register( Component.For <IClientPasswordSet>() .ImplementedBy <EnvironmentVariableClientPasswordSet>(), //Register from this application Classes.FromAssemblyInThisApplication() .BasedOn <IPollerJob>() .WithServiceFirstInterface(), Classes.FromAssemblyInThisApplication() .BasedOn <IPollerTest>() .WithServiceFirstInterface(), //Rgister from dll that contains Jobs in name. Classes.FromAssemblyInDirectory(new AssemblyFilter(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.Jobs.*.*")) .BasedOn <IPollerJob>() .WithServiceFirstInterface(), Classes.FromAssemblyInDirectory(new AssemblyFilter(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.Jobs.*.*")) .BasedOn <IPollerTest>() .WithServiceFirstInterface() ); _container.Install( FromAssembly.InDirectory( new AssemblyFilter(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.Jobs.*.*"))); _logger = _container.Resolve <ILogger>(); }
public Boolean Start(JobsHostConfiguration config) { Console.WriteLine("Starting"); _config = config; BuildContainer(config); var allPollers = _container.ResolveAll<IPollerJob>(); if (allPollers.Length == 0) { _logger.Error("No poller configured, jobs assembly does not contains class that inherits from AbstractOutOfProcessPollerJob or the name of assemblies does not contains Jobs in the name."); } foreach (var poller in allPollers) { _logger.InfoFormat("Poller: {0} - IsOutOfProcess {1} - IsActive {2} - Type {3}", poller.QueueName, poller.IsOutOfProcess, poller.IsActive, poller.GetType().Name); } var testResult = ExecuteTests(); if (!testResult) return false; var queuePoller = allPollers.SingleOrDefault(p => p.IsOutOfProcess && p.QueueName.Equals(_queueName, StringComparison.OrdinalIgnoreCase) && p.IsActive); if (queuePoller == null) { _logger.ErrorFormat("No configured poller for queue {0}", _queueName); return false; } else { _logger.InfoFormat("Start poller for queue {0} implemented by {1}", _queueName, queuePoller.GetType().Name); queuePoller.Start(new List<String>() { _serverAddress.AbsoluteUri}, _handle); } return true; }
public void TestFixtureSetUp() { _config = new JobsHostConfiguration(); }
public HtmlToPdfConverterFromDiskFile(String inputFileName, JobsHostConfiguration config) { _inputFileName = inputFileName; _config = config; }
public LibreOfficeConversion(JobsHostConfiguration config) { _config = config; }
void BuildContainer(JobsHostConfiguration config) { _container = new WindsorContainer(); ContainerAccessor.Instance = _container; _container.Register(Component.For<JobsHostConfiguration>().Instance(config)); _container.Kernel.Resolver.AddSubResolver(new CollectionResolver(_container.Kernel, true)); _container.Kernel.Resolver.AddSubResolver(new ArrayResolver(_container.Kernel, true)); _container.AddFacility<LoggingFacility>(config.CreateLoggingFacility); _container.AddFacility<StartableFacility>(); _container.AddFacility<TypedFactoryFacility>(); _container.Register( Component.For<IClientPasswordSet>() .ImplementedBy<EnvironmentVariableClientPasswordSet>(), //Register from this application Classes.FromAssemblyInThisApplication() .BasedOn<IPollerJob>() .WithServiceFirstInterface() , Classes.FromAssemblyInThisApplication() .BasedOn<IPollerTest>() .WithServiceFirstInterface() , //Rgister from dll that contains Jobs in name. Classes.FromAssemblyInDirectory(new AssemblyFilter(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.Jobs.*.*")) .BasedOn<IPollerJob>() .WithServiceFirstInterface(), Classes.FromAssemblyInDirectory(new AssemblyFilter(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.Jobs.*.*")) .BasedOn<IPollerTest>() .WithServiceFirstInterface() ); _container.Install( FromAssembly.InDirectory( new AssemblyFilter(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "*.Jobs.*.*"))); _logger = _container.Resolve<ILogger>(); }
static void LoadConfiguration() { _jobsHostConfiguration = new JobsHostConfiguration(); }