Ejemplo n.º 1
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testTimerRecalculationBasedOnProcessVariable()
        public virtual void testTimerRecalculationBasedOnProcessVariable()
        {
            // given
            IDictionary <string, object> variables = new Dictionary <string, object>();

            variables["timerExpression"] = "PT10S";
            ProcessInstance instance = runtimeService.startProcessInstanceByKey("TimerRecalculationProcess", variables);

            ProcessInstanceQuery instancesQuery = runtimeService.createProcessInstanceQuery().processInstanceId(instance.Id);
            JobQuery             jobQuery       = managementService.createJobQuery();

            assertEquals(1, instancesQuery.count());
            assertEquals(1, jobQuery.count());

            Job      job        = jobQuery.singleResult();
            DateTime oldDueDate = job.Duedate;

            // when
            runtimeService.setVariable(instance.Id, "timerExpression", "PT1S");
            managementService.recalculateJobDuedate(job.Id, true);

            // then
            assertEquals(1, jobQuery.count());
            Job jobRecalculated = jobQuery.singleResult();

            assertNotEquals(oldDueDate, jobRecalculated.Duedate);

            DateTime calendar = new DateTime();

            calendar = new DateTime(jobRecalculated.CreateTime);
            calendar.AddSeconds(1);
            DateTime expectedDate = calendar;

            assertEquals(expectedDate, jobRecalculated.Duedate);

            waitForJobExecutorToProcessAllJobs();

            assertEquals(0, instancesQuery.count());
        }
Ejemplo n.º 2
0
        /*
         * Test for when multiple boundary timer events are defined on the same user
         * task
         *
         * Configuration: - timer 1 -> 2 hours -> secondTask - timer 2 -> 1 hour ->
         * thirdTask - timer 3 -> 3 hours -> fourthTask
         *
         * See process image next to the process xml resource
         */
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testMultipleTimersOnUserTask()
        public virtual void testMultipleTimersOnUserTask()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            // After process start, there should be 3 timers created
            ProcessInstance pi       = runtimeService.startProcessInstanceByKey("multipleTimersOnUserTask");
            JobQuery        jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job>     jobs     = jobQuery.list();

            assertEquals(3, jobs.Count);

            // After setting the clock to time '1 hour and 5 seconds', the second timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + ((60 * 60 * 1000) + 5000));
            waitForJobExecutorToProcessAllJobs(5000L);
            assertEquals(0L, jobQuery.count());

            // which means that the third task is reached
            Task task = taskService.createTaskQuery().singleResult();

            assertEquals("Third Task", task.Name);
        }
        public async Task QueryCount_QueryByQueueIdOnly_YieldsAllResults()
        {
            var exampleQueueId = QueueId.Parse("ExampleQueue");
            var exampleQuery   = new JobQuery
            {
                QueueId = exampleQueueId
            };

            var existingJobs = new[] { new Job
                                       {
                                           Id      = JobId.Generate(),
                                           QueueId = exampleQueueId
                                       }, new Job
                                       {
                                           Id      = JobId.Generate(),
                                           QueueId = exampleQueueId
                                       }, new Job
                                       {
                                           Id      = JobId.Generate(),
                                           QueueId = QueueId.Parse(Guid.NewGuid().ToString("N"))
                                       } };

            await RunInMongoLand(async database =>
            {
                var jobs = database.GetJobCollection();

                await jobs.InsertManyAsync(existingJobs).ConfigureAwait(false);

                var sut = new MongoJobQueryCountService(database);

                var results = (await sut.QueryCount(exampleQuery).ConfigureAwait(false));

                long expected = 2;

                Assert.That(results, Is.Not.Null);
                Assert.AreEqual(results, expected);
            }).ConfigureAwait(false);
        }
Ejemplo n.º 4
0
        //sorting //////////////////////////////////////////

