Пример #1
0
        private void AddPluginContributions(IBioLinkPlugin plugin)
        {
            Logger.Debug("Looking for workspace contributions from {0}", plugin.Name);
            List <IWorkspaceContribution> contributions = plugin.GetContributions();

            try {
                foreach (IWorkspaceContribution contrib in contributions)
                {
                    if (contrib is MenuWorkspaceContribution)
                    {
                        AddMenu(contrib as MenuWorkspaceContribution);
                    }
                    else if (contrib is IExplorerWorkspaceContribution)
                    {
                        IExplorerWorkspaceContribution explorer = contrib as IExplorerWorkspaceContribution;
                        DockableContent newContent = new DockableContent();
                        newContent.Title   = explorer.Title;
                        newContent.Content = explorer.Content;
                        newContent.Name    = plugin.Name + "_" + explorer.Name;

                        this.explorersPane.Items.Add(newContent);

                        JobExecutor.QueueJob(() => {
                            explorer.InitializeContent();
                        });
                    }
                }
            } finally {
            }
        }
Пример #2
0
        private void RunLongJob()
        {
            var startTime = ConsoleEx.ReadLine("Start Time (UTC)", DateTime.UtcNow - TimeSpan.FromMinutes(1));
            var jobId     = ConsoleEx.ReadLine("JobId", "longJob001");

            var storageConnectionstring = Config.Root[Config.NAH_EHLISTENER_STORAGECONNECTIONSTRING];

            var syncProvider  = new BlobSynchronizationProvider(storageConnectionstring); // Responsible for Singleton Implementation
            var stateProvider = new BlobJobStateProvider(storageConnectionstring);        // Responsible for state
            var jobExecutor   = new JobExecutor(syncProvider, stateProvider);
            var every5Seconds = new EveryMinuteOnTheMinuteSchedule();

            while (true)
            {
                jobExecutor.RunAsSingletonAsync(jobId, every5Seconds, (dt) =>
                {
                    Console.WriteLine($"Start 15s Job for Time {dt}");
                    Thread.Sleep(TimeSpan.FromSeconds(15));
                    Console.WriteLine("Job done!");

                    return(Task.CompletedTask);
                }, startTime).Wait();

                Console.Write(".");

                Thread.Sleep(1000);

                if (EscPressed())
                {
                    break;
                }
            }
        }
Пример #3
0
        public virtual void testDeleteJobThatWasAlreadyAcquired()
        {
            ClockUtil.CurrentTime = DateTime.Now;

            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("timerOnTask");
            Job             timerJob        = managementService.createJobQuery().processInstanceId(processInstance.Id).singleResult();

            // We need to move time at least one hour to make the timer executable
            ClockUtil.CurrentTime = new DateTime(ClockUtil.CurrentTime.Ticks + 7200000L);

            // Acquire job by running the acquire command manually
            ProcessEngineImpl processEngineImpl = (ProcessEngineImpl)processEngine;
            JobExecutor       jobExecutor       = processEngineImpl.ProcessEngineConfiguration.JobExecutor;
            AcquireJobsCmd    acquireJobsCmd    = new AcquireJobsCmd(jobExecutor);
            CommandExecutor   commandExecutor   = processEngineImpl.ProcessEngineConfiguration.CommandExecutorTxRequired;

            commandExecutor.execute(acquireJobsCmd);

            // Try to delete the job. This should fail.
            try
            {
                managementService.deleteJob(timerJob.Id);
                fail();
            }
            catch (ProcessEngineException)
            {
                // Exception is expected
            }

            // Clean up
            managementService.executeJob(timerJob.Id);
        }
