Sunday, October 18, 2009

Pos .Net Series, Post #12 – Sample Check (Cheque) Scanner Application

This is the twelfth post in a series on Pos .Net. You can find the first post here, or see all the posts here. You can get the sample code for this post here.

I have created a sample application for integrating to a Pos .Net CheckScanner device. While this code is only a sample, I think it will be useful as the CheckScanner is one of the more complex Pos .Net devices and has a relatively ugly programmatic interface.

If you are going to integrate to a CheckScanner device in your application you must read the section of the Pos .Net SDK help that begins

“The basic programming model for the CheckScanner interface is as follows:”

Without reading that, you are likely to make mistakes. For example, the interface for the device has a RetrieveImage method and an ImageData property. It would make sense that calling RetrieveImage would fill the ImageData property (although a return value from the method would have been better)… and it does, but not synchronously.

This means if you immediately follow your call RetrieveImage with a call to the get accessor of the ImageData property you will likely get only a partial image, no data, or an error. One poster in the Pos .Net forum had exactly this problem.

There are other issues too, such as when to call RetrieveImage, and how to write your code so it works with devices that require an explicit BeginInsertion/EndInsertion/BeginRemoval/EndRemoval and those that don’t (always use those methods, you can’t tell if the device needs them or not, and they should be harmless when called on a device that doesn’t need them). There can also be issued with error handling around the insert and remove methods, and which state the device is left in in the event of an error… again the ‘programming model’ section of the CheckScanner class documentation talks about these issues.

The sample I’ve posted is very simple, it doesn’t deal with storing images in the device or with performing validation/MICR reads at the same time as the scan but it will demonstrate how to simply capture the image of the scanned document without any major issues.

If you find this sample helpful, please leave a comment.


3 comments:

  1. Thanks for the post. I will test it against my MICRimage and let you know the results.

    ReplyDelete
  2. hi
    thanks a billion!
    i couldnt find any code anywhere, and your code got me started
    god bless ya!
    btw, might you have any MICR reading code anywhere?

    ReplyDelete
    Replies
    1. Hi,

      Glad it helped ! I don't have any sample code handy just now, but if I'm able to pull something together I'll post it for you.

      Delete