//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQuerySorting()
        public virtual void testQuerySorting()
        {
            // asc
            assertEquals(4, managementService.createJobQuery().orderByJobId().asc().count());
            assertEquals(4, managementService.createJobQuery().orderByJobDuedate().asc().count());
            assertEquals(4, managementService.createJobQuery().orderByExecutionId().asc().count());
            assertEquals(4, managementService.createJobQuery().orderByProcessInstanceId().asc().count());
            assertEquals(4, managementService.createJobQuery().orderByJobRetries().asc().count());
            assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionId().asc().count());
            assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionKey().asc().count());

            // desc
            assertEquals(4, managementService.createJobQuery().orderByJobId().desc().count());
            assertEquals(4, managementService.createJobQuery().orderByJobDuedate().desc().count());
            assertEquals(4, managementService.createJobQuery().orderByExecutionId().desc().count());
            assertEquals(4, managementService.createJobQuery().orderByProcessInstanceId().desc().count());
            assertEquals(4, managementService.createJobQuery().orderByJobRetries().desc().count());
            assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionId().desc().count());
            assertEquals(4, managementService.createJobQuery().orderByProcessDefinitionKey().desc().count());

            // sorting on multiple fields
            setRetries(processInstanceIdTwo, 2);
            ClockUtil.CurrentTime = new DateTime(timerThreeFireTime.Ticks + ONE_SECOND);     // make sure all timers can fire

            JobQuery query = managementService.createJobQuery().timers().executable().orderByJobRetries().asc().orderByJobDuedate().desc();

            IList <Job> jobs = query.list();

            assertEquals(3, jobs.Count);

            assertEquals(2, jobs[0].Retries);
            assertEquals(3, jobs[1].Retries);
            assertEquals(3, jobs[2].Retries);

            assertEquals(processInstanceIdTwo, jobs[0].ProcessInstanceId);
            assertEquals(processInstanceIdThree, jobs[1].ProcessInstanceId);
            assertEquals(processInstanceIdOne, jobs[2].ProcessInstanceId);
        }
Ejemplo n.º 5
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test @OperateOnDeployment("clientDeployment") public void testResolveRetryConfigBean()
        public virtual void testResolveRetryConfigBean()
        {
            // given
            ProcessInstance processInstance = runtimeService.startProcessInstanceByKey("testRetry");

            JobQuery query = managementService.createJobQuery().processInstanceId(processInstance.Id);

            Job job = query.singleResult();

            // when job fails
            try
            {
                managementService.executeJob(job.Id);
            }
            catch (Exception)
            {
                // ignore
            }

            // then
            job = query.singleResult();
            Assert.assertEquals(6, job.Retries);
        }
Ejemplo n.º 6
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testIncludeJobsWithoutTenantIdParameter()
        public virtual void testIncludeJobsWithoutTenantIdParameter()
        {
            IList <Job> jobs = Arrays.asList(MockProvider.mockJob().tenantId(null).build(), MockProvider.mockJob().tenantId(MockProvider.EXAMPLE_TENANT_ID).build());

            mockQuery = setUpMockJobQuery(jobs);

            Response response = given().queryParam("tenantIdIn", MockProvider.EXAMPLE_TENANT_ID).queryParam("includeJobsWithoutTenantId", true).then().expect().statusCode(Status.OK.StatusCode).when().get(JOBS_RESOURCE_URL);

            verify(mockQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID);
            verify(mockQuery).includeJobsWithoutTenantId();
            verify(mockQuery).list();

            string         content     = response.asString();
            IList <string> definitions = from(content).getList("");

            assertThat(definitions).hasSize(2);

            string returnedTenantId1 = from(content).getString("[0].tenantId");
            string returnedTenantId2 = from(content).getString("[1].tenantId");

            assertThat(returnedTenantId1).isEqualTo(null);
            assertThat(returnedTenantId2).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
        }
Ejemplo n.º 7
0
        public virtual void testSuspensionByProcessDefinitionIdUsingBuilder()
        {
            // given

            // a running process instance with a failed job
            runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true));

            // the failed job
            JobQuery jobQuery = managementService.createJobQuery();

            assertEquals(1, jobQuery.active().count());

            ProcessDefinition processDefinition = repositoryService.createProcessDefinitionQuery().singleResult();

            // when
            // the job will be suspended
            managementService.updateJobSuspensionState().byProcessDefinitionId(processDefinition.Id).suspend();

            // then
            // the job should be suspended
            assertEquals(0, jobQuery.active().count());
            assertEquals(1, jobQuery.suspended().count());
        }