Пример #4
0
        public virtual void testJobCommandsWithMessage()
        {
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;
            JobExecutor     jobExecutor     = processEngineConfiguration.JobExecutor;
            string          jobId           = commandExecutor.execute(new CommandAnonymousInnerClass(this));

            AcquiredJobs            acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(jobExecutor));
            IList <IList <string> > jobIdsList   = acquiredJobs.JobIdBatches;

            assertEquals(1, jobIdsList.Count);

            IList <string> jobIds = jobIdsList[0];

            IList <string> expectedJobIds = new List <string>();

            expectedJobIds.Add(jobId);

            assertEquals(expectedJobIds, new List <string>(jobIds));
            assertEquals(0, tweetHandler.Messages.Count);

            ExecuteJobHelper.executeJob(jobId, commandExecutor);

            assertEquals("i'm coding a test", tweetHandler.Messages[0]);
            assertEquals(1, tweetHandler.Messages.Count);

            clearDatabase();
        }
        private void DoConvert()
        {
            JobExecutor.QueueJob(() => {
                try {
                    this.InvokeIfRequired(() => {
                        btnCancel.IsEnabled  = false;
                        btnConvert.IsEnabled = false;
                    });

                    this.InvokeIfRequired(() => {
                        totalProgressBar.Maximum = _jobList.Count;
                        totalProgressBar.Value   = 0;
                    });

                    foreach (GazetteerConversionTarget job in _jobList)
                    {
                        job.IsCurrent = true;
                        ConvertFile(job);
                        this.InvokeIfRequired(() => {
                            totalProgressBar.Value++;
                        });
                        job.IsComplete = true;
                        job.IsCurrent  = false;
                    }
                } finally {
                    this.InvokeIfRequired(() => {
                        btnCancel.IsEnabled  = true;
                        btnConvert.IsEnabled = true;
                    });
                }
            });
        }
Пример #6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @OperateOnDeployment("pa1") @Test public void testDeploymentUnawareJobAcquisition()
        public virtual void testDeploymentUnawareJobAcquisition()
        {
            JobExecutor defaultJobExecutor = processEngineConfiguration.JobExecutor;

            ProcessInstance instance1 = engine1.RuntimeService.startProcessInstanceByKey("archive1Process");
            ProcessInstance instance2 = processEngine.RuntimeService.startProcessInstanceByKey("archive2Process");

            Job job1 = managementService.createJobQuery().processInstanceId(instance1.Id).singleResult();
            Job job2 = managementService.createJobQuery().processInstanceId(instance2.Id).singleResult();

            // the deployment unaware configuration should return both jobs
            CommandExecutor commandExecutor = processEngineConfiguration.CommandExecutorTxRequired;

            processEngineConfiguration.JobExecutorDeploymentAware = false;
            try
            {
                AcquiredJobs acquiredJobs = commandExecutor.execute(new AcquireJobsCmd(defaultJobExecutor));

                Assert.assertEquals(2, acquiredJobs.size());
                Assert.assertTrue(acquiredJobs.contains(job1.Id));
                Assert.assertTrue(acquiredJobs.contains(job2.Id));
            }
            finally
            {
                processEngineConfiguration.JobExecutorDeploymentAware = true;
            }
        }
Пример #7
0
        static void Main(string[] args)
        {
            ChannelServices.RegisterChannel(new TcpChannel(), false);
            GridJobController controller = (GridJobController)Activator.GetObject(typeof(GridJobController), "tcp://localhost:3000/Grid");

            if (controller == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }


            JobExecutor exe = new JobExecutor();

            for (int i = 0; i < 100; i++)
            {
                var job = controller.GetJob();
                if (job == null)
                {
                    break;
                }
                Console.WriteLine($"Берем работу: " + i);
                //System.Threading.Thread.Sleep(500);
                controller.SetResult(job, exe.Execute(job));
            }

            Console.WriteLine("END");
            Console.ReadKey();
        }
