Returning all jobs takes three minutes

Forum for users and developers of Bullhorn's Webservices API suite

Moderators: StaffingSupport, s.emmons, BullhornSupport

nb_healthpro
User
Posts: 11
Joined: Thu Oct 25, 2012 2:59 pm

Returning all jobs takes three minutes

Post by nb_healthpro » Fri Oct 26, 2012 11:25 am

We have a query - we modeled it VERY closely on your sample query. We have less than 150 jobs up, but it could be X number of jobs.

150 or so jobs is taking THREE MINUTES to come back. Is this normal? Obviously, this makes the functionality unusable from our perspective. We need to be able to return a couple of hundred jobs fast.

What are we doing wrong, or what should we be doing to improve response time?

r.knight
User
Posts: 68
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by r.knight » Fri Oct 26, 2012 12:27 pm

Hi nb_healthpro,

Thanks for your post. Can you specifically identify the sample code you are using and for what language? If you are willing to also post the code you've modified we can take a look. Our support team is aware of some of the outdated examples/errors, and I've communicated this as such to the Product Managers to provide updates, if possible. There are efforts to fix some of these issues but unfortunately, at this time, the edits are prioritized with some other requests. I truly apologize and am happy to take any of your feedback to our management teams.

To answer your question, no I wouldn't consider that normal. May I ask what you are trying to accomplish with retrieving all of the jobs? It sounds like you may be trying to retrieve all jobs in the system to populate your own datasource. If so, it may be useful to review the Event Subscription document at http://developer.bullhorn.com/doc/under ... events.htm . This is often something we recommend in lieu of pulling down large data sets and more importantly allows you to design your app to be updated in near real time by consuming these events and performing the appropriate actions.

I look forward to hearing back and assisting as best as possible.
Ryan Knight
Principal Enterprise Support Analyst and Team Lead
B U L L H O R N
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
US Support: 617-478-9126
International Support: +1 617 478 9131
http://www.bullhorn.com

nb_healthpro
User
Posts: 11
Joined: Thu Oct 25, 2012 2:59 pm

Re: Returning all jobs takes three minutes

Post by nb_healthpro » Fri Oct 26, 2012 1:02 pm

Thanks for the reply.

Here is my code. Its not doing anything dramatic:

Code: Select all