Ejemplo n.º 8
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testExpressionRecalculateCurrentDateBased() throws Exception
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
        public virtual void testExpressionRecalculateCurrentDateBased()
        {
            // Set the clock fixed
            Dictionary <string, object> variables = new Dictionary <string, object>();

            variables["duration"] = "PT1H";

            // After process start, there should be timer created
            ProcessInstanceWithVariables pi1 = (ProcessInstanceWithVariables)runtimeService.startProcessInstanceByKey("intermediateTimerEventExample", variables);
            JobQuery jobQuery = managementService.createJobQuery().processInstanceId(pi1.Id);

            assertEquals(1, jobQuery.count());
            Job      job       = jobQuery.singleResult();
            DateTime firstDate = job.Duedate;

            // After variable change and recalculation, there should still be one timer only, with a changed due date
            moveByMinutes(1);
            DateTime currentTime = ClockUtil.CurrentTime;

            runtimeService.setVariable(pi1.ProcessInstanceId, "duration", "PT15M");
            processEngine.ManagementService.recalculateJobDuedate(job.Id, false);

            assertEquals(1, jobQuery.count());
            job = jobQuery.singleResult();
            assertNotEquals(firstDate, job.Duedate);
            assertTrue(firstDate > job.Duedate);
            DateTime expectedDate = LocalDateTime.fromDateFields(currentTime).plusMinutes(15).toDate();

            assertThat(job.Duedate).isCloseTo(expectedDate, 1000l);

            // After waiting for sixteen minutes the timer should fire
            ClockUtil.CurrentTime = new DateTime(firstDate.Ticks + TimeUnit.MINUTES.toMillis(16L));
            waitForJobExecutorToProcessAllJobs(5000L);

            assertEquals(0, managementService.createJobQuery().processInstanceId(pi1.Id).count());
            assertProcessEnded(pi1.ProcessInstanceId);
        }
Ejemplo n.º 9
0
        public async Task QueryFor_Limit_YieldsOnlyToTheLimit()
        {
            var exampleQueueId = QueueId.Parse("ExampleQueue");
            var exampleQuery   = new JobQuery
            {
                QueueId = exampleQueueId,
                Limit   = 2,
            };

            var existingJobs = new[] { new Job
                                       {
                                           Id      = JobId.Generate(),
                                           QueueId = exampleQueueId
                                       }, new Job
                                       {
                                           Id      = JobId.Generate(),
                                           QueueId = exampleQueueId
                                       }, new Job
                                       {
                                           Id      = JobId.Generate(),
                                           QueueId = exampleQueueId
                                       } };

            await RunInMongoLand(async database =>
            {
                var jobs = database.GetJobCollection();

                await jobs.InsertManyAsync(existingJobs).ConfigureAwait(false);

                var sut = new MongoJobQueryService(database);

                var results = (await sut.QueryFor(exampleQuery).ConfigureAwait(false))?.ToList();

                Assert.That(results, Is.Not.Null);
                Assert.That(results, Has.Count.EqualTo(2));
            }).ConfigureAwait(false);
        }
Ejemplo n.º 10
0
        public virtual void testActivationByJobDefinitionId_shouldActivateJob()
        {
            // given

            // a running process instance with a failed job
            IDictionary <string, object> @params = new Dictionary <string, object>();

            @params["fail"] = true;
            runtimeService.startProcessInstanceByKey("suspensionProcess", @params);

            // suspended job definitions and corresponding jobs
            managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);

            // the job definition
            JobDefinition jobDefinition = managementService.createJobDefinitionQuery().singleResult();

            // the failed job
            JobQuery jobQuery = managementService.createJobQuery();
            Job      job      = jobQuery.singleResult();

            assertTrue(job.Suspended);

            // when
            // the job will be activated
            managementService.activateJobByJobDefinitionId(jobDefinition.Id);

            // then
            // the job should be activated
            assertEquals(0, jobQuery.suspended().count());
            assertEquals(1, jobQuery.active().count());

            Job activeJob = jobQuery.active().singleResult();

            assertEquals(job.Id, activeJob.Id);
            assertEquals(jobDefinition.Id, activeJob.JobDefinitionId);
            assertFalse(activeJob.Suspended);
        }