Пример #8
0
        protected internal virtual void HintJobExecutor(JobEntity job)
        {
            JobExecutor jobExecutor = context.Impl.Context.ProcessEngineConfiguration.JobExecutor;

            if (!jobExecutor.IsActive)
            {
                return;
            }

            JobExecutorContext   jobExecutorContext  = context.Impl.Context.JobExecutorContext;
            ITransactionListener transactionListener = null;

            if (!job.Suspended && job.Exclusive && jobExecutorContext != null && jobExecutorContext.ExecutingExclusiveJob && AreInSameProcessInstance(job, jobExecutorContext.CurrentJob))
            {
                // lock job & add to the queue of the current processor
                DateTime currentTime = ClockUtil.CurrentTime;
                job.LockExpirationTime = new DateTime(currentTime.Ticks + jobExecutor.LockTimeInMillis);
                job.LockOwner          = jobExecutor.LockOwner;
                transactionListener    = new ExclusiveJobAddedNotification(job.Id, jobExecutorContext);
            }
            else
            {
                // notify job executor:
                transactionListener = new MessageAddedNotification(jobExecutor);
            }
            context.Impl.Context.CommandContext.TransactionContext.AddTransactionListener(TransactionJavaStatus.Committed, transactionListener);
        }
        private void StartExport()
        {
            _isCancelled = false;

            // save the file off in prefs for later...
            Config.SetUser(User, "XMLIOExport.LastExportFile", txtFilename.Text);

            if (string.IsNullOrEmpty(txtFilename.Text))
            {
                ErrorMessage.Show("You must select a destination file before you can continue");
                return;
            }

            btnStart.IsEnabled  = false;
            btnCancel.IsEnabled = true;

            var options = new XMLIOExportOptions {
                Filename = this.Filename, ExportChildTaxa = this.ExportChildTaxa, ExportMaterial = this.ExportMaterial, ExportTraits = this.ExportNotes, ExportMultimedia = this.ExportMultimedia, ExportNotes = this.ExportNotes, IncludeFullClassification = this.IncludeFullClassification, KeepLogFile = this.KeepLogFile
            };

            var service = new XMLIOService(User);

            JobExecutor.QueueJob(() => {
                service.ExportXML(TaxonIDs, options, this, IsCancelled);
                this.InvokeIfRequired(() => {
                    btnStart.IsEnabled  = true;
                    btnCancel.IsEnabled = false;
                });
            });
        }
Пример #10
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Before public void replaceJobExecutor() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void replaceJobExecutor()
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = engineRule.ProcessEngineConfiguration;

            defaultJobExecutor = processEngineConfiguration.JobExecutor;
            jobExecutor        = new CountingJobExecutor(this);
            processEngineConfiguration.JobExecutor = jobExecutor;
        }
Пример #11
0
        protected internal virtual void notifyAcquisition(CommandContext commandContext)
        {
            JobExecutor jobExecutor = Context.ProcessEngineConfiguration.JobExecutor;
            MessageAddedNotification messageAddedNotification = new MessageAddedNotification(jobExecutor);
            TransactionContext       transactionContext       = commandContext.TransactionContext;

            transactionContext.addTransactionListener(TransactionState.COMMITTED, messageAddedNotification);
        }
Пример #12
0
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: protected org.camunda.bpm.engine.impl.jobexecutor.JobExecutor getJobExecutorService(final org.camunda.bpm.container.impl.spi.PlatformServiceContainer serviceContainer)
        protected internal virtual JobExecutor getJobExecutorService(PlatformServiceContainer serviceContainer)
        {
            // lookup container managed job executor
            string      jobAcquisitionName = processEngineXml.JobAcquisitionName;
            JobExecutor jobExecutor        = serviceContainer.getServiceValue(ServiceTypes.JOB_EXECUTOR, jobAcquisitionName);

            return(jobExecutor);
        }
Пример #13
0
        public ProcessEngineImpl(ProcessEngineConfigurationImpl processEngineConfiguration)
        {
            this.processEngineConfiguration = processEngineConfiguration;
            this.name = processEngineConfiguration.ProcessEngineName;

            this.repositoryService    = processEngineConfiguration.RepositoryService;
            this.runtimeService       = processEngineConfiguration.RuntimeService;
            this.historicDataService  = processEngineConfiguration.HistoryService;
            this.identityService      = processEngineConfiguration.IdentityService;
            this.taskService          = processEngineConfiguration.TaskService;
            this.formService          = processEngineConfiguration.FormService;
            this.managementService    = processEngineConfiguration.ManagementService;
            this.authorizationService = processEngineConfiguration.AuthorizationService;
            this.caseService          = processEngineConfiguration.CaseService;
            this.filterService        = processEngineConfiguration.FilterService;
            this.externalTaskService  = processEngineConfiguration.ExternalTaskService;
            this.decisionService      = processEngineConfiguration.DecisionService;

            this.databaseSchemaUpdate       = processEngineConfiguration.DatabaseSchemaUpdate;
            this.jobExecutor                = processEngineConfiguration.JobExecutor;
            this.commandExecutor            = processEngineConfiguration.CommandExecutorTxRequired;
            commandExecutorSchemaOperations = processEngineConfiguration.CommandExecutorSchemaOperations;
            this.sessionFactories           = processEngineConfiguration.SessionFactories;
            this.historyLevel               = processEngineConfiguration.HistoryLevel;
            this.transactionContextFactory  = processEngineConfiguration.TransactionContextFactory;

            executeSchemaOperations();

            if (string.ReferenceEquals(name, null))
            {
                LOG.processEngineCreated(ProcessEngines.NAME_DEFAULT);
            }
            else
            {
                LOG.processEngineCreated(name);
            }

            ProcessEngines.registerProcessEngine(this);

            if ((jobExecutor != null))
            {
                // register process engine with Job Executor
                jobExecutor.registerProcessEngine(this);
            }

            if (processEngineConfiguration.MetricsEnabled)
            {
                string            reporterId        = processEngineConfiguration.MetricsReporterIdProvider.provideId(this);
                DbMetricsReporter dbMetricsReporter = processEngineConfiguration.DbMetricsReporter;
                dbMetricsReporter.ReporterId = reporterId;

                if (processEngineConfiguration.DbMetricsReporterActivate)
                {
                    dbMetricsReporter.start();
                }
            }
        }
Пример #14
0
 public SessionDebugManager(JobExecutor jobExecutor, IJobQueue jobQueue,
                            LaunchAndAttachFlow launchAndAttachFlow,
                            IDebugSession debugSession)
 {
     _jobExecutor         = jobExecutor;
     _jobQueue            = jobQueue;
     _launchAndAttachFlow = launchAndAttachFlow;
     Session = debugSession;
 }
Пример #15
0
        //we cannot use waitForExecutor... method since there will always be one job left
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: private void moveByHours(int hours) throws Exception
        private void moveByHours(int hours)
        {
            ClockUtil.CurrentTime = new DateTime(ClockUtil.CurrentTime.Ticks + ((hours * 60 * 1000 * 60) + 5000));
            JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;

            jobExecutor.start();
            Thread.Sleep(1000);
            jobExecutor.shutdown();
        }
Пример #16
0
        static void Main(string[] args)
        {
            JobExecutor  je           = new JobExecutor();
            ControlPanel controlPanel = new ControlPanel();
            Action       action       = new Action(Displayed);

            Console.WriteLine($"1-Добавить имена\n2-Запустить работу\n3-Очистить список\n4-Остановить работу");
            Console.WriteLine("Для запуска действия, введите цифру и нажмите ENTER...");
            controlPanel.ReaderKeys(je, action, 10);
        }
Пример #17
0
        static void Main(string[] args)
        {
            ChannelServices.RegisterChannel(new TcpChannel(), false);
            GridJobController controller = (GridJobController)Activator.GetObject(typeof(GridJobController), "tcp://localhost:3000/Grid");

            if (controller == null)
            {
                Console.WriteLine("could not locate server");
                return;
            }

            bool q = false;

            while (!q)
            {
                try
                {
                    JobExecutor exe     = new JobExecutor();
                    var         start   = DateTime.Now;
                    var         hasJobs = false;

                    for (int i = 0; i < 100; i++)
                    {
                        var job = controller.GetJob();
                        if (job == null)
                        {
                            break;
                        }

                        hasJobs = true;
                        //Console.WriteLine($"Берем работу: " + i);
                        var res = exe.Execute(job);


                        controller.SetResult(res);
                    }
                    var end = DateTime.Now;
                    if (hasJobs)
                    {
                        Console.WriteLine((end - start).TotalMilliseconds + " ms.");
                    }
                    System.Threading.Thread.Sleep(500);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex);
                }

                if (Console.KeyAvailable && Console.ReadKey().Key == ConsoleKey.Q)
                {
                    break;
                }
            }
        }