Dim service As New ApiService()
        Dim session As apiStartSessionResult = service.startSession(_BHUserName, _BHPassword, _BHApiKey)
        Dim strSession = session.session

        Dim positions As New dtoQuery()
        positions.entityName = "JobOrder"
        positions.maxResults = "200"
        positions.maxResultsSpecified = True
        positions.where = "isDeleted=0"
        Dim qr As apiQueryResult = service.query(strSession, positions)

        strSession = qr.session

        Dim dt As New DataTable("positions")

        'loop thru all of the properties in the jobOrderDto object
        'and insert a column in the data table for each property
        ''Dim mtype As Type = GetType(jobOrderDto)
        ''Dim properties As System.Reflection.PropertyInfo() = mtype.GetProperties()
        ''For Each p As System.Reflection.PropertyInfo In properties
        ''dt.Columns.Add(p.Name)
        ''Next

        dt.Columns.Add("jobOrderId")
        dt.Columns.Add("address")
        dt.Columns.Add("benefits")
        dt.Columns.Add("billRateCategoryID")
        dt.Columns.Add("bonusPackage")
        dt.Columns.Add("branchCode")
        dt.Columns.Add("certificationList")
        dt.Columns.Add("clientBillRate")
        dt.Columns.Add("clientContactID")
        dt.Columns.Add("clientCorporationID")
        dt.Columns.Add("costCenter")
        dt.Columns.Add("dateAdded")
        dt.Columns.Add("dateClosed")
        dt.Columns.Add("dateEnd")
        dt.Columns.Add("dateLastExported")
        dt.Columns.Add("degreeList")
        dt.Columns.Add("description")
        dt.Columns.Add("durationWeeks")
        dt.Columns.Add("educationDegree")
        dt.Columns.Add("employmentType")
        dt.Columns.Add("externalCategoryID")
        dt.Columns.Add("externalID")
        dt.Columns.Add("feeArrangement")
        dt.Columns.Add("hoursOfOperation")
        dt.Columns.Add("hoursPerWeek")
        dt.Columns.Add("isClientEditable")
        dt.Columns.Add("isDeleted")
        dt.Columns.Add("isInterviewRequired")
        dt.Columns.Add("isJobcastPublished")
        dt.Columns.Add("isOpen")
        dt.Columns.Add("isPublic")
        dt.Columns.Add("jobBoardList")
        dt.Columns.Add("numOpenings")
        dt.Columns.Add("onSite")
        dt.Columns.Add("optionsPackage")
        dt.Columns.Add("ownerID")
        dt.Columns.Add("payRate")
        dt.Columns.Add("publicDescription")
        dt.Columns.Add("publishedZip")
        dt.Columns.Add("reasonClosed")
        dt.Columns.Add("reportTo")
        dt.Columns.Add("reportToClientContactID")
        dt.Columns.Add("responseUserID")
        dt.Columns.Add("salary")
        dt.Columns.Add("salaryUnit")
        dt.Columns.Add("skillList")
        dt.Columns.Add("source")
        dt.Columns.Add("startDate")
        dt.Columns.Add("status")
        dt.Columns.Add("taxRate")
        dt.Columns.Add("taxStatus")
        dt.Columns.Add("title")
        dt.Columns.Add("travelRequirements")
        dt.Columns.Add("type")
        dt.Columns.Add("willRelocate")
        dt.Columns.Add("willSponsor")
        dt.Columns.Add("workersCompRateID")
        dt.Columns.Add("yearsRequired")

        For Each i As Integer In qr.ids
            'get the data object
            Dim position As apiFindResult = service.find(strSession, "JobOrder", i)

            'reset the session 
            strSession = position.session

            'type the data object as a job order
            Dim thisPosition As jobOrderDto = position.dto

            'create the new row in the datatable
            Dim row As DataRow
            row = dt.NewRow()

            row.Item("jobOrderID") = thisPosition.jobOrderID.ToString()            
            row.Item("address") = thisPosition.address.address11.ToString() & " " & thisPosition.address.city.ToString() & " " & thisPosition.address.state.ToString() & " " & thisPosition.address.zip.ToString()            
            row.Item("benefits") = thisPosition.benefits.ToString()

            If thisPosition.billRateCategoryIDSpecified Then
                row.Item("billRateCategoryID") = thisPosition.billRateCategoryID.ToString()
            Else : row.Item("billRateCategoryID") = ""
            End If

            row.Item("bonusPackage") = thisPosition.bonusPackage.ToString()
            row.Item("branchCode") = thisPosition.branchCode.ToString()
            row.Item("certificationList") = thisPosition.certificationList.ToString()
            row.Item("clientBillRate") = thisPosition.clientBillRate.ToString()

            If thisPosition.clientContactIDSpecified Then
                row.Item("clientContactID") = thisPosition.clientContactID.ToString()
            Else : row.Item("clientContactID") = ""
            End If

            If thisPosition.clientCorporationIDSpecified Then
                row.Item("clientCorporationID") = thisPosition.clientCorporationID.ToString()
            Else : row.Item("clientcorporationID") = ""
            End If

            row.Item("costCenter") = thisPosition.costCenter.ToString()

            If thisPosition.dateAddedSpecified Then
                row.Item("dateAdded") = thisPosition.dateAdded.ToString("MM/dd/yyyy")
            Else
                row.Item("dateAdded") = ""
            End If

            If thisPosition.dateClosedSpecified Then
                row.Item("dateClosed") = thisPosition.dateClosed.ToString("MM/dd/yyyy")
            Else
                row.Item("dateClosed") = ""
            End If

            If thisPosition.dateEndSpecified Then
                row.Item("dateEnd") = thisPosition.dateEnd.ToString("MM/dd/yyyy")
            Else : row.Item("dateEnd") = ""
            End If

            If thisPosition.dateLastExportedSpecified Then
                row.Item("dateLastExported") = thisPosition.dateLastExported.ToString("MM/dd/yyyy")
            Else : row.Item("dateLastExported") = ""
            End If

            row.Item("degreeList") = thisPosition.degreeList.ToString()

            If thisPosition.durationWeeksSpecified Then
                row.Item("durationWeeks") = thisPosition.durationWeeks.ToString()
            Else : row.Item("durationWeeks") = ""
            End If

            row.Item("educationDegree") = thisPosition.educationDegree.ToString()
            row.Item("employmentType") = thisPosition.employmentType.ToString()

            If thisPosition.externalCategoryIDSpecified Then
                row.Item("externalCategoryID") = thisPosition.externalCategoryID.ToString()
            Else : row.Item("externalCategoryID") = ""
            End If

            row.Item("externalID") = thisPosition.externalID.ToString()

            If thisPosition.feeArrangementSpecified Then
                row("feeArrangement") = thisPosition.feeArrangement.ToString()
            Else : row("feeArrangement") = ""
            End If

            row.Item("hoursOfOperation") = thisPosition.hoursOfOperation.ToString()

            If thisPosition.hoursPerWeekSpecified Then
                row.Item("hoursPerWeek") = thisPosition.hoursPerWeek.ToString()
            Else : row.Item("hoursPerWeek") = ""
            End If

            If thisPosition.isClientEditableSpecified Then
                row.Item("isClientEditable") = thisPosition.isClientEditable.ToString()
            Else : row.Item("isClientEditable") = ""
            End If

            If thisPosition.isDeletedSpecified Then
                row.Item("isDeleted") = thisPosition.isDeleted.ToString()
            Else : row.Item("isDeleted") = ""
            End If

            If thisPosition.isInterviewRequiredSpecified Then
                row.Item("isInterviewRequired") = thisPosition.isInterviewRequired.ToString()
            Else : row.Item("itInterviewRequired") = ""
            End If

            If thisPosition.isOpenSpecified Then
                row.Item("isOpen") = thisPosition.isOpen.ToString()
            Else
                row.Item("isOpen") = ""
            End If

            If thisPosition.isPublicSpecified Then
                row.Item("isPublic") = thisPosition.isPublic.ToString()
            Else : row.Item("isPublic") = ""
            End If

            If thisPosition.isJobcastPublishedSpecified Then
                row.Item("isJobcastPublished") = thisPosition.isJobcastPublished.ToString()
            Else : row.Item("isJobcastPublished") = ""
            End If

            row.Item("jobBoardList") = thisPosition.jobBoardList.ToString()

            If thisPosition.numOpeningsSpecified Then
                row.Item("numOpenings") = thisPosition.numOpenings.ToString()
            Else : row.Item("numOpenings") = ""
            End If

            row.Item("onSite") = thisPosition.onSite.ToString()
            row.Item("optionsPackage") = thisPosition.optionsPackage.ToString()

            If thisPosition.ownerIDSpecified Then
                row.Item("ownerID") = thisPosition.ownerID
            Else : row.Item("ownerID") = ""
            End If

            If thisPosition.payRateSpecified Then
                row.Item("payRate") = thisPosition.payRate.ToString()
            Else : row.Item("payRate") = ""
            End If

            row.Item("publicDescription") = thisPosition.publicDescription.ToString()
            row.Item("publishedZip") = thisPosition.publishedZip.ToString()
            row.Item("reasonClosed") = thisPosition.reasonClosed.ToString()
            row.Item("reportTo") = thisPosition.reportTo.ToString()

            If thisPosition.reportToClientContactIDSpecified Then
                row.Item("reportToClientContactID") = thisPosition.reportToClientContactID.ToString()
            Else : row.Item("reportToClientContactID") = ""
            End If

            If thisPosition.responseUserIDSpecified Then
                row.Item("responseUserID") = thisPosition.responseUserID.ToString()
            Else : row.Item("reponseUserID") = ""
            End If

            If thisPosition.salarySpecified Then
                row.Item("salary") = thisPosition.salary.ToString()
            Else : row.Item("salary") = ""
            End If

            row.Item("salaryUnit") = thisPosition.salaryUnit.ToString()
            row.Item("skillList") = thisPosition.skillList.ToString()
            row.Item("source") = thisPosition.source.ToString()

            If thisPosition.startDateSpecified Then
                row.Item("startDate") = thisPosition.startDate.ToString("MM/dd/yyyy")
            Else : row.Item("startDate") = ""
            End If

            row.Item("status") = thisPosition.status.ToString()

            If thisPosition.taxRateSpecified Then
                row.Item("taxRate") = thisPosition.taxRate.ToString()
            Else : row.Item("taxRate") = ""
            End If

            row.Item("taxStatus") = thisPosition.taxStatus.ToString()
            row.Item("title") = thisPosition.title.ToString()
            row.Item("travelRequirements") = thisPosition.travelRequirements.ToString()

            If thisPosition.typeSpecified Then
                row.Item("type") = thisPosition.type.ToString()
            Else : row.Item("type") = ""
            End If

            If thisPosition.willRelocateSpecified Then
                row.Item("willRelocate") = thisPosition.willRelocate.ToString()
            Else : row.Item("willRelocate") = ""
            End If

            If thisPosition.willSponsorSpecified Then
                row.Item("willSponsor") = thisPosition.willSponsor.ToString()
            Else : row.Item("willSponsor") = ""
            End If

            If thisPosition.workersCompRateIDSpecified Then
                row.Item("workersCompRateID") = thisPosition.workersCompRateID.ToString()
            Else : row.Item("workersCompRateID") = ""
            End If

            If thisPosition.yearsRequiredSpecified Then
                row.Item("yearsRequired") = thisPosition.yearsRequired.ToString()
            Else : row.Item("yearsRequired") = ""
            End If

            dt.Rows.Add(row)
        Next