Ejemplo n.º 11
0
        public virtual void testMultipleActivationByProcessDefinitionKey_shouldActivateJob()
        {
            // given
            string key = "suspensionProcess";

            // Deploy three processes and start for each deployment a process instance
            // with a failed job
            int nrOfProcessDefinitions = 3;

            for (int i = 0; i < nrOfProcessDefinitions; i++)
            {
                repositoryService.createDeployment().addClasspathResource("org/camunda/bpm/engine/test/api/mgmt/SuspensionTest.testBase.bpmn").deploy();
                IDictionary <string, object> @params = new Dictionary <string, object>();
                @params["fail"] = true;
                runtimeService.startProcessInstanceByKey(key, @params);
            }

            // suspended job definitions and corresponding jobs
            managementService.suspendJobDefinitionByProcessDefinitionKey(key, true);

            // when
            // the job will be suspended
            managementService.activateJobByProcessDefinitionKey(key);

            // then
            // the job should be activated
            JobQuery jobQuery = managementService.createJobQuery();

            assertEquals(0, jobQuery.suspended().count());
            assertEquals(3, jobQuery.active().count());

            // Clean DB
            foreach (org.camunda.bpm.engine.repository.Deployment deployment in repositoryService.createDeploymentQuery().list())
            {
                repositoryService.deleteDeployment(deployment.Id, true);
            }
        }
Ejemplo n.º 12
0
        public virtual void testRecalculateChangedExpressionOnTimerCreationDateBased()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            Dictionary <string, object> variables = new Dictionary <string, object>();

            variables["duedate"] = "PT1H";

            // After process start, there should be a timer created
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("testExpressionOnTimer", variables);

            JobQuery    jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job> jobs     = jobQuery.list();

            assertEquals(1, jobs.Count);
            Job      job     = jobs[0];
            DateTime oldDate = job.Duedate;

            // After recalculation of the timer, the job's duedate should be the same
            runtimeService.setVariable(pi.Id, "duedate", "PT15M");
            managementService.recalculateJobDuedate(job.Id, true);
            Job jobUpdated = jobQuery.singleResult();

            assertEquals(job.Id, jobUpdated.Id);
            assertNotEquals(oldDate, jobUpdated.Duedate);
            assertEquals(LocalDateTime.fromDateFields(jobUpdated.CreateTime).plusMinutes(15).toDate(), jobUpdated.Duedate);

            // After setting the clock to time '16 minutes', the timer should fire
            ClockUtil.CurrentTime = new DateTime(startTime.Ticks + TimeUnit.MINUTES.toMillis(16L));
            waitForJobExecutorToProcessAllJobs(5000L);
            assertEquals(0L, jobQuery.count());

            // which means the process has ended
            assertProcessEnded(pi.Id);
        }
