コード例 #1
0
        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;
        }
コード例 #2
0
        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);
                }
            }
        }
コード例 #3
0
 public HtmlToPdfConverterFromDiskFile(String inputFileName, JobsHostConfiguration config)
 {
     _inputFileName = inputFileName;
     _config        = config;
 }
コード例 #4
0
        private void ExecuteJobCore()
        {
            do
            {
                //if half of the task thread finished working, we should end all the pool and restart
                if (ThreadNumber > 2 && _numOfPollerTaskActive < (ThreadNumber / 2))
                {
                    //This can happen because jobs are generated not in block, if we have ex 6 threads
                    //base jobs started 6 tasks, then if in a moment only one task remain only one task remain active
                    //then if the queue manager queue 100 jobs, we have only one thread active. This condition
                    //stops the poll if half of the threads are active, so we need to restart polling with all the tasks.
                    return;
                }
                String       workingFolder = null;
                QueuedJobDto nextJob       = DsGetNextJob();
                if (nextJob == null)
                {
                    System.Threading.Interlocked.Decrement(ref _numOfPollerTaskActive);
                    return;
                }
                Logger.ThreadProperties["job-id"] = nextJob.Id;
                var baseParameters = ExtractJobParameters(nextJob);
                //remember to enter the right tenant.
                workingFolder = Path.Combine(
                    JobsHostConfiguration.GetWorkingFolder(baseParameters.TenantId, GetType().Name),
                    baseParameters.JobId
                    );
                if (Directory.Exists(workingFolder))
                {
                    Directory.Delete(workingFolder, true);
                }

                Directory.CreateDirectory(workingFolder);
                try
                {
                    var task   = OnPolling(baseParameters, workingFolder);
                    var result = task.Result;
                    if (result.Result)
                    {
                        Logger.DebugFormat("Successfully executed Job: {0}", nextJob.Id);
                    }
                    else
                    {
                        Logger.ErrorFormat("Job {0} completed with errors: {1} with result", nextJob.Id, result.ErrorMessage);
                    }

                    //The execution if failed can be posticipated to future time, probably because the job can retry after a certain
                    //period of time.
                    if (!result.Posticipate)
                    {
                        DsSetJobExecuted(QueueName, nextJob.Id, result.ErrorMessage, result.ParametersToModify);
                    }
                    else
                    {
                        DsReQueueJob(QueueName, nextJob.Id, result.ErrorMessage, result.PosticipateExecutionTimestamp, result.ParametersToModify);
                    }
                }
                catch (AggregateException aex)
                {
                    Logger.ErrorFormat(aex, "Error executing queued job {0} on tenant {1} - {2}",
                                       nextJob.Id,
                                       nextJob.Parameters[JobKeys.TenantId],
                                       aex?.InnerExceptions?[0]?.Message);
                    StringBuilder aggregateMessage = new StringBuilder();
                    aggregateMessage.Append(aex.Message);
                    foreach (var ex in aex.InnerExceptions)
                    {
                        var errorMessage = String.Format("Inner error queued job {0} queue {1}: {2}", nextJob.Id, this.QueueName, ex.Message);
                        LogExceptionAndAllInnerExceptions(ex, errorMessage);
                        aggregateMessage.Append(errorMessage);
                    }
                    DsSetJobExecuted(QueueName, nextJob.Id, aggregateMessage.ToString(), null);
                }
                catch (Exception ex)
                {
                    var errorMessage = String.Format("Error executing queued job {0} on tenant {1}", nextJob.Id, nextJob.Parameters[JobKeys.TenantId]);
                    LogExceptionAndAllInnerExceptions(ex, errorMessage);
                    DsSetJobExecuted(QueueName, nextJob.Id, ex.Message, null);
                }
                finally
                {
                    DeleteWorkingFolder(workingFolder);
                    Logger.ThreadProperties["job-id"] = null;
                }
            } while (true); //Exit is in the internal loop
        }
コード例 #5
0
 public LibreOfficeConversion(JobsHostConfiguration config)
 {
     _config = config;
 }
コード例 #6
0
 private static void LoadConfiguration()
 {
     _jobsHostConfiguration = new JobsHostConfiguration();
 }
 public void TestFixtureSetUp()
 {
     _config = new JobsHostConfiguration();
 }
コード例 #8
0
 public void OneTimeSetUp()
 {
     _config = new JobsHostConfiguration();
 }