So, during my presentation @ DC07 - Consuming DataExchange, I used a mobile device, outlook, and a check in printer in a demo on “thinking forward” and outside of the norm on DataExchange. While I had all of my plates spinning I plowed through the demo without explaining the code and technology behind it… for all of those who have forgiven me ;) here ya go:
What I used:
1 x Cingular HTC 8525 w/WM6 + Push synchronization
1 x Exchange Mail Server
1 x Instance of Outlook 2007
1 x Microsoft OfficeXP WebServices Toolkit 2.0 (So that my VBA could talk to DataExchange)
1 x Redemption (3rd party freeware that suppressed security warnings – I did not want to disrupt the demo with having to click a dialog box)
1 x Check in Printer
This is what I did:
I walked up to Andrew Mitry and Bob VanDerPloeg (of Discovery Church) told them some scenario that I was part of the first time visitors ministry and wanted to talk to them because they were new to my church – I recorded their First and Last names as well as their Phone numbers (note: I could’ve captured their email, address, spouse – to generate another individual, children, etc….).
While I was entering Bob’s information into my HTC Andrew’s information was being pushed to our exchange server – synchronization happens automatically on my device, though you could schedule it for every minute or something more appropriate.
Once the information hit our exchange server my outlook client pulled down the new information into my contacts folder. I had the following script setup to run each time a new contact arrived during my session:
'==================================================
'ExportContacts(oiContact As ContactItem)
' This sub handles the following
' Create a safe object to avoid security warnings - see (http://www.dimastr.com/redemption/) for more information
' Create XML based on the new contact
' Send XML to the DataExchange web service
' Notify the user
'==================================================
Private Sub ExportContacts(oiContact As ContactItem)
On Error Resume Next
Dim sXML As String
Dim SafeContact
Set SafeContact = CreateObject("Redemption.SafeContactItem")
SafeContact.Item = oiContact
sXML = "<?xml version='1.0' encoding='UTF-8'?>"
sXML = sXML + "<tns:dataRequest xmlns:tns='UpdateHousehold'>"
sXML = sXML + " <authenticateHeader>"
sXML = sXML + " <churchCode>[ChurchCode] </churchCode>"
sXML = sXML + " <user>[USERID]</user>"
sXML = sXML + " <password>[PASSWORD] </password>"
sXML = sXML + " <method>UpdateHousehold</method>"
sXML = sXML + " <version>2.0</version>"
sXML = sXML + " <methodGroup>People</methodGroup>"
sXML = sXML + " </authenticateHeader>"
sXML = sXML + " <configuration>"
sXML = sXML + " <requestProcessType>Synchronous</requestProcessType>"
sXML = sXML + " </configuration>"
sXML = sXML + " <data>"
sXML = sXML + " <household entityState='Added'>"
sXML = sXML + " <householdName>" + SafeContact.FirstName + " " + SafeContact.LastName + "</householdName>"
sXML = sXML + " <addresses/>"
sXML = sXML + " <communications/>"
sXML = sXML + " <individuals>"
sXML = sXML + " <individual entityState='Added'>"
sXML = sXML + " <title/>"
sXML = sXML + " <salutation/>"
sXML = sXML + " <prefix/>"
sXML = sXML + " <firstName>" + SafeContact.FirstName + "</firstName>"
sXML = sXML + " <lastName>" + SafeContact.LastName + "</lastName>"
sXML = sXML + " <suffix/>"
sXML = sXML + " <middleName/>"
sXML = sXML + " <goesByName/>"
sXML = sXML + " <formerName/>"
sXML = sXML + " <gender/>"
If Len(SafeContact.Birthday) <> 0 Then
sXML = sXML + " <dateOfBirth>" + SafeContact.Birthday + "</dateOfBirth>"
Else
sXML = sXML + " <dateOfBirth/>"
End If
sXML = sXML + " <maritalStatus/>"
sXML = sXML + " <householdMemberType>Head</householdMemberType>"
sXML = sXML + " <occupation/>"
sXML = sXML + " <occupationDescription/>"
sXML = sXML + " <employer/>"
sXML = sXML + " <school/>"
sXML = sXML + " <formerChurch/>"
sXML = sXML + " <status>New from Mobile</status>"
sXML = sXML + " <weblink entityState='UnChanged'>"
sXML = sXML + " <userId/>"
sXML = sXML + " <password/>"
sXML = sXML + " <passwordHint/>"
sXML = sXML + " <passwordAnswer/>"
sXML = sXML + " </weblink>"
sXML = sXML + " <attributes/>"
If Len(SafeContact.HomeAddress) <> 0 Then
sXML = sXML + " <addresses>"
sXML = sXML + " <address entityState='Added'>"
sXML = sXML + " <addressType>Primary</addressType>"
sXML = sXML + " <address1>" + SafeContact.HomeAddressStreet + "</address1>"
sXML = sXML + " <address2/>"
sXML = sXML + " <city>" + SafeContact.HomeAddressCity + "</city>"
sXML = sXML + " <postalCode>" + SafeContact.HomeAddressPostalCode + "</postalCode>"
sXML = sXML + " <country>USA</country>"
sXML = sXML + " <stProvince>" + UCase(SafeContact.HomeAddressState) + "</stProvince>"
sXML = sXML + " </address>"
sXML = sXML + " </addresses>"
Else
sXML = sXML + " <addresses/>"
End If
sXML = sXML + " <communications>"
If Len(SafeContact.Email1Address) <> 0 Then
sXML = sXML + " <communication entityState='Added'>"
sXML = sXML + " <communicationType>Email</communicationType>"
sXML = sXML + " <communicationValue>" + SafeContact.Email1Address + "</communicationValue>"
sXML = sXML + " <listed>true</listed>"
sXML = sXML + " </communication>"
End If
If Len(oiContact.HomeTelephoneNumber) <> 0 Then
sXML = sXML + " <communication entityState='Added'>"
sXML = sXML + " <communicationType>Home Phone</communicationType>"
sXML = sXML + " <communicationValue>" + SafeContact.HomeTelephoneNumber + "</communicationValue>"
sXML = sXML + " <listed>true</listed>"
sXML = sXML + " </communication>"
End If
sXML = sXML + " </communications>"
sXML = sXML + " </individual>"
sXML = sXML + " </individuals>"
sXML = sXML + " </household>"
sXML = sXML + " </data>"
sXML = sXML + " </tns:dataRequest>"
'Call the Web Service - See Class Module - clsws_DataRequest for more information
CallDataExchangeWebMethod sXML
MsgBox "Contact Exported..."
End Sub
The function CallDataExchangeWebMethod would send the information to DataExchange. DataExchange would then synchronously store the data into the Database, making it instantly available to check in and all of the other applications that use the same data store…ta-da!
Sorry again for not going more in depth during the demo, I had a bit too much Monster Java energy drink that morning and was moving @ light-speed. Thanks again to all who were able to make it to the DataExchange sessions – remember think “Why Not”!
--Nick