Ejemplo n.º 13
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testTenantIdListPostParameter()
        public virtual void testTenantIdListPostParameter()
        {
            mockQuery = setUpMockJobQuery(createMockJobsTwoTenants());

            IDictionary <string, object> queryParameters = new Dictionary <string, object>();

            queryParameters["tenantIdIn"] = MockProvider.EXAMPLE_TENANT_ID_LIST.Split(",", true);

            Response response = given().contentType(POST_JSON_CONTENT_TYPE).body(queryParameters).expect().statusCode(Status.OK.StatusCode).when().post(JOBS_RESOURCE_URL);

            verify(mockQuery).tenantIdIn(MockProvider.EXAMPLE_TENANT_ID, MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
            verify(mockQuery).list();

            string         content = response.asString();
            IList <string> jobs    = from(content).getList("");

            assertThat(jobs).hasSize(2);

            string returnedTenantId1 = from(content).getString("[0].tenantId");
            string returnedTenantId2 = from(content).getString("[1].tenantId");

            assertThat(returnedTenantId1).isEqualTo(MockProvider.EXAMPLE_TENANT_ID);
            assertThat(returnedTenantId2).isEqualTo(MockProvider.ANOTHER_EXAMPLE_TENANT_ID);
        }
Ejemplo n.º 14
0
        public virtual void testActivationByProcessDefinitionKeyUsingBuilder()
        {
            // given

            // a running process instance with a failed job
            runtimeService.startProcessInstanceByKey("suspensionProcess", Variables.createVariables().putValue("fail", true));

            // suspended job definitions and corresponding jobs
            managementService.suspendJobDefinitionByProcessDefinitionKey("suspensionProcess", true);

            // the failed job
            JobQuery jobQuery = managementService.createJobQuery();

            assertEquals(1, jobQuery.suspended().count());

            // when
            // the job will be activated
            managementService.updateJobSuspensionState().byProcessDefinitionKey("suspensionProcess").activate();

            // then
            // the job should be active
            assertEquals(1, jobQuery.active().count());
            assertEquals(0, jobQuery.suspended().count());
        }
Ejemplo n.º 15
0
        // [END language_code_filter]

        // [START company_display_name_filter]

        public static void CompanyDisplayNameSearch(string companyName, List <string> companyDisplayNames)
        {
            RequestMetadata requestMetadata = new RequestMetadata()
            {
                // Make sure to hash your userID
                UserId = "HashedUserId",
                // Make sure to hash the sessionID
                SessionId = "HashedSessionId",
                // Domain of the website where the search is conducted
                Domain = "www.google.com"
            };

            JobQuery jobQuery = new JobQuery()
            {
                CompanyDisplayNames = companyDisplayNames
            };

            if (companyName != null)
            {
                jobQuery.CompanyNames = new List <string>
                {
                    companyName
                };
            }

            SearchJobsRequest searchJobRequest = new SearchJobsRequest()
            {
                RequestMetadata = requestMetadata,
                JobQuery        = jobQuery,
                SearchMode      = "JOB_SEARCH"
            };

            SearchJobsResponse searchJobsResponse = jobServiceClient.Projects.Jobs.Search(searchJobRequest, parent).Execute();

            Console.WriteLine("Jobs company display names searched: " + ToJsonString(searchJobsResponse));
        }
Ejemplo n.º 16
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testFinishedJob()
        public virtual void testFinishedJob()
        {
            // given
            Dictionary <string, object> variables1 = new Dictionary <string, object>();

            variables1["dueDate"] = DateTime.Now;

            ProcessInstance pi1 = runtimeService.startProcessInstanceByKey("intermediateTimerEventExample", variables1);

            assertEquals(1, managementService.createJobQuery().processInstanceId(pi1.Id).count());

            JobQuery jobQuery = managementService.createJobQuery().executable();

            assertEquals(1L, jobQuery.count());

            // job duedate can be recalculated, job still exists in runtime
            string jobId = jobQuery.singleResult().Id;

            managementService.recalculateJobDuedate(jobId, false);
            // run the job, finish the process
            managementService.executeJob(jobId);
            assertEquals(0L, managementService.createJobQuery().processInstanceId(pi1.Id).count());
            assertProcessEnded(pi1.ProcessInstanceId);

            try
            {
                // when
                managementService.recalculateJobDuedate(jobId, false);
                fail("The recalculation of a finished job should not be possible");
            }
            catch (ProcessEngineException pe)
            {
                // then
                assertTextPresent("No job found with id '" + jobId, pe.Message);
            }
        }
Ejemplo n.º 17
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Deployment public void testReceiveTaskWithBoundaryTimer()
        public virtual void testReceiveTaskWithBoundaryTimer()
        {
            // Set the clock fixed
            DateTime startTime = DateTime.Now;

            Dictionary <string, object> variables = new Dictionary <string, object>();

            variables["timeCycle"] = "R/PT1H";

            // After process start, there should be a timer created
            ProcessInstance pi = runtimeService.startProcessInstanceByKey("nonInterruptingCycle", variables);

            JobQuery    jobQuery = managementService.createJobQuery().processInstanceId(pi.Id);
            IList <Job> jobs     = jobQuery.list();

            assertEquals(1, jobs.Count);

            // The Execution Query should work normally and find executions in state "task"
            IList <Execution> executions = runtimeService.createExecutionQuery().activityId("task").list();

            assertEquals(1, executions.Count);
            IList <string> activeActivityIds = runtimeService.getActiveActivityIds(executions[0].Id);

            assertEquals(1, activeActivityIds.Count);
            assertEquals("task", activeActivityIds[0]);

            runtimeService.signal(executions[0].Id);

            //    // After setting the clock to time '1 hour and 5 seconds', the second timer should fire
            //    ClockUtil.setCurrentTime(new Date(startTime.getTime() + ((60 * 60 * 1000) + 5000)));
            //    waitForJobExecutorToProcessAllJobs(5000L);
            //    assertEquals(0L, jobQuery.count());

            // which means the process has ended
            assertProcessEnded(pi.Id);
        }
Ejemplo n.º 18
0
        public static IQueryable <Job> ApplyFiltering(this IQueryable <Job> query, JobQuery queryObj)
        {
            if (queryObj.Id.HasValue)
            {
                query = query.Where(j => j.Id == queryObj.Id);
            }

            if (queryObj.IsActive.HasValue)
            {
                query = queryObj.IsActive == true
                    ? query.Where(j => j.ExpirationDate >= DateTime.Now)
                    : query.Where(j => j.ExpirationDate < DateTime.Now);
            }

            if (!string.IsNullOrEmpty(queryObj.Title))
            {
                query = query.Where(j => j.Title.Contains(queryObj.Title));
            }

            if (queryObj.SchedulingPod.HasValue)
            {
                query = query.Where(j => j.SchedulingPod == queryObj.SchedulingPod);
            }

            if (queryObj.OfficeId.HasValue)
            {
                query = query.Where(j => j.OfficeId == queryObj.OfficeId);
            }

            if (!string.IsNullOrEmpty(queryObj.JobBoard))
            {
                query = query.Where(j => j.JobBoard.JobBoardName.Contains(queryObj.JobBoard));
            }

            if (!string.IsNullOrEmpty(queryObj.Division))
            {
                query = query.Where(j => j.Division.Contains(queryObj.Division));
            }

            if (!string.IsNullOrEmpty(queryObj.City))
            {
                query = query.Where(j => j.City.Contains(queryObj.City));
            }

            if (!string.IsNullOrEmpty(queryObj.State))
            {
                query = query.Where(j => j.State.StateName.Contains(queryObj.State));
            }

            if (!string.IsNullOrEmpty(queryObj.Country))
            {
                query = query.Where(j => j.Country.CountryName.Contains(queryObj.Country));
            }

            if (!string.IsNullOrEmpty(queryObj.Category))
            {
                query = query.Where(j => j.Category.CategoryName.Contains(queryObj.Category));
            }

            if (!string.IsNullOrEmpty(queryObj.CompanyName))
            {
                query = query.Where(j => j.CompanyName.Contains(queryObj.CompanyName));
            }

            if (!string.IsNullOrEmpty(queryObj.CreatedBy))
            {
                query = query.Where(j => j.CreatedBy.Contains(queryObj.CreatedBy));
            }

            if (queryObj.ListType == ListType.Stats)
            {
                query = query
                        .Where(j => j.Stat == null || j.Stat.ApsCl == null)
                        .Where(j => j.ExpirationDate < DateTime.Now.AddDays(-30));
            }

            return(query);
        }
Ejemplo n.º 19
0
        // [START job_search_commute_search]
        public static object CommuteSearchJobs(string projectId, string tenantId)
        {
            JobServiceClient jobServiceClient = JobServiceClient.Create();
            TenantName       name             = TenantName.FromProjectTenant(projectId, tenantId);

            string          domain          = "www.example.com";
            string          sessionId       = "Hashed session identifier";
            string          userId          = "Hashed user identifier";
            RequestMetadata requestMetadata = new RequestMetadata
            {
                Domain    = domain,
                SessionId = sessionId,
                UserId    = userId
            };

            CommuteMethod commuteMethod  = CommuteMethod.Driving;
            long          seconds        = 3600L;
            Duration      travelDuration = new Duration
            {
                Seconds = seconds
            };

            double latitude         = 37.422408;
            double longitude        = -122.084068;
            LatLng startCoordinates = new LatLng
            {
                Latitude  = latitude,
                Longitude = longitude
            };

            CommuteFilter commuteFilter = new CommuteFilter
            {
                CommuteMethod    = commuteMethod,
                TravelDuration   = travelDuration,
                StartCoordinates = startCoordinates
            };

            JobQuery jobQuery = new JobQuery
            {
                CommuteFilter = commuteFilter
            };

            SearchJobsRequest request = new SearchJobsRequest
            {
                ParentAsTenantName = name,
                RequestMetadata    = requestMetadata,
                JobQuery           = jobQuery
            };

            var response = jobServiceClient.SearchJobs(request);

            foreach (var result in response)
            {
                Console.WriteLine($"Job summary: {result.JobSummary}");
                Console.WriteLine($"Job title snippet: {result.JobTitleSnippet}");
                Job job = result.Job;
                Console.WriteLine($"Job name: {job.Name}");
                Console.WriteLine($"Job title: {job.Title}");
            }

            return(0);
        }
Ejemplo n.º 20
0
 public SetJobsRetriesBatchCmd(IList <string> jobIds, JobQuery jobQuery, int retries)
 {
     this.jobQuery = jobQuery;
     this.jobIds   = jobIds;
     this.retries  = retries;
 }
Ejemplo n.º 21
0
        public static IQueryable <Job> SortBasedOnListType(this IQueryable <Job> query, JobQuery queryObj)
        {
            if (queryObj.ListType == ListType.Listing)
            {
                query = query.SortForListing();
            }

            else if (queryObj.ListType == ListType.Conversion)
            {
                query = query.SortForConversion();
            }

            else if (queryObj.ListType == ListType.Duplicate)
            {
                query = query.SortForDuplicate();
            }

            else if (queryObj.ListType == ListType.Stats)
            {
                query = query.SortForStatsPending();
            }

            return(query);
        }
Ejemplo n.º 22
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByActive()
        public virtual void testQueryByActive()
        {
            JobQuery query = managementService.createJobQuery().active();

            verifyQueryResults(query, 4);
        }
Ejemplo n.º 23
0
        public virtual void testQueryByJobsWithoutTenantId()
        {
            JobQuery query = managementService.createJobQuery().withoutTenantId();

            assertThat(query.count(), @is(1L));
        }
Ejemplo n.º 24
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByOnlyTimers()
        public virtual void testQueryByOnlyTimers()
        {
            JobQuery query = managementService.createJobQuery().timers();

            verifyQueryResults(query, 3);
        }
Ejemplo n.º 25
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByOnlyMessages()
        public virtual void testQueryByOnlyMessages()
        {
            JobQuery query = managementService.createJobQuery().messages();

            verifyQueryResults(query, 1);
        }
Ejemplo n.º 26
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByProcessDefinitionKey()
        public virtual void testQueryByProcessDefinitionKey()
        {
            JobQuery query = managementService.createJobQuery().processDefinitionKey("timerOnTask");

            verifyQueryResults(query, 3);
        }
Ejemplo n.º 27
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByProcessInstanceId()
        public virtual void testQueryByProcessInstanceId()
        {
            JobQuery query = managementService.createJobQuery().processInstanceId(processInstanceIdOne);

            verifyQueryResults(query, 1);
        }
Ejemplo n.º 28
0
//JAVA TO C# CONVERTER TODO TASK: Most Java annotations will not have direct .NET equivalent attributes:
//ORIGINAL LINE: @Test public void testQueryByNoCriteria()
        public virtual void testQueryByNoCriteria()
        {
            JobQuery query = managementService.createJobQuery();

            verifyQueryResults(query, 4);
        }
Ejemplo n.º 29
0
 public async Task <IEnumerable <JobLog> > GetLogs(JobQuery jobSettings)
 {
     _logger.LogInformation("GetLogs {0} called", jobSettings.JobId);
     return(await _jobmanagementDBContext.JobLogs.Where(p => p.JobId == jobSettings.JobId).ToListAsync());
 }
Ejemplo n.º 30
0
        public virtual void testQueryByNonExistingTenantId()
        {
            JobQuery query = managementService.createJobQuery().tenantIdIn("nonExisting");

            assertThat(query.count(), @is(0L));
        }