I'm intrigured by your event subscriptions, but your documentation regarding how to do it, and exactly how it works, is sketchy (to say the least). Do you have any examples?

r.knight
User
Posts: 68
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by r.knight » Fri Oct 26, 2012 3:03 pm

nb_healthpro,

Nothing stands out in your code...but your right, the event subscription documents also have their share of voids. I can only really direct you to the operations you would want to use for with the event system. We actually offer a priced add-on product, called the Data Replicator (http://bullhorn.custhelp.com/app/answer ... _id/100068) which is used to replicate event changes via the API's to a local SQL database. I only refer to that as a reference.

Anyhow, you can build an application to consume events from the subscriptions via some scheduling mechanism, queue them into your own database, and use that database to retrieve jobs and display them to your website, for example. (Im not sure what you are trying to accomplish)

The basic logic would be something like this:
1. Create a new subscription using the 'eventsSubscribe' operation. (http://developer.bullhorn.com/doc/opera ... scribe.htm)

2. Use 'eventsGetEvents' to consume the events from the queue. These events are stored and retrieved FIFO. 'eventsRegetEvents' should be used to re-get failed events. (http://developer.bullhorn.com/doc/opera ... events.htm AND http://developer.bullhorn.com/doc/opera ... events.htm)

3. After consuming the event from step 2, you can do a variety of things. The most common action would be to parse out the entityName and entityID and perform a 'find' to retrieve the full entity DTO. (http://developer.bullhorn.com/doc/opera ... n-find.htm)

4. The results of the 'find' will provide all metadata from that record, which you can then push into your own database.

Other operations:
- use 'eventsGetLastRequestID' to get the last requestID that was consumed. The next 'eventsGetEvents' number should be in sequential order, if not you know something was missed and therefore a reget should occur.
- 'eventsSubscribe' will remove an existing subscription and deleted any un-consumed events

I hope that is somewhat helpful.
Ryan Knight
Principal Enterprise Support Analyst and Team Lead
B U L L H O R N
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
US Support: 617-478-9126
International Support: +1 617 478 9131
http://www.bullhorn.com

r.knight
User
Posts: 68
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by r.knight » Fri Oct 26, 2012 4:52 pm

Hi nb_healthpro,

Have you tried using findMultiple to retrieve the JobDto's? You can pull back 20 at a time and loop through the jobOrderID's to get the data you need.

The event subscription is simply another option. I've laid out the basic idea on how to utilize them to create a subscription and retrieve events. The SOAP API is not a bulk API but future releases may have more flexibility on syncing large quantities of data.
Ryan Knight
Principal Enterprise Support Analyst and Team Lead
B U L L H O R N
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
US Support: 617-478-9126
International Support: +1 617 478 9131
http://www.bullhorn.com

nb_healthpro
User
Posts: 11
Joined: Thu Oct 25, 2012 2:59 pm

Re: Returning all jobs takes three minutes

Post by nb_healthpro » Sun Oct 28, 2012 2:53 pm

Does anyone in your office have any example code - in any language - for subscribing and consuming your events? I think this is the best option for us - I tried your getmultiple functionality and it is just incredibly slow - but I have absolutely no idea on where to even start with it.

Any help would be greatly appreciated. We have to get this working, and unfortunately, your documentation doesn't help much - in fact, some of it is worse than missing, its misleading and wrong. If you have any code - for your _current_ api - that would help us out a lot.

r.knight
User
Posts: 68
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by r.knight » Sun Oct 28, 2012 3:46 pm

I will see if I can scrounge something up tomorrow. Thanks for your patience.
Ryan Knight
Principal Enterprise Support Analyst and Team Lead
B U L L H O R N
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
US Support: 617-478-9126
International Support: +1 617 478 9131
http://www.bullhorn.com

nb_healthpro
User
Posts: 11
Joined: Thu Oct 25, 2012 2:59 pm

Re: Returning all jobs takes three minutes

Post by nb_healthpro » Sun Oct 28, 2012 7:38 pm

I cannot begin to tell you how much we would appreciate that. Thank you.

r.knight
User
Posts: 68
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by r.knight » Mon Oct 29, 2012 9:45 am

nb_healthpro,

Okay, I've only got one Java code sample to provide that I have approval to share. Hopefully more to come in the future as I work with the PM team to get some of the articles updated with new examples. Hopefully this gets you going.

This code does not cover creating the subscription but that should be the easiest part. After it's initially created, the getEvents() function below should do the major work. As far as creating the subscription, we can accomplish this in one of two ways:
1. You can use something like SOAPUI to manually create the subscription using 'eventsSubscribe' operation per article http://developer.bullhorn.com/doc/opera ... scribe.htm
2. If you have an idea of the entities you are handling (ie. JobOrder or ALL) and the eventTypes you are listening for (ie. INSERTED, DELETED, UPDATED) , I can create a subscription for you. After it's initial creation, however, you will be responsible for consuming the events or deleting the subscription using 'eventsUnsubsribe'.

It probably makes sense to create a JobOrder only sub for the time being while you test the code. Let me know.

NOTE: I did not write this code so I can only help to a certain degree.

In the main function, you will have to specify the api username, password, api key, and subscription name:

Code: Select all

		
PullEvents eventpuller = new PullEvents("INSERT USERNAME","INSERT PASSWORD","INSERT API KEY");
		eventpuller.getEvents("INSERT SUBSCRIPTION NAME");
The function getEvents() should do the most important part in getting the events and performing a 'find' to get the full entity DTO. Beyond that you would have to work on storing the data somehow.

Code: Select all

import com.bullhorn.dataevent.event.DataEvent;
import com.bullhorn.dataevent.event.DataEvent.EventMetadata;
import com.bullhorn.dataevent.event.EntityEvent;
import com.bullhorn.dataevent.event.EntityInsertedEvent;
import com.bullhorn.dataevent.event.EntityUpdatedEvent;
import com.bullhorn.entity.AbstractDto;
import com.bullhorn.apiservice.ApiService;
import com.bullhorn.apiservice.ApiService_Service;
import com.bullhorn.apiservice.result.ApiFindResult;
import com.bullhorn.apiservice.result.ApiEventsGetEventsResult;
import com.bullhorn.apiservice.result.ApiStartSessionResult;
import com.bullhorn.entity.note.*;

import com.bullhorn.entity.job.*;
import java.net.URL;
import java.util.List;


import javax.xml.namespace.QName;


	


public class PullEvents {
	
	 private static final QName SERVICE_NAME = new QName("http://apiservice.bullhorn.com/", "ApiService");
	 private String wsdlUrl;
	 private URL serviceUrl;
	 private ApiService service;
	 private String username;
     private String password;
     private String apiKey;
	
     public PullEvents(String usrname, String pass, String apiKey) throws Exception
	 {
	    	   username = usrname;
	           password = pass;
	           this.apiKey = apiKey;
	    	
	          wsdlUrl = "https://api.bullhornstaffing.com/webservices-2.5/?wsdl";
		       // obtain the api web service
	          serviceUrl = new URL(ApiService_Service.class.getResource("."), wsdlUrl);
	          service = new ApiService_Service(serviceUrl, SERVICE_NAME).getApiServicePort();
	 }
	
	public static void main(String args[]) throws Exception
	{
		PullEvents eventpuller = new PullEvents("INSERT USERNAME","INSERT PASSWORD","INSERT API KEY");
		eventpuller.getEvents("INSERT SUBSCRIPTION NAME");
		
	}
	
	public String refreshSession()
    {
        
          // first, login to obtain an api session
          ApiStartSessionResult startSession = service.startSession(username, password, apiKey);
          return startSession.getSession();
          
    }
	
	private void getEvents(String subName)
	{
		String session = refreshSession();
		ApiEventsGetEventsResult result = service.eventsGetEvents(session, subName, 1); //session
		System.out.println("result from: "+subName+" with id of: "+result.getResults().getRequestId());
		
		DataEvent datE = result.getResults().getEvents().get(0);
		
		EntityEvent entE = (EntityEvent)datE;
		
		//Here you want to record the message id, as it'll be necessary given any error that you have processing it.
		//  In our code we just print it out
		System.out.println(entE.getEntityName() + " number "+ entE.getEntityId() +" has been "+ entE.getEntityEventType());
		
		//Depending on the type of event, we want to do different actions, we break it up in an IF statement
		if(entE.getEntityEventType().toString()=="UPDATED")
		{
			//To get the specific fields that have been updated, you want to move to the update event type
			//  You'll want to pull those values from a FIND operation, again all we do is print them out
			EntityUpdatedEvent updateE = (EntityUpdatedEvent) entE;
			List<String> changes= updateE.getUpdatedProperties();
			for(String change : changes)
			{
				System.out.println(change);
			}
		}
		else if(entE.getEntityEventType().toString()=="INSERTED")
		{
			//No real need to case to the Inserted Event, you'll mainly just do a Find and pull in the record
			EntityInsertedEvent insertE = (EntityInsertedEvent) entE;
			ApiFindResult findResult = service.find(refreshSession(), insertE.getEntityName(), insertE.getEntityId());
			findResult.getDto();
			
		}
		else if(entE.getEntityEventType().toString()=="DELETED")
		{
			//Pull back the appropriate data.  You can consider if you want to mark the status as Deleted or remove the row from your local repository
		}
	
	}
	

}
Ryan Knight
Principal Enterprise Support Analyst and Team Lead
B U L L H O R N
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
US Support: 617-478-9126
International Support: +1 617 478 9131
http://www.bullhorn.com

nb_healthpro
User
Posts: 11
Joined: Thu Oct 25, 2012 2:59 pm

Re: Returning all jobs takes three minutes

Post by nb_healthpro » Mon Oct 29, 2012 12:48 pm

This will get us started. Thanks so much.

On a side note, posting even this in your examples would help people a lot. Even if it is only in Java, anyone who can write any of the C family of languages can read Java.

r.knight
User
Posts: 68
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by r.knight » Mon Oct 29, 2012 2:20 pm

I agree. Unfortunately I cannot change the content of the documentation pages on my own. I've already been discussing the example code with our management and project management team to get the pages updated, also to add examples to any operations that are missing examples.

It's a work in progress and hopefully the remaining pages will be added soon. Please let me know how things go as you build this out.
Ryan Knight
Principal Enterprise Support Analyst and Team Lead
B U L L H O R N
33-41 Farnsworth Street, 5th Floor, Boston, MA 02210
US Support: 617-478-9126
International Support: +1 617 478 9131
http://www.bullhorn.com

nb_healthpro
User
Posts: 11
Joined: Thu Oct 25, 2012 2:59 pm

Re: Returning all jobs takes three minutes

Post by nb_healthpro » Fri Nov 09, 2012 1:26 pm

I have created a VB class that does what you've given me in java - it is _extremely_ different because the java code you sent me uses a deprecated version of your API. But... I'm at the same point now as the code you had sent me. However, findResult.dto() isn't a stand alone method. Do you guys have any code examples that further this? I have included my own code for anyone who might be having similiar problems - ANY help from ANY source would be much appreciated.

Code: Select all

'Imports HealthPRO_VB.com.bullhornstaffing.api
Imports System.Data.SqlClient
Imports System.Data.Sql
Imports System.Data

Public Class EventPuller
    Private _BHUserName As String = "YOUR_API_USERNAME"
    Private _BHPassword As String = "YOUR_API_PASSWORD"
    Private _BHApiKey As String = "YOUR_API_KEY"
    Private _Service As com.bullhornstaffing.api.ApiService
    Private _Session As com.bullhornstaffing.api.apiStartSessionResult
    Private _SessionString As String
    Private Shared _EventName As String

    Public Sub New(ByVal eventName As String)
        _Service = New com.bullhornstaffing.api.ApiService()
        _Session = _Service.startSession(_BHUserName, _BHPassword, _BHApiKey)
        _SessionString = _Session.session
        _EventName = eventName
    End Sub

    Public Shared Sub Main(ByVal args() As String)
        Dim ep As New EventPuller("OpenPositions")

        ep.GetEvents(_EventName)
    End Sub

    Public Sub refreshSession()
        _Session = _Service.startSession(_BHUserName, _BHPassword, _BHApiKey)
        _SessionString = _Session.session
    End Sub

    Private Sub GetEvents(ByVal eventName As String)
        refreshSession()

        Dim result As com.bullhornstaffing.api.apiEventsGetEventsResult = _Service.eventsGetEvents(_SessionString, eventName, 1)

        Dim evt As com.bullhornstaffing.api.dataEvent = result.results.events.First()
        Dim ent As com.bullhornstaffing.api.entityEvent = CType(evt, com.bullhornstaffing.api.entityEvent)

        If ent.entityEventType.ToString() = "UPDATED" Then

        ElseIf ent.entityEventType.ToString() = "INSERTED" Then
            Dim insertedEntity As com.bullhornstaffing.api.entityInsertedEvent = CType(ent, com.bullhornstaffing.api.entityInsertedEvent)

            'refresh the session
            refreshSession()

            'get the actual event entity
            Dim findResult As com.bullhornstaffing.api.apiFindResult = _Service.find(_SessionString, insertedEntity.entityName, insertedEntity.entityId)


        ElseIf ent.entityEventType.ToString() = "DELETED" Then

        End If

    End Sub
End Class


c.choy
User
Posts: 49
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by c.choy » Mon Nov 12, 2012 6:11 pm

Not quite sure what you're hoping to do after this point, it's rather open ended on how you want to process the events (dump the data in to db, email notify info, etc).

Don't forget that the event (EntityEvent) will have the name of the entity, such as Job, Candidate etc. With that you can cast the result (abstract) dto to the appropriate dto type (ie CandidateDto). That'll grant you access to other functions to grab the data: candDto.getEmail() etc.

Hope that helps.

nb_healthpro
User
Posts: 11
Joined: Thu Oct 25, 2012 2:59 pm

Re: Returning all jobs takes three minutes

Post by nb_healthpro » Tue Nov 13, 2012 10:49 am

Yep, I am past that point now - I switched over to C# (muuuch more comfortable). The issue I am dealing with now is that it seems your result object is null if no events are found? Is this correct?

c.choy
User
Posts: 49
Joined: Wed Dec 31, 1969 8:00 pm

Re: Returning all jobs takes three minutes

Post by c.choy » Tue Nov 13, 2012 11:06 am

The dto part of it will be null yes. The Result object itself should not be null and contain at least the session.

Post Reply