Automating with ID Works SDK Leslie Dreyer Kalra NACCU 2014
KU Fast Facts Midway between Allentown and Reading, about 70 miles northwest of Philadelphia Founded in 1866 as Keystone State Normal School Part of PASSHE (owned by the Commonwealth) ~9500 full- and part-time students, mostly PA residents Known for Education and Communication Design 45% commuter Kutztown Golden Bears
Cool Things about KU Buggies! Kutztown Folk Festival The Chicken GeoEye-1 Earth-imaging satellite
About Me At KU since 2007, began in the card office In 2012, moved to Business Office as Computer-Nerd-in- Chief Blackboard user since 2007, started with Unix Interested in integration, data flow, business intelligence Now working with PeopleSoft, Adirondack in addition to Blackboard, supporting Admin & Finance (Bursar, Dining, Housing, Public Safety, Purchasing)
One Cool Thing about Me My children go to school in the Millennium Falcon Parkland High School (image from MapQuest, via huffingtonpost.com)
What is an SDK? SDK = Software Development Kit Provides a software environment for a programmer and/or Provides hooks into a software package that let a developer enhance it. ID Works SDK gives us the hooks to enhance ID Works using Visual Studio
Why use ID Works SDK? ID Works doesn t quite do what we need it to do. We want to automate some steps that ID Works does manually. We have an unusual setup that ID Works doesn t handle as well as we d like. We want to lead staff through a procedure, leaving less room for human error. We like to play with software toys.
KU s Needs Streamline Transfer Orientation process Automate Freshman Orientation card printing, speed up phototaking. For the 2009 recard, we wanted: To keep existing card number if old card turned in. To use swipe tech to exchange cards. To reduce human error Speed!!!!! ID production logging to database and file Automation of ID billing to student accounts
Other SDK Uses Replace all or part of the ID Works interface Use a capture source that ID Works doesn t know about natively (requires purchase of Capture Server for each station) Use a printer setup that ID Works doesn t know about natively (requires purchase of Print Server for each station)
Included in the SDK Libraries to manipulate ID Works Datacard Workstation Utility (for custom print/capture) RegisterInterops.cmd Programmer s Reference Guide Samples in VB.NET and C++ IDWRegtool
Using the SDK
Event Handler: a different programming paradigm Simple procedural programming: start at the beginning, go to the end, then stop Event-driven programming: set up the environment, wait for something to happen, then react. Getting started: Flowchart process, identify what can be automated.
Recard Production Flow Student presents card Staff looks up and enters ID# Card # Match? Yes Photo Match? Yes Print new card Log card production No No Have student bring in newer card Yes Newer Card? No Ask for other photo ID Shred old card Change card number Photo, Name Match? Yes Take new photo No Inform student of policy, decline new card
Object-Oriented Programming Objects belong to classes, classes can have hierarchy Properties describe objects Methods act on objects Properties and methods can be inherited and overloaded Before a class can be used, an instance of it must be created. It refers to itself as Me (VB.NET) or this (C++, C#, Java)
Event Handler as (permissive) parent Whenever an event takes place, ID Works checks in with the Event Handler Event Handler can allow/disallow, cause other things to happen before/after, require things to happen before continuing. Default behavior is to allow the event to occur, as ID Works would normally behave.
m_processing A method called because of an event can cause other events. This can lead to unexpected behavior, including infinite loops. m_processing is set to true when an event fires. The last thing done in the select statement of the event handler is to set it to false again. Setting this to true prevents other events from triggering.
ID Works events and methods An event can be a mouse click, keystroke, project open, record deletion, update, etc. When ID Works does most things, there is an event before it happens (_PRE) and another one afterwards (_POST). ID Works methods make things happen programmatically instead of interactively. Methods can fire events, too, so watch for side effects.
IDataEntry3 object Some events we used EV_SEARCH_PRE EV_READRECORD_POST EV_UPDATE_POST EV_PRINT_POST EV_PROJECT_UNLOAD Some methods we used ExecuteSQLSearch() GetFieldData() ClearForm() ClearRecordSet() Capture() UpdateRecord() PrintCard()
Setting up the Environment Run (your favorite version of ) Visual Studio command prompt as Administrator Cd c:\program files (x86)\datacard\id Works\bin (or wherever ID Works is installed) Run RegisterInterops.cmd from the SDK install folder (which is probably different from the ID Works folder). This registers the ID Works libraries and makes them available as COM References in Visual Studio. Add them as you would any other reference
The VB.Net Event Handler template Open a sample project and modify/save it in your own Projects folder, or open your own new project Add the ID Works library reference with Copy Local = True Set up debugging in Visual Studio with Projects->Properties- >Debug. EventNotify() sub is mom. This is where events are processed. m_ide3 refers to your ID Works session (IDataEntry3) object instance Template and documentation were built for Visual Studio 2005, but everything still works the same way in VS2010
Debugging In Visual Studio, open Project Properties On Debug tab, click on Start External Program In the adjacent box, enter path to the ID Works program DataEntry.exe Set up a test ID Works project for debugging Add your event handler to the project and save. Click on the green arrow to fire er up!
Trying out your event handler In ID Works Designer, open your test project In File->Project Properties, choose the Event Handler tab Add event handlers from unassigned list to assigned list, in order, with the Add button Back out event handlers by moving them back to the unassigned list with the Remove button Order matters!
Deploying Compile your code in Visual Studio Copy files to ID station (I just put them on a USB drive or shared network drive) IDWRegtool Idsdk.DataEntry.Interop.dll (and/or other dlls needed by your project) Your.dll file Run IDWRegtool on ID station to register your new event handler
IDWRegTool Requires Admin rights Browse for your.dll file Click Register button This registers the library in the GAC If it works, this window appears. If it doesn t work, the window will simply say The.NET component was not successfully registered. So read it carefully!
Replacement/New Our Event Handler
SEARCHBOX REPLACEMENT: REPLACEMENT/NEW Clicking on the search icon brings up this box instead of the default box. Advanced Search is unaffected. We require searches by ID number, not name The Change Card Number checkbox is checked by default.
REPLACEMENT/NEW (CONT D) Photo is displayed, operator compares it to the customer. If it doesn t look like the customer, the operator can ask for another ID and require a new photo. If it does look like the customer, the operator asks if the customer wants a new photo (if there is time). If the operator clicks No, the camera window comes up to take a new photo
REPLACEMENT/NEW (CONT D) Once a new photo is taken, it replaces the old photo in the searchbox. If the operator clicks No here, the camera window comes up again and the process repeats. If the operator clicks Yes, then they are asked if they are sure they don t want to change the card number.
REPLACEMENT/NEW (CONT D) The operator is reminded of policy regarding changing the card number If they choose Yes, then the record is saved and another box for logging information comes up.
REPLACEMENT/NEW (CONT D) We use a single ID Works login on each station, so this is where the actual operator takes credit (blame?) for the ID.Choices made in the Reason menu (e.g. System Error) may bring up default values (e.g. No Charge) in the Charge To menu. This box is not displayed if an ID is produced by Public Safety. In that case, the fields are filled with Public Safety values and saved transparently. Public Safety never sees this box.
REPLACEMENT/NEW (CONT D) If the Change Card Number box is unchecked the operator has one more chance to make sure policy is followed. This box does not appear if the card number is changed. If they forget to choose their name from the dropdown, I remind them and don t allow the ID to print until they do. If No Charge is chosen from the Charge To menu, or System Error is the reason, then an explanation is required in the Comment box.. Once all is done, the card is printed, and its production is logged to the database. More on that later.
Freshman Orientation Our Event Handler
FRESHMAN ORIENTATION Speed is of the essence Photos are taken, but cards are printed and distributed later We assume : The photo capture source has already been set This is the student s first KU ID photo. Even if it isn t, we take a new one. As with regular replacements, we require ID number lookup, so we type in a number. The camera window comes up right away.
FRESHMAN ORIENTATION (CONT D) Once again, it asks us if the photo is acceptable after it is taken. In this context, we only retake if there s something really wrong. No glamour reshots! If operator clicks No, the camera window comes back up. If operator clicks Yes, the record is saved and the production is logged to a file and to the database. Reason = 1 st ID, Charge to = Connections, Produced By = Staff
FRESHMAN ORIENTATION: PRINT ALL Once all photos are taken and the office is quiet, we can batch print. Click Print All on the Freshman Connections tab Enter the date of the Connections event ID Works reads the log file, finds all saved records from that date, and prints each card. We just have to keep the hopper full.
Transfer Orientation Our Event Handler
Transfer Orientation Searchbox works like the Replacement/New tab but fills in Transfer Orientation defaults in the logs. Reason = 1 st ID, Charge to = Connections, Produced by = Staff Cards are printed and distributed right after the photos are taken. No batch printing for Transfers
Recard Our Event Handler
Recard searchbox Programmable USB card reader configured to read tracks 1 and 2 into this format: 999999999^DENT/STU A^6220010000999999= Event handler splits string into its component parts: SSN = 999999999 Name = DENT/STU A Card Number = 6220010000999999 Searches database for that SSN (we were renumbering, but it could just as easily search on campus ID). If the SSN and the card number match, load photo and ask operator if it matches the customer. If so, save the record, print the card and log to file.
RECARD (CONT D) We moved from SSN as campus ID to unique campus ID in 2009. We had already renumbered everyone in Blackboard We temporarily kept the SSN in a udf until the recard was over, then purged them all. Replacing a card for someone who brought in their old card and looked like their photo took 45 seconds.
Logging and Billing Our Event Handler
What do we log? Campus ID Name Classification Card event (Recard, Replacement, Freshman Connections, Transfer Connections) Reason (1 st ID, Lost/Stolen, System Error, Damaged, etc.) Charge to (Student Account, Connections, Facilities, Other) Produced Date Produced by (operator s name) Comments Operator (ID Works login)
Where do we log? Local file system (limited data) Used to batch print for Freshman Connections Only logging location in initial iteration of the event handler Predates Reason, Chargeto, Producedby dropdowns, so they are not logged here. SQL Server database Used to bill to student accounts (we do not accept payment for IDs in the office) Public Safety-produced IDs are now logged automatically. We don t have to rely on notifications from busy dispatchers. When the appropriate charge is assessed, we log the following in the database: Charge date Charged by (AD login name) We also log similar information for reversals.
ID Billing Program Pulls ID production data from database for specified date range All records with Student Account in the chargeto field have their Charge checkboxes checked automatically. User can modify these settings. Creates and uploads a file to PeopleSoft for overnight processing.
Billing
Future development Deposit Orientation lunch money on the card at production for freshmen. Possibly send new photos or card numbers to other systems when they are updated, in real time. Handle other kinds of billing (PSECU, Facilities, Rec Center, etc.) Incorporate Rec Center/Pool cards into this project, decide which design to use based on choices made in the interface. Incorporate other kinds of cards into this project.
Questions, Comments
Reaching me Leslie Dreyer Kalra Business Systems Manager Kutztown University 610-683-4829 dreyer@kutztown.edu