Пример #18
0
        public virtual void waitForJobExecutorToProcessAllJobs(long maxMillisToWait)
        {
            ProcessEngineConfigurationImpl processEngineConfiguration = (ProcessEngineConfigurationImpl)processEngine.ProcessEngineConfiguration;
            JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;

            jobExecutor.start();
            long intervalMillis = 1000;

            int jobExecutorWaitTime = jobExecutor.WaitTimeInMillis * 2;

            if (maxMillisToWait < jobExecutorWaitTime)
            {
                maxMillisToWait = jobExecutorWaitTime;
            }

            try
            {
                Timer         timer = new Timer();
                InterruptTask task  = new InterruptTask(Thread.CurrentThread);
                timer.schedule(task, maxMillisToWait);
                bool areJobsAvailable = true;
                try
                {
                    while (areJobsAvailable && !task.TimeLimitExceeded)
                    {
                        Thread.Sleep(intervalMillis);
                        try
                        {
                            areJobsAvailable = areJobsAvailable();
                        }
                        catch (Exception)
                        {
                            // Ignore, possible that exception occurs due to locking/updating of table on MSSQL when
                            // isolation level doesn't allow READ of the table
                        }
                    }
                }
                catch (InterruptedException)
                {
                }
                finally
                {
                    timer.cancel();
                }
                if (areJobsAvailable)
                {
                    throw new AssertionError("time limit of " + maxMillisToWait + " was exceeded");
                }
            }
            finally
            {
                jobExecutor.shutdown();
            }
        }
Пример #19
0
        public XxlJobExecutorMiddleware(RequestDelegate next, IServiceProvider services)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            _next     = next;
            _executor = services.GetService <JobExecutor>();
            _logger   = services.GetService <ILoggerFactory>().CreateLogger <XxlJobExecutorMiddleware>();
        }
Пример #20
0
        public async Task SetUp()
        {
            serviceProvideMock = MocksFactory.ServiceProvider();
            loggerMock         = MocksFactory.GetLogger <JobExecutor>();

            jobExecutor = new JobExecutor(
                loggerMock,
                serviceProvideMock,
                new ExecutionCache()
                );

            await jobExecutor.StopAsync(new CancellationToken(true));
        }
Пример #21
0
        private void HintJobExecutorIfNeeded(JobEntity jobEntity, DateTime duedate)
        {
            // Check if this timer fires before the next time the job executor will check for new timers to fire.
            // This is highly unlikely because normally waitTimeInMillis is 5000 (5 seconds)
            // and timers are usually set further in the future
            JobExecutor jobExecutor      = context.Impl.Context.ProcessEngineConfiguration.JobExecutor;
            int         waitTimeInMillis = jobExecutor.WaitTimeInMillis;

            if (duedate.Ticks < (ClockUtil.CurrentTime.TimeOfDay.Ticks + waitTimeInMillis))
            {
                HintJobExecutor(jobEntity);
            }
        }
Пример #22
0
 public virtual void run()
 {
     try
     {
         JobExecutor jobExecutor = outerInstance.processEngineConfiguration.JobExecutor;
         jobs = (AcquiredJobs)outerInstance.processEngineConfiguration.CommandExecutorTxRequired.execute(new ControlledCommand(activeThread, new AcquireJobsCmd(jobExecutor)));
     }
     catch (OptimisticLockingException e)
     {
         this.exception = e;
     }
     LOG.debug(Name + " ends");
 }
Пример #23
0
        private void LoadModelAsync()
        {
            JobExecutor.QueueJob(() => {
                var service = new LoanService(User);
                var list    = service.ListLoansForContact(ContactID);
                _model      = new ObservableCollection <LoanViewModel>(list.Select((model) => {
                    return(new LoanViewModel(model));
                }));

                this.InvokeIfRequired(() => {
                    lvw.ItemsSource = _model;
                });
            });
        }
Пример #24
0
        private void CheckForUpdates()
        {
            var checker = new UpdateChecker();

            var progress = new UpdateCheckWindow();

            progress.Owner = MainWindow.Instance;
            progress.Show();

            JobExecutor.QueueJob(() => {
                var results = checker.CheckForUpdates(progress);
                progress.InvokeIfRequired(() => progress.ShowUpdateResults(results));
            });
        }
        public override void OnPageEnter(WizardDirection fromdirection)
        {
            var progress = new ProgressWindow(this.FindParentWindow(), "Extracting column information from data source...", true);

            _fields = _fieldSource();
            lvwFields.ItemsSource = _fields;

            CollectionView           myView           = (CollectionView)CollectionViewSource.GetDefaultView(lvwFields.ItemsSource);
            PropertyGroupDescription groupDescription = new PropertyGroupDescription("Category");

            myView.GroupDescriptions.Add(groupDescription);
            var model = new List <ImportFieldMapping>();

            JobExecutor.QueueJob(() => {
                List <String> columns = null;
                columns = ImportContext.Importer.GetColumnNames();

                var existingMappings = ImportContext.FieldMappings;
                if (existingMappings != null && existingMappings.Count() > 0)
                {
                    foreach (ImportFieldMapping mapping in existingMappings)
                    {
                        model.Add(mapping);
                    }
                }
                else
                {
                    foreach (string columnName in columns)
                    {
                        var mapping = new ImportFieldMapping {
                            SourceColumn = columnName
                        };
                        model.Add(mapping);
                    }
                }

                _model = new ObservableCollection <ImportFieldMappingViewModel>(model.Select((m) => {
                    return(new ImportFieldMappingViewModel(m));
                }));

                lvwMappings.InvokeIfRequired(() => {
                    lvwMappings.ItemsSource = _model;
                });

                progress.InvokeIfRequired(() => {
                    progress.Dispose();
                });
            });
        }
Пример #26
0
        private void DisplayMultimedia(MultimediaLinkViewModel selected)
        {
            if (selected != null)
            {
                JobExecutor.QueueJob(() => {
                    BitmapSource image = null;
                    try {
                        string filename       = _tempFileManager.GetContentFileName(selected.MultimediaID, selected.Extension);
                        selected.TempFilename = filename;
                        image = GraphicsUtils.LoadImageFromFile(filename);
                        if (image != null)
                        {
                            imgPreview.InvokeIfRequired(() => {
                                imgPreview.Stretch          = Stretch.Uniform;
                                imgPreview.StretchDirection = StretchDirection.DownOnly;
                                imgPreview.Source           = image;
                                gridInfo.DataContext        = image;
                                FileInfo f = new FileInfo(filename);

                                if (f.Length != selected.SizeInBytes)
                                {
                                    selected.SuspendChangeMonitoring = true;
                                    selected.SizeInBytes             = (int)f.Length;
                                    selected.SuspendChangeMonitoring = false;
                                }

                                lblImageInfo.Content = string.Format("{0}x{1}  {2} DPI  {3}", image.PixelWidth, image.PixelHeight, image.DpiX, ByteLengthConverter.FormatBytes(f.Length));
                                lblFilename.Content  = string.Format("Filename: {0}", filename);
                            });
                        }
                    } finally {
                        if (image == null)
                        {
                            imgPreview.InvokeIfRequired(() => {
                                imgPreview.Source    = null;
                                lblImageInfo.Content = "No image";
                                lblFilename.Content  = "";
                            });
                        }
                    }
                });
            }
            else
            {
                imgPreview.Source    = null;
                lblFilename.Content  = "";
                lblImageInfo.Content = "";
            }
        }
Пример #27
0
        public CreateInvoiceByServiceOrderPost() : base()
        {
            billingBy = ID.Billing_By.SERVICE_ORDER;
            CreateInvoiceByServiceOrderPost graphCreateInvoiceByServiceOrderPost = null;

            PostLines.SetProcessDelegate(
                delegate(List <ServiceOrderToPost> serviceOrderToPostRows)
            {
                graphCreateInvoiceByServiceOrderPost = PXGraph.CreateInstance <CreateInvoiceByServiceOrderPost>();

                var jobExecutor = new JobExecutor <InvoicingProcessStepGroupShared>(true);

                CreateInvoices(graphCreateInvoiceByServiceOrderPost, serviceOrderToPostRows, Filter.Current, this.UID, jobExecutor, PXQuickProcess.ActionFlow.NoFlow);
            });
        }
        public CreateInvoiceByAppointmentPost() : base()
        {
            billingBy = ID.Billing_By.APPOINTMENT;
            CreateInvoiceByAppointmentPost graphCreateInvoiceByAppointmentPost = null;

            PostLines.SetProcessDelegate(
                delegate(List <AppointmentToPost> appointmentToPostRows)
            {
                graphCreateInvoiceByAppointmentPost = PXGraph.CreateInstance <CreateInvoiceByAppointmentPost>();

                var jobExecutor = new JobExecutor <InvoicingProcessStepGroupShared>(true);

                CreateInvoices(graphCreateInvoiceByAppointmentPost, appointmentToPostRows, Filter.Current, this.UID, jobExecutor, PXQuickProcess.ActionFlow.NoFlow);
            });
        }
Пример #29
0
        public async Task Should_not_throw_on_lock_exceptions()
        {
            //arrange
            var lockManager = new Mock <ISingletonLockManager>();

            lockManager.Setup(x => x.TryLockAsync(typeof(DummySchedule).FullName, TimeSpan.FromSeconds(60), It.IsAny <CancellationToken>()))
            .Throws <Exception>();
            var processor = new Mock <IProcessSchedule <DummySchedule> >();
            var di        = new Mock <IDependencyInjection>();

            di.Setup(x => x.GetScope()).Returns(di.Object);
            di.Setup(x => x.GetInstance <IProcessSchedule <DummySchedule> >()).Returns(processor.Object);
            var executor = new JobExecutor <DummySchedule>(Mock.Of <ILog>(), lockManager.Object, di.Object);
            //act & assert
            await executor.Execute(Mock.Of <IJobExecutionContext>());
        }
Пример #30
0
        public virtual void waitForJobExecutorOnCondition(long maxMillisToWait, Callable <bool> condition)
        {
            JobExecutor jobExecutor = processEngineConfiguration.JobExecutor;

            jobExecutor.start();
            long intervalMillis = 500;

            if (maxMillisToWait < (jobExecutor.WaitTimeInMillis * 2))
            {
                maxMillisToWait = (jobExecutor.WaitTimeInMillis * 2);
            }

            try
            {
                Timer         timer = new Timer();
                InterruptTask task  = new InterruptTask(Thread.CurrentThread);
                timer.schedule(task, maxMillisToWait);
                bool conditionIsViolated = true;
                try
                {
                    while (conditionIsViolated && !task.TimeLimitExceeded)
                    {
                        Thread.Sleep(intervalMillis);
                        conditionIsViolated = !condition.call();
                    }
                }
                catch (InterruptedException)
                {
                }
                catch (Exception e)
                {
                    throw new ProcessEngineException("Exception while waiting on condition: " + e.Message, e);
                }
                finally
                {
                    timer.cancel();
                }
                if (conditionIsViolated)
                {
                    throw new ProcessEngineException("time limit of " + maxMillisToWait + " was exceeded");
                }
            }
            finally
            {
                jobExecutor.shutdown();
            }
        }
Пример #31
0
 public void Setup() {
     sut = new JobExecutor